Playing with events functions : troubles


I started to test a lot the new alpha “events functions”, and i’m quite enthousiast with it. I already use a lot of tiny functions to avoid copy/paste of lot of events. This features is really awesome !

I started this topic because i’m facing an issuie didn’t succeed to solve. I’ve written a function to make a progressive color change on sprite, using global color effect. To compare to well known animation, it’s a bit like JQuery animate background-color effect.

Everything (or almost) works well, you can set the desired colors as functions parameters, and the speed of the animation. If i trigger the action at scene beginning for each object i want to animate, it works without troubles.
Things become “touchy” if i manually trigger the action on multiple objects in a short laps of time : for example on “mouse release”, if i click one by one all the sprites objects, the animation will work fine on the first object, but all other animation triggered on other objects while the animation of the first one is playing will turn the sprite on black, wich is not the desired color…

i can’t figure out what make this… It’s supposed to work, it’s pretty simple… It’s like if some events or subevents of the action event function don’t execute while they should.

I attach an example, composed of two scenes :

  1. on the first scene, to reproduce the problem, just click fast on all Gdevelop logo, you’ll see 2nd logo clicked and next turning black. On contrary, it you take your time, and wait for an animation to finish, then click another one, it will will work.
  2. On the second scene, i just trigger random color/speed on all objects on “For Each” at the scene beginning, and surprise, it works fine…

A little “debugger” is included : on mouse over on the logo, you’ll be able to check the value of the objects variables used by the function. (43.2 KB)

Help appreciated, i plan to release a little “library” of event function for animation purpose in the future.

The problem is the “Trigger once” condition, seems that it doesn’t work for function calls, it doesn’t run once per function call but once each time there are no objects with “applyEffect” = 1, the objects count is = 0 or “KCF_Progressive_RGB_color_change” is 1. The trigger once resets when any of the other conditions is false, and it seems that if you click two objects too fast the trigger once doesn’t reset (there’s always objects with “applyFilter” = 1 and “KCF_Progressive_RGB_color_change” < 1, because the previous object has not ended its animation). If the trigger once doesn’t reset then you don’t initialize the object current color variables, then the object color is 0;0;0, finalizing the animation instantly :neutral_face:

How to make it to work?, with another variable, something like “KCF_first_time”, if this variable is 1 initialize the variables and set “KCF_first_time” = 0. You’ll have to work with it a bit more if you want to be able to set a new color :slight_smile:

Brillant !

So this work :

But maybe i misunderstood something about the event functions… Isn’t it weird that “trigger once” doesn’t work ? I mean without event functions, in a conventionnal events sequence, i would never have to use a variable like this instead of “Trigger once”.

Should i post an issue on Github for this ?