Game Development Community

How to create game object by script

by Harry Chow · in General Discussion · 07/24/2012 (12:42 am) · 1 replies

Greetings,

I'm not sure if I put my question in the right place.

I'm using iTorque2D to do a game app for iOS. Currently I want to create some static spirits by script, not in editor. Could any one help on this, better in code? Thanks a lot!

#1
07/24/2012 (1:35 am)
Hi all,

After several tries, I found the solution.

1. My bad, spirit was totally wrong. Should use Sprite...
2. There are a lot of documents talking about how to create objects, like this one: http://tdn.garagegames.com/wiki/TorqueScript/Objects. But I couldn't find any one mentions to do addToScene;
3. So the correct script is:

%myObj = new t2dStaticSprite() {
imageMap = "Character_Alarm_01ImageMap";
position = "0 0";
frame = "0";
mUseSourceRect = "0";
sourceRect = "0 0 0 0";
canSaveDynamicFields = "1";
size = "62.000 62.000";
Layer = "3";
CollisionMaxIterations = "3";
AlphaTestValue = "-1";
mountID = "2";
};

%scenegraph.addToScene(%myObj);