help with walls

8 posts

Flag Post

the below code doesnt work for when the character hits the walls. he is supposed to respawn in the middle, but just falls off the screen untill you put him back on again

if(root._parent.walls.hitTest(x, _y, true)) {
xspeed = 0
yspeed = 0
_x = 120
_y = 120
}

 
Flag Post

I think the problem may be that you need to use “char._x” and “char._y” in place of your _x and y. Or, if this code is inside the character, then “this._x” and "this.y".

 
Flag Post

If it still doesn’t work, try _root.walls.hitTest without _parent

 
Flag Post

_parent is the directory, ill try your method alex

 
Flag Post

Yeah I was a little confused as to your use of “_parent” there. Can’t you just name the MC that holds all the walls “walls”? There may be some problem that has to do with that, unless you’re positive that works.

 
Flag Post

also using pre tags is better:

if(_root._parent.walls.hitTest(_x, _y, true)) {
    xspeed = 0
    yspeed = 0
    _x = 120
    _y = 120
}

see?

 
Flag Post

_root by definition doesn’t have a parent

 
Flag Post

if(root.walls.hitTest(this._x, this.y, true)) {
xspeed = 0
yspeed = 0
_x = 120
_y = 120
}

it works now!!!!!!!!!!!!!!!!!!!!!!! thanks everybody