简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM