Noble Engine: a li'l game engine for Playdate

, ,

Links!

:robot: Project Template repository (start here!)
:steam_locomotive: Engine repository
:receipt: Documentation
:white_check_mark: GitHub Project board

4 Likes

Hi, I am testing this engine and is great but I have a problem with animations.
I am using this code:

MyHero = {}
class("MyHero").extends(Graphics.sprite)

function MyHero:init()
	MyHero.super.init(self)
	-- ...
	self.animation = Noble.Animation.new("assets/images/player")
	self.animation:addState("idle", 1, 3)
	self.animation:addState("walk", 4, 6, "", true, function()
          print ("walk end")
      end)

	self:moveTo(100, 100)
	self:setCollideRect(0,0,16,32)

    self:add();
    
	-- ...
end

function MyHero:draw()
	self.animation:draw()
end

function MyHero:update()
	self.animation:setState(self.animation.walk, false, self.animation.turn)
end

and I have no error in console, all is ok, I can see the collider in the simulator actually but I never get the animation or even a frame, actually the finish function in walk never executes

What am I doing wrong?
Thanks so much

1 Like

Umm. Lua is annoying in that it frequently fails silently without error, so it relies on a lot on writing error-checks into the code yourself. And honestly I haven't put as much error-checking into the engine as I'd like.

You're not the first person to have trouble wiring up Sprite animations, though, so I bet we can solve this.

My first thought, which I've seen before, that you don't have a self:setSize(16, 32) line in your init function, so it's possible that the animation is drawing, it's just drawing it into a 0x0 frame.

The other thing I noticed is that you enter "" as the next animation for your "walk" animation, when I think you should enter nil. The engine might try to load an animation named "" after the first walk cycle completes (it's also possible the engine accounts for "" but I don't recall offhand).

But... none of that explains why the onComplete function doesn't run...

But but... with the most recent update to the engine, it now recommends that you use the new NobleSprite for your animated sprites instead of extending Graphics.sprite. It handles a lot of the fiddly bits for you. Docs here -> Noble Sprite

Let me know if any of these suggestions help (or not!).

Thanks so much, setSize was the key to draw the sprite (I thought it was automatically called when I import the imagetable) and nil instead "" was the key for onComplete function runs.
Thanks so much

Fantastic! It even solved the problem I didn't think it would :laughing:.

Do let me know how your game comes along!

I know this is an old thread, but there were a few people on the squad discord asking how to use the engine so I've spent the past few days making a little example project. Almost done, just need to add some documentation!

playdate-20230628-013056-2

Edit: It’s released! GitHub - GammaGames/NobleEngine-Example-Project: A simple project showcasing various functions of NobleEngine for Playdate

4 Likes

how to build the game?