Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use KVO on SKSpriteNode position property

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?

like image 801
user3321101 Avatar asked Dec 14 '25 01:12

user3321101


1 Answers

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.

like image 193
LearnCocos2D Avatar answered Dec 16 '25 23:12

LearnCocos2D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!