PDA

View Full Version : [AS3] Multiple Platformer & Engine Trouble


Darksydaz
06-24-2009, 06:33 AM
Hello, I'm attempting to create a platformer (with multiple platforms) and I am having a bit of trouble creating multiple platforms with Jumping capability. As the Script is now, i can create one "ground1" but if I create a second "ground2" I lose the ability to jump (hypothesized by the grounded attribute being false because the "player" is not on the second platform, thus eliminating the ability to jump)...

So, I was wonder what were some of the other methods that others have found to creating multiple platforms with gravity and such, thanks in advance.

this was my Engine... I attempted to use a loop to manage the platforms but that has apparently failed... if anyone has Insight to where I failed at... that would be much appreciated...

ground1.addEventListener(Event.ENTER_FRAME, Engine);

function Engine(event:Event) {
//VCAM.x = joestand.x;
//VCAM.y = joestand.y - 100;
joestand.y += Ymotion;
Xmotion *= friction;
joestand.x += Xmotion;
if (grounded == false) {
if (falling == false) {
Ymotion *= inversegrav;
} else {
Ymotion *= gravity;
}
if (Ymotion >-1) {
if (falling == false) {
falling = true;
Ymotion = 1;
}
}
}
for (i=1; i<=2; i++) {
trace(this["ground"+i],i);
if (joestand.hitTestObject(this["ground"+i])) {
if (falling == true) {
grounded = true;
falling = false;
joestand.y = this["ground"+i].y;
Ymotion = 0;
}
} else {
grounded = false;
}
}

bluemagica
06-24-2009, 12:13 PM
put all platforms inside a single movieclip, and check for hitTest with shapeFlag as true.

Darksydaz
06-25-2009, 07:54 PM
Thank you...