Tagged: animation, exception, nil, spritesheet, stack trace
|April 30, 2012 at 1:45 pm #2465|
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];
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
Whether or not that is any help to anyone is another thing, please get back to me soon.
Thank you guys.
|April 30, 2012 at 11:07 pm #2466|
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.
|May 1, 2012 at 4:24 am #2468|
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 have 2 that I can post as an example. In the GameKit, it expects the file names to be a certain convention:
So, in the Sprite Profile.plist, it then is actually looking for a set of animations, that are tagged “walk” and “standing”, with
So the replacable parameters in the plist correspond to the filename subscripts for “Direction” and the frameCount index.
|May 1, 2012 at 8:26 am #2469|
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.
|May 2, 2012 at 2:19 am #2470|
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.
You must be logged in to reply to this topic.