Hi guys and thanks to accept me in your forum...
sorry if as presentation i use a scream of help but i'm really gonna mad...
well, i'm tryng to make a very simple flash game with a car that goes around on the stage...
and it works good... but i had a little(big) problem... the car won't stop when it hit the other objects on the stage... i'll give you the code so you can take a look and understand the problem...
//velocitą base//
onClipEvent (load) {
var speed : Number = new Number (0);
}
//movimenti auto//
//accellerazione//
onClipEvent (enterFrame) {
if (Key.isDown (Key.UP) & !Key.isDown (Key.CONTROL)) {
speed += 1.5;
}
speed = speed * 0.98;
//movimenti//
if (Key.isDown (Key.DOWN)) {
speed -= 0.8;
}
if (Key.isDown (Key.RIGHT)) {
_rotation += 8;
}
if (Key.isDown (Key.LEFT)) {
_rotation -= 8;
}
//curve in seno e coseno//
_x += Math.sin (_rotation * Math.PI / 180) * speed;
_y += Math.cos (_rotation * Math.PI / 180) * -speed;
//velocitą massima//
if (Math.abs (speed) > 20) {
speed = 20;
}
if (speed < -10) {
speed = -10;
}
//freno a mano//
if (Key.isDown (Key.CONTROL)) {
speed -= speed / 10;
if (Key.isDown (Key.RIGHT)) {
_rotation += speed / 2;
}
if (Key.isDown (Key.LEFT)) {
_rotation -= speed / 2;
}
//prove di collisione//
if (car.hitTest(_root.aiuola1)) {
speed == 0;
}
}
}
the code is write on the MC "car" located on the stage.....
Thanks a lot for had wasted time in my help...
Bookmarks