PDA

View Full Version : driving game variables


leight
10-19-2002, 11:01 AM
hi guys,
im new to actionscript.org ok so i may ask some dumb questions:S

im making a driving game right, and im wanting to know how to make it so that when the player clicks onto the track they chose it goes onto a screen which lets them chose the car they want to race. when they chose the car it goes onto the track they chose with the car that they chose. how do i do that???
thanks heaps
leighton

Ricod
10-19-2002, 11:12 AM
Make at least one mc with different framelabels and stops() on them. On the track selection, you could either name the tracks or give them numbers. Anything to identify them. Then, when a track is selected save it in a variable. Let's say in the _root. the code of the trackbutton could then have sumthing like
on (release){
_root.chosenTrack = "MonacoGP";
gotoAndStop("CarSelection");
}
Then on the car selection frame, do the same thing, but then for instance _root.chosenCar = "LamourghiniDiablo";

You can then use these variables to load in the right track and car. Using either if else statements or switch case (still need to look into that one) You know how to attach mcs right ?

leight
10-19-2002, 11:58 AM
ok, i have got the 'mainMenu' in frame 1, 'trackSelection' in frame 2 and 'carSelection' in frame 3.

on the main menu a button says 'time trial'. i click on that button and it goes onto the 'trackSelection'. i chose my track 'bathurst' and it goes onto the 'carSelection'. now when i chose my car im wanting it to go to the 'bathurst' scene because the 'bathurst' track was chosen, but it doesn't for some reason.

attach movieClips - is it where you have one mc inside another mc??? i dont really know

thanks again
leighton

Ricod
10-19-2002, 12:50 PM
attachMovie() ... you can search for it in the F1 html (press f1 for the helpfile)

If you are using scenes, you should use framelabels. Label the first frame of your scene, and tell the _root to go to that label, instead of a scene. Going to scenes isn't possibly from anywhere else but the main timeline. This is because scenes are normal frames behind each other (if scene 1 consists of 20 frames, then the 1st frame of scene 2 is frame 21 of the main timeline).

leight
10-19-2002, 08:15 PM
what would be faster and easier to work - to make it so that all the tracks are in one mc or to have one scene for each track???

and also, what do i need to attachMovie () for???
thanks
leighton

leight
10-19-2002, 09:15 PM
ok i have made it so that all of the scenes/tracks are now on the main timeline in different frames with lables.

-----NOTE-----
track1 - bathurst
track 2 - easternCreek
car 1 - skaife
car 2 - ambrose

for the tracks actionscript

-----BATHURST-----
on (release) {
_root.chosenTrack = "bathurst";
gotoAndStop ("carSelection");
}

-----EASTERNCREEK-----
on (release) {
_root.chosenTrack = "easternCreek";
gotoAndStop ("carSelection");
}

-----SKAIFE-----
on (release) {
_root.chosenCar = "skaife";
gotoAndStop = _root.chosenTrack = "";
}

-----AMBROSE-----
on (release) {
_root.chosenCar = "ambrose";
gotoAndStop = _root.chosenTrack = "";
}


i dont know whats wrong with that:S
thanks again

leighton - the actionscript dummy;)

leight
10-20-2002, 08:12 AM
hey kool - i got it so that when the user clicks on the track and then the car it goes onto the track which they chose

now - i have a movieclip with the different cars in different frames. how do i make it so that the car is chosen is on the track???

thanks
leighton:D

farafiro
10-20-2002, 08:38 AM
make your cars as a MC and linkage them in the library.
a holder empty mc on the stage
and when the user choses the car (clicks at the chosing's button):on(release){
_root.holder.attachMovie("chosenCar","newName",10)
gotoAndStop("the First Frame Of The Track's Movie"
}

leight
10-20-2002, 09:00 AM
so from what i gather - our saying that i need to make my cars - all mc's, and put them into one mc ('supercar'). then i have to attach all of the cars inside the 'supercar' mc by writing this in the 'supercar' actions:

on (release) {
set (_root.holder.attachMovie("chosenCar", "newName",0), "");
gotoAndStop(_root.chosenTrack);
}

is that right??? or do i need to put that actionscript in the car buttons where the user choses the car???

thanks
leighton:confused:

farafiro
10-20-2002, 09:43 AM
no, every car should have its own linkage name
also there is a 'Chose Your Car Screen', which has all the cars instance that works as a buttons to chose from it

Ricod
10-26-2002, 09:08 AM
And for the next step in learning : this is where the whole object oriented can get real handy ! (Don't ask me, its still vague to me too), but here's a nice explanation : http://www.debreuil.com/docs/ch01_Intro.htm
(it made sense to me when I read it (ofcourse it didn't the second I closed the window)) but you can use it to make a general "car" class and make subclasses for the different cars with their variable pro's and cons ... but thats for a later stage ...

Anyway, you could make a supercar clip with all the other clips in it, its just not handy. You'll be making yourself some extra troubles wich you probably don't want (even though its educational (after a couple of days of extra bug scouting you'll probably never do it again), but it's handier to just take other people's word for it) ;)