How can I use KVO on SKSpriteNode position property

廉价感情. 提交于 2019-12-21 20:15:29

问题


I would like to use KVO to observe changes to the SKSpriteNode position property, but it doesn't seem to work. Is SKNode's position property observable?


回答1:


Nope, it is not. SK behind the scenes is a C++ engine that bypasses most of Objective-C's overhead, like for instance KVO (KVC will still work cause that's entirely on you).

Unlike in UI(Kit) apps, most values of most objects change often anyway, so if you're interested in changes to a property it's faster to simply check it every frame using SKScene's update: or (better) didSimulatePhysics methods.



来源:https://stackoverflow.com/questions/22746925/how-can-i-use-kvo-on-skspritenode-position-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!