Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Slider Widget

    2D Blocks
    1
    1
    185
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

      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:

      s1.gif

       
      To do that, use the following block:

      201ed808-9dfb-4bff-bf4e-45556b68fbf1-image.png

       

      • 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:

      cf55d8b2-d123-48ac-9da1-cc3ff3a1a009-image.png

       
       

      Read a Slider’s Value

      To read the value selected by the user, you can use the reporter block “value of widget”:

      91d8f2ff-392a-40aa-b9a0-c693bdacf72e-image.png

       
       

      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:

      50ef0528-6514-4500-bbfe-c235230b4c57-image.png

       
       

      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.

      slid.gif

      1 Reply Last reply Reply Quote 0
      • First post
        Last post