sceneWindow2D.loadlevel not working.
by Jack-S- · in iTorque 2D · 09/21/2011 (11:27 am) · 2 replies
Hi I have been struggling to get iTorque 2D to load a level for a couple of hours now and while I have been able to swap levels using the behaviour genericbutton I would rather try and do this via script as I cant call functions from behaviours.I dont seem to be getting any erros in my console but I do get a black screen.
this is my game.cs
function startButton::onMouseDown(%this, %modifier, %worldPos)
{
if(startButton.clicked)
{
return;
}
else
{
startButton.clicked = true;
schedule(10,0,"loadSectorChoice");
echo("button has been clicked!!");
}
}
function startButton::onMouseUp(%this, %modifier, %worldPos)
{
startButton.clicked = false;
}
//
//
function loadSectorChoice(%level)
{
%level = "/game/data/levels/sectorMenu.t2d";
sceneWindow2D.endLevel();
if (isFile(%level))
{
sceneWindow2D.loadLevel(%level);
}
}
this is my game.cs
function startButton::onMouseDown(%this, %modifier, %worldPos)
{
if(startButton.clicked)
{
return;
}
else
{
startButton.clicked = true;
schedule(10,0,"loadSectorChoice");
echo("button has been clicked!!");
}
}
function startButton::onMouseUp(%this, %modifier, %worldPos)
{
startButton.clicked = false;
}
//
//
function loadSectorChoice(%level)
{
%level = "/game/data/levels/sectorMenu.t2d";
sceneWindow2D.endLevel();
if (isFile(%level))
{
sceneWindow2D.loadLevel(%level);
}
}
About the author
#2
My code suddenly just started to work. I had no error or anything before hand in the console. So im completely baffled! lol.
Im wondering though, if we must have at least one behavior in a game???
09/22/2011 (4:10 am)
Hi sorry simon thanks for the reply. I actually solved this yesterday, and yes all my datablocks were in place, it wasn't until I placed a behavior into my game that the problem just vanished.......My code suddenly just started to work. I had no error or anything before hand in the console. So im completely baffled! lol.
Im wondering though, if we must have at least one behavior in a game???
Simon Almqvist Pettersson
Dohi Sweden