NobleRobot / NobleEngine

A li'l game engine for Playdate.
https://noblerobot.github.io/NobleEngine/
Other
417 stars 31 forks source link

Animated sprites don't draw unless calling animation.draw() explicitly #22

Closed JerryVerhoeven closed 2 years ago

JerryVerhoeven commented 2 years ago

Documentation says:

When attached to a NobleSprite, this is called by NobleScene:draw() when added to a scene. For non-NobleSprite sprites, put this method inside your sprite's draw() method, or inside NobleScene:update.

Doesn't seem to be true for me unfortunately.

I'm actually curious where NobleScene:draw() is supposed to be because I haven't found it.

Mark-LaCroix commented 2 years ago

Looks like this was me making a typo in the docs, sorry about that. It's supposed to refer to NobleSprite:draw() (not NobleScene:draw()), which is called like any other sprite in the Playdate SDK's update loop.

image

Not sure what's preventing it from working in your case. Can you post some code?

JerryVerhoeven commented 2 years ago

image image

This is how I've set it up. Not sure what else I can say except that if I call draw explicitly on the sprite, it does render as expected.

Mark-LaCroix commented 2 years ago

You might want to try having the scene be the one to add the NobleSprite directly, instead of the NobleSprite calling to add itself. So, use self:addSprite(testTargetDownSprite) inside your NobleScene:init() function. NobleSprite:add(), which you are using, will call the current scene's self.addSprite(yourSprite) method, but I don't think the current scene has been changed to the new scene yet when NobleScene:init() runs. I think it happens on NobleScene:enter().

Almost certainly unrelated, but you don't need to include the "table-32-32" part of the filename when you create from a spritesheet.

Mark-LaCroix commented 2 years ago

The documentation typo was fixed in #26. I think the other issue is more a case of "works as designed, but maybe it's designed weirdly?" I'm going to close this issue, but feel free to open a new thread in the discussions tab if I didn't fully address the topic.