TGB Editor: how to define a scene object and feature request
by Pedro Vicente · in Torque Game Builder · 12/13/2011 (7:29 pm) · 4 replies
I was wondering if someone could provide some clues in this:
I am following this tutorial
tdn.garagegames.com/wiki/TGB/PlatformerStarterKit/Demo_Level
1) how to create a scene object in the editor? There is a drag and drop feature in "Other" , but how to define the object shown in the tutorial? Also I don't see the need for the tilemap here if it will not store collision information; it seems that the scene object alone would be enough.
2) Feature request Double clicking on the selected object in the TGB editor would pop up your favorite text editor (Torsion) with the line of code where the object is declared: it would make life easier to learn how TGB objects are translated into code.
I am following this tutorial
tdn.garagegames.com/wiki/TGB/PlatformerStarterKit/Demo_Level
Quote:
The tilemap itself will not store the collision information ... To avoid this, we will use three separate t2dSceneObjects to act as the actual platform object.
1) how to create a scene object in the editor? There is a drag and drop feature in "Other" , but how to define the object shown in the tutorial? Also I don't see the need for the tilemap here if it will not store collision information; it seems that the scene object alone would be enough.
2) Feature request Double clicking on the selected object in the TGB editor would pop up your favorite text editor (Torsion) with the line of code where the object is declared: it would make life easier to learn how TGB objects are translated into code.
#2
Thanks.
1) Ok. I don't see very well the practical use for an invisible scene object. Why not just use a static sprite and do all that collision detection in it? Why the extra trouble of having to mount the static sprite on the invisible object?
2) Yes, that's the best way to learn what the TGB Editor does to code, do the tutorial in a revision control system (e.g. svn) and record changes in revisions.
12/13/2011 (11:31 pm)
@ConorThanks.
1) Ok. I don't see very well the practical use for an invisible scene object. Why not just use a static sprite and do all that collision detection in it? Why the extra trouble of having to mount the static sprite on the invisible object?
2) Yes, that's the best way to learn what the TGB Editor does to code, do the tutorial in a revision control system (e.g. svn) and record changes in revisions.
#3
I'm finding that the longer I look at the process of making games the more I think that it's just finding the right series of hacks and workarounds to get things working the way you want with what you have. There are probably a few different ways to build the level presented, but each has its own compromises. Using the tilemap saves us some texture memory over using sprites for that section, but there's no reason you couldn't have used three sprites for that. Experiment and see what happens.
12/14/2011 (7:51 am)
For an answer to #1, you want to be able to edit the collision shape of the tile map terrain but the tilemap itself only supports collision with whole tiles. This method lets you give a "ramp" to walk up instead of "steps" to hop up. And, as the level was constructed, the first part would have required more than one static sprite anyway for the water portion since collision polygons must be convex.I'm finding that the longer I look at the process of making games the more I think that it's just finding the right series of hacks and workarounds to get things working the way you want with what you have. There are probably a few different ways to build the level presented, but each has its own compromises. Using the tilemap saves us some texture memory over using sprites for that section, but there's no reason you couldn't have used three sprites for that. Experiment and see what happens.
#4

12/14/2011 (10:11 pm)
Sorry for the total novice question, but after designing the scene below (from the tutorial above), the static sprite (dragon) is not visible at run; I must obviously be doing something wrong, but object layer is 0, set to visible, it shows in the editor, so not really sure ...
%levelContent = new t2dSceneGraph() {
canSaveDynamicFields = "1";
UseLayerSorting = "1";
layerSortMode0 = "Normal";
layerSortMode1 = "Normal";
layerSortMode2 = "Normal";
layerSortMode3 = "Normal";
layerSortMode4 = "Normal";
layerSortMode5 = "Normal";
layerSortMode6 = "Normal";
layerSortMode7 = "Normal";
layerSortMode8 = "Normal";
layerSortMode9 = "Normal";
layerSortMode10 = "Normal";
layerSortMode11 = "Normal";
layerSortMode12 = "Normal";
layerSortMode13 = "Normal";
layerSortMode14 = "Normal";
layerSortMode15 = "Normal";
layerSortMode16 = "Normal";
layerSortMode17 = "Normal";
layerSortMode18 = "Normal";
layerSortMode19 = "Normal";
layerSortMode20 = "Normal";
layerSortMode21 = "Normal";
layerSortMode22 = "Normal";
layerSortMode23 = "Normal";
layerSortMode24 = "Normal";
layerSortMode25 = "Normal";
layerSortMode26 = "Normal";
layerSortMode27 = "Normal";
layerSortMode28 = "Normal";
layerSortMode29 = "Normal";
layerSortMode30 = "Normal";
layerSortMode31 = "Normal";
DebugRendering = "0";
cameraPosition = "0.000000 0.000000";
cameraSize = "800.000000 600.000000";
new t2dStaticSprite() {
imageMap = "sky_duskImageMap";
frame = "0";
useSourceRect = "0";
sourceRect = "2.26805e-039 0 2.26805e-039 6.20121e-039";
canSaveDynamicFields = "1";
size = "800.000 600.000";
Layer = "30";
mountID = "2";
};
new t2dTileLayer() {
LayerFile = "~/data/tilemaps/layer_01.lyr";
canSaveDynamicFields = "1";
Position = "0.000 150.000";
size = "800.000 300.000";
CollisionMaxIterations = "1";
mountID = "3";
};
new t2dSceneObject() {
canSaveDynamicFields = "1";
Position = "-275.825 151.000";
size = "248.350 298.000";
CollisionPolyList = "-1.000 -1.000 0.660 -1.000 1.000 -0.673 1.000 1.000 -1.000 1.000";
mountID = "4";
_behavior0 = "PlatformBehavior";
};
new t2dSceneObject() {
canSaveDynamicFields = "1";
Position = "302.500 150.879";
size = "195.000 301.757";
CollisionPolyList = "-1.000 -0.683 -0.570 -1.000 1.000 -1.000 1.000 1.000 -1.000 1.000";
mountID = "5";
_behavior0 = "PlatformBehavior";
};
new t2dSceneObject() {
canSaveDynamicFields = "1";
Position = "26.675 175.000";
size = "356.650 250.000";
mountID = "6";
_behavior0 = "PlatformBehavior";
};
new t2dAnimatedSprite() {
animationName = "DragonIdleAnimation";
canSaveDynamicFields = "1";
Position = "-264.744 -42.668";
size = "170.000 170.000";
mountID = "7";
_behavior0 = "SpawnPointBehavior TargetType pskActor2D TargetObject DragonActorTemplate MinSpawnDistance 0 AutoDespawn 0";
};
};
Conor O'Kane
cokane.com
A tilemap is used to create the background because tilemaps are a very efficient way to create large levels. You can actually put collision in a tilemap by editing the collision box in the tilemap editor, but that's not used in this tutorial.
2 - You can open the .t2d file where the level is saved in a text editor and see all the object declarations.