在Corona SDK中出于某种原因,我的按钮不会出现在屏幕上

时间:2014-11-25 00:30:42

标签: lua corona

我的按钮在Corona SDK中出于某种原因不会出现在屏幕上这里是我的代码,我错过了什么?

local composer = require(“composer”)

local scene = composer.newScene()

- 包括Corona的“小部件”库 local widget = require“widget”

- 处理按钮事件的功能 本地函数handleButtonEvent(event)

if ( "ended" == event.phase ) then
    print( "Button was pressed and released" )
end


- 前瞻声明和其他本地人 本地playBtn

- playBtn的'onRelease'事件监听器 本地函数onPlayBtnRelease()

-- go to levelSelect.lua scene
composer.gotoScene( "levelSelect", "fade", 500 )

return true -- indicates successful touch

- 背景  local sky = display.newImage(“startScreen / sky.png”)  sky.x = display.contentWidth / 2; sky.y = display.contentHeight / 2;

- 图片  local preston = display.newImage(“startScreen / PrestonArt.png”) 普雷斯顿:规模(0.4,0.4) preston.x = display.contentWidth / 2; preston.y = display.contentHeight / 2;

- 标签 local learningLabel = display.newImage(“startScreen / Learning.png”) learningLabel:scale(0.3,0.3) learningLabel.x = 506; learningLabel.y = 170;

local centerLabel = display.newImage(“startScreen / Center.png”) centerLabel:scale(0.3,0.3) centerLabel.x = 506; centerLabel.y = 600;

功能场景:创建(事件)     local sceneGroup = self.view

-- Called when the scene's view does not exist.
-- 
-- INSERT code here to initialize the scene
-- e.g. add display objects to 'sceneGroup', add touch listeners, etc.

-- create a widget button (which will loads levelSelect.lua on release)
playBtn = widget.newButton{
    defaultFile = "startScreen/Play.png",       --the "default" image file
    overFile = "startScreen/Play-Over.png",     --the "over" image file 
    width=240, height=120,
    onRelease = onPlayBtnRelease    -- event listener function
}
playBtn.x = 300; playBtn.y = 695;

-- all display objects must be inserted into group
 sceneGroup:insert( playBtn )

功能场景:显示(事件)     local sceneGroup = self.view     local phase = event.phase

if phase == "will" then
    -- Called when the scene is still off screen and is about to move on screen
elseif phase == "did" then
    -- Called when the scene is now on screen
    -- 
    -- INSERT code here to make the scene come alive
    -- e.g. start timers, begin animation, play audio, etc.
end 

功能场景:隐藏(事件)     local sceneGroup = self.view     local phase = event.phase

if event.phase == "will" then
    -- Called when the scene is on screen and is about to move off screen
    --
    -- INSERT code here to pause the scene
    -- e.g. stop timers, stop animation, unload sounds, etc.)
elseif phase == "did" then
    -- Called when the scene is now off screen
end 

功能场景:破坏(事件)     local sceneGroup = self.view

-- Called prior to the removal of scene's "view" (sceneGroup)
-- 
-- INSERT code here to cleanup the scene
-- e.g. remove display objects, remove touch listeners, save state, etc.

if playBtn then
    playBtn:removeSelf()    -- widgets must be manually removed
    playBtn = nil
end


- 监听器设置 场景:addEventListener(“创建”,场景) 场景:addEventListener(“show”,场景) 场景:addEventListener(“隐藏”,场景) 场景:addEventListener(“destroy”,场景)


返回场景

1 个答案:

答案 0 :(得分:2)

我的猜测是

  1. 评论说转到level1.lua但它尝试转到levelSelect
  2. 不要在文件名中使用大写(通常)
  3. 尝试删除" fade",500以查看它是否有效
  4. 在levelselect.lua中,你没有返回场景或没有处理场景:创建
  5. 请提供更多代码和信息