Hi - I have added a scrollview to my scene group (I’m using storyboard api) and added some rects to the scrollview (for testing purposes). But the scrollview won’t scroll.
Note that the code below is the entire scene. I haven’t done anything else yet - I just want to make the scrollview scroll
I would be incredibly grateful if anyone could point out why the scrollview isn’t scrolling.
Thanks in advance!
The code I am using looks like this:
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local level\_data = require( "settings\_levels" ) local widget = require( "widget" ) -- local function onButtonReturn( event ) storyboard.gotoScene( storyboard.getPrevious(), 'slideDown', 500 ) return true end -- local function scrollListener( event ) local phase = event.phase local direction = event.direction if "began" == phase then --print( "Began" ) elseif "moved" == phase then --print( "Moved" ) elseif "ended" == phase then --print( "Ended" ) end end -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view self.menu = {} -- background image background = display.newImageRect( "scenes/intro/background.png", display.contentWidth, display.contentHeight ) background.x = display.contentWidth / 2 background.y = display.contentHeight / 2 group:insert( background ) -- Create a ScrollView local scrollView = widget.newScrollView { left = 10, top = 10, width = display.contentWidth - 20, height = display.contentHeight - 90, verticalScrollDisabled = true, listener = scrollListener, hideScrollBar = true, isLocked = false, --hideBackground = true, } group:insert( scrollView ) --scrollView:takeFocus() local x = 0 for i = 10, 1, -1 do local rect = display.newRect( scrollView, x, 10, 110, 200 ) rect:setFillColor( 0, 0, 0 ) rect.alpha = 0.5 x = x + 130 end local menuButton menuButton = widget.newButton( { defaultFile = "scenes/menu/button.png", label = "Close", width = 120, height = 60, font = gameConst.font, labelColor = gameConst.labelStyle, onRelease = onButtonReturn, left = screenCenterX - 60, top = display.contentHeight - 70, id = "playButton", } ) group:insert( menuButton ) end -- Called BEFORE scene has moved onscreen: function scene:enterBegan( event ) local group = self.view end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view end -- Called AFTER scene has finished moving offscreen: function scene:exitEnded( event ) local group = self.view end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view end -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterBegan" event is dispatched before scene transition begins scene:addEventListener( "enterBegan", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "exitEnded" event is dispatched after scene has finished transitioning out scene:addEventListener( "exitEnded", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) return scene