Help wanted :O (what am I doing wrong?)
by Ed van Tedened · in Torque Game Builder · 11/25/2005 (12:55 pm) · 3 replies
Hi! Yesterday I bought the EA of Torque 2D.. I'm loving it BUT I'm stuck already :(
I'm following the beginner's guide that's both on the TDN and in the doc map in the SDK.
I'm at the part were i should clean the code up by categorising it. I don't know what I am doing wrong.. its prolly some small thing that I'm overlooking. I just don't see it..
I'm following the beginner's guide that's both on the TDN and in the doc map in the SDK.
I'm at the part were i should clean the code up by categorising it. I don't know what I am doing wrong.. its prolly some small thing that I'm overlooking. I just don't see it..
// --------------------------------------------------------------------
// Setup T2D Scene.
// --------------------------------------------------------------------
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );
// Set Camera Position to be centered on (0,0) with
// view width/height of (100/80).
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
// Set up the images for the game
SetupImages();
// Set up the player's stuff
CreatePlayer();
// Set up the enemy
CreateEnemy();
}
function SetupImages()
{
// Create an image for the player ship
datablock t2dImageMapDatablock(playershipImageMap)
{
mode = full;
textureName = "~/client/images/playerShip";
};
// Create an image for enemy ships
datablock t2dImageMapDatablock(enemyship1ImageMap)
{
mode = full;
textureName = "~/client/images/enemyship1";
};
// Create an image for the enemy's missiles
datablock t2dImageMapDatablock(enemymissileImageMap)
{
mode = full;
textureName = "~/client/images/enemyMissile";
};
}
function CreatePlayer()
{
// Create the player's ship sprite
$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );
// Create a new action map.
new ActionMap(playerMap);
// Bind keys to actions.
playerMap.bindCmd(keyboard, "w", "playerUp();", "playerUpStop();");
playerMap.bindCmd(keyboard, "s", "playerDown();", "playerDownStop();");
playerMap.bindCmd(keyboard, "a", "playerLeft();", "playerLeftStop();");
playerMap.bindCmd(keyboard, "d", "playerRight();", "playerRightStop();");
playerMap.bindCmd(keyboard, "space", "playerFire();", "");
// Activate the action map.
playerMap.push();
}
function CreateEnemy()
{
// Create an enemy ship
%enemy = new t2dStaticSprite() { scenegraph = t2dScene; };
%enemy.setImageMap( enemyship1ImageMap );
%enemy.setSize( "14 7" );
%enemy.setPosition("40 0");
// Move the enemy towards us.
%enemy.setLinearVelocityX(-20);
// Create an enemy missile and fire it
%enemyFire = new t2dStaticSprite() { scenegraph = t2dScene; };
%enemyFire.setPosition( %enemy.getPosition() );
%enemyFire.setSize( "3 1.5" );
%enemyFire.setImageMap( enemymissileImageMap );
%enemyFire.setLinearVelocityX( -35 );
%enemyFire.setWorldLimit( kill, "-60 -40 60 40" );
}
#2
Is there a way to copy the text in your console log?
anyway it says:
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dStaticSprite
And then it of course has trouble to set the position and other options for the images:
Unable to find object '0' attempting to call function 'setPosition'/'setSize'/'imageMap/etcetera
11/25/2005 (1:39 pm)
Errm the 1.0 version.Is there a way to copy the text in your console log?
anyway it says:
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dImageMapDatabock
Unable to instantiate non-conobject class t2dStaticSprite
And then it of course has trouble to set the position and other options for the images:
Unable to find object '0' attempting to call function 'setPosition'/'setSize'/'imageMap/etcetera
#3
The original version named objects like this; fxStaticSprite2D, which is a hangover from the way I named objects historically on this site. T2D now uses the non-melv-may way of naming things so the above becomes t2dStaticSprite; note the prefix of "t2d" before everything.
As of the alpha, all objects are named this way so select "my account" at the top of this page, in the table entitled "Downloadable Products You Own", select "Download" against the T2D Product and you should be presented with the alpha version that uses this naming convention.
If you don't want to use an alpha (although I'd definately recommend it) then you need to refer to your objects using the old naming style.
All the TDN stuff uses the new one and even now, some of this stuff needs updating to bring it into line with the very latest ways of doing things so you could say that it sits between the old v1.0.2 release and the v1.1.0 alpha.
Hope this helps,
- Melv.
11/26/2005 (4:50 am)
Kevin,The original version named objects like this; fxStaticSprite2D, which is a hangover from the way I named objects historically on this site. T2D now uses the non-melv-may way of naming things so the above becomes t2dStaticSprite; note the prefix of "t2d" before everything.
As of the alpha, all objects are named this way so select "my account" at the top of this page, in the table entitled "Downloadable Products You Own", select "Download" against the T2D Product and you should be presented with the alpha version that uses this naming convention.
If you don't want to use an alpha (although I'd definately recommend it) then you need to refer to your objects using the old naming style.
All the TDN stuff uses the new one and even now, some of this stuff needs updating to bring it into line with the very latest ways of doing things so you could say that it sits between the old v1.0.2 release and the v1.1.0 alpha.
Hope this helps,
- Melv.
Torque Owner Vashner
What does your console.log say? Normally it will show where torque jams up.