Game Development Community

Animated sprites

by Gavin Beard · in Torque Game Builder · 03/16/2005 (3:04 am) · 13 replies

Hi, i have a character for my game that has 3 frames of animation for its walk cycle. i can set up the animation and use it as a animated tile, but if i try to use the fxAnimatedSpriteDatablock2D and create a fxAnimatedSprite2D() i dont seem to have any way of tell it to use the fxAnimatedspritedatablock2d, i've tried the SetImageMap parameter that exists for the static sprites but this doesnt exist for the animted ones. Also once i do get it working is it easy to change the anim. to reflect the direct that player is walked. ie. a seperate anim for up down left right.?

cheers

#1
03/16/2005 (3:16 am)
I thought it was a bit different. unless I read you wrong.

Basically you would set up fxAnimatedSpriteDatablock2D with whatever animation, name it, etc..

And then for fxanimatedsprite2d()You would do a add whatever you named the fxAnimatedSpriteDatablock2D to fxanimatedsprite2d's .setimagemap.

I'll post some code in a minute
#2
03/16/2005 (3:20 am)
The setimagemap causes the console to display an error saying that 'setimagemap' doesnt exist. if i do $player.dump(); (player being the name i gave to the animated sprite) sure enough there is no setimagemap listed.
#3
03/16/2005 (3:27 am)
I thought it was a bit different. unless I read you wrong.

Basically you would set up fxAnimatedSpriteDatablock2D with whatever animation, name it, etc..

And then for fxanimatedsprite2d()You would do a add whatever you named the fxAnimatedSpriteDatablock2D to fxanimatedsprite2d's .setimagemap.

I'll post some code in a minute

Ok heres an example:

Quote:

datablock fxAnimationDatablock2D(somesuchthing)
{
imageMap = yo;
animationFrames = "8 9 10";
animationTime = 0.75;
animationCycle = 0;
randomStart = 0;
}

That would create the datablock
[quote]

then in your fxanimatedsprite2d, try using .playanimation("somesuchthing"); or playanimation="somesuchthing"

Where somesuchthing is what you named the datablock
Whatever it is. I'm at work so I'm winging it
#4
03/16/2005 (3:34 am)
Looking at the object list you may need to create a fxAnimationDatablock2D like above asign it to fxAnimatedSpriteDatablock2D and then asign it to fxAnimatedSprite2D.

The reason being is that the first one sets up the animation, the second is for Configuring fxAnimatedSprite2D-Based Object and third being the object itself

Edit: just so you know. I am following the reference doc that is located in the docs folder. I have not yet messed with animated sprites
#5
03/16/2005 (3:35 am)
Ah see, thats it, i was using fxAnimatedDatablock2D instead of fxAnimationDatablock2D

edit: i loked at the ref. and it didnt read like that to me :) but it works so u read it bettr than i do.

i create a fxImageMapDatablock2D which is then ref'd in the fxAnimationDatablock2D and then ref that in fxAnimatedSprite2D.

thanks for the help
#6
03/16/2005 (3:52 am)
Actually, thank you.

When I'm at work and see these things it gives me a chance to look into stuff that I normally don't get a chance to look at.

So thanks
#7
03/16/2005 (4:08 am)
Well its now changing animation depending on what way my player is moving, and resets to a standard 'stop' anim when he's not walking
#8
03/16/2005 (4:12 am)
Thats what you wanted right?

I really need to start looking into animated sprites.

I gutted an old sierra classic that I loved when I was younger. I basically removed all of the houses trees etc and then rebuilt the scenes in layers so they would look the same. That way I could remake the game with the classic graphics and it would play the same.

I would really love to remake the game exactly how it is but with better graphics. Since I am not graphically inclined, I figure I will do it with the old ones and then redo it with new ones at a later time.

Just out of respect to the game itself of course. And for practice
#9
03/16/2005 (4:28 am)
Yeah t'was exactly what i was after.

if i had to remake an old fav. i think i would pick 'mega-lo-mania' was one of my fav games on the megadrive/ early pc.

only prob is i'm not sure how well a rts would run in t2d (if even poss) even one as simple as megalomania.

well, if ure not gfx minded as such all u can do is try, u can rough out some gfx and keep refining over the course of game dev.
#10
03/16/2005 (6:43 am)
There's no reason why you couldn't do an RTS. You can pretty much do anything in T2D apart from games that need stuff like ISO tile views. There's also the option to add custom objects to do custom work. It's all pretty open and with the source, the possibilities are practically limitless. :)

- Melv.
#11
03/16/2005 (7:18 am)
Lol, i stand corrected then Melv, i was just unsure coz of all the units being deleted and added to each team constantly.
#12
03/16/2005 (7:24 am)
What units are those that you're destroying? Why do you need to do that?

Maybe I can offer you some advice on how to solve your particular problem?

Do you know that you only really need to have animations/images for one direction and that you can use "setFlip()" which will flip your sprite images, mount-points and mounted-images automatically.

Just thought I'd mention it. :)

- Melv.
#13
03/16/2005 (11:11 am)
Well by deleting units i ment when they get destryed/killed they need to be removed from memory and as the user creates new units they get added to memory.

i knew images could be rotated but the ones i'm using are draw from a slight angle so as the player oves away u see the back of him, which couldnt be done with rotation

i am real tempted to try a TBS first tho......