Game Development Community

Load a Animation sprite with script

by Harrison Brock · in Torque Game Builder · 01/03/2007 (5:58 pm) · 1 replies

I can load a static sprite like this:

function toyman::ShowImage(%this)
{
%this.setWorldLimit( kill, "-85 -115 155 50" );
%this.setLinearVelocityX(-20);
%this.setPosition(%this.enemySaucer.getPosition());
%this.setImageMap(Zook_64ImageMap);
%this.setSize(10, 10);
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}

Than I can this on the enemy ship

function enemySaucer::explode(%this)
{
%this.toyman = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = toyMan;
enemySaucer = %this;
};

}

But I need a animation sprite. So I change the t2dStaticSprite() to t2dAnimationSprite().

But the Animationsprite dose not a method for setImageMap. So what would be the best way to do this?

I would be something like this:

function enemySaucer::explode(%this)
{
%this.toyman = new t2dAnimationSprite()
{
scenegraph = %this.scenegraph;
class = toyMan;
enemySaucer = %this;
};

}

Thanks for any help

#1
01/03/2007 (9:15 pm)
You need to create an animation from an image that you can then assign to the animation sprite via setAnimation(). Use TGB's animation builder - see the docs for more info