views:

36

answers:

0

Hi,

I'm trying to animate my CCMenu.

CCSpriteFrameCache * cache = [CCSpriteFrameCache sharedSpriteFrameCache];
    [cache addSpriteFramesWithFile:@"PlayButton.plist"];

    CCAnimation * animation = [[CCAnimation alloc] initWithName:@"idle" delay:1/20.0];
    for ( int i=1; i < 6; ++i )
    {

        NSString * fname = [NSString stringWithFormat:@"Play%i.png", i];
        [animation addFrame:[cache spriteFrameByName:fname]];
    }
    CCSprite * blob = [CCSprite spriteWithSpriteFrameName:@"Play1.png"];
    id action = [CCAnimate actionWithAnimation:animation];


    [blob setDisplayFrame:[CCSprite spriteWithSpriteFrameName:@"Play1.png"]];

    CCMenuItemSprite *playSprite = [CCMenuItemSprite itemFromNormalSprite:blob
                                                       selectedSprite:blob target:self 
                                                             selector:@selector(startGame)];


    [playSprite runAction:[CCRepeatForever actionWithAction:action]];
    CCMenu * myMenu = [CCMenu menuWithItems:playSprite, nil];

     //Arrange the menu items vertically
    [myMenu alignItemsVertically];
    myMenu.position = CGPointMake(240,160);
    [self addChild:myMenu];

but it doesn't work. Returns Program received signal: “SIGABRT”. and " Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CCSprite offsetInPixels]: unrecognized selector sent to instance 0x74aff10'".

what should i do?

thanks.