gpt4 book ai didi

swift - SpriteKit : how to find the position at which two sprites or physics bodies contact

转载 作者:行者123 更新时间:2023-11-28 07:01:14 25 4
gpt4 key购买 nike

我创建了两个 Sprite 并处理了它们的接触。我想在两个物体接触的位置创建一个新的 Sprite 。我怎样才能得到一个接触的 Sprite 的位置?

最佳答案

请查看 SKPhysicsContact 类。 (See here)

To receive contact messages, read the physicsWorld property of an SKScene object you are interested in, and assign its contactDelegate property to point to an object that implements the SKPhysicsContactDelegate protocol. Then, for each physics body in your scene, set the categoryBitMask and contactTestBitMask properties to define which interactions should generate contact messages.

在生成的 SKPhysicsContact 属性上,您可以读取 contactPoint 变量。

关于swift - SpriteKit : how to find the position at which two sprites or physics bodies contact,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31996845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com