Displaying more than 1 Animated Sprite
by Kneekick · in Torque Game Builder · 03/10/2006 (4:36 am) · 4 replies
Just wondering how other people are displaying more than 1 animated sprite in their sceneobject and the best ways of doing this.
I was playing around with it last night and I couldn't get past the point where each animated sprite that I loaded would just take the place of the last one I loaded, ie I always had only 1 sprite in my scene.
My steps were:
Created an imageMap with my animations in it (imagedatablock).
Setup 5 animation datablocks for each direction of movement (can flip 3 of them to achieve all 8 directions).
Create the animated sprite object, setup ScriptObjects for the animations, bind an actionmap, and used the actionmap to update the animation based on input.
This all works fine.
However if I create another player object with a different name and try to display it in it's default animation (which is just standing), it displays and the first player object disappears.
Does each animated sprite object need to have its own animationdatablocks and those need their own imagemap. I was thinking perhaps since they are both sharing the same animation datablocks and thus the same imagemap then perhaps last player object to be displayed is taking control?
I've looked through the tutorials and I can't seem to find any that load more than 1 animated sprite.
Just curious how anyone else is accomplishing this. It could very well be my logic.
I was playing around with it last night and I couldn't get past the point where each animated sprite that I loaded would just take the place of the last one I loaded, ie I always had only 1 sprite in my scene.
My steps were:
Created an imageMap with my animations in it (imagedatablock).
Setup 5 animation datablocks for each direction of movement (can flip 3 of them to achieve all 8 directions).
Create the animated sprite object, setup ScriptObjects for the animations, bind an actionmap, and used the actionmap to update the animation based on input.
This all works fine.
However if I create another player object with a different name and try to display it in it's default animation (which is just standing), it displays and the first player object disappears.
Does each animated sprite object need to have its own animationdatablocks and those need their own imagemap. I was thinking perhaps since they are both sharing the same animation datablocks and thus the same imagemap then perhaps last player object to be displayed is taking control?
I've looked through the tutorials and I can't seem to find any that load more than 1 animated sprite.
Just curious how anyone else is accomplishing this. It could very well be my logic.
About the author
#2
03/10/2006 (5:09 am)
Post the code.
#3
03/10/2006 (10:18 am)
Chris' suggestion is a good one, because what Anthony said is probably true! You can certainly have pretty much any amount of different animated sprites in a scene.
#4
03/10/2006 (2:07 pm)
I figured it out, once I started writing out my code on here it dawned on me. I was creating a seperate object for each player but in my setPlayerState function I had it hardcoded for just 1 player object. I didn't update it when I started adding more players.
Associate Anthony Rosenbaum
in order to have multiple sprites you need multiple varibales. for instance make a $player2 and repeat the origianl code you will have 2 sprite.