"sprite.play_flipbook()" complete function arguments

1. if cardinal == utility.north then sprite.playflipbook("#sprite", "player_dead_north", utility.reset_stage)
2. function utility.reset_stage(stage_id)

In the first line, I’m calling “sprite.play_flipbook()” and passing “utility.reset_stage()” as the complete function. This complete function requires an argument of “stage_id” so it can be generalized. How do I pass an argument through the “play_flipbook()” function?

Please don’t post screenshots of code. Post the code as text instead and either indent it with four spaces or select the text and press </> to format it as code.

All callback functions have self as first argument. Store the stage_id on self for easy access to the value in the callback.

2 Likes

Alternatively you could wrap the function call in an anonymous function:

sprite.play_flipbook("#sprite", "player_dead_north", function() utility.reset_stage(stage_id) end)
3 Likes

Oops, didn’t know about the code formatting. Thanks for telling me. Great, problem solved! :slight_smile: