1

我现在很困惑,因为我试图让滚动视图在 Storyboard 中工作。我在 Corona 中使用带有滚动视图的文件/示例应用程序胡闹,它可以找到滚动视图,因为它没有遵循 Storyboard。当我转到我的游戏时,我值得实现情节提要,我将图像放在板条箱屏幕中,但是当我尝试插入滚动视图时它不起作用。有人可以把这个文件放在故事板格式我会很感激。这是文件

display.setStatusBar( display.HiddenStatusBar ) 

local bg = display.newImage ("bg.png")

local widget = require( "widget" )

-- Our ScrollView listener
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

    -- If the scrollView has reached it's scroll limit
    if event.limitReached then
        if "up" == direction then
            print( "Reached Top Limit" )
        elseif "down" == direction then
            print( "Reached Bottom Limit" )
        elseif "left" == direction then
            print( "Reached Left Limit" )
        elseif "right" == direction then
            print( "Reached Right Limit" )
        end
    end

    return true
end

-- Create a ScrollView
local scrollView = widget.newScrollView
{
    left = 0,
    top = 0,
    width = display.contentWidth,
    height = display.contentHeight,
    bottomPadding = 50,
    id = "onBottom",
    horizontalScrollDisabled = true ,
    verticalScrollDisabled = false ,
    hideBackground = true, 
    listener = scrollListener,
}


local worlds = display.newImage ("pink.png")
worlds.x = 100
worlds.y = 100
scrollView:insert( worlds)


local worlds1 = display.newImage ("pink.png")
worlds1.x = 100
worlds1.y = 800
scrollView:insert( worlds1)


local worlds2 = display.newImage ("pink.png")
worlds2.x = 100
worlds2.y = 500
scrollView:insert( worlds2)


local worlds3 = display.newImage ("pink.png")
worlds3.x = 100
worlds3.y = 1000
scrollView:insert( worlds3)


local worlds4 = display.newImage ("pink.png")
worlds4.x = 100
worlds4.y = 2000
scrollView:insert( worlds4)

我是 Corona SDK 的新手。如果有人能回答我的问题,如果您需要我放入故事板的文件,我将不胜感激,只需发表评论并进行编辑,但我没有看到任何理由,因为它不起作用。我只想要故事板格式的这个文件。

4

1 回答 1

0

这是 Composer 格式。故事板和作曲家都是一样的。

  display.setStatusBar( display.HiddenStatusBar ) 

本地作曲家 = 要求(“作曲家”)

本地场景 = composer.newScene()

本地小部件 = 要求(“小部件”)

功能场景:创建(事件)

local sceneGroup = self.view
local bg = display.newImage ("bg.png")

-- Initialize the scene here.
-- Example: add display objects to "sceneGroup", add touch listeners, etc.
-- Our ScrollView listener
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

    -- If the scrollView has reached it's scroll limit
    if event.limitReached then
        if "up" == direction then
            print( "Reached Top Limit" )
        elseif "down" == direction then
            print( "Reached Bottom Limit" )
        elseif "left" == direction then
            print( "Reached Left Limit" )
        elseif "right" == direction then
            print( "Reached Right Limit" )
        end
    end

    return true
end

-- Create a ScrollView
local scrollView = widget.newScrollView
{
    left = 0,
    top = 0,
    width = display.contentWidth,
    height = display.contentHeight,
    bottomPadding = 50,
    id = "onBottom",
    horizontalScrollDisabled = true ,
    verticalScrollDisabled = false ,
    hideBackground = true, 
    listener = scrollListener,
}


local worlds = display.newImage ("images (2).jpg")
worlds.x = 100
worlds.y = 100
scrollView:insert( worlds)

local worlds1 = display.newImage ("images (2).jpg")
worlds1.x = 100
worlds1.y = 800
scrollView:insert( worlds1)


local worlds2 = display.newImage ("images (2).jpg")
worlds2.x = 100
worlds2.y = 500
scrollView:insert( worlds2)


local worlds3 = display.newImage ("images (2).jpg")
worlds3.x = 100
worlds3.y = 1000
scrollView:insert( worlds3)


local worlds4 = display.newImage ("images (2).jpg")
worlds4.x = 100
worlds4.y = 2000
scrollView:insert( worlds4)
    sceneGroup:insert(scrollView)

结尾

功能场景:展示(事件)

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
    -- Called when the scene is still off screen (but is about to come on screen).
elseif ( phase == "did" ) then
    -- Called when the scene is now on screen.
    -- Insert code here to make the scene come alive.
    -- Example: start timers, begin animation, play audio, etc.
end

结尾

--“场景:隐藏()”函数场景:隐藏(事件)

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
    -- Called when the scene is on screen (but is about to go off screen).
    -- Insert code here to "pause" the scene.
    -- Example: stop timers, stop animation, stop audio, etc.
elseif ( phase == "did" ) then
    -- Called immediately after scene goes off screen.
end

结尾

-- "scene:destroy()" 函数场景:destroy(event)

local sceneGroup = self.view

-- Called prior to the removal of scene's view ("sceneGroup").
-- Insert code here to clean up the scene.
-- Example: remove display objects, save state, etc.

结尾


-- 监听器设置 scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) scene:addEventListener("destroy", scene)


返回场景

当你调用故事板时,在这里你调用composer.gotoScene(你的故事板或作曲家文件名)

于 2014-08-02T11:51:47.750 回答