Game Development Community

About T2D Basic Tutorial

by Guo Qiang · in Torque Game Builder · 05/19/2005 (7:37 pm) · 9 replies

$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );

Which file write in????

#1
05/19/2005 (10:06 pm)
The client.cs file, in the CreatePlayer() function. That is, make a CreatePlayer() function, paste that code in it.
Make sure to call the function :)

If I understand your question correctly.
#2
05/19/2005 (10:40 pm)
How to call the function?
How to run the Scripts?

Thanks,
#3
05/19/2005 (10:42 pm)
Call the func in your initiialization function in the client.cs script. You dont run the scripts, you run the T2D.exe which utilizes the script.
#4
05/19/2005 (10:46 pm)
//This script is edited in Brain Editor Pro - v1.0.7 DEMO
//-----------------------------------------------------------------------------
// Torque 2D.
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

// --------------------------------------------------------------------
// Initialise Client.
// --------------------------------------------------------------------
function initialiseClient()
{
// Initialise Base Client.
InitBaseClient();

// Key-Bindings.
GlobalActionMap.bind(keyboard, tilde, ToggleConsole);
GlobalActionMap.bindCmd(keyboard, "alt enter", "", "toggleFullScreen();");


// Initialise Canvas.
InitCanvas("T2D");


// ************************************************************************
// Load-up Demo Datablocks.
// NOTE:- Remove this is you're not interested in running the demos
// or any or the default datablocks.
// ************************************************************************
exec("./demoDatablocks.cs");



// Load-up Datablocks.
exec("./datablocks.cs");
// Load-up GUIs.
exec("./mainScreenGui.gui");

// Set GUI.
Canvas.setContent(mainScreenGui);
// Set Cursor.
Canvas.setCursor(DefaultCursor);

// Setup Scene.
setupT2DScene();
CreatePlayer();
}


// --------------------------------------------------------------------
// Destroy Client.
//
// Here we destroy the SceneGraph.
// --------------------------------------------------------------------
function destroyClient()
{
// Destroy fxSceneGraph2D.
if ( isObject(t2dSceneGraph) )
t2dSceneGraph.delete();
}


// --------------------------------------------------------------------
// 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" );


// ************************************************************************
//
// Add your custom code here...
//
// ************************************************************************



}


function CreatePlayer()
{
$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );

}
#5
05/19/2005 (10:50 pm)
Place the call to CreatePlayer in setup2TDScene, under where it says ADD CUSTOM CODE HERE.

also make sure your datablock is created for your player.
#6
05/19/2005 (10:57 pm)
Can you give me a whole list for this?
Thanks,
#7
05/19/2005 (11:01 pm)
But the tutorial explains it all ? I thought the tut did an excellant job. It explained everything 100% for me.
#8
05/19/2005 (11:05 pm)
This issue has been resolved, thank you very much.
#9
05/19/2005 (11:08 pm)
Ok :)