I am making a super mario game in flash. I just started working on the collision but I met a problem whenever I step on the top corner of my wal. In super mario, when you step on the blocks, you will stay there, right. That is my exact problem in my game, it won't step there instead it won't collide :(
Okay, first, I made an object converted to a symbol with the instance name of "character". Then I made another object, a long block I named "wall". I went to the character object and placed this code to handle the left and right collision.
onClipEvent(enterFrame) {
//this handles the right collision
if (Key.isDown(Key.RIGHT)) {
//handles the collision with the wall (instance name of the wall obstacle)
if(this.hitTest(_root.wall)) {
this._x+= 7;
}
}
//this handles the left collision
if (Key.isDown(Key.LEFT)) {
//handles the collision with the wall (instance name of the wal obstacle
if (this.hitTest(_root.wall)) {
this._x+= -7;
}
}
}
On this code, I only made the collision with the left and right side of the wall. How about if I want to make the ones in the top so Mario would step on the wall at the top?