Slider Widget
-
Introduction
You can add a slider widget to the stage to make it easy for the user to specify a value within a range that looks like this:

To do that, use the following block:
- X and Y: you can set the position of the center of the slide using the X and Y parameters.
- Width: the width of the slider widget
- Minimum and Maximum Values: You can set the value range of the slider to be between a minimum value (like 0) and a maximum value (like 100). As the user slides the knob on the slider, the value will stay within this range.
- Name: give the slider a name so that you can refer to it later.
Set a Slider’s Value
You can set the value of the slider to a certain value after adding it. For example, this block would set the slider to the value of 50, in the middle between 0 and 100:

Read a Slider’s Value
To read the value selected by the user, you can use the reporter block “value of widget”:

When Slider’s Value Changes
To handle the event that the user is sliding the knob of the slider, you can use the “when widget changes” block:

Demo
In this program, we create a slider between 0 and 180, and set its value to 90 initially. Whenever the user slides the slider, we would update the direction of the apple sprite using the value of the slider.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login