Clone a level function...
by Isaac Barbosa · in Torque Game Builder · 12/12/2006 (9:57 am) · 5 replies
Well... I guess that I'm starting to understand the nuts and bolts of TGB :) But it seems a large road...
There is a respawnPoint and a MoleLevel functions in whackAMole tutorial.
So I'm trying to reply exactly that functions for new respawnPoints and a NonMoleLevel function...
So, I save one cs file as respawnPointB and another as NonMoleLevel. So I will have another datablock named respawnPointB that works exactly as respawnPoint but it has to be independent ... (I add B where necessary... so I have
datablock t2dSceneObjectDatablock( respawnPointBDatablock )
{
class = "respawnPointB"; // the class that will be associated with the object
layer = 5; // the render layer
size = "16 16"; // the size of the object
};
function respawnPointB::onLevelLoaded(%this, %level)
{
%level.respawnPointSetB.add(%this);
}
function respawnPointB::onLevelEnded(%this, %level)
{
if( isObject( %level.respawnPointSetB ) )
%level.respawnPointSetB.remove(%this);
}
And I use the same logic for the NonMoleLevel function... where I found a Mole I change it for another name, say, BALLOON, and I call another imageMap, and every factory statement becomes now factoryB...
I delete
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
moleHammer.setPosition(%worldPosition);
}
to avoid two equal functions and too
function moleLevel::onUpdateScene(%this)
{
// Calculate how much time is left
%timeLeft = $MOLE_LEVEL::timePerGame - %this.getSceneTime();
// Round it to full seconds
%timeLeft = mFloor( %timeLeft + 0.5 );
// Time-check
if( %timeLeft < 0 )
{
%this.setScenePause( true );
MoleGuiGameOver.visible = 1;
%timeLeft = 0;
}
// Update the GuiTextCtrl
MoleGuiTimer.text = "Timer:" SPC %timeLeft ;
}
to avoid two functions managing time. But at the end no new instances are spawned in the new respawnPointB....
can somebody explain me if this make sense which is the approach that I have to take when trying to reply functions?
Thanks
There is a respawnPoint and a MoleLevel functions in whackAMole tutorial.
So I'm trying to reply exactly that functions for new respawnPoints and a NonMoleLevel function...
So, I save one cs file as respawnPointB and another as NonMoleLevel. So I will have another datablock named respawnPointB that works exactly as respawnPoint but it has to be independent ... (I add B where necessary... so I have
datablock t2dSceneObjectDatablock( respawnPointBDatablock )
{
class = "respawnPointB"; // the class that will be associated with the object
layer = 5; // the render layer
size = "16 16"; // the size of the object
};
function respawnPointB::onLevelLoaded(%this, %level)
{
%level.respawnPointSetB.add(%this);
}
function respawnPointB::onLevelEnded(%this, %level)
{
if( isObject( %level.respawnPointSetB ) )
%level.respawnPointSetB.remove(%this);
}
And I use the same logic for the NonMoleLevel function... where I found a Mole I change it for another name, say, BALLOON, and I call another imageMap, and every factory statement becomes now factoryB...
I delete
function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{
moleHammer.setPosition(%worldPosition);
}
to avoid two equal functions and too
function moleLevel::onUpdateScene(%this)
{
// Calculate how much time is left
%timeLeft = $MOLE_LEVEL::timePerGame - %this.getSceneTime();
// Round it to full seconds
%timeLeft = mFloor( %timeLeft + 0.5 );
// Time-check
if( %timeLeft < 0 )
{
%this.setScenePause( true );
MoleGuiGameOver.visible = 1;
%timeLeft = 0;
}
// Update the GuiTextCtrl
MoleGuiTimer.text = "Timer:" SPC %timeLeft ;
}
to avoid two functions managing time. But at the end no new instances are spawned in the new respawnPointB....
can somebody explain me if this make sense which is the approach that I have to take when trying to reply functions?
Thanks
#2
Sorry for the untagged code. Now I know how to tag it :)
Well, I'm trying to duplicate the functions moleLevel and respawnPoint from whack-a-mole tutorial, so I will be able to have some respawnpoint at the bottom and some at the top working (creating and respawning) different sprites. So I will use original moleLevel as it is and a duplicated moleLevelDuplicated function to respawn another sprite from library. The point is that I dont know if there is a way to respawn different sprites from different respawn points. So I guess that the right way is do two spriteLevel functions and two resawn point functions... and so on.
I don't know if this makes sense.
The path I follow actually was save actual moleLevel as otherLevel and change every mole call and variable for anything else, I save respawnpoint function as respawnfunctionB and so I have two different datablocks but it is not working... not the replicated function, just the mole level is working.
Thanks and sorry for this explanation, I don't know how to explain it better.
12/14/2006 (8:36 am)
Thanks Tom,Sorry for the untagged code. Now I know how to tag it :)
Well, I'm trying to duplicate the functions moleLevel and respawnPoint from whack-a-mole tutorial, so I will be able to have some respawnpoint at the bottom and some at the top working (creating and respawning) different sprites. So I will use original moleLevel as it is and a duplicated moleLevelDuplicated function to respawn another sprite from library. The point is that I dont know if there is a way to respawn different sprites from different respawn points. So I guess that the right way is do two spriteLevel functions and two resawn point functions... and so on.
I don't know if this makes sense.
The path I follow actually was save actual moleLevel as otherLevel and change every mole call and variable for anything else, I save respawnpoint function as respawnfunctionB and so I have two different datablocks but it is not working... not the replicated function, just the mole level is working.
Thanks and sorry for this explanation, I don't know how to explain it better.
#3
12/14/2006 (3:59 pm)
When I use the
#4
"Unable to find object"
Can somebody point me? I have no idea on what could be wrong...
Thanks!
%this is code
[datablock t2dSceneObjectDatablock( respawnBalloonPointDatablock )
{
class = "respawnBalloonPoint"; // the class that will be associated with the object
layer = 5; // the render layer
size = "16 16"; // the size of the object
};
function respawnBalloonPoint::onLevelLoaded(%this, %nivel)
{
%nivel.respawnBalloonPointSet.add(%this);
}
function respawnBalloonPoint::onLevelEnded(%this, %nivel)
{
if( isObject( %nivel.respawnBalloonPointSet ) )
%nivel.respawnBalloonPointSet.remove(%this);
}]
12/14/2006 (4:00 pm)
When I use the compiler window to check for errors I get an error in my respawnBalloonPointDatablock function that says:"Unable to find object"
Can somebody point me? I have no idea on what could be wrong...
Thanks!
%this is code
[datablock t2dSceneObjectDatablock( respawnBalloonPointDatablock )
{
class = "respawnBalloonPoint"; // the class that will be associated with the object
layer = 5; // the render layer
size = "16 16"; // the size of the object
};
function respawnBalloonPoint::onLevelLoaded(%this, %nivel)
{
%nivel.respawnBalloonPointSet.add(%this);
}
function respawnBalloonPoint::onLevelEnded(%this, %nivel)
{
if( isObject( %nivel.respawnBalloonPointSet ) )
%nivel.respawnBalloonPointSet.remove(%this);
}]
Associate Tom Eastman (Eastbeast314)
Also, you can use the {code}%this is code, etc{/code} tags to make code more readable. Obviously, replace { with [ and } with ]