Game Development Community

Can't create t2danimatedsprite on the fly

by Michael S · in Torque Game Builder · 11/07/2006 (6:39 am) · 3 replies

Hi there i've trouble to make t2danimatedsprite on the fly

before i do that first i create that t2danimatedsprite on levelbuilder
and i open my level.t2d on textpad and
copy that t2danimatedsprite creation's script on my spawngrasshopper function


is there something wrong on my script

here is my script

function factory::onlevelloaded(%this)
{

%this.schedule(5000,"spawngrasshopper");

}

function factory::spawngrasshopper(%this)
{

new t2dAnimatedSprite() {
animationName = "grasshopperstandbyAnimation";
canSaveDynamicFields = "1";
class = "GrassHopper";
position = "45.000 85.000";
size = "20.000 20.000";
Layer = "3";
WorldLimitMode = "KILL";
WorldLimitMin = "-125.000 -75.000";
WorldLimitMax = "240.000 170.000";
WorldLimitCallback = "1";
CollisionActiveReceive = "1";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
CollisionCallback = "1";
CollisionPolyList = "-0.953 -0.271 -0.147 -0.597 0.845 -0.349 0.876 0.891 -0.736 0.814";
LinearVelocity = "30.000 0.000";
mountID = "8";
};

error("Bim Salabim");
%this.schedule(5000,"spawngrasshopper");
}


when i play my level the "Bim salabim" text is appear on my console window
but not my t2danimatedsprite
what is wrong with this?

#1
11/07/2006 (6:54 am)
Oh crap i forget to add

scenegraph = %this

even though i copy that creation script on my level.t2d
i guess there is something incomplete thing
#2
11/07/2006 (11:06 pm)
Does your "animation" show and doesn't play? Or doesn't show at all.

If it shows and doesn't play call playAnimation on it.

playAnimation(%animation, [%autoRestore = false], [%startFrame = 0],
[%mergeTime = false])

Purpose
Sets the animation to play and plays it.
Syntax
%animation - t2dAnimationDatablock
The animation to play.
%autoRestore - Bool
If true, the previous animation will be played when this new animation finishes.
%startFrame - Integer
The animation frame to start playing from.
%mergeTime - Bool
Merges the previous animation with the new one. If this is true, and the previous animation is
50% complete, the new animation will start 50% of the way through.

But you can't do that unless your animation is an object. So do..

%animation = new t2dAnimatedSprite() { ... }
%animation.playAnimation(...);
#3
11/12/2006 (7:44 am)
My animation couldn't show
but i've solved this
thanks for the reply matthew