0

我有一个 level1.lua 独立和工作程序。但是当我想使用 导航到它时gotoScene(),它不会播放!

local storyboard = require "storyboard"
local scene = storyboard.newScene("level1")

local function level1_pressed()
    storyboard.gotoScene( "level1", "fade" ,40 )
    print("level1 should start")
    return true
end

local level1 = display.newText( "level1",20 ,20,font, 40 )
level1:setTextColor(math.random( 50, 200 ),math.random( 50, 200 ),math.random( 50, 200 ))

level1:addEventListener( "touch", level1_pressed )

这是我的 main.lua。“level1 should start”字符串在终端上正确打印,但它没有启动!问题是什么?

4

2 回答 2

0

你读过文档吗?level1.lua 应该包含类似这样的内容。还可以从该页面查看故事板教程。

于 2013-08-05T17:07:33.760 回答
0

根据http://docs.coronalabs.com/api/library/storyboard/gotoScene.html提供的故事板文档,您的 storyboard.gotoScene() 语法不正确

    local storyboard = require "storyboard"
    local scene = storyboard.newScene("level1")

    local options = {
        effect = "fade",
        time = 40
    }

    local function level1_pressed()
            storyboard.gotoScene( "level1", options)
            print("level1 should start")
            return true
    end

    local level1 = display.newText( "level1",20 ,20,font, 40 )
    level1:setTextColor(math.random( 50, 200 ),math.random( 50, 200 ),math.random( 50, 200 ))

    level1:addEventListener( "touch", level1_pressed )
于 2013-08-16T06:09:43.990 回答