Game Development Community

new t2danimationsprite help

by jerryg7rk3w · in Game Design and Creative Issues · 09/01/2011 (12:20 pm) · 3 replies

I know this is a really simple problem but i don't know what im doing wrong.

I'm trying to add an animation sprite to my scene with no luck.
I had no problems adding a static sprite using the same code, i just changed the t2danimationsprite to t2dstaticsprite and imagemap to a static one and the code will work.

If i run it using the animated sprite it won't work?
heres my code:..........................................


function createobject(%this)
{
$g = new t2danimatedSprite(%this)
{
imagemap = "triggerfish1sheetImageMapAnimation";//"triggerfish2sheetImageMap";

};
sceneWindow2D.getSceneGraph().addtoScene($g);
$g.SetPositionX(-17);
$g.SetPositionY(-16);
$g.setsize(10,10);
$g.setLayer(0);
$g.setvisible(true);

echo("created new object");
echo($g.GetLayer());
echo($g.getid());
}

All the echos work and i can reference the object through its id but i don't see it anywhere on the screen?

#1
09/02/2011 (12:54 pm)
My TGB is a little rusty. Where is the datablock for your imagemap triggerfish1sheetImageMapAnimation?
#2
09/02/2011 (5:02 pm)
Do i have to use datablocks for animated spites? because I ran the same exact code below using a static sprite and it works without any problems.


function createobject(%this)
{
$g = new t2dstaticSprite(%this)
{
imagemap = "triggerfish2sheetImageMap";

};
sceneWindow2D.getSceneGraph().addtoScene($g);
$g.SetPositionX(-17);
$g.SetPositionY(-16);
$g.setsize(10,10);
$g.setLayer(0);
$g.setvisible(true);

echo("created new object");
echo($g.GetLayer());
echo($g.getid());
}

How come this code only works for static sprites and not animated ones, i must be missing some code or do i have to use datablocks to get animated sprites to work?
#3
09/09/2011 (6:13 am)
You need a t2dAnimationDatablock for it to work.