Hi guys and girls,
Never had much luck on Forums in the past but i have been urged to try out this site, so here i am.
My problem is simple (i imagine) i have in the past made a simple car game that collects coins. In the past to stop the car from going off the stage i used a peice of code like…
var playerBounds = car_mc.getBounds(stage);
if (playerBounds.left < 0 || playerBounds.right > stage.stageWidth)
{
if (speed < 0)
{
car_mc.rotation + 10;
speed = speed + speedAcceleration;
trace (speed);
trace ("speed < 0");
}
if (speed > 0)
{
trace ("hellllllo");
car_mc.rotation + 10;
speed = speedMaxReverse;
}
}
This would then do the appropiate turns/speed reductions to simulate a bounce off effect.
Now my level is a bit more demanding, made up of several different “islands”, and bridges where the rules are different. See image below:
If the car bounces into any of the walls on the green “islands” i want it to do the similar bouncing off effect, If they hit the edges on the brown “bridges” i want the car to fall off (some animation/tween to simulate falling and then loose a life and start again).
I have tried converting the line of the side of one of the islands to a movieclip, and doing a test against it like so:
if (Boundary1.hitTestPoint(car_mc.x, car_mc.y, true))
{
trace ("Collision Detected");
}
But this does not do anything at all. Any ideas please i am going mad.
Thanks in advance
Chris