How to bring a SKSpriteNode to front?

前端 未结 4 971
悲&欢浪女
悲&欢浪女 2021-01-03 18:26

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

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

4条回答
  •  借酒劲吻你
    2021-01-03 18:35

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

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

    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.

    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

提交回复
热议问题