gre.animation_create

gre.animation_create(fps, [auto_destroy], [end_callback])
                    

Create a new animation at the desired frame rate (fps). The second parameter (optional), auto_destroy, tells if the animation should be released once completed. If you specify a value of 1 the animation will be released and the returned id is not valid once the animation has completed. The third parameter (optional) indicates a callback function to be invoked when the animation is complete.


Parameters:
        fps    The animation frame rate
        auto_destroy    Pass 1 in to release the animation once completed
        end_callback    Provide a Lua function to be called in the animation
Returns
        An animation id to be used on future animation calls, nil on failure.

Example:        

function animation_create(mapargs, fps)
    local id
    id = gre.animation_create(fps)
end

--Example of an creating an animation with an animation complete callback
local animation_state = "STOPPED"
function animation_create(mapargs, fps)
    local id
    id = gre.animation_create(fps, 0, animation_complete)

    gre.animation_trigger(id, {context="my_layer.my_control",
    id="my_control_animation"})
    animation_state = "RUNNING"
end

--The callback's first argument will be the completed animation's id.
--When triggered with an animation instance id (e.g., "my_control_animation"),
--otherwise it will be the id returned from calling animation_create.
function animation_complete(id)
    animation_state = "COMPLETED"
end