Jump to content

hit test


dcole.ath.cx

Recommended Posts

How do I do a hit test with an object and a wall. If the wall is added by action script.MAIN speed = 3;stageHeight = 400;stageWidth = 400;tunnelHeight = 200;points = 5;startPoint = {x1:0, y1:30, x2:0, y2:170};z = 1;function addSection() {attachMovie("tunnel1", "tunnel"+"_"+z, ++d);z++;if (z>2) {z = 1;}}addSection();OBJECT onClipEvent (load) {gravity = 6;force = 12;}onClipEvent (enterFrame) {setProperty ("", _y, _y+gravity);if (mousedown == 1) {setProperty ("", _y, _y-force);}}onClipEvent (mouseDown) {mousedown = 1;}onClipEvent (mouseUp) {mousedown = 0;}onClipEvent (enterFrame) {if (_root.circle, hitTest(_root.blah)) {_root.text = "Collision Detected";} else {_root.text = "No Collision";}}INSIDE WALL Symbol _x = 400;stageHeight = _parent.stageHeight;stageWidth = _parent.stageWidth;tunnelHeight = Math.round(_parent.tunnelHeight);points = _parent.points;speed = Math.round(_parent.speed);landMass = stageHeight-tunnelHeight;xint = 800/(points-1)count = true;pointsArray = [];pointsArray[0] = _parent.startPoint;for (var i = 0; i<points-1; ++i) {var rand = random(landMass);var i2 = i+1;pointsArray[i2] = {x1i2*xint), y1:rand, x2i2*xint), y2:rand+tunnelHeight};}_parent.startPoint = {x1:0, y1ointsArray[points-1].y1, x2:0, y2ointsArray[points-1].y2};clear();beginFill(0x00000, 100);lineStyle(1, 1, 100);lineTo(0, pointsArray[0].y1);for (var x = 0; x<pointsArray.length; ++x) {lineTo(pointsArray[x].x1, pointsArray[x].y1);}lineTo(pointsArray[points-1].x1, 0);lineTo(0, 0);moveTo(0, pointsArray[0].y2);for (var z = 0; z<pointsArray.length; ++z) {lineTo(pointsArray[z].x2, pointsArray[z].y2);}lineTo(pointsArray[points-1].x2, stageHeight);lineTo(0, stageHeight);endFill();onEnterFrame = function () {_x -= speed;if ((_x-speed)<-400 && count) {count = false;_parent.addSection();}if (_x<-(_width)) removeMovieClip(this);};If you look in OBJECT you will see I have blah, what should I replace blah with??Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...