在运行Corona SDK时出现黑屏(我正在使用Composer)。
2014-7-15 21:59:5
收藏:0
阅读:63
评论:2
当我保存并点击启动时,屏幕是黑色的,没有场景显示。
有人能找出问题并知道如何正确修复它吗? 如果有人可以的话,我会很高兴。
谢谢。
这是我的 Main.lua-
display.setStatusBar(display.HiddenStatusBar)
local composer = require( "composer" )
local scene = composer.newScene()
-- your code goes here...
composer.gotoScene("menu")
这是我的 Menu.lua-
display.setStatusBar(display.HiddenStatusBar)
local composer = require( "composer" )
local scene = composer.newScene()
-- -----------------------------------------------------------------------------------------------------------------
-- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called.
-- -----------------------------------------------------------------------------------------------------------------
-- local forward references should go here
-- -------------------------------------------------------------------------------
-- "scene:create()"
function scene:create( event )
local sceneGroup = self.view
local background = display.newImageRect( "background.png", 730, 400 )
sceneGroup:insert( background )
end
-- "scene:show()"
function scene:show( event )
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.
print("menu")
end
end
-- "scene:hide()"
function scene:hide( event )
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
end
-- "scene:destroy()"
function 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.
end
-- -------------------------------------------------------------------------------
-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -------------------------------------------------------------------------------
return scene
点赞
用户2653067
我认为可能的问题可能是图片和场景的路径。
如果您使用上述代码,则所有背景图像和菜单.lua都应在主文件夹中,而不是在任何子文件夹中,请首先检查这两个事项。
然后我认为您没有给出图片的x和y值,
background.x = display.contentWidth / 2 background.y = display.contentHeight / 2
这些都是可能的问题。
2014-07-18 10:15:17
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
请在你的menu.lua的起始位置加入以下代码:
display.setStatusBar(display.HiddenStatusBar) local composer = require("composer") local scene = composer.newScene() local background -- ----------------------------------------------------------------------------------------------------------------- -- 所有的监听函数以外的代码,除非调用“composer.removeScene()”,否则将只执行一次。 -- ----------------------------------------------------------------------------------------------------------------- -- 此处应添加正向引用 -- ------------------------------------------------------------------------------- -- "scene:create()" function scene:create(event) local sceneGroup = self.view background = display.newImageRect("background.png", 730, 400) background.x = display.contentCenterX background.y = display.contentCenterY sceneGroup:insert(background) end在你的场景文件(menu.lua)中,你需要将背景图片声明为局部变量,而不是在create函数中局部声明。