Game Development Community

Animated Character Movement from an ImageMap

by Cameron Aycock · in Torque Game Builder · 09/23/2005 (6:46 am) · 3 replies

(warning: newbie post)
Hi guys,

I'm going beyond the tutorial, finally, and I'm trying to set up a character that has animated movement based off of an image map that I have. The ImageMap is a single png that has all of the positions of the character that I need (ie: 4 frames of walking to the right, 4 frames to the left, 4 frames down, 4 frames up, and then a still of being stopped in all directions).

So.. I have 20 "cells" on the imagemap. For the sake of trying to make it work, I took them out of the 4x5 box I had and just put them all in one long row. So, with each cell supposedly 30w x 55h (the size of the character), I have a png that is 600w x 55h.

So, with that, I have added:

datablock fxImageMapDatablock2D(PlayerImageMap){
    mode = cell;
    cellWidth = 30;
    cellHeight = 55;  
    textureName = "~/client/images/Player1/player";
};

So, this basically establishes my ImageMap, if I'm correct... so now, what I'm wanting to do is to get the avatar to animate when, say, I hold down the right arrow key to move. So, for the Animation, I have:

datablock fxAnimationDatablock2D(PlayerRightAnimation){
   imageMap = PlayerImageMap;
   animationFrames = "8 9 10 11";
   animationTime = .5; 
   animationCycle = true;
};

So, when I hold down the key (arrow or D), I just call the PlayerRightAnimation...


But here's the problem. When the animation plays, it doesn't... look right. To put it in easy terms, it looks like if I were to lay the strip down on the table and cut out a square section of another piece of paper and put over the strip and just move down the line to show each piece of the image at a time...

The look I thought I was trying to create was more of a 'flip-book' sort of animation.. where the 'cell' of the imagemap was overlayed over the top of the last to create the animation.

So, instead, I actually wind up with a square on the screen and my avatar runs out from one side and off to the other. Which means even if I load the game and call the Animation Sequence (to let it just play even while sitting there), I can see the hard edges of the sides of the cell.. like the head emerges from the left side and then he runs through the middle and off to the right side.


Is there a way to "fix" the animation to act more like a flip-book than a film strip? Or is there another way I need to go about coding this?

Thanks for any help. =)

#1
09/23/2005 (7:12 am)
Hmm... think I may have figured out the problem, looking at it frame-by-frame... looks like each cell is too big or something.. because if I just load one cell of the image map at a time, its cut off at that point... so I just need to look at the size of things..

Will play with this a little more and see what I can come up with.. but I'm pretty sure it's just a sizing issue on my part with the image itself.
#2
09/23/2005 (7:47 am)
Yep. That was the problem. Works great, now. ;)
#3
09/23/2005 (9:34 am)
Glad you solved your problem. Even moreso glad you posted that you did, really helps if others find your thread with the same problems, now they know what you did works and can possibly help them too, thanks :)