I know there is like a million post about this, and the tutorial are there. But I looked at the tutorial and I am having some problems with it. I also looked at the forms and no such luck. Ok what I have is a car (box) and when it goes over the wall it says you hit the wall. Anyways, i donte the tutorial and it doesnt seem to be working for me when i follow what it says for me to do :S Can someone please help me. Here is my code
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
_root.box._rotation = 360;
currentY = this._y;
this._y = currentY - 15;
} else if (Key.isDown(Key.DOWN)) {
_root.box._rotation = 180;
currentY = this._y;
this._y = currentY + 15;
}
if (Key.isDown(Key.RIGHT)) {
_root.box._rotation = 90;
currentX = this._x;
this._x = currentX + 15;
} else if (Key.isDown(Key.LEFT)) {
_root.box._rotation = 270;
currentX = this._x;
this._x = currentX - 15;
}
if ((Key.isDown(Key.UP)) && (Key.isDown(Key.RIGHT))) {
_root.box._rotation = 45;
}
if ((Key.isDown(Key.RIGHT)) && (Key.isDown(Key.DOWN))) {
_root.box._rotation = 135;
}
if ((Key.isDown(Key.DOWN)) && (Key.isDown(Key.LEFT))) {
_root.box._rotation = 225;
}
if ((Key.isDown(Key.LEFT)) && (Key.isDown(Key.UP))){
_root.box._rotation = 315;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PROBLEMS WITH THIS CODE HERE!!!!
hit = false; //set hit variable to false
for(i in _root.wall.perimeter) { //loop through all opjects in perimeter clip
point = new Object(); //create a new generic object to hold the coordinates
point.x = _root.wall.perimeter*._x; //x coordinate
point.y = _root.wall.perimeter*._y; //y coordinate
_root.wall.localToGlobal(point); //convert coordinates from local (within shape1) to global (_root)
if(this.hitTest(point.x, point.y, true)) { //check for collision between perimeter clip coordinates and shape 2
hit = true; //make our hit variable true
}
}
if(hit) { //check out hit variable for a true or false collision detection
_root.text = "You Hit the WALL";
} else {
_root.text = "YOUR GOOD"; //do actions if they aren't touching
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//WALL this works
/* if (_root.box, hitTest(_root.wall.perimeter)) {
_root.text = "Collision Detected";
} else {
_root.text = "No Collision";
}*/
}
P.S I know there is a way to make the keyPress easy on me but I just want to do it this way LoL