Actionscript 3:使子 A 中的某些对象出现在子 B 上方,而其他对象出现在子 B 下方
想象我有一个背景,我想在玩家对象下显示背景。这可以轻松完成:
var player:Player = new Player();
addChild(player);
var background:Background = new Background();
addChildAt(background, 0);
但是,想象一下在这个背景中,我有透明的云,必须出现在船的上方,不透明的星星需要出现在船的下方。上面的代码只会让所有背景对象都进入船下。有什么建议吗?
Imagine I have a background and I want to show the background under the player object. This can be done with ease:
var player:Player = new Player();
addChild(player);
var background:Background = new Background();
addChildAt(background, 0);
However, imagine in this background I have transparent clouds which have to appear above the ship and non-transparent stars which need to appear under the ship. The above code would simply make all background objects go under the ship. Any tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个在 Player 对象之后渲染的前景层。这是实现这种效果的最简单方法。
即
我想象您将在前景层和背景层之间出现多个对象,因此我实际上还建议创建一个“活动”层,它是“玩家”对象的实际父级。
所以对象层次结构看起来类似于:
Make a foreground layer that is rendered after the Player object. That is the easiest way to accomplish this effect.
i.e.
I'd imagine you're going to have multiple objects that you want to appear between the foreground and background layers, so I would actually also recommend creating an "active" layer, which is the actual parent of your "player" object.
So the object hierarchy looks akin to this: