简体   繁体   中英

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. Whereas GKAgent2D also has a position property which according to the documentation is its position in 2D space. How are these two related? And how do we convert between each other and is a conversion necessary?

You can use GameplayKit without SpriteKit. The Agent's position is internal to GameplayKit and then you synchronize your sprite's position to your agent's position. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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