(SOLVED) Setting sprite offset and playback rate has no effect. Is this intentional?

Hello, does anyone has explanation of this?

It seems, these optional properties are useless if you can set them but not use… Forces me to create side-offs when I need to just set animation (to show its 1st frame) but not play it

I recommend creating a new post instead of necromancing old threads. (Is there a way to lock old threads? :thinking:)

As for the statement that the properties are useless, I’m not sure I understand?

1 Like

Well, they work fine if they were set before build process, but if you set them at runtime while you trying to set a new animation, they just don’t do anything, like was described in above posts

FYI Moved this to a new post

2 Likes

Could you please share the code you are using?

1 Like

Yeah, sure.

function init(self)
    -- if side door then change sprite (isSide is go.property)
    if self.isSide then
       -- DOOR_VIEW only used to add "Front" of "Side" strings later
        view = DOOR_VIEW.SIDE 
    end
    -- set sprite by view
    -- I want to set an animation here, but not play it at the moment it is set
    sprite.play_flipbook("#sprite", "DoorClose"..view, {playback_rate = 0}) 
end  

If I print playback_rate, the value is the one I set with sprite.play_flipbook, but the animation still plays from the start.
I tried, also, to set playback_rate with go.set before or after play_flipbook, but the result is the same.

I use Defold 1.9.0

The function signature for sprite.play_flipbook() is:

sprite.play_flipbook(url,id,[complete_function],[play_properties])

The complete_function is optional, but you still need to pass nil if you don’t want to use a complete_function. You can’t omit it and pass the play_properties as the third argument. Try:

sprite.play_flipbook("#sprite", "DoorClose"..view, nil, {playback_rate = 0}) 
4 Likes

Works perfectly, thank you very much! :orange_heart: :blue_heart:

We should do a better check of the callback argument :thinking: