I’ve created a moving MC (responding on Up,Left,…).
But I want I to NOT move if it’s underneath something like a wall.
I’ve named the wall “muur”. Any suggestions to stop the MC moving if it’s right underneath/above/ left to/right to the wall, so you’ll have to go around the wall. I tried some hitTest stuff, but it didn’t work. Though I think it’s related with hitTest.
Anyone?
[AS]onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x +=20;
this.gotoAndStop( “rechts” );
if(this.hitTest(_parent.wall)){
this._x=_root.wall._x-22;//<–this is the distance from the wall when its touched pressing the right arrow key
No, I’m sorry it didn’t work, but I think I know why.
In the original code the pinguin’s position was set. You could move around and get back on EXACTLY the same position where you started. (Because it uses “20” and “50” values). If you change one of that values (like “50” into “53”) it will run badly, because all the blocks have been set on locations like ( X=40; Y=350) or (X=120;Y=200). The position of all objects on the Y axis must be a multiple of 50 and on the X axis a multiple of 20.
But how do you stop the pinguin without changing its position a single pixel?