After collision function ????????
by Michael S · in Torque Game Builder · 10/10/2006 (9:27 pm) · 4 replies
Hi
i'm a newbie and i have a question
i have 2 sprite
player and spike
if my player collide with spike
their health was reduced
function player::onlevelloaded
{
$crash=false;
}
function player::reducehealth
{
$health--;
if ($health>0)
{%this.schedule(1000,"reducehealth");}
}
function player::oncollision(bla bla)
{
if ($crash==false)
{
%srcobject.schedule(200,"reducehealth");
$crash=true;
}
}
this was no problem . but the problem start
how can i stop reducing my health when my player leave that spike (after collision)
(moving outside spike after my player stepped on the spike )
i really2 get stumbled here
thanks
i'm a newbie and i have a question
i have 2 sprite
player and spike
if my player collide with spike
their health was reduced
function player::onlevelloaded
{
$crash=false;
}
function player::reducehealth
{
$health--;
if ($health>0)
{%this.schedule(1000,"reducehealth");}
}
function player::oncollision(bla bla)
{
if ($crash==false)
{
%srcobject.schedule(200,"reducehealth");
$crash=true;
}
}
this was no problem . but the problem start
how can i stop reducing my health when my player leave that spike (after collision)
(moving outside spike after my player stepped on the spike )
i really2 get stumbled here
thanks
#2
is there any solutions?
10/13/2006 (4:38 pm)
Thanks tom but hmmmmm i have tried that and if i don't use schedule my helthbar will reduce so quicklyis there any solutions?
#3
and there is no delay
is there any solutions?
10/13/2006 (4:46 pm)
Thanks tom but hmmmmm i have tried that and if i don't use schedule my healthbar will reduce so quicklyand there is no delay
is there any solutions?
#4
10/13/2006 (6:43 pm)
What's happening makes perfect sense. If you collide with something, you schedule reduceHealth which in turn reschedules itself indefinitely. Instead what you want is the player only to be damaged every few seconds while on the spikes... correct? Just follow that logic. =)
Associate Tom Eastman (Eastbeast314)
As in:
function player::onlevelloaded { //do nothing special } function player::reducehealth() { $health--; } function player::oncollision(bla bla) { %srcObj.reducehealth(); }