如何将SKSpriteNode置于最前面? [英] How to bring a SKSpriteNode to front?

查看:145
本文介绍了如何将SKSpriteNode置于最前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将SKSpriteNode带到所有其他节点的前面?

How can I bring a SKSpriteNode to the front of all other node?

借助UIView,我可以使用BringSubviewToFront将uiview置于其他视图的前面.

With UIView, I can use bringSubviewToFront to bring an uiview in front of other views.

推荐答案

您不能将其放在最前面",但是可以更改它的zPosition.

You can't "bring it to front" but you can change the zPosition of it.

节点的zPosition越高,它呈现的时间就越晚.

The higher the zPosition of the node the later it gets rendered.

因此,如果您有三个zPositions分别为-1、0和1的节点,则-1将出现在后面.然后是0.然后1将出现在前面.

So if you have three nodes with zPositions of -1, 0 and 1 then the -1 will appear at the back. Then the 0. Then 1 will appear at the front.

如果它们全部使用默认的zPosition 0.0,则将按照它们在父节点的子节点数组中出现的顺序进行渲染.

If they all use the default zPosition of 0.0 then they are rendered in the order they appear in the children array of the parent node.

您可以在文档中全部阅读.

You can read it all in the docs.

https://developer.apple.com/documentation/spritekit/sknode

这篇关于如何将SKSpriteNode置于最前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆