我正在尝试为静态设置动画,例如在电视上。我有 5 帧,我正在尝试快速切换它们。每次运行它时,我都会收到无法识别的选择器错误和崩溃。它崩溃了[staticSprite runAction:repeat];
。我是 cocos2d 的新手。
CCLayer *staticlayer = [[CCLayer alloc]init];
staticlayer.contentSize = CGSizeMake(640, 960);
staticlayer.position = CGPointMake(winSize.width/2, winSize.height/2);
staticlayer.isRelativeAnchorPoint = YES;
NSArray *staticFrames = [[NSArray alloc]initWithObjects:@"static_0.jpg",
@"static_1.jpg",@"static_2.jpg",@"static_3.jpg",@"static_4.jpg",nil];
CCSprite *staticSprite = [CCSprite spriteWithFile:@"static_0.jpg"];
staticSprite.position = ccp(winSize.width/2, winSize.height);
CCAnimation *staticAnimation = [CCAnimation animationWithFrames:staticFrames delay:0.1f];
CCAnimate *staticAnimate = [CCAnimate actionWithAnimation:staticAnimation];
CCRepeatForever *repeat = [CCRepeatForever actionWithAction:staticAnimate];
[staticlayer addChild:staticSprite];
[self addChild:staticlayer z:0];
[staticSprite runAction:repeat];