Load lvl
by Anthony Ratcliffe · in Torque Game Builder · 02/13/2008 (2:43 pm) · 4 replies
I've added a position movement withing my game and when the loop ends i want to change to a diffrent level (scene) however tgb crashes when i use the code below. any help please.
function si::onLevelLoaded(%this)
{
$level = "game/data/levels/end.t2d";
$node=0;
%this.setPositionTarget(48,-30, true, true);
%this.setLinearVelocityX(15);
$node++;
}
//goes along 15
function si::onPositionTarget(%this)
{
if ($node==1)
{
%this.setPositionTarget(48,-28, true, true);
echo ("reached call2");
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(2);
$node++;
}
// code continues to node 36 in the loop
else if ($node==36)
{
echo ("reached call37");
sceneWindow2d.loadLevel ($level);
$node++;
}
function si::onLevelLoaded(%this)
{
$level = "game/data/levels/end.t2d";
$node=0;
%this.setPositionTarget(48,-30, true, true);
%this.setLinearVelocityX(15);
$node++;
}
//goes along 15
function si::onPositionTarget(%this)
{
if ($node==1)
{
%this.setPositionTarget(48,-28, true, true);
echo ("reached call2");
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(2);
$node++;
}
// code continues to node 36 in the loop
else if ($node==36)
{
echo ("reached call37");
sceneWindow2d.loadLevel ($level);
$node++;
}
About the author
#2
then set the function below and it came up with scripting errors ?
02/13/2008 (8:06 pm)
I set up scedule at the top declaring %destthen set the function below and it came up with scripting errors ?
#3
behaviour component::add behaviors missing behaviors ??
02/13/2008 (8:32 pm)
Also after using this code i am recieving an error whilst trying to use behavioursbehaviour component::add behaviors missing behaviors ??
#4
02/13/2008 (9:12 pm)
I'm not sure I'm following what you're saying. Can you be more specific about the errors, or post the code?
Torque Owner Dan Maruschak
Instead, try to schedule the loadLevel instead of calling it directly from an object's method, e.g.:
function DoTransition(%dest) { sceneWindow2D.loadLevel(%dest); }