Hi,
I’m trying to use Widgets for the first time and I’m trying to implement a slider with the following code:
[lua]module(…, package.seeall);
local widget = require “widget”
function new()
local someGroup = display.newGroup()
local bg = display.newRect( 0, 0, _W, _H)
bg.x = _W * 0.5; bg.y = _H * 0.5;
someGroup:insert( bg)
– Callback listener for slider widget:
local sliderListener = function( event )
local sliderObj = event.target
print( "New value is: " … event.target.value )
end
– Create the slider widget
local mySlider = widget.newSlider{
width=160,
callback=sliderListener
}
– Center the slider widget on the screen:
mySlider.x = display.contentWidth * 0.5
mySlider.y = display.contentHeight * 0.5
– adjust the slider width:
mySlider.width = 240
– set the value manually:
mySlider.value = 75
– insert the slider widget into a group:
someGroup:insert( mySlider.view )
return someGroup
end[/lua]
As you can see I’m using Director with this. I have also downloaded and added the following to my project folder root:
widget_ios/uiSlider/
including all the images of course.
The problem is, although the ends and the handle of the slider are visible, the middle section does not display. The terminal output print statement works correctly and there are no errors showing.
I’m sure it’s a stupid mistake I’ve made somewhere, but why is this happening?
Thanks
[import]uid: 74503 topic_id: 15920 reply_id: 315920[/import]