如何使用Lua/Corona SDK创建/使用分层图像?

如何使用Lua/Corona SDK创建/使用分层图像?,lua,coronasdk,Lua,Coronasdk,假设我想要一个由两层组成的动画笑脸:脸背景+脸前景 背景层是一个简单的颜色/纹理。 前景层是动画层(动画的微笑、哭泣、大笑等) 我如何在Lua中写下这些,以便Corona将这些层视为单个对象/实体?我希望使用单个实体(用于碰撞、动画移动等)。我将使用一个实体 大概是这样的: local smiley = display.newGroup() local emotion = display.newImage("happy.png") local background = display.newIm

假设我想要一个由两层组成的动画笑脸:脸背景+脸前景

背景层是一个简单的颜色/纹理。 前景层是动画层(动画的微笑、哭泣、大笑等)

我如何在Lua中写下这些,以便Corona将这些层视为单个对象/实体?我希望使用单个实体(用于碰撞、动画移动等)。

我将使用一个实体

大概是这样的:

local smiley = display.newGroup()
local emotion = display.newImage("happy.png")
local background = display.newImage("background.png")

smiley:insert(background)
smiley:insert(emotion)

-- moving smiley will also move background and emotion
-- because they are attached to the smiley displayGroup
smiley.x = 100
smiley.y = 100
我会用一只手来做这件事

大概是这样的:

local smiley = display.newGroup()
local emotion = display.newImage("happy.png")
local background = display.newImage("background.png")

smiley:insert(background)
smiley:insert(emotion)

-- moving smiley will also move background and emotion
-- because they are attached to the smiley displayGroup
smiley.x = 100
smiley.y = 100

希望这对你有所帮助

smiley:insert(1,background)
smiley:insert(2,emotion)

数字越大,图像越突出

希望这对您有所帮助

smiley:insert(1,background)
smiley:insert(2,emotion)
数字越大,图像越前端