Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-11-2001, 07:18 PM   #1
spolk
Registered User
 
Join Date: Jul 2001
Posts: 6
Send a message via ICQ to spolk
Question

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.
spolk is offline   Reply With Quote
Old 07-11-2001, 08:22 PM   #2
20 Ton Squirrel
Risu Oyabun!
 
20 Ton Squirrel's Avatar
 
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
Default

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...
Code:
onClipEvent(load){ 
    stopframe=1;
    stop();
}

onClipEvent(enterFrame) {
    if (_currentframe == stopframe)
        stop();
}
Put a button down to do the spinning.

Code:
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.
20 Ton Squirrel is offline   Reply With Quote
Old 07-11-2001, 11:59 PM   #3
spolk
Registered User
 
Join Date: Jul 2001
Posts: 6
Send a message via ICQ to spolk
Arrow

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.
spolk is offline   Reply With Quote
Old 07-12-2001, 02:13 PM   #4
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

the code goes ON not IN the MC. Right click the MC > Actions.
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder
Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 07-12-2001, 02:45 PM   #5
20 Ton Squirrel
Risu Oyabun!
 
20 Ton Squirrel's Avatar
 
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
Default

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.
20 Ton Squirrel is offline   Reply With Quote
Old 07-12-2001, 03:24 PM   #6
spolk
Registered User
 
Join Date: Jul 2001
Posts: 6
Send a message via ICQ to spolk
Thumbs up

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.
spolk is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Augh. Too many ways to skin a cat. (game design q's) beau Gaming and Game Development 0 01-14-2005 08:08 PM
Swapdepth using txt files and dynamic content for game. superbnerb ActionScript 1.0 (and below) 3 09-22-2004 08:27 PM
Design Flaw Question or Retarded User Question (thats the real question) ptk22 Simple Stuff (Newbies) 1 01-31-2004 06:00 AM
Another Game Timer question (MX) friz2002 Gaming and Game Development 13 04-17-2003 01:47 AM
Game "Time Delay" after question is answered kunafish Gaming and Game Development 1 07-29-2002 08:04 PM


All times are GMT. The time now is 10:44 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.