简体   繁体   English

SKNode的position属性和GKAgent2d的position属性有什么区别

[英]What is the difference between SKNode's position property and GKAgent2d's position property

SKNode has a position property which represents the node's position in parent. SKNode具有position属性,该属性表示节点在父级中的位置。 Whereas GKAgent2D also has a position property which according to the documentation is its position in 2D space. 而GKAgent2D也具有position属性,根据文档,该属性是其在2D空间中的位置。 How are these two related? 这两个有什么关系? And how do we convert between each other and is a conversion necessary? 以及我们如何在彼此之间进行转换,并且有必要进行转换吗?

You can use GameplayKit without SpriteKit. 您可以使用不带SpriteKit的GameplayKit。 The Agent's position is internal to GameplayKit and then you synchronize your sprite's position to your agent's position. 特工的位置在GameplayKit内部,然后将子画面的位置与特工的位置同步。 It means you can also have agents with other frameworks. 这意味着您也可以将代理与其他框架一起使用。

GKAgent2D position is arbitrary to whatever system you are using it for, you so there is no exact need to convert it. GKAgent2D位置对于使用它的任何系统都是任意的,因此您无需转换。 Now to keep your game simple and easy to understand, you are probably going to want to keep everything based on the scene coordinates, so you are going to want to convert your SKNode position to the position it is at on the scene, this way you can keep all of your GKAgent values based on scene position as well. 现在,为了使您的游戏简单易懂,您可能需要根据场景坐标保留所有内容,因此您需要将SKNode位置转换为场景中的位置,这样您就可以也可以根据场景位置保留所有GKAgent值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM