Cocos2D: Problem Rotating a CCMenu
- by srikanth rongali
If I try to do actions over menuItems but the actions are not running as expected.
I think code below should make the menuItem rotate by 90 degrees but when I run it, the menuItem translates from its coordinates to another coordinate then returns to its original coordinate. The complete translation takes 3 seconds.
What I need is for the menuItem to rotate by 90 degrees in place within a 3 seconds duration. Please explain where I have done wrong?
CCMenuItemImage *targetE;//Globally declared
CCMenu *menu;//Globally declared
-(id)init
{
if( (self = [super init]) )
{
isTouchEnabled = YES;
CGSize windowSize = [[CCDirector sharedDirector] winSize];
targetE = [CCMenuItemImage itemFromNormalImage:@"grossinis_sister1.png" selectedImage:@"grossinis_sister1.png" target:self selector:@selector(touch:)];
menu = [CCMenu menuWithItems:targetE,nil];
id action4 = [CCRotateBy actionWithDuration:3.0 angle:90];
[menu runAction: [CCSequence actions: action4, nil]];
menu.position = ccp(windowSize.width/2 + 200, windowSize.height/2);
[self addChild: menu z:10];
}
return self;
}
@end
Thank You.