I have a scroll View in my code, it works fine, but I don’t know how to remove it once I go to another scene.
I thought it was going to work just like the buttons.
if buttonGame then buttonGame:removeSelf() buttonGame = nil end if scrollView then scrollView:removeSelf() scrollView = nil end
In the destroy scene, but it did not work.
This is the scroll view code
local scrollView = widget.newScrollView { left = 500, top = 200, width = 400, height = 200, scrollWidth = 400, scrollHeight = 200, maskFile = "images/maskTest.png", --bgColor = {0, 0, 0} } local function levelTap(event) local pad = event.target print("level chosen: ", pad.idx) storyboard.gotoScene( "mainMenu", "fromRight", 200 ) end local monster = display.newImage ("images/testBg.png") monster.x = 500 monster.y = scrollView.height / 2 scrollView:insert(monster) local trebleApart = 120 for idx = 1, 3 do local lpad = display.newImageRect("images/trebleClef.png", 71, 182) lpad.x = (idx \* trebleApart) lpad.y = (scrollView.height / 2) - 10 lpad.idx = idx lpad:addEventListener ("tap", levelTap) scrollView:insert(lpad) local levelText = display.newText ("Level " .. tostring(idx), 0, 0, "Helvetica", 16 ) levelText:setTextColor(0, 134, 146) levelText.x = (idx \* trebleApart) levelText.y = scrollView.height / 2 + 85 scrollView:insert(levelText) if idx == 11 then lpad.alpha = 0 levelText.alpha = 0 end end
Thanks for your help
Victor