Hello, I’m working on a platformer game, and i’m wanting to have a wall/platform that can be approached from either side, and also jumped on top of. I’ve gotten the hitTest to work on both sides for the wall, but have been unsuccessful getting the character to jump properly on top of the wall.
Here’s a snippet of code for the wall hitTest:
if (_root.wall.hitTest(_x+radius,_y,true)) {
this._x -= speed;
_root._x += speed;
} else if (_root.wall.hitTest(_x-radius,_y,true)) {
this._x += speed;
_root._x -= speed;
} else if (_root.wall.hitTest(_x,_y+radius,true)) {
this._y -= gravity;
grav = 0;
}
}
When I run this code, the character sucessfully jumps on top of the platform, but hovers about 10 pixels higher in the air. if you take away the “+radius” then the character falls to one side of the wall.
It could be just a lack of understanding about the nature of the (_x,_y) part of the hitTest, any help would be appreciated. Thank you!
I am new to the forums, but after reading several of the tutorials and lurking on the forums, I think it would be very beneficial to get some active participation/help =) So in short, nice to meet everyone!
Layne