Animations help

edited March 2011 in Help request
I was trying to create my own animations according to animations tutorial on wiki.

My idea is, that I have random spawner and want appear animation of object, then switch to "static" animation and then after deleting object by spawner create object with disappearing animation at same place.

I have created config files for appear and disappear animation, registered animation handler and added animation set in create and delete handler of spawner.

Problem is, that in tutorial is used one clock for object to handle its animations and I'm unable to use it like this in my game so animation doesn't start and log is becoming crazy.

There are few lines from log
[2011-03-11 11:09:23] <ANIM> (orxAnimSet_ComputeAnim() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimSet.c:2289) Couldn't compute next animation.
[2011-03-11 11:09:23] <ANIM> (orxAnimPointer_GetCurrentAnimHandle() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:696) Anim pointer does not have a current anim.
[2011-03-11 11:09:23] <ANIM> (orxAnimPointer_Compute() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:333) Cannot process animation pointer without a current animation.
[2011-03-11 11:09:23] <OBJECT> (orxObject_UpdateAll() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/object/orxObject.c:296) Failed to update structure #0 for object <Krtek>.
[2011-03-11 11:09:23] <ANIM> (orxAnimPointer_GetCurrentAnimHandle() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:696) Anim pointer does not have a current anim.
[2011-03-11 11:09:23] <ANIM> (orxAnimPointer_Compute() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:333) Cannot process animation pointer without a current animation.
[2011-03-11 11:09:23] <OBJECT> (orxObject_UpdateAll() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/object/orxObject.c:296) Failed to update structure #0 for object <Krtek>.

Funny is, that log is generating soo many lines in one second and object with animation is created once in about 2 seconds.

Will be thankful for any ideas how to solve this :unsure:

Comments

  • edited March 2011
    Kenn wrote:
    I was trying to create my own animations according to animations tutorial on wiki.

    My idea is, that I have random spawner and want appear animation of object, then switch to "static" animation and then after deleting object by spawner create object with disappearing animation at same place.

    For the first transition (apear->idle loop), it will happen automatically if setup correctly in config. As for the second animation, why creating a new object with an animation instead of using the current one?
    I have created config files for appear and disappear animation, registered animation handler and added animation set in create and delete handler of spawner.

    You don't have to set the first animation, orx will take the first one defined in the animation list when an object is created.
    Problem is, that in tutorial is used one clock for object to handle its animations and I'm unable to use it like this in my game so animation doesn't start and log is becoming crazy.

    You shouldn't need any clock for handling animation. In the tutorial we simply register an update function on the core clock that will handle the input and change the animation accordingly.
    There are few lines from log
    [2011-03-11 11:09:23] <ANIM> (orxAnimSet_ComputeAnim() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimSet.c:2289) Couldn't compute next animation.
    [2011-03-11 11:09:23] <ANIM> (orxAnimPointer_GetCurrentAnimHandle() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:696) Anim pointer does not have a current anim.
    [2011-03-11 11:09:23] <ANIM> (orxAnimPointer_Compute() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/anim/orxAnimPointer.c:333) Cannot process animation pointer without a current animation.
    [2011-03-11 11:09:23] <OBJECT> (orxObject_UpdateAll() - Users/adamtomecek/Programování/The Game/orx_svn/code/build/mac/xcode/../../../src/object/orxObject.c:296) Failed to update structure #0 for object <Krtek>.
    

    Funny is, that log is generating soo many lines in one second and object with animation is created once in about 2 seconds.

    Will be thankful for any ideas how to solve this :unsure:

    The log tells you that there isn't a current animation. That means that either you requested an animation he cannot play/reach or that the animation graph isn't set correctly in data.

    You need something like this:

    In data:
    [AnimSet]
    AnimationList = Appear # Loop # Disappear
    LinkList = Appear2Loop # Loop2Loop # Loop2Disappear
    
    [Appear2Loop]
    Source = Appear
    Destination = Loop
    
    [Loop2Loop]
    Source = Loop
    Destination = Loop
    
    [Loop2Disappear]
    Source = Loop
    Destination = Disappear
    Property = immediate
    
    [...] (All the three animations and their content)
    

    In code:
    // Nothing for creation: Appear will be played first and when it's done, Loop will play continuously
    
    // When you want to remove your object
    orxObject_SetTargetAnim(MyObject, "Disappear");
    orxObject_SetLifeTime(MyObject, LengthOfDisappearAnimation);
    

    And that should be all. You can also add some orxFX to have a fadein-fadeout in the same manner (it's automatic on creation if you set it correctly in data and on deletion you simply call orxObject_AddFX(MyObject, "DisappearFX");

    Let me know if you still have a problem.

    EDIT: It might not have been clear, but when using orxObject_SetLifeTime() you don't need to call orxObject_Delete(). If the object is already getting deleted, that won't work. In this case I would simply set a timer for every object when it's created (orxClock_AddGlobalTimer()) and in the function called by the timer, you can then play the anim and call SetLifeTime(). If the object needs to be removed before the end of the timer, you can remove the timer (orxClock_RemoveGlobalTimer()).
  • edited March 2011
    Again, thank you for your help. I'll play with this as soon as I have some free time :)

    And for that question why creating object again. I'm "listening" to mouse click and if user clicks on object created by spawner, I delete object and add score. So if object will be in state "disappearing" I don't want it to be count as regular object and I don't know any other way how to do it :)
  • edited March 2011
    Everything works great, I had only little mistakes in config files, that was the reason why animations don't work.

    I just wonder how to delete global timer? If I don't do it and delete object before timer does, game just crashes after while, which I expect.

    But if I want to delete global timer, I simply don't know how. I don't get why remove function got delay and callback so I don't know how to use it. I tried something like this
    //in function which is called after mouse click on propriet object
    orxClock_RemoveGlobalTimer(Game::DeleteTimer, 0, object);
    orxObject_Delete(object);
    ...
    void orxFASTCALL Game::DeleteTimer(const orxCLOCK_INFO *clockInfo, void *context){
    	//add anything?
    }
    

    But game just crashes in function which is deleting objects automatically (while getting objects name - object is tested not to be orxNULL) after while if object is clicked and deleted.
  • edited March 2011
    Kenn wrote:
    Again, thank you for your help. I'll play with this as soon as I have some free time :)

    And for that question why creating object again. I'm "listening" to mouse click and if user clicks on object created by spawner, I delete object and add score. So if object will be in state "disappearing" I don't want it to be count as regular object and I don't know any other way how to do it :)

    Ah, I see! The easiest way would then be to create your own struct/class for those objects in which you can maintain a bool that say if the object can be clicked or not. You can then link this struct to an orxOBJECT with orxObject_SetUserData().

    Another, more dirty way to do it would be to pull the non clickable object further in the foreground by decreasing its Z coordinate value when clicked and make sure you call the picking function with a Z greater than this value (this way those foreground objects would become automatically non-pickable).
  • edited March 2011
    Kenn wrote:
    Everything works great, I had only little mistakes in config files, that was the reason why animations don't work.

    I just wonder how to delete global timer? If I don't do it and delete object before timer does, game just crashes after while, which I expect.

    But if I want to delete global timer, I simply don't know how. I don't get why remove function got delay and callback so I don't know how to use it. I tried something like this
    //in function which is called after mouse click on propriet object
    orxClock_RemoveGlobalTimer(Game::DeleteTimer, 0, object);
    orxObject_Delete(object);
    ...
    void orxFASTCALL Game::DeleteTimer(const orxCLOCK_INFO *clockInfo, void *context){
    	//add anything?
    }
    

    But game just crashes in function which is deleting objects automatically (while getting objects name - object is tested not to be orxNULL) after while if object is clicked and deleted.

    The parameters sent to the remove timer function are simply to find which one you want to remove. If you set the context, only the timer that has the same context will be removed, otherwise all the timers that use the same callback you gave will be removed.
    Same for the delay, it's only to find the right occurence. If I remember correctly, passing -1 would then ignore the delay parameter and remove all the timers that match the callback/ context. Let me know if this still sound obscure to you. :)
  • edited March 2011
    Perfect! Thank you :)
  • edited March 2011
    Hmm, just one more thing.

    I'm trying to compile it on WIndows too, so my friend who does graphics for me could see it, but I got crash right after running it in orxAnimSet_CreateFromConfig.

    Can this be some problem of latest SVN version? Because it just crashes probably without using any of my code :)
  • edited March 2011
    I just tested the latest svn version on windows (with visual studio 2008) with Mushroom Stew that uses a lot of animations and everything runs just fine.

    Are you running in release or debug? mingw or visual studio? My guess is there's something unexpected by orx in the config files. :)

    If you can't find it, just send me a zip of your current work and I'll give it a look tonight. :)
  • edited March 2011
    Was playing with it for more than hour. If I leave animations in config, game just crashes immediately, if I comment out animation set, it just creates Command window without ORX window. I'll send you complete project with compiled ORX so maybe you can figure out what am I doing wrong, because this is really weird.
  • edited March 2011
    I'll check that tonight.
  • edited March 2011
    Well, problem was in compiling wrong version of ORX (Embeded versions) and in Visual Studio 2008 Pro bug (linker was unable to generate final product). So I installed SP1 and everything is now OK.
Sign In or Register to comment.