stackiphone
stackiphone

Reputation: 1245

Animating a CCMenuItem in Cocos2d iphone

I created this code below to show a button in the view in init statement:

    CCMenuItem *contacts = [CCMenuItemImage 
                            itemFromNormalImage:@"play.png" selectedImage:@"play.png" 
                            target:self selector:@selector(switchcontact)];
    contacts.position = ccp(300, 550);
    CCMenu *starMenu6 = [CCMenu menuWithItems:contacts, nil];
    starMenu6.position = CGPointZero;
    [self addChild:starMenu6];

I need to rotate or animate this button in the view in same position, just like the Fruitninjas menu button. How could I do this?

Thanks in advance.

Upvotes: 0

Views: 885

Answers (1)

tassinari
tassinari

Reputation: 2363

Not familiar with the fruit ninja method but to rotate the contacts menu button do:

[contacts runAction:[CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:.5 angle:45]]];

You could do it on the menu as well, they're both CCNodes.

Upvotes: 2

Related Questions