Hi,
I’ve just been trying to work with newSwitch for an ON/OFF switch that will use a skin with imagesheet.
Unfortunately, even using exactly the code example from docs, and also the image that is in there, the result if not working correctly.
Using the examples from
http://docs.coronalabs.com/api/library/widget/newSwitch.html#onoff-switch
And the example images, although I had to rename them to fit the example code:
(on-off-sheet.png)
(switch-mask.png)
and the code I’ve put in my lua file :
-- Image sheet options and declaration local options = { frames = { { x=0, y=0, width=160, height=44 }, { x=0, y=45, width=42, height=42 }, { x=44, y=45, width=42, height=42 }, { x=88, y=44, width=96, height=44 } }, sheetContentWidth = 184, sheetContentHeight = 88 } local onOffSwitchSheet = graphics.newImageSheet( "on-off-sheet.png", options ) -- Create the widget local onOffSwitch = widget.newSwitch { left = 250, top = 200, style = "onOff", id = "OnOffSwitch", onPress = onSwitchPress, sheet = onOffSwitchSheet, onOffBackgroundFrame = 1, onOffBackgroundWidth = 160, onOffBackgroundHeight = 44, onOffMask = "switch-mask.png", onOffHandleDefaultFrame = 2, onOffHandleOverFrame = 3, onOffOverlayFrame = 4, onOffOverlayWidth = 96, onOffOverlayHeight = 44 }
So everything exactly as in the attached screenshot.
However, the result looks like this - basically the blue box from lower left corner of the imagesheet… and over it is the same blue box just in a different size.
Clicking this makes it move and work the switch ok, but the look remains with the same error.
Any ideas, or perhaps a fixed code so that it actually looks like it should according to the documentation?
(btw. that means it should look like this: )
Thanks to anyone who can help.
Joe