diff --git a/Noble.lua b/Noble.lua index 9f69600..92ea886 100644 --- a/Noble.lua +++ b/Noble.lua @@ -330,12 +330,12 @@ function playdate.update() Graphics.pushContext(currentTransition.newSceneScreenshot) end - Graphics.sprite.update() -- Let's draw our sprites (and backgrounds). - if (currentScene ~= nil) then currentScene:update() -- Scene-specific update code. end + Graphics.sprite.update() -- Let's draw our sprites (and backgrounds). + if (isTransitioning) then if (currentTransition._captureScreenshotsDuringTransition) then Graphics.popContext() diff --git a/modules/NobleSprite.lua b/modules/NobleSprite.lua index 4e929f4..a5e34b4 100644 --- a/modules/NobleSprite.lua +++ b/modules/NobleSprite.lua @@ -97,10 +97,15 @@ function NobleSprite:init(__view, __viewIsSpritesheet, __singleState, __singleSt end +function NobleSprite:update() + if (self.animation ~= nil) then + self:markDirty() + end +end + function NobleSprite:draw() if (self.animation ~= nil) then self.animation:draw() - self:markDirty() end end @@ -112,6 +117,9 @@ end --- This will disable the update loop for this NobleSprite, which also causes its Noble.Animation to pause. function NobleSprite:pause() self:setUpdatesEnabled(false) + if (self.animation ~= nil) then + self:markDirty() + end end --- This will disable the update loop for this NobleSprite, and also reset its Noble.Animation (if it exists) to the first frame of its current state. @@ -119,6 +127,7 @@ function NobleSprite:stop() self:setUpdatesEnabled(false) if (self.animation ~= nil) then self.animation.currentFrame = self.animation.current.startFrame + self:markDirty() end end @@ -127,8 +136,8 @@ end -- To add a `playdate.graphics.sprite` to a scene, use `NobleScene:addSprite(__sprite)`. -- @see NobleScene:addSprite function NobleSprite:add(__x, __y) - local x = __x or 0 - local y = __y or 0 + local x = __x or self.x + local y = __y or self.y self:moveTo(x, y) Noble.currentScene():addSprite(self) end