Custom Animation Events

edited December 2012 in Help request
Hello guys.

I've been using the custom animation events with no problems.

But now it looks like the moment which those events are triggered has changed.

They used to be triggered at the end of each animation frame and now they are triggered at the begining of each animation frame.

iarwain, have you changed something related to the animation events?

Comments

  • edited December 2012
    Hi Peso!

    Yes, that was changed almost 3 months ago and it was a bug: https://forum.orx-project.org/discussion/4732&limit=20&start=40#5267

    That was only happening with events declared in config (if you were using the code API, the events would have been registered at the beginning of the frame).

    Sorry for the inconvenience!
  • edited December 2012
    Noooo! This is really bad to me. I'll have to change most of my animations.

    Is it possible to add some kind of indicator that tells the animation system whether an event should be registered either at the begining or at the end of a frame?

    I think that would be good not only to me.

    Thanks.
  • edited December 2012
    Mmh, I'm afraid not, it really was a bug. :(

    However you should be able to write a pretty simple piece of code that would change all the events for you and save them back to config.

    Another simple option would be to cycle through all the anim after they're loaded, go through all the events with orxAnim_GetNextEvent(), and re-add them with the new timestamps with orxAnim_AddEvent().

    Or a regexp executed on your config files should do the trick.

    Lastly, you can always simply backout the change that contains the fix from orx's source in your local hg repository clone for your current project. It's this one: https://bitbucket.org/orx/orx/commits/d4603f59b0d277aca872e96eac105abbbf714305
  • edited December 2012
    Actually, if you send me all your config files, I should be able to do it within a couple of minutes.
  • edited December 2012
    I can not just change the config files. I will need to change the code called after the event is triggered.

    So, I will do the get/add event method. Can you help me with this one?

    I think I have to get the event and add the frame duration to its timestamp, right?

    When I re-add the event, will it overwrite the current event?
  • edited December 2012
    I'm confused: why do you need to change the code? If the new events are at the exact same time as with the old code, why wouldn't it work?

    For the get/add, you need to go through all events, store them locally with the new timestamps, remove them all and then finally re-add them all.
  • edited December 2012
    Now I am confused. :)

    The way orx were before the fix, the events were triggered at the end of the animation frames. So, in the event handler, I put some game specific code for each event triggered.

    Now that orx triggers the events at the beginning of the animation frames, my game specific code is called before it should be. So, I have to change it in order to work properly.

    Having said that, I don't know which events you are talking about when you say "the new events are at the exact same time as with the old code".
  • edited December 2012
    I mean that if all your events are moved to the next frame in config (ie KeyEventName4 -> KeyEventName5, etc), your code shouldn't need to be changed.

    The new event added with KeyEventName5 will have the exact same time stamp as an event named KeyEventName4 with the old version of orx, isn't it? :)
  • edited December 2012
    Ok, but how about the events added to the first or last frames? Can I use the start and stop events?
  • edited December 2012
    Yes you can. For the first frame, it's not a problem as you're moving keys further in time only.

    For events that were on the last frames, you can either use the stop/loop event, or better add a new key at the end of the anim with a duration of 0, that should do the trick!
  • edited December 2012
    Ok, I'll try that.

    Thank you.
Sign In or Register to comment.