@ponywolf
Unfortunately I’ve run into a weird problem…
If you take the following menu.lua (modified from your example project - with my mods typed in, not pasted), the option for the number of rounds works perfectly, but when the lives option is selected - regardless of it’s initial value it will always jump to ‘3’ before working normally.
-- Requirements local composer = require "composer" local snap = require "com.ponywolf.snap" local ponymenu = require "com.ponywolf.ponymenu" local snd = require "com.ponywolf.ponysound" local fx = require "com.ponywolf.ponyfx" -- Variables local to scene local scene = composer.newScene() local menu local selectedOptions = { lives = 6, -- Lives per player per frame. framesToPlay = 1 -- Total number of frames to play. } function scene:create( event ) local view = self.view -- add display objects to this group -- menu listener local function onMenu(event) local phase, name = event.phase, event.name or "none" print (phase, name) if phase == "selected" then snd:play("blip") if name == "play" then fx.fadeOut(function() composer.gotoScene("scene.game") end) elseif string.sub ( name, 1, 6 ) == "rounds" then local this = string.sub( name, 8 ) selectedOptions.framesToPlay = tonumber(this) elseif string.sub ( name, 1, 5 ) == "lives" then local this = string.sub( name, 7 ) selectedOptions.lives = tonumber(this) elseif name == "quit" then native.requestExit() end end end -- create a start menu menu = ponymenu.new( onMenu, { align = "center", font = "RobotoMono.ttf", fontSize = 32 }) menu:add("Play") local tmp = "lives:"..tostring(selectedOptions.lives) menu:add("Lives: 1,Lives: 2,Lives: 3,Lives: 4,Lives: 5,Lives: 6,Lives: 7") menu:set(tmp) local tmp = "rounds:"..tostring(selectedOptions.framesToPlay) menu:add("Rounds: 1,Rounds: 3,Rounds: 5,Rounds: 7,Rounds: 9") menu:set(tmp) menu:add("Quit") view:insert(menu) snap(menu) -- keys to toggle volume and music local function key(event) local phase = event.phase local name = event.keyName if phase == "up" then elseif name == "v" then snd:toggleVolume() if snd.volume \> 0 then menu:set("soundoff") else menu:set("soundon") end end end Runtime:addEventListener( "key", key ) end local function enterFrame(event) local elapsed = event.time end function scene:show( event ) local phase = event.phase if ( phase == "will" ) then Runtime:addEventListener("enterFrame", enterFrame) elseif ( phase == "did" ) then end end function scene:hide( event ) local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then Runtime:removeEventListener("enterFrame", enterFrame) end end function scene:destroy( event ) end scene:addEventListener("create") scene:addEventListener("show") scene:addEventListener("hide") scene:addEventListener("destroy") return scene
I’ve been through it with a fine tooth comb but cannot for the life of me figure out why it is doing it