PDA

View Full Version : game design question


spolk
07-11-2001, 06:18 PM
Im trying to create a spinner for a game, much like the real spinner for the game Twister. There are 51 numbers on the game spinner. I need the spinner to randomly stop at a number after the spin button has been pressed. Im using an arrow instance as a MC, and i can get it to spin, i just need to know how to get it to randomly stop. Any help would be appreciated. If you would like to view the image, go to http://users.computron.net/scottisdn/images/spinner.png
Note: This is just an image, not the actual movie.

20 Ton Squirrel
07-11-2001, 07:22 PM
Kinda tricky, but easy. Put that thar spinner arrow in a MC and tween it through a complete circle. Put the spinner on the stage, name it spinner (clever, no?). Click on it, add this to the exterior code of the MC...

onClipEvent(load){
stopframe=1;
stop();
}

onClipEvent(enterFrame) {
if (_currentframe == stopframe)
stop();
}



Put a button down to do the spinning.


on (release) {
spinner.stopframe = random(100);
spinner.gotoAndPlay(1);
}


The caveat here is that you'd need to set your tween where the tweened rotation of the arrow matches the frame number... for example, when at frame 30 the spinner should point at 30. This shouldn't be too hard to accomplish, though.

You could put a tween down of it spinning once completely, then add that to whatever random number is generated for the stopframe variable. This would make it look like the spinner goes around once all the way before stopping. Just make certain to add the frame count of this "animation fluff" to the base calculations above (instead of frame 30 for 30, it could be 130).


Hope that is of service to you. Happy coding.

spolk
07-11-2001, 10:59 PM
ok, i did that, but for the MC, i am getting this error:
Scene=GameSpinner, Layer=Arrow, Frame=1: Line 1: Clip events are permitted only for movie clip instances
onClipEvent (load) {

Scene=GameSpinner, Layer=Arrow, Frame=1: Line 6: Clip events are permitted only for movie clip instances
onClipEvent (enterFrame) {

I have the spinner saved as an MC, why does it keep givin me this error.

Jesse
07-12-2001, 01:13 PM
the code goes ON not IN the MC. Right click the MC > Actions. :)

20 Ton Squirrel
07-12-2001, 01:45 PM
Yup, as da man said... I'm kinda new on the onClipEvent thing m'self, having only experimented a little with it. It is a VERY cool feature, though, that can save LOTS of time. I can see many ways to exploit this feature. Learn it! Gawd F5 rocks.

Thanks for the clarification, Jesse. I can be cryptic at times... or just downright odd.

spolk
07-12-2001, 02:24 PM
Thanx 20 Ton Squirrel and Jesse, you were a great help to me. It worked. I found out i was putting the code on the frame with the MC instead of on the MC itself. Thank you very much, my spinner is now finished because of your help.