Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
a simple horizontal slider (for beginners) — Gideros Forum

a simple horizontal slider (for beginners)

mrcmrc Member
edited May 2015 in Code snippets
Hi,
I have been reading so much on this forum lately and it has been a one way deal: me reading and learning, using the samples etc. I am a beginner in mobile app developement and I would like to give back something to this community. It is not much, but maybe a beginner will find it useful.

It is a simple slider class, where you can set the button position by touch, or programmatically. Sample code would be:
local slider= hSlider.new("bevel.png","barthick.png")
slider.name = "1st"				--optional
stage:addChild(slider)
slider:setPosition(40,20)
 
 
slider:setPositonbyPercentage(0.5)
print("slider 1 set by percentage to", slider.percent)
 
slider:SetPositionFromBar(500) 	 
print("slider 1 set by absolute x to", slider.percent)
You can try different bmps, pngs for bar and button. Class will adapt. You just need to make sure your bar length stays within bounds. (unlike the third slider in the sample code).
use it to play mp3s, scroll picture gallery, zoom, pan, etc...

feel free to use for your projects.

I will also post something to the introduction soon.

cheers

+1 -1 (+8 / -0 )Share on Facebook

Comments

Sign In or Register to comment.