local physics = require( "physics" ) --Requires the Corona sdk physics engine
physics.start()
--Background
local background = display.newImage("Background.png")
background:translate(220,150)
--background:toBack();
--screenGroup:insert(background)
--Ground
local ground = display.newImage("GROUND1.png", 220, 300 )
physics.addbody(ground,"static",{density=1.6, friction=0.5, bounce=0.2} )
--ground:toBack(); (possibility)
--ground.x = (220)
--ground.y = (300)
--Player
local player = display.newImage("Player.png")
player:translate(200,200)
--physics.addbody(player,{})
player:toFront();
这是我的lua代码,背景显示,地面显示,但播放器隐藏在背景后面。有谁能解释为什么?提前致谢
答案 0 :(得分:1)
插入组元素时,您执行此操作的顺序将在屏幕上呈现。试试这个:
local background = display.newImage("Background.png")
background:translate(220,150)
local ground = display.newImage("GROUND1.png", 220, 300 )
local player = display.newImage("Player.png")
player:translate(200,200)
screenGroup:insert(background)
screenGroup:insert(player)
--the rest of your functions or validations...
这样玩家将面对背景