The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.34 / 5.00 31,296 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 10,082 ViewsOk, I managed to beat my head against the wall enough to get it to semi work.
On character:
if (!touchingGround)
{
grav++;
this._y += grav;
}
else
{
grav = 0;
}
On objects:
onClipEvent (enterFrame) {
if ((_currentframe == 1) and (this.hitTest(_root.hero)))
{
_root.hero.touchingGround = (true);
}
}
The problem is, of course, that once a character touches one of these objects, gravity is switched off permanently.
I tried making a flat
touchingGround = (false);
on the character, but then the two just fight over who wins...and gravity eventually does.
I assume there is a simple way to make touchingGround = false if it's not getting constant feedback otherwise?
this is probably more than what you wanted, but this tut shows the full creating of a platformer game...so the jump & gravity code is in there
Click to view.
hope it helps
i like to have fun with the girls.
Your code's flaw is that you're not detecting when the character 'falls' off from the edge of a platform.
A better approach would be to detect if the character is on the ground (or will be on the ground after the velocity +gravity is applied) and if so, set the y-velocity to 0.
Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
touchingGround is a simple boolean variable that's either on or off.
Hm. I have no idea how I'd go about that. 0.o
you have to either loop through all your objects your hitting against on the character, or put all the objects into 1 movieclip and hittest against that.
Design the level, then select them all and make them a movie? ^_^. That could work very well. Thanks for the advice!
I tried using a "while" command in place of for. Like "while blah blah code for hit test is true, touchingGround = true."
Unfortunately, flash didn't like that and crashed, so I'm guessing I don't understand the correct use of while. xD