how to use a time interval method with your slider: timer.performWithDelay(200, addNewBox, 0)

How would I use a slider to adjust the time interval to this method:

timer.performWithDelay(200, addNewBox, 0)

Also How would I connect a radio button to authorize the use of that slider,

like slider enabled.

I cant find any tutorials that has this feature to demonstrate.

Thank You

Please Help

Take a look at here: https://docs.coronalabs.com/api/library/widget/newSlider.html

The sample code at the bottom of the docs page and something like this should help you.

local tmrWait = 0 local function sliderListener( event ) print( "Slider at " .. event.value .. "%" ) tmrWait = event.value end

It may not be as straight forward as just getting the value. You’ve set a repeating timer. It’s going to repeat at that value until it’s canceled or the number of iterations complete.

The way most people would do this is to not set a repeating timer, but simply start a new timer when the function called by the timer (addNewBox in your case) completes. That way you could have a variable holding the speed of the timer and you could use a slider to change the timer’s time value.

local tmrWait = 200 -- default value. local boxTimer = nil local function sliderListener( event )     print( "Slider at " .. event.value .. "%" )     tmrWait = event.value end local function addNewBox()     -- do stuff     if tmrWait \> 0 then  -- give yourself a way to stop the timer from restarting.          boxTimer = timer.performWithDelay( tmrWait, addNewBox, 1)     end end boxTimer = timer.performWithDelay(tmrWait, addNewBox, 1)

The code is untested, but it should give you an idea.

Rob

Take a look at here: https://docs.coronalabs.com/api/library/widget/newSlider.html

The sample code at the bottom of the docs page and something like this should help you.

local tmrWait = 0 local function sliderListener( event ) print( "Slider at " .. event.value .. "%" ) tmrWait = event.value end

It may not be as straight forward as just getting the value. You’ve set a repeating timer. It’s going to repeat at that value until it’s canceled or the number of iterations complete.

The way most people would do this is to not set a repeating timer, but simply start a new timer when the function called by the timer (addNewBox in your case) completes. That way you could have a variable holding the speed of the timer and you could use a slider to change the timer’s time value.

local tmrWait = 200 -- default value. local boxTimer = nil local function sliderListener( event )     print( "Slider at " .. event.value .. "%" )     tmrWait = event.value end local function addNewBox()     -- do stuff     if tmrWait \> 0 then  -- give yourself a way to stop the timer from restarting.          boxTimer = timer.performWithDelay( tmrWait, addNewBox, 1)     end end boxTimer = timer.performWithDelay(tmrWait, addNewBox, 1)

The code is untested, but it should give you an idea.

Rob