Cocos 2D - Hold down CCMenuItem
- by Will Youmans
I am using the following code to move a CCSprite left and right.
-(id)init{
CCMenuItemImage * moveLeftButton = [CCMenuItemImage itemFromNormalImage:@"Move Left Button.png" selectedImage:@"Move Left Button.png" target:self selector:@selector(moveLeftVoid:)];
}
-(void)moveLeftVoid{
id moveLeft = [CCMoveBy actionWithDuration:.3 position:ccp(-10, 0)];
[_mainSprite runAction:moveLeft];
}
This does work, but only as a single tap. What I want for the CCSprite to move continously in that direction when the CCMenuItem is held down. Then when it's released the character stops moving. If you need to see more code, please just ask. :) Thanks