NobleEngine icon indicating copy to clipboard operation
NobleEngine copied to clipboard

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

Open JerryVerhoeven opened this issue 2 years ago • 3 comments

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.

JerryVerhoeven avatar Jul 05 '22 16:07 JerryVerhoeven

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?

Mark-LaCroix avatar Jul 05 '22 16:07 Mark-LaCroix

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.

JerryVerhoeven avatar Jul 05 '22 16:07 JerryVerhoeven

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 avatar Jul 05 '22 17:07 Mark-LaCroix

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.

Mark-LaCroix avatar Aug 15 '22 00:08 Mark-LaCroix