How do I create a rotary knob ?

0 favourites
  • 10 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello,

    I'd like to create a rotary knob (it will apply audio FX on some audio tag), but I don't know ho to do it.

    I'd want that when a user click on the knob, he have to maintain the click, then drag and drop to the up or down to change the value (like in audio VST). (don't want to be set by the angle of the mouse).

    If he click later on the knob, it must not reset the value but goes from the value it was before.

    Knob will not have to do more than 280° (like an audio knob ^^)

    Can somebody can help me please ? :)

    PS : my first search seems to go to anglelerp expression, but I'm too noob to find how to use it properly :/

  • angle(touch.x,touch.y,knob.x,knob.y) will get you 360 points to use.

    You can divide that up i.e. 360/11 to use as your indicators.

    If you don't want to use the angle, then use the y.

    knob.y -touch.y

  • Thanks a lot newt, I'll try it :)

  • Thanks a lot too dop2000 :)

    Unfortunately this is not the exact behavior I'm looking for.

    If I'm not wrong, the side your knob is turning depend on the side I click on.

    I'd like the knob to turn clockwise if I drag to the up, and anti clockwise if I drag to the down (regardless of where the user click), with a limit of around 300°, and it set a variable depending on the position.

    The purpose is to make a knob smiliar to a gain/FX knob on a guitar amp.

    I tried the newt's solution, but I only managed to do it to follow the mouse position, and the value is set to default at each click.

    AS a workaround I was think about creating an invisible slider on the top of knob (because the behavior look a lot like of a fader one), but I have the same problem : beacuse the slider appears at the same place, the knob is not keeping his position so the value is set back to default each time I click on the knob.

  • I'd like the knob to turn clockwise if I drag to the up, and anti clockwise if I drag to the down

    You mean like this?

    dropbox.com/s/b4v6f5vy69y0s6y/RotatingKnobs2.c3p

  • I would be interested in some actual user testing here. People intuitively understand how to twist a knob. I am not convinced that users will understand that up always turns clockwise, down always means anti-clockwise. If I clicked on a knob, I would want to make a circular motion. Dop's first example seems more intuitive to me - although I would want the button to continue turning if the mouse/touch drifted off the button.

    I would say use a really nice looking slider if you want up = more, down = less.

  • although I would want the button to continue turning if the mouse/touch drifted off the button.

    Thanks for the tip! Its an easy change, should be fixed now.

  • Thanks a lot Dop2000, I'm at work now, I'll try it right after. :)

    AllanR, I understand your point of view for circular control, but in the "music world" the knob behavior are more often like what I described, (like in vst and DAWs per exemple).

    Ps : didn't tryed it yet, but indeed it would have to continue if mouse goes off the knob ^^

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks again Dop2000, that is exactly what I want.

    You deserve some coffees :)

    For precision about the behavior that don't follow the mouse angle, it may look less intuitive (and yes it is), but it is far more precise to make some live modifiation :)

    Thanks everybody for your answers and your help :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)