Copy link to clipboard
Copied
Hi,
I've made a simple game spinning wheel in Animate CC with HTML5 canvas platform. But I have no idea to make the wheel spin like roulette. Simply if button SPIN is pressed (mouse down event), the wheel will spin fast... Then if button SPIN is released (mouse up event) the wheel slowly decrease speed until it stop. I do hope there is kind someone solve this code.
Best regards...
if b is your button and w is your wheel:
th
this.slowRate = .1;
this.initialRate = 10;
this.spinFF = spinF.bind(this);
this.slowFF = slowF.bind(this);
this.b.addEventListener("mousedown",startSpinF.bind(this));
this.b.addEventListener("pressup",startSlowF.bind(this));
function startSpinF(){
this.rotateSpeed = this.initialRate;
createjs.Ticker.removeEventListener("tick", this.spinFF);
createjs.Ticker.addEventListener("tick", this.spinFF);
}
function startSlowF(){
createjs.Ticker.removeEventListener("tick"
Copy link to clipboard
Copied
if b is your button and w is your wheel:
th
this.slowRate = .1;
this.initialRate = 10;
this.spinFF = spinF.bind(this);
this.slowFF = slowF.bind(this);
this.b.addEventListener("mousedown",startSpinF.bind(this));
this.b.addEventListener("pressup",startSlowF.bind(this));
function startSpinF(){
this.rotateSpeed = this.initialRate;
createjs.Ticker.removeEventListener("tick", this.spinFF);
createjs.Ticker.addEventListener("tick", this.spinFF);
}
function startSlowF(){
createjs.Ticker.removeEventListener("tick", this.slowFF);
createjs.Ticker.addEventListener("tick", this.slowFF);
}
function slowF(){
this.rotateSpeed = Math.max(0,this.rotateSpeed-this.slowRate);
if(this.rotateSpeed==0){
createjs.Ticker.removeEventListener("tick", this.slowFF);
}
}
function spinF(){
this.w.rotation += this.rotateSpeed;
}
Copy link to clipboard
Copied
I've copied your code. I replaced b to spinBtn and w to wheel. I got this error :
Copy link to clipboard
Copied
you're welcome (and i assume you restored that missing t from this.
Copy link to clipboard
Copied
Yes, exactly.... hahaha... my mistake
Copy link to clipboard
Copied
excellent.
Copy link to clipboard
Copied
Oh my god! I just miss one letter in the code!
It works fine now. Very impressife.
Thanks for your kindness...
Best Regards...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now