Cocos 2D - Hold down CCMenuItem

Posted by Will Youmans on Game Development See other posts from Game Development or by Will Youmans
Published on 2012-06-28T02:42:46Z Indexed on 2012/06/28 3:25 UTC
Read the original article Hit count: 199

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

© Game Development or respective owner

Related posts about iphone

Related posts about cocos2d-iphone