Introduction
A t2dSceneObject is the base of all other objects in iTorque 2D.
Static sprites, animated sprites, scrollers, etc, all derive from this
base. What this means is that every object you add to your scene will
have a shared set of properties. This doc covers the common properties.
Creation
Any object created within the iTorque 2D editor is derived from a
t2dSceneObject. If you wish to create a blank scene object, navigate to
the Create panel. Find the Scene Object object in the Other panel.
Drag and drop this into the scene where you want it to exist. Once the
scene object has been placed, it can be resized like any other object
within the Scene View.
Properties
The following properties can be modified from the editor on every object in the level.
Behaviors

Behaviors are pieces of code that give a particular object a
specific... well, behavior! Whether you want to turn a certain object
into an enemy, make it move back and forth, move to wherever the player
touches the screen or more - Behaviors allow you to very quickly add
code to an object without need to do a lot of extra work.
To select one of your behaviors, choose it from the Drop Down List and
press the green plus button. Your project must have behaviors associated
with it for this list to have anything in it.
iOS Target
This drop-down will affect what platforms that this object will load and render on.
- IPHONE - This object will only exist when the game is played on an iPhone.
- IPAD - This object will only exist when the game is played on the iPad.
- UNIVERSAL - This object will exist on both the iPhone and the iPad.
Scene Object
- Position
- X - The position of this object upon the X axis in the scene.
- Y - The position of this object upon the X axis in the scene.
- Size
- Width - The width of this object.
- Height - The height of this object.
- Rotation - The rotation of this object, in degrees.
- Auto Rotation - The speed that this object will
automatically rotate when loaded into the scene. Positive will rotate
clockwise, negative will rotate counter clockwise.
- Flip Horizontal - If true, the object will be flipped horizontally.
- Flip Vertical - If true, the object will be flipped vertically.
- Sort Point
- X - The X position, relative to the object, that the Sort Point is located.
- Y - The Y position, relative to the object, that the Sort Point is located.
- Layer - Which depth layer that this object will exist upon.
- Group - Which object group that this object will be in.
- Back/Forward - Moves the object backwards and forwards
within the layer it is in. Use this if you have multiple objects in the
same layer and need to adjust their sorting.
- Lifetime - How long this object will exist.
- Visible - If true, the object is visible in the scene. If false, the object will not render.
Align
Modify how this object is aligned with the camera view.
-
- Align to the left.
-
- Align to the horizontal center.
-
- Align to the right.
-
- Align to the top.
-
- Align the to vertical center.
-
- Align to the bottom.
-
- Match horizontal size to horizontal viewport size.
-
- Match vertical size to vertical viewport size.
-
- Match size of object to the viewport size.
Scripting
- Persist - Set this object to persist across all levels.
- Config Datablock - The configuration datablock to associate this sceneobject with.
- Name - Name the object for referencing in script.
- Class - Link this object to a Class.
- Super Class - Link this object to a Parent Class.
- Use Mouse Events - Enable mouse callbacks on the object.
Mounting
- Rotation - Mount Rotation
- Auto Rotation - Automatic Mount Rotation
- Mount Force - (Only available when object is mounted) If
this is not zero, this "tightens" or "loosens" how quickly the mounted
object follows the parent, with lower numbers resulting in the mounted
object taking longer to "catch up to" the parent.
- Track Rotation - (Only available when object is mounted) If this is checked the mounted object will rotate with its parent object.
- Owned by Mount - (Only available when object is mounted) Owned by Mount
- Inherit Attributes - (Only available when object is
mounted) If this is checked the mounted object will inherit the object
properties (such as visibility) of the parent object.
World Limits
- Limit Mode - The selected Limit Mode affects what occurs when the object touches the edges of the bounds of the World Limits.
- Off - The world limits are not even tested by the object.
- Null - The world limits are tested, but no action is
taken when the object reaches the limits; it just continues on its way.
This mode is used in combination with the Callback checkbox to script
your own responses to reaching the world limits.
- Clamp - The object slides along the world limits and will not move past them.
- Bounce - The object bounces off the world limits in a simple, pong-like way and doesn't include spin.
- Sticky - The object stops all movement when it touches the world limits.
- Kill - The object deletes itself when it touches the world limits.
- Min Bounds - The minimum X and Y position of the bounds
for the World Limit. This can be edited here, however is also modified
by using the visual World Limit Editor.
- Max Bounds - The maximum X and Y position of the bounds
for the World Limit. This can be edited here, however is also modified
by using the visual World Limit Editor.
- Callback - If true, will cause a script-response to
occur when the World Limits are reached. In your script, the callback
for this object should look like this to function:
function myObject::onWorldLimit(%this, %mode, %limit)
{
// %mode will be one of the following strings:
// off, null, bounce, clamp, sticky, kill
// %limit will be one of the following strings:
// top, bottom, left, right
}
Alpha Testing
- Alpha Test Value - Enables alpha testing for this object if the value is between 0 - 255. Set to -1 to disable Alpha Testing.
Blending
- Enabled - Enable blending for this object
- Source Factor - Source blend factor for this object. These represent constants in the format (R, G, B, A).
- ZERO - The blend factor is (0, 0, 0, 0).
- ONE - The blend factor is (1, 1, 1, 1).
- DST_COLOR - The blend factor is (R, G, B, A) of the destination pixel applied as alpha to each channel.
- ONE_MINUS_DST_COLOR - The blend factor is (1 - R, 1 - G, 1 - B, 1 - A) of the destination pixel applied as alpha to each channel.
- SRC_ALPHA - The blend factor is (A, A, A, A) of the source pixel alpha channel.
- ONE_MINUS_SRC_ALPHA - The blend factor is (1 - R, 1 - G, 1 - B, 1 - A) of the source pixel applied as alpha to each channel.
- DST_ALPHA - The blend factor is (A, A, A, A) of the destination pixel alpha channel.
- ONE_MINUS_DST_ALPHA - The blend factor is (1 - A, 1 - A, 1 - A, 1 - A) of the destination pixel alpha channel.
- SRC_ALPHA_SATURATE - The blend factor is (f, f, f, 1) where f = min(Asource, 1 - Adestination).
- Destination Blend Factor - Destination blend factor for this object. These represent constants in the format (R, G, B, A).
- ZERO - The blend factor is (0, 0, 0, 0).
- ONE - The blend factor is (1, 1, 1, 1).
- SRC_COLOR - The blend factor is (R, G, B, A) of the source pixel applied as alpha to each channel.
- ONE_MINUS_SRC_COLOR - The blend factor is (1 - R, 1 - G, 1 - B, 1 - A) of the source pixel applied as alpha to each channel.
- SRC_ALPHA - The blend factor is (A, A, A, A) of the source pixel alpha channel.
- ONE_MINUS_SRC_ALPHA - The blend factor is (1 - R, 1 - G, 1 - B, 1 - A) of the source pixel applied as alpha to each channel.
- DST_ALPHA - The blend factor is (A, A, A, A) of the destination pixel alpha channel.
- ONE_MINUS_DST_ALPHA - The blend factor is (1 - A, 1 - A, 1 - A, 1 - A) of the destination pixel alpha channel.
- Blend Color
- Red - Red Blending Value
- Green - Green Blending Value
- Blue - Blue Blending Value
- Alpha - Alpha (Transparency) Blending Value
At no point should you ever need Alpha Testing and Blending enabled.
Only use one or the other. They both serve a similar purpose, but they
have dramatically different appearances. By Default, Blending is enabled
and Alpha Testing is turned off. The following examples show how the
two settings are toggled:
Blending Enabled
Blending and Alpha Testing Disabled
Alpha Testing 128
Dynamic Fields
Each entry specifies another Dynamic Field for the object. Their
functionality should be defined in the scripts that utilize the object.
Script Representation
new t2dSceneObject() {
canSaveDynamicFields = "1";
PlatformTarget = "UNIVERSAL";
Position = "128.769 -110.190";
size = "128.000 128.000";
CollisionMaxIterations = "3";
AlphaTestValue = "-1";
mountID = "13";
};
Conclusion
All objects in iTorque2D derive off the t2dSceneObject class, allowing for powerful, object-oriented system design. |