function PlayerFish::modifyLife(%this, %dmg) { %this.life += %dmg;
by hamed · in Torque Game Builder · 02/03/2012 (1:21 am) · 7 replies
hi,
would anyone tell me that whats the dmg factor?
we havent defined it before, and its not any field in the level builder
its a part of fish game tutorial
thanks
would anyone tell me that whats the dmg factor?
we havent defined it before, and its not any field in the level builder
its a part of fish game tutorial
thanks
About the author
the great costly games, but the only purpose is killing, and the only amuse but why we just should kill to be satisfied,why the games should not change ? great drama in the games ? maybe today , is the time to change from bullets to flowers
#2
{
%this.life = %dmc + %this.life;
if(%this.life > 100)
{
%this.life = 100;
} else if (%this.life < 0)
{
%this.life = 0;
}
if(%this.life <= 30)
{
%this.dead();
} else
{
%this.updateLifeSize();
}
}
function PlayerFish::updateLifeSize(%this)
{
%lifeMultiplier = %this.life / 100;
%newWidth = %this.maxWidth * %lifeMultiplier;
%newHeight = %this.maxHeight * %lifeMultiplier;
%this.setSize(%newWidth, %newHeight);
}
function PlayerFish::dead(%this)
{
%this.setFlipY(true);
%this.setLinearVelocityY(-10);
%this.dead = true;
}
function PlayerFish::lowerLife(%this)
{
%this.modifyLife(%this.lifeDrain);
if(!%this.dead)
{
%this.schedule(5000, "lowerLife");
}
}
this is the code, we dont use the dmg any longer,
ok its an argumant we pass to the function but when we havent defined it anywhere before ,how can we use it ?
02/03/2012 (10:06 am)
function PlayerFish::modifyLife(%this, %dmc){
%this.life = %dmc + %this.life;
if(%this.life > 100)
{
%this.life = 100;
} else if (%this.life < 0)
{
%this.life = 0;
}
if(%this.life <= 30)
{
%this.dead();
} else
{
%this.updateLifeSize();
}
}
function PlayerFish::updateLifeSize(%this)
{
%lifeMultiplier = %this.life / 100;
%newWidth = %this.maxWidth * %lifeMultiplier;
%newHeight = %this.maxHeight * %lifeMultiplier;
%this.setSize(%newWidth, %newHeight);
}
function PlayerFish::dead(%this)
{
%this.setFlipY(true);
%this.setLinearVelocityY(-10);
%this.dead = true;
}
function PlayerFish::lowerLife(%this)
{
%this.modifyLife(%this.lifeDrain);
if(!%this.dead)
{
%this.schedule(5000, "lowerLife");
}
}
this is the code, we dont use the dmg any longer,
ok its an argumant we pass to the function but when we havent defined it anywhere before ,how can we use it ?
#3
02/03/2012 (10:28 am)
Again, it's an argument, so it's defined in the function definition. It's scope is only valid within that function.
#4
would u tell me for the third time that where can i learn whole the tgb functions, and its methods ?
02/03/2012 (10:38 am)
thanks that you repeat your answer,would u tell me for the third time that where can i learn whole the tgb functions, and its methods ?
#5
02/03/2012 (9:48 pm)
thanks alot for your answers
#6
02/04/2012 (5:22 pm)
Have you seen the documentation that comes with the engine? It has all of the TGB functions and methods.
#7
02/05/2012 (12:46 am)
im studying it, and im in the middle of the way,exactly the scond part of mole tutorial,but should i read the tdn resources or the offline documention is complete and theres no need to reeading anything more ?
Torque Owner RollerJesus
Dream. Build. Repeat.
function PlayerFish::modifyLife(%this, %dmg) { %this.life += %dmg; }Then %dmg is an argument that is passed to the modifyLife function. So if you called......then %dmg would be equal to -10.
This assumes %fishObject is an object with class PlayerFish.