Custom events [Solved]

edited November 2010 in Help request
Having a little problem with custom events. I inserted one into the animation list, but a second one causes the project to break.

For example:
[BlockAnim]
DefaultKeyDuration  = 0.15; 
KeyData1            = tile1
EventName1	    = AR1
EventTime1	    = 0.1
EventValue1	    = 1.0
KeyData2            = tile2
KeyData3            = tile3
KeyData4            = tile4

This works perfectly and I'm hooked on the concept. Every first frame, a custom event is generated with
...
  switch(_pstEvent->eID)
  {

	case orxANIM_EVENT_CUSTOM_EVENT:
...

If I insert a second one in my config like this:
[BlockAnim]
DefaultKeyDuration  = 0.15; 
KeyData1            = tile1
EventName1	    = AR1
EventTime1	    = 0.1
EventValue1	    = 1.0
KeyData2            = tile2
EventName2	    = AR2
EventTime2	    = 0.1
EventValue2	    = 1.0
KeyData3            = tile3
KeyData4            = tile4

..the project breaks.

The final output from the debug log was:
[2010-11-05 15:13:02] <ASSERT> (orxAnim_AddEvent() - c: mporxcodesrcanimorxanim.c:869) [Assertion failed] : <(orxAnim_GetEventCounter(_pstAnim) == 0) || (_fTimeStamp > _pstAnim->astEventList[orxAnim_GetEventCounter(_pstAnim) - 1].fTimeStamp)>

Comments

  • edited November 2010
    sausage wrote:
    If I insert a second one in my config like this:
    [BlockAnim]
    DefaultKeyDuration  = 0.15; 
    KeyData1            = tile1
    EventName1	    = AR1
    EventTime1	    = 0.1
    EventValue1	    = 1.0
    KeyData2            = tile2
    EventName2	    = AR2
    EventTime2	    = 0.1
    EventValue2	    = 1.0
    KeyData3            = tile3
    KeyData4            = tile4
    

    ..the project breaks.

    The final output from the debug log was:
    [2010-11-05 15:13:02] <ASSERT> (orxAnim_AddEvent() - c: mporxcodesrcanimorxanim.c:869) [Assertion failed] : <(orxAnim_GetEventCounter(_pstAnim) == 0) || (_fTimeStamp > _pstAnim->astEventList[orxAnim_GetEventCounter(_pstAnim) - 1].fTimeStamp)>

    Thanks for the output, it helped me find the issue right away.

    So basically the answer is that there can only be one custom event on a given timestamp. Internally timestamps are used as keys so they can't be duplicated on the same channel (here the event channel). If you still want to have both events fired at the same time, you can go wild with the decimals:

    EventTime1 = 0.09999
    EventTime2 = 0.1
    EventTime3 = 0.10001

    These 3 events will be fire at the same time but don't share the same key. Sorry about the inconvenience, I'll have to figure out to handle things differently internally to allow more than one event per timestamp.
  • edited November 2010
    Ahhhhhhh!!! That's totally it. Thank you!
  • edited November 2010
    A tutorial based on this discussion can be located in the wiki here: http://orx-project.org/wiki/en/orx/tutorials/community/sausage/realistic_walk_movement
  • edited November 2010
    Excellent tutorial, thanks for it!

    I should probably reorganize the tutorial home page so that the community tutorials should be the first thing people see there.
  • edited November 2010
    I may be bias, but for some reason I think this is a great idea ;)
  • edited November 2010
    I'll do it right now, but I was afraid you'd feel forced to, you know, write other tutorials! :P
  • edited November 2010
    Yeah, you might be right... such a cruel slave-driver you are haha
  • edited November 2010
    Haha. Yep. You'll notice I moved the english tutorials under the main page in the wiki. The other tutorials in other languages should probably be moved to suit.
  • edited November 2010
    Grey wrote:
    Yeah, you might be right... such a cruel slave-driver you are haha

    Ahah, apparently not that efficient as a slave driver, though! :P
  • edited November 2010
    sausage wrote:
    Haha. Yep. You'll notice I moved the english tutorials under the main page in the wiki. The other tutorials in other languages should probably be moved to suit.

    Yep, very good idea. Not sure I'll venture myself to do the same for Chinese as I can't read it, unfortunately. Same for Spanish actually and the French pages are still non-existent. I blame me.
Sign In or Register to comment.