本文介绍了如何使用Lua/Corona SDK创建/使用分层图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想要一个动画笑脸,该笑脸由2层组成:脸部背景+脸部前景.

Suppose I want an animated smiley face composed to 2 layers: the face background + face foreground.

背景层是简单的颜色/纹理.前景层是动画层(动画的微笑,哭泣,大笑等).

The background layer is a simple color/texture.The foreground layer is the animated layer (animated smiling, crying, laughing...etc).

我该如何在Lua中编写这些内容,以使Corona将这些图层视为单个对象/实体?我希望使用一个实体(用于碰撞,动画动作等).

How can i write this up in Lua such that Corona will treat these layers as a single object/entity? I would like a single entity to work with (for collision, animated movements, ...etc).

推荐答案

我会使用 displayGroup .

类似这样的东西:

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

这篇关于如何使用Lua/Corona SDK创建/使用分层图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:26