
One of the enemies walk cycle, let´s call him bully, is made out of 16 different bitmaps in a sprite. That gives us a nice 4 x 4 sprite sheet for the engine to chew on. Or does it? For some odd reason, the walk cycle does not run like it should and seems that the bitmaps are feed into the engine randomly, not as defined.
The movement of bully is in 3 files (for this problem), first is the Actionscript file, which in addition to movement holds all the logic for bully (I called it BullyWalkerController.as). Inside the file are two variables, which hold the information for run cycle start and end position:
public var spriteIndexRunStart:int = 0; public var spriteIndexRunEnd:int = 15;Then there is the master sprite sheet xml file, which tells the engine how many pieces it should create from a sprite.
And finally the templates.xml for how the character should move and which tile to use for a specific action (in our example start the run cycle from tile 0 (first tile) and end it on 15th. While the action loops, we have a nice smooth animation for the bully to run around the game, trying to beat you up.
There are of course other files which require attention for a single character, but they are not a part of the problem here, so let´s keep them out.
While tracking the problem for a solid hour and half I finally started working on another character to see if the problem´s still there. The sprite sheet for a new character was 6x2 this time and everything worked just fine.
What was the solution then? We just created a new sprite sheet, this time 8x2 and it worked like a charm. Bully can now track our main character with a smoother animation, like planned.
PS. I tried to paste more code from the .xml as well as .as part, but blogger turned it into some weird looking binary.