1

ストーリーボードでスクロールビューを機能させようとしていたので、今はとても行き詰まっています。スクロール ビューを使用してコロナのファイル/サンプル アプリをいじっていましたが、ストーリーボードに従っていないため、スクロール ビューが機能します。ストーリーボードの実装に値するゲームに移動すると、画像をクレート画面に配置しましたが、スクロールビューを挿入しようとすると機能しません。誰かがこのファイルをストーリー ボード形式にしてくれませんか? ここにファイルがあります

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)

私はコロナSDKの初心者です。私がストーリー ボードに入れたファイルが必要な場合は、誰かが私の質問に答えていただければ幸いです。コメントを残して編集しますが、機能しないため理由がわかりません。このファイルをストーリーボード形式にしたいだけです。

4

1 に答える 1

0

Composer 形式は次のとおりです。絵コンテもコンポーザーも同じです。

  display.setStatusBar( display.HiddenStatusBar ) 

local composer = require( "composer" )

ローカル シーン = composer.newScene()

ローカル ウィジェット = require( "ウィジェット" )

関数シーン:create( イベント )

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)

終わり

関数 scene:show( イベント )

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

終わり

-- "scene:hide()" 関数 scene:hide( イベント )

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()" 関数 scene: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 に答える