MouseOver on node to change animation (solved)

I want to change animation each time mouse over node, but the problem when i move pointer, the code always start animation, not wait until finish then loop.
Here my code,

function on_input(self, action_id, action)
  if gui.pick_node(n, action.x, action.y) then
    gui.play_flipbook(n, "slide")
  else
    gui.play_flipbook(n, "idle")
  end
end

How to solve this issue?

Is it looping? If not you can set a flag if animation is completed in a callback function and check this flag before starting a new one.

1 Like

gui.play_flipbook() has a complete_function as a third parameter. I would set a flag to indicate that the animation is playing and clear the flag in the complete_function. While the flag is set no new animations should be started.

EDIT: @Ivan_Lytkin beat me to it!

yes, it loop. Trying to understand what you mean, i can’t figure out what i must to do or what code should I change/add.

After amount of time and effort, i change code like this :

function tes()
  playanim2 = false
  playanim1 = false
end

if gui.pick_node(n, action.x, action.y) then      
  if (playanim2) then
    gui.play_flipbook(n, "slide", tes())
  end
  playanim1 = true
else
  if (playanim1) then
    gui.play_flipbook(n, "idle", tes())
  end
  playanim2 = true  
end

Thank you guys, i am using callback like you said, it work fine. You are best.

1 Like