Custom circle sliders

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply

Is this tutorial Useful?

Yes.
5
83%
No.
0
No votes
Too difficult to understand.
1
17%
 
Total votes: 6

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Custom circle sliders

Post by malte » Fri Apr 07, 2006 6:09 pm

This tutorial will let you create a custom circle slider that will put a percent value in a variable when you drag the thumb. I will show 2 variations of it. One full circle slider and one half circle slider.

Full circle slider:

1.) Make sure you have ArcadeEngine in use (load the stack into memory and type into the messagebox:

start using stack "ArcadeEngine"

2.) create a stack
3.) Create a button
4.) set the name of the buton to "mySliderThumb"
5.) type into the messageBox:

set the constrainCircular of button "mySliderThumb" to the loc of this card,80

6.) put the following script into the button:

Code: Select all

on mouseMove
  local thePercent,theAngle
  put item 1 of the constrainCircular of me into myX
  put item 2 of the constrainCircular of me into myY
  put findAngleX(myX,myY, the mouseLoc) into theAngle
  put theAngle/3.6 into thePercent
  --do something wit thePercent here  
  put thePercent
  pass mouseMove
end mouseMove
7.) Choose Browse tool and drag the button. The percent value will be put into the messagebox.

If you want the slider to not travel the whole circle path change the script of button "mySliderThumb"

Half circle Slider

Code: Select all

on mouseMove
  local thePercent,theAngle
  put item 1 of the constrainCircular of me into myX
  put item 2 of the constrainCircular of me into myY
  put findAngleX(myX,myY, the mouseLoc) into theAngle
  if theAngle<90 then 
     put 90 into theAngle
     set the loc of me to pointOncircle(myX,myY,90,\
         item 3 of the constrainCircular of me)
     put (theAngle-90)/1.8 into thePercent
     put thePercent
     --do someThing with thePercent here
     exit mouseMove
  end if 
  if theAngle>270 then 
    set the loc of me to pointOncircle(myX,myY,270,\
        item 3 of the constrainCircular of me)
    put 270 into theAngle
     put (theAngle-90)/1.8 into thePercent
     put thePercent
     --do someThing with thePercent here
     exit mouseMove
  end if
  put (theAngle-90)/1.8 into thePercent
  put thePercent
  pass mouseMove
end mouseMove
If you have any questions feel free to ask.

Malte

mlkasozi
Posts: 2
Joined: Mon May 09, 2011 4:59 pm

Spin/drag wheel

Post by mlkasozi » Thu May 24, 2012 3:11 pm

I am attempting to make a spinning wheel much like a disc on a DJ table. I am using AE5 but I am running out of ideas. I would appreciate any help with this.

Thank you

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Custom circle sliders

Post by bn » Thu May 24, 2012 3:46 pm

Hi Mikasozi,
I am attempting to make a spinning wheel much like a disc on a DJ table
maybe this will give you some ideas.

http://revonline2.runrev.com/stack/322/Beachballs

Kind regards

Bernd

Post Reply

Return to “Animation Engine”