 christiansra | Hi guys, Just been reading through the book and have been trying my best for a few hours now to get the piggy to show up in the game however, when I add [Code]profile = [[KITProfile profileWithName:(team == kTeamOne ? @"Piggy" : @"MonsterBlue")] retain]; [profile copyAnimations:@"wiggle" toKey:@"hover" numFrames:1 delay:0.05f];[/Code] The game crashes every time it tries to add the Pig into the game I have tried using breakpoints to sort this but I have had no avail with this. The console is reading this: 2012-04-30 14:36:30.748 Checkers[10394:707] applicationDidFinishLaunching started 2012-04-30 14:36:30.770 Checkers[10394:707] cocos2d: cocos2d v1.0.1 2012-04-30 14:36:30.775 Checkers[10394:707] cocos2d: Using Director Type:CCDirectorDisplayLink 2012-04-30 14:36:31.023 Checkers[10394:707] cocos2d: OS version: 5.1 (0×05010000) 2012-04-30 14:36:31.027 Checkers[10394:707] cocos2d: GL_VENDOR: Imagination Technologies 2012-04-30 14:36:31.032 Checkers[10394:707] cocos2d: GL_RENDERER: PowerVR SGX 535 2012-04-30 14:36:31.036 Checkers[10394:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-63.24 2012-04-30 14:36:31.043 Checkers[10394:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048 2012-04-30 14:36:31.047 Checkers[10394:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16 2012-04-30 14:36:31.051 Checkers[10394:707] cocos2d: GL_MAX_SAMPLES: 4 2012-04-30 14:36:31.055 Checkers[10394:707] cocos2d: GL supports PVRTC: YES 2012-04-30 14:36:31.059 Checkers[10394:707] cocos2d: GL supports BGRA8888 textures: YES 2012-04-30 14:36:31.063 Checkers[10394:707] cocos2d: GL supports NPOT textures: YES 2012-04-30 14:36:31.069 Checkers[10394:707] cocos2d: GL supports discard_framebuffer: YES 2012-04-30 14:36:31.073 Checkers[10394:707] cocos2d: compiled with NPOT support: NO 2012-04-30 14:36:31.077 Checkers[10394:707] cocos2d: compiled with VBO support in TextureAtlas : YES 2012-04-30 14:36:31.081 Checkers[10394:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES 2012-04-30 14:36:31.086 Checkers[10394:707] cocos2d: compiled with Profiling Support: NO 2012-04-30 14:36:31.188 Checkers[10394:707] Window width is 960 pixels/480 points, HD=yes, Retina available=yes (enabled=yes) 2012-04-30 14:36:31.197 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Effects-hires-hd.plist 2012-04-30 14:36:31.205 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Effects-hires-hd.pvr.ccz AudioStreamBasicDescription: 2 ch, 44100 Hz, ‘lpcm’ (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved 2012-04-30 14:36:31.298 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Board-hires-hd.png 2012-04-30 14:36:31.536 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Logo-hires-hd.png 2012-04-30 14:36:31.612 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Credits-hires-hd.png 2012-04-30 14:36:31.765 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: font-hires-hd.fnt 2012-04-30 14:36:31.794 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: font-hires-hd.png 2012-04-30 14:36:31.932 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Death profile-hd.plist 2012-04-30 14:36:31.941 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: MonsterBlue-and-Death-hires-hd.plist 2012-04-30 14:36:31.956 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: MonsterBlue-and-Death-hires-hd.pvr.ccz 2012-04-30 14:36:32.365 Checkers[10394:707] cocos2d: CCFileUtils: Warning HD file not found: Piggy profile-hd.plist 2012-04-30 14:36:32.370 Checkers[10394:707] *** Assertion failure in -[CCAnimate initWithDuration:animation:restoreOriginalFrame:], /Users/christianadam1994/Desktop/Checkers Game 5.1.0/MonsterCheckers/Code/cocos2d/CCActionInterval.m:1283 2012-04-30 14:36:32.376 Checkers[10394:707] *** Uncaught exception: Animate: argument Animation must be non-nil 2012-04-30 14:36:32.418 Checkers[10394:707] *** Stack trace: ( 0 CoreFoundation 0x34e628a7 __exceptionPreprocess + 186 1 libobjc.A.dylib 0×36289259 objc_exception_throw + 32 2 CoreFoundation 0x34e62789 +[NSException raise:format:] + 0 3 Foundation 0x30cdd3a3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 90 4 Checkers 0x00019ead -[CCAnimate initWithDuration:animation:restoreOriginalFrame:] + 148 5 Checkers 0x00019bd1 +[CCAnimate actionWithDuration:animation:restoreOriginalFrame:] + 80 6 Checkers 0x0000920b -[CheckerPiece animateStand:] + 198 7 Checkers 0x00009c63 -[CheckerPiece setTeam:] + 278 8 Checkers 0×00004439 -[CheckerBoard resetBoard] + 1084 9 Checkers 0x00003a5d -[CheckerBoard init] + 2112 10 Checkers 0x0008d539 -[CCScene(Extended) initWithChildClass:] + 76 11 Checkers 0x0000a1cb -[KITApp(MonsterCheckers) startApp] + 162 12 Checkers 0x0008b7c7 -[KITApp launch] + 86 13 Checkers 0x0008c0b5 -[KITApp applicationDidFinishLaunching:] + 24 14 UIKit 0x31eb8ea9 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1268 15 UIKit 0x31eb2985 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 408 16 UIKit 0x31e80c6b -[UIApplication handleEvent:withNewEvent:] + 1010 17 UIKit 0x31e8070f -[UIApplication sendEvent:] + 54 18 UIKit 0x31e800e3 _UIApplicationHandleEvent + 5826 19 GraphicsServices 0x360b522b PurpleEventCallback + 882 20 CoreFoundation 0x34e36523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38 21 CoreFoundation 0x34e364c5 __CFRunLoopDoSource1 + 140 22 CoreFoundation 0x34e35313 __CFRunLoopRun + 1370 23 CoreFoundation 0x34db84a5 CFRunLoopRunSpecific + 300 24 CoreFoundation 0x34db836d CFRunLoopRunInMode + 104 25 UIKit 0x31eb1a13 -[UIApplication _run] + 550 26 UIKit 0x31eaee7d UIApplicationMain + 1080 27 Checkers 0x00093e4f main + 214 28 Checkers 0×00002340 start + 40 ) 2012-04-30 14:36:32.434 Checkers[10394:707] *** Please set a breakpoint in main.m at line 22 or add an ‘All Objective C Exceptions’ breakpoint with the Breakpoint navigator Whether or not that is any help to anyone is another thing, please get back to me soon. Thank you guys. |
 Nat Weiss | Hey way to go posting the console messages. They are your key. See the lines that start with *** ? First you get an assertion failure, then an uncaught exception, then the stack trace. Everything you need to solve your problem is right there. The assertion failure points you to the line for what went wrong. You can see that Cocos2D is trying to initialize an animation (-[CCAnimate initWithDuration:animation:restoreOriginalFrame:]). When an assert fails, it throws an exception. The exception catcher/handler gives you another clue: “Animate: argument Animation must be non-nil”. So it looks like the code is trying to create a CCAnimate action and the animation argument is nil. Why would that be? Think about it for a sec. Maybe one of the lines in the .plist file is wrong and so the KITProfile class can’t load a particular animation correctly? You can see exactly which animation is causing the assertion failure in the stack trace. It lists the methods which were called up to the failure in reverse. So the last method is listed first (__exceptionPreprocess), the very first method call is listed last (start). Looking through the stack trace you can see that it’s calling -[CheckerPiece animateStand:] right before it creates the CCAnimate with +[CCAnimate actionWithDuration:animation:restoreOriginalFrame:]. That’s where it’s loading a nil animation, in [CheckerPiece animateStand]. This is where Monster Checkers animates the piece when it’s just standing. So there must be something wrong with the Piggy profile.plist’s stand animation. Give it a good look and compare carefully to the MonsterBlue profile.plist. Fix it up and it ought to work. If you are still having trouble, try starting the spritesheet-making chapter over again. Sometimes it really helps to just do it a second time. |
 virag0 | I had the same trouble the other day. I think it is understanding the file naming conventions. I am still not sure what they all are. I just bought TexturePacker and refreshed all my textures so they are no longer graffitoed with a red “Buy me!” stamp. Along the way, I have sort of got a bit more used to the names. But I think we need a little bit of a guide that explains the parameters. I have 2 that I can post as an example. In the GameKit, it expects the file names to be a certain convention: walk-s0000.png standing0000.png In the example above, the files are both the “start files” for the animation. The “s” in the walk example is a “South Facing” sprite. You could have an extra character in there eg “sw” to represent “South West”. I do not understand the script for the “standing” aspect though. It is formatted differently, but seems to know which way to face, without a direction subscript. So, in the Sprite Profile.plist, it then is actually looking for a set of animations, that are tagged “walk” and “standing”, with walk listed as walk-%@00%02d.png and standing as standing000%d.png. So the replacable parameters in the plist correspond to the filename subscripts for “Direction” and the frameCount index. I think I know that %@ means a string (direction) and the “00″ is the body of the filename and %02d is the index of the frame. But I don’t understand how the “standing” sprite attribute works – it doesn’t have a direction, yet I needed to supply a sprite for each direction ( I used 2 sprites for each direction for a max of 8). Can we please get this explained a little more? I almost understand it, but I don’t quite “get” it myself yet….. rachel |
 christiansra | Hey guys, Thank you very much both of you, the issue was residing in the fact I had set the frame count incorrectly as it required a frame count of 6 instead of 5 as I had previously put. I seem to have got the hang of what is going on now and will probably try going through it with a different sprite without the guidance of the book to make sure that I have got it totally. For the time being though thank you very much for your support. Thank you again. |
 MeachWare | Standing sprites all use the same (numerical) order. I’m not at my Mac but lets say that “0″ is South, then “1″ is SW, “2″ is W, “3″ is NW, etc until “7″ which would be SE. Take a look at the standing sprites and you’ll see the circular pattern and Nat has a handy method to determine the direction (int) by movement angle. |