megamarc / Tilengine

Free 2D graphics engine with raster effects for retro/classic style game development
https://www.tilengine.org
Mozilla Public License 2.0
847 stars 95 forks source link

Crash when resuming animation #105

Closed danielgholmes closed 2 years ago

danielgholmes commented 2 years ago

Hi there!

I've been trying out the new features to pause and resume animations. The pause seems to work fine, but when resuming the animation, it causes a crash and returns tilengine.TilengineException: 'No error'.

Here is the Python code that reproduces the issue. Associated assets are here:

area

area.txt

from tilengine import Engine, Window, Spriteset, Sequence, Input

engine = Engine.create(400, 240, 1, 1, 20)
engine.set_load_path("assets/sprites")

spriteset = Spriteset.fromfile("area")
sequence = Sequence.create_sprite_sequence(spriteset, "area", 10)
sprite = engine.sprites[engine.get_available_sprite()]
sprite.setup(spriteset)
sprite.set_animation(sequence)
sprite.set_position(0, 0)

window = Window.create()
while window.process():
    window.draw_frame()
    if window.get_input(Input.UP):
        sprite.pause_animation()
    if window.get_input(Input.DOWN):
        sprite.resume_animation()

I'm using Tilengine v2.12.0

megamarc commented 2 years ago

Hi! That was an stupid copy'n paste error where TLN_ResumeSpriteAnimation() was returning false on successful operation. This slipped harmless on C tests, but causes python binding to throw an exception.