This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-09-16 22:13:45

matthewjose
Scratcher
Registered: 2008-07-16
Posts: 100+

Sliders

Hi, can anyone show me some scripts to make a slider?
Thanks,
matthewjose


My chat room, and join a Critique Group for feedback on your projects.

Offline

 

#2 2008-09-16 22:43:10

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Sliders

Sure! I think the included sliders in Scratch are ugly and I generally avoid using them. You'll need to make two sprites: first, make a 100x3 rectangle, then name it "bar". Next, make a 20x3 rectangle and name it "handle". Move the rotation points on both of them to the far left of each rectangle. Now align them onscreen so "handle" is directly above "bar". Now place the following script on "handle":

//Note: some local variables ("for this sprite only") may be used, and will always begin with "my"

On "handle"
When Flag Clicked:
Forever:
Wait until <<touching mouse pointer?> and <mouse down?>
if <(selected)=0>
set selected to 1
repeat until <not<mouse down?>>
   if <<(mouse x)>(x pos of bar)>and<(mouse x)<(x pos of bar)+100>>
     set x to (x pos of bar)
     set myValue to (x position)-(x pos of bar)
end if
end repeat
end if
end forever

Or, just look at the code I used in my3D Solar System Demo or Cover Flow Slideshow, both of which include very similar sliders. Hope this helps!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#3 2008-09-17 07:32:37

matthewjose
Scratcher
Registered: 2008-07-16
Posts: 100+

Re: Sliders

Uhmm......I dont know what 20X3 or stuff like that means, and Scratch's slider are not so ugly.

Last edited by matthewjose (2008-09-17 07:33:07)


My chat room, and join a Critique Group for feedback on your projects.

Offline

 

#4 2008-09-17 10:39:19

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sliders

matthewjose wrote:

Uhmm......I dont know what 20X3 or stuff like that means, and Scratch's slider are not so ugly.

I think 20X3 means a costume, 20 pixels wide and 3 pixels high.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#5 2008-09-17 19:50:04

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Sliders

matthewjose wrote:

Uhmm......I dont know what 20X3 or stuff like that means, and Scratch's slider are not so ugly.

Okay, then, just use the sliders in the examples I included.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#6 2008-09-17 20:49:34

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Sliders

fullmoon wrote:

Sure! I think the included sliders in Scratch are ugly and I generally avoid using them. You'll need to make two sprites: first, make a 100x3 rectangle, then name it "bar". Next, make a 20x3 rectangle and name it "handle". Move the rotation points on both of them to the far left of each rectangle. Now align them onscreen so "handle" is directly above "bar". Now place the following script on "handle":

//Note: some local variables ("for this sprite only") may be used, and will always begin with "my"

On "handle"
When Flag Clicked:
Forever:
Wait until <<touching mouse pointer?> and <mouse down?>
if <(selected)=0>
set selected to 1
repeat until <not<mouse down?>>
   if <<(mouse x)>(x pos of bar)>and<(mouse x)<(x pos of bar)+100>>
     set x to (x pos of bar)
     set myValue to (x position)-(x pos of bar)
end if
end repeat
end if
end forever

Or, just look at the code I used in my3D Solar System Demo or Cover Flow Slideshow, both of which include very similar sliders. Hope this helps!

Wow! That's really useful! Thanks so much!!

Offline

 

#7 2008-09-20 03:59:28

matthewjose
Scratcher
Registered: 2008-07-16
Posts: 100+

Re: Sliders

Paddle2See wrote:

matthewjose wrote:

Uhmm......I dont know what 20X3 or stuff like that means, and Scratch's slider are not so ugly.

I think 20X3 means a costume, 20 pixels wide and 3 pixels high.

And.... is 1 pixel = to one pen down in Scratch Draw?


My chat room, and join a Critique Group for feedback on your projects.

Offline

 

#8 2008-09-20 04:25:35

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Sliders

matthewjose wrote:

Paddle2See wrote:

matthewjose wrote:

Uhmm......I dont know what 20X3 or stuff like that means, and Scratch's slider are not so ugly.

I think 20X3 means a costume, 20 pixels wide and 3 pixels high.

And.... is 1 pixel = to one pen down in Scratch Draw?

Each "Step" in Scratch is one pixel.  When you ask Scratch to "Move 10", you are moving 10 pixels.  In the Paint Editor, each of the checkerboard squares that you see is 4 pixels wide.  In the Costumes tab, under each costume name you will see the size of the costume in pixels.  The Scratch Cat costume, in a new Scratch project, is 95x111.  Which is 95 pixels wide and 111 pixels high.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#9 2008-09-20 13:52:49

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: Sliders

Ive already made one aswell, just got a bug or 2 on the impact of the side of the bar http://scratch.mit.edu/projects/yambanshee/265773

Offline

 

Board footer