PDA

View Full Version : Motorcycle action script



Mr.Pancake
July 2nd, 2005, 12:07 PM
long time i haven't been on the forum but im making a motor racing game and i was wandering how to do this: i made a motor movieclip (1st frame = normal 2d = motor to the left 3rd = motor to the right) if i push left the motor shows he is going to the left, now i already have done that but now i want it so if i release left button it goes to the normal position .

can anyone help me out?

thnx in advance

Templarian
July 3rd, 2005, 01:08 AM
onClipEvent(enterframe){
if(btnpushedcodeleft){
//nothing goes here
}else{
if(btnpushedcoderight){
//nothing goes here
}else{
//that way if both buttons arn't down it will have to go to the middle.
_root.motorthingy.gotoAndPlay(1);
}
}
}

KIERIOSHIMOTO
July 3rd, 2005, 03:26 AM
oi pancake man go onto ur msn and a guy added u it was me i wanna talk to u

Mr.Pancake
July 3rd, 2005, 04:12 AM
ok thanks for helping me out templarian :D

hmm now i stand in front of another problem how can i make the motor scroll with the bg just like in my other GTA style game? (can someone please explain how it's done, with only the code i can't learn much of the script)

here :
onClipEvent(enterFrame){
speed = 20;
if(Key.isDown(Key.LEFT)){
gotoAndStop(2)
//nothing goes here
}else{
if(Key.isDown(Key.RIGHT)){
gotoAndStop(3)
//nothing goes here
}else{
//that way if both buttons arn't down it will have to go to the middle.
_root.motor.gotoAndPlay(1);
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation += 14;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 14;
}
if (Key.isDown(Key.UP)) {
_y -= speed*Math.cos(_rotation*(Math.PI/180));
_x += speed*Math.sin(_rotation*(Math.PI/180));
}
if (Key.isDown(Key.DOWN)) {
_y += speed*Math.cos(_rotation*(Math.PI/180));
_x -= speed*Math.sin(_rotation*(Math.PI/180));
}
}