Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Spinning wheel like Roullete

Explorer ,
Jul 01, 2022 Jul 01, 2022

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...

spinning roullete.jpg

598
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 01, 2022 Jul 01, 2022

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"

...
Translate
Community Expert ,
Jul 01, 2022 Jul 01, 2022

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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2022 Jul 01, 2022

I've copied your code. I replaced b to spinBtn and w to wheel. I got this error :pghh.jpg

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2022 Jul 01, 2022

you're welcome (and i assume you restored that missing t from this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2022 Jul 01, 2022

Yes, exactly.... hahaha... my mistake

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2022 Jul 02, 2022
LATEST

excellent.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2022 Jul 01, 2022

Oh my god! I just miss one letter in the code!

It works fine now. Very impressife.

Thanks for your kindness...

Best Regards...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines