Be a Supporter!

hitTest and falling through floors

  • 477 Views
  • 3 Replies
New Topic
Zephren
Zephren
  • Member since: Dec. 4, 2011
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
hitTest and falling through floors Dec. 4th, 2011 @ 05:11 PM

I'm trying to make a simple platformer i've tried these 2 tutorials:

But have the same problem of falling through the floor. My code:

onClipEvent(enterFrame){
if(_root.ground.hitTest(_x,_y,true)){
touchingGround=true;
}else{
touchingGround=false;
}
if(!touchingGround){
grav++;
this._y+=grav;
}else{
grav=0;
}
}
This code is under my Player movieclip and i have made a ground movieclip.

MegaMulp
MegaMulp
  • Member since: Oct. 29, 2011
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to hitTest and falling through floors Dec. 4th, 2011 @ 05:44 PM

Try asking in the flash forums.


I have no idea what I am doing.

Wolfos
Wolfos
  • Member since: Jan. 19, 2008
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to hitTest and falling through floors Dec. 6th, 2011 @ 08:31 AM

Try... You know, not copy/pasting everything.

Spudzy
Spudzy
  • Member since: Aug. 16, 2010
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to hitTest and falling through floors Dec. 11th, 2011 @ 02:34 PM

At 12/4/11 05:11 PM, Zephren wrote: I'm trying to make a simple platformer i've tried these 2 tutorials:
http://www.newgrounds.com/portal/view/45 5972
http://www.newgrounds.com/portal/view/46 5099
But have the same problem of falling through the floor. My code:

onClipEvent(enterFrame){
if(_root.ground.hitTest(_x,_y,true)){
touchingGround=true;
}else{
touchingGround=false;
}
if(!touchingGround){
grav++;
this._y+=grav;
}else{
grav=0;
}
}
This code is under my Player movieclip and i have made a ground movieclip.

Trying making the ground movieclip taller and make sure that for the player movieclip it's centre point is by it's feet.

PS: You should post this in the Flash Forum.