Copy link to clipboard
Copied
Hi. I'm using Animate CC and AS3 and I want to program a spinning wheel for a desktop game like Wheel of Fortune. I want it to rotate and I'm trying to create a meter to determine the strength of the spinning. The wheel is attached to this post.
Copy link to clipboard
Copied
I'm not really sure that you asked a question yet.
With a spinning wheel you may well use an enterframe function to update things. When you start spinning the wheel you would change the rotation by a lot, and over time you would rotate by less. The code might look like this (I did test it):
addEventListener(Event.ENTER_FRAME, onenterframe);
var spinamount: Number = 30;
function onenterframe(e: Event) {
spinner.rotation += spinamount;
spinamount -= .1;
if (spinamount < .1) stopspinner();
}
function stopspinner() {
removeEventListener(Event.ENTER_FRAME, onenterframe);
}
The spinner movieclip will spin quickly, and slow down over time. You could change the spinamount -= .1 part, or the var spinamount: Number = 30;; part to change the range o start speed.
Copy link to clipboard
Copied
if a user is dragging and dropping the wheel and that's what determines the strength of spin, you can use something like the following to as a spinamount to be used in colin's code:
var prevT:int
var prevY:int;
spinner.addEventListener(MouseEvent.MOUSE_DOWN,downF);
function downF(e:MouseEvent):void{
startF();
stage.addEventListener(MouseEvent.MOUSE_UP,upF);
}
function upF(e:MouseEvent):void{
stopF();
stage.removeEventListener(MouseEvent.MOUSE_UP,upF);
}
function startF():void{
this.addEventListener(Event.ENTER_FRAME,loopF);
}
function loopF(e:Event):void{
prevT=getTimer();
prevY=mouseY;
}
function stopF():void{
this.removeEventListener(Event.ENTER_FRAME,loopF);
spinamount = (mouseY-prevY)/(getTimer()-prevT); // you'll probably need some function of this parameter to get it right
addEventListener(Event.ENTER_FRAME, onenterframe); // then colin's code
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Have you ever played Wheel of Fortune on the Nintendo Entertainment System (NES)? I've attached the "Spin strength" meter to show you what I'm talking about. I want the meter to go in and out automatically so when the user presses "enter" to stop the meter, it determines the strength of the spinning of the wheel
Copy link to clipboard
Copied
then use the timer on mousedown to start a loop that increments spin strength.