So I’m trying to utilize this widget but I have some questions about it since I can’t figure it out.
-
Am I able to adjust the size of this widget? When I switch between different screen sizes on the simulator, it remains the same size and I ideally want to adjust the size accordingly.
-
Default for the switch is a blue color when the switch is on, can I somehow change it to green? I’m completely lost on how to do this because all I did was copy paste the code for the widget (without adding images to my main.lua) and somehow it is showing pictures to create the widget! haha, So If I wanted to create my own custom images, I don’t know the sizes of the pictures that are required, etc.
heres a convenient link to the corona doc:
https://docs.coronalabs.com/api/library/widget/newSwitch.html#initialswitchstate-optional
Here’s what I copy/pasted into my main.lua as a test
[lua] local widget = require( “widget” )
– Handle press events for the checkbox
local function onSwitchPress( event )
local switch = event.target
print( “Switch with ID '”…switch.id…"’ is on: "…tostring(switch.isOn) )
end
– Create the widget
local onOffSwitch = widget.newSwitch(
{
x = display.viewableContentWidth/2, — x location
y = display.viewableContentHeight/2, — y location
style = “onOff”,
id = “onOffSwitch”,
onPress = onSwitchPress
}
)
onOffSwitch.anchorX = 0 – doesn’t seem to do anything
onOffSwitch.anchorX = 0
[/lua]
Thanks for any help!!