Collision with wall on simple pacman game using flash -
i can stop pacman going through wall 1 way can go through wall when going in other direction, code have used is:
onclipevent (enterframe) { if (_root.char.hittest(this)) { _root.char._x -= 7; }
}
i need him not go through wall when travelling in either direction! in advance
you facing bug this, because, when modifying heroe's "x" property, decrease it. so, in 1 direction, when move left right , increasing object's "x" value, code works fine. when you're moving in opposite direction, decrease "x" value , on collison object little speeded (by 7 pixels).
to avoid bug have decrease object's "x" when increasing during moving, in other situations, must increase it.
Comments
Post a Comment