View Full Version : making a racing game... Need help doing some collision stuff
patricktheking
May 25th, 2004, 11:02 PM
K im making a racing game and I want it so as you race over the finish line it goes to the next frame which will have the next track..... How do i do that...
I make the finish line a movie clip... then what?
Yeldarb
May 25th, 2004, 11:14 PM
It's called a hitTest, there is a tutorial here on kirupa that should help you out. I'll see if I can find it for you.
http://www.kirupa.com/developer/actionscript/hittest.htm
There you go :)
Just change the code where it changes the text to be nextFrame(); and change the movieclips to the instance names of your movieclips (car and finishline)
patricktheking
May 25th, 2004, 11:16 PM
thanks so mUCH....!!!!
patricktheking
May 25th, 2004, 11:54 PM
onClipEvent (enterFrame) {
if (_root.circle, hitTest(_root.block)) {
_root.text = "Collision Detected";
} else {
_root.text = "No Collision";
}
}
thats what it gives me on that turtorial.... so do i change it 2....
onClipEvent (enterFrame) {
if (_root.car, hitTest(_root.finishline)) {
_root.nextframe();
??
patricktheking
May 26th, 2004, 12:14 AM
Thats all i can think of and it isnt working...
onClipEvent (enterFrame) {
if (_root.car, hitTest(_root.finishline)) {
actions
}
nextFrame();
} else {
play();
Yeldarb
May 26th, 2004, 12:44 AM
onClipEvent (enterFrame) {
if (_root.car, hitTest(_root.finishline)) {
_root.nextframe();
} else {
stop();
}
it should look something like that.
patricktheking
May 26th, 2004, 04:39 PM
na it doenst work
patricktheking
May 26th, 2004, 04:52 PM
K... I attached wat you said 2 and now my car wont move.....
onClipEvent (enterFrame) {
if (_root.car, hitTest(_root.finishline)) {
_root.nextframe();
} else {
play();
onClipEvent (enterFrame) {
//This code will advance the car forward.
if (Key.isDown(Key.UP)) {
speed += 1;
}
// This will make the car go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
//The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .6;
}
// This will change the angle of the car
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
// This will make the car move
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
that is wat the movieclip car has attached 2 it and now it wont move as i added that hittest stuuff....
these errors keep poping up as i test teh movie
cene=Scene 1, Layer=Layer 2, Frame=1: Line 36: Syntax error.
Scene=Scene 1, Layer=Layer 2, Frame=1: Line 1: Statement block must be terminated by '}'
onClipEvent (enterFrame) {
Scene=Scene 1, Layer=Layer 2, Frame=1: Line 36: Syntax error.
its really getting anooying.... plz help......
note *I put the movieclip finishline on a seperate layer but that wont matter i dun think as long as it has it's instance name
Marz
May 27th, 2004, 01:44 AM
if(_root.car.hitTest(_root.finishline))
;)
patricktheking
May 27th, 2004, 02:03 PM
lol it dont work
patricktheking
May 27th, 2004, 02:04 PM
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.finishline))
_root.nextframe();
} else {
play();
still dun work...lol
Johnny64
May 27th, 2004, 02:38 PM
all little tut:
That goes up, must come down.
the same is for (),{},[],""
end tut
now take a look at you code
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.finishline)){
_root.nextframe();
} else {
play();
}
}
bold and underline are things you missed.
:)
patricktheking
May 27th, 2004, 02:50 PM
k lemme try it
patricktheking
May 27th, 2004, 02:53 PM
It Works.... It Works .... Thankyee It Works
Skinny_T
May 28th, 2004, 05:27 AM
they say when a you get a peice of code to work an angel gets its wings
patricktheking
June 1st, 2004, 06:47 PM
Ehhh... no need for help on collision i got tat down 110%, Just keeping this thread alive as i dunt want to flood the forums.... Anywyaz...
K For my racing game I have movieclips inside other movie clips and I was wondering How u like aknowledge it.... Like example....
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.hotspot6)){
_root.road.easeXY(307, 315)
} else {
play();
}
}
That is the hittest for 2 moviecips onscreen...not in any other MC.... how do I do it when ones in the MC and another on the main screen.
Example... lets pretend that hotspot6 is in a moviecip "trigger". Do i edit my command like this.....
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.hotspot6.trigger)){
_root.road.easeXY(307, 315)
} else {
play();
}
}
K i know i havnt done the best job explaining wat i need but if u understand plz.. answer
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.