Instances of "ScriptObject
by Daniel Jami · in Torque Game Builder · 07/27/2007 (4:26 am) · 5 replies
Hi
i tryed to build my weapons like this:
how i cand create on object that i cand instantiate it !!
i tryed to build my weapons like this:
new scriptObject() {
class = weapon_ICE;
power = 100;
fire_speed = 100;
misile_speed = 800;
level = 2;
};now i need to create multi instances of my "ScriptObject" , and i use this code:function playerShip::setWeapons(%this) {
%this.playerMissile[0] = new weapon_ICE();
}but followeing error is result :Unable to instantiate non-conobject class weapon_ICE.
how i cand create on object that i cand instantiate it !!
About the author
#2
the ":" tells it to copy all the properties from the object after it... The class field is for namespace linking only...
07/27/2007 (10:29 am)
To get your new missile using the defaults you are trying to create you can do somet hing like this though...new scriptObject(Weapon_ICE) {
power = 100;
fire_speed = 100;
misile_speed = 800;
level = 2;
};function playerShip::setWeapons(%this) {
%this.playerMissile[0] = new t2dStaticSprite( : Weapon_ICE)
{
scenegraph = %this.scenegraph;
};
}the ":" tells it to copy all the properties from the object after it... The class field is for namespace linking only...
#3
Where is the " : " operator in the documentation? I would like to read more about it and be able to refer people to it!
07/27/2007 (11:53 am)
Whoa that is cool! Where is the " : " operator in the documentation? I would like to read more about it and be able to refer people to it!
#5
07/27/2007 (2:33 pm)
Pretty neat example... gonna give it a try, and maybe change some bits of code using the example... thx Matthew.
Torque 3D Owner Matthew Langley
Torque
function playerShip::setWeapons(%this) { %this.playerMissile[0] = new weapon_ICE(); }to
function playerShip::setWeapons(%this) { %this.playerMissile[0] = new t2dStaticSprite() { scenegraph = %this.scenegraph; class = weapon_ICE; }; }