I'm using Zwoptex to display my sprites. I can show the first frame of the sprite, but not the animation.
I have the following code to set up my animation:
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"sprite_sheet.plist" textureFile:@"sprite_sheet.png"];
spriteBatch = [CCSpriteBatchNode batchNodeWithFile:@"sprite_sheet.png"];
[self addChild:spriteBatch];
NSArray *animationFrames = [NSArray arrayWithObjects:
@"game_1.png",
@"game_2.png",
@"game_3.png",
nil];
myAnimation = [[CCAnimation animationWithFrames:animationFrames delay:0.25] retain];
I can display my sprite by doing this:
mySprite = [CCSprite spriteWithSpriteFrameName:@"game_1.png"];
[mySprite setPosition:ccp(161,80)];
[mySprite setRotation:90];
[spriteBatch mySprite];
However, when I try to animate it, it crashes:
mySprite = [CCSprite spriteWithSpriteFrameName:@"game_1.png"];
[mySprite setPosition:ccp(161,80)];
[mySprite setRotation:90];
id a1 = [CCAnimate actionWithAnimation:myAnimation restoreOriginalFrame:NO];
[mySprite runAction:a1];
[spriteBatch mySprite];
And the log:
2011-07-10 02:40:41.126 MyApp[25699:40b] -[NSCFString rect]: unrecognized selector sent to instance 0x1008d8
2011-07-10 02:40:41.128 MyApp[25699:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString rect]: unrecognized selector sent to instance 0x1008d8'
*** Call stack at first throw:
(
0 CoreFoundation 0x014615a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x015b5313 objc_exception_throw + 44
2 CoreFoundation 0x014630bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x013d2966 ___forwarding___ + 966
4 CoreFoundation 0x01462502 __forwarding_prep_1___ + 50
5 MyApp 0x000945e3 -[CCSprite isFrameDisplayed:] + 67
6 MyApp 0x000422e9 -[CCAnimate update:] + 297
7 MyApp 0x0003a197 -[CCActionInterval step:] + 295
8 MyApp 0x00047cdd -[CCActionManager update:] + 269
9 MyApp 0x0008df56 -[CCScheduler tick:] + 310
10 MyApp 0x000b765f -[CCDirectorIOS drawScene] + 159
11 MyApp 0x000b9a2a -[CCDirectorDisplayLink mainLoop:] + 58
12 QuartzCore 0x007d0a88 _ZN2CA7Display11DisplayLink8dispatchEyy + 128
13 QuartzCore 0x007d0bcd _ZN2CA7Display19EmulatorDisplayLink8callbackEP16__CFRunLoopTimerPv + 145
14 CoreFoundation 0x014428c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
15 CoreFoundation 0x01443e74 __CFRunLoopDoTimer + 1220
16 CoreFoundation 0x013a02c9 __CFRunLoopRun + 1817
17 CoreFoundation 0x0139f840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x0139f761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x0298e1c4 GSEventRunModal + 217
20 GraphicsServices 0x0298e289 GSEventRun + 115
21 UIKit 0x00884c93 UIApplicationMain + 1160
22 MyApp 0x00002ab4 main + 100
23 MyApp 0x00002a45 start + 53
Can anyone help me with why it shows the first frame but won't animate?
Many thanks in advance.