Closed iain-reid closed 6 months ago
Hi! Currently this isn't really possible, but I have a PR #32 that fixes this.
Instead of setting an update function on a sprite, you will be able to subclass Sprite and override the update function:
class MyGameObject: Sprite {
override func update() {
// update code
}
}
I was waiting on some fixes to embedded swift, and currently the draw function can't be overridden/set due to a bug in the swift compiler, but it looks like the issues blocking the update function were fixed so I'll try to merge this PR later today.
Looks like a good solution. Thanks for the quick response - and great work!
I'm pretty excited about this library - and the instructions worked perfectly!
However I'm running into an issue (that may be my misunderstanding of how to use PlaydateKit!)
When I use
setUpdateFunction
on a sprite - the closure defaults to passing me a variable calledsprite
(which makes perfect sense - I probably want access to that sprite to do something with it) - but the type isOpaquePointer
...Is there a way to cast this into a PlaydateKit
Sprite
? What is the best way to use this?