Animationen

  • #10, by afrlmeWednesday, 04. March 2015, 23:31 9 years ago
    I believe a text / number input field will be added eventually. The upcoming release has a new input field for offsetting animation frames which is useful.

    Image & animation positions are always based on the top left pixel of the active sprite. & yes it would be nice if it could add new images animations into the current viewport instead of at 0,0 on the background, but having said that, it's done for a reason as you can use Lua script & action parts to reposition animations around the screen easily enough.

    Imperator

    7278 Posts


  • #11, by LebosteinSunday, 10. May 2015, 11:52 9 years ago
    I have some general questions about animations too:

    If I start an animation, the animation is listed in ActiveAnimations[]
    1. In which cases the animation was removed from the active animation list? Only if the animation has finished?
    2. If I start an animation at the beginning of the game and I mark this animation with Infinity, then this animation will always be in the list, no matter in which scene I am?
    3. How I can check with LUA, wether the animation "xyz" is an active animation (in the ActiveAnimations list)?
    4. If I need some infinity background animations in one scene only, it is advisable to stop these animations if I leave the room (in reasons of better performace or memory) or is this negligible?
    5. An animation as a standard animation of an object is stopped/removed from the list after leaving the scene automatically?
    6. Can I stop an animation at a specific frame?

    Key Killer

    621 Posts

  • #12, by afrlmeSunday, 10. May 2015, 13:25 9 years ago
    1. Active animation = playing or preloaded animation. If an animation was not preloaded & has finished playing (on screen) then it will be added to temp cache. If it was preloaded then it will remain in active animation table until you manually unload the animation.

    2. I think it is only active if playing on the screen. If you change to a new scene then it will end up in the temp cache. The cache as far as I understood dumps older animations for newer ones when it reaches its limit. The limit can be adjusted via game properties tab or via Lua script. The only exception to this is current character walk, talk, & idle animations I think, they are preloaded to keep it smooth between scenes. Interface animations will only be active if interface is active & visible.

    3. I suppose you could do something like...
    if ActiveAnimations["name"] then print(true) end -- not 100% sure on this, as it might return an error for accessing incorrect table.
    


    4. see 2.

    5. see 2.

    6. Yes you can use Lua script with AnimationFirstFrame & AnimationLastFrame to force which frames should be playing. You can also use Lua to return current frame index values or for controlling the direction, loop amount, frame pause values & so on. Actually I tend to control animations this way because it means I don't have to use as many animation frames or duplication frames to achieve whatever it is I'm wanting to do.

    Imperator

    7278 Posts

  • #13, by LebosteinSunday, 10. May 2015, 14:21 9 years ago
    if ActiveAnimations["name"] then ....
    

    don't work, because
    print(ActiveAnimations["name"])
    

    returns "---empty---" and that is also true. How I can catch such empty objects?

    Key Killer

    621 Posts

  • #14, by afrlmeSunday, 10. May 2015, 14:25 9 years ago
    That was the point. If it's empty then you know it's not active. You could if you want to see if it exists to do something...
    if not ActiveAnimations["name"] then -- if it's empty / nil.
    


    Ideally it would be nice if their was a field in the animations table that returned a boolean value of true or false depending on whether the animation was active or not. Unfortunately the active table & preloaded tables only exist in the active animations table. Finally the active animations table can't be iterated with Lua (I spent ages trying different methods the other day without success), which means that you can't simply return a list of active animations; however, if you are running your game through the editor you can open developer console (TAB) & simply type: print animations or print preloadedanimations to display a list of all animations or preloaded animations with information. Use page up & down keys to navigate through the pages.

    Imperator

    7278 Posts

  • #15, by LebosteinSunday, 10. May 2015, 14:33 9 years ago
    No, that don't work with a simple boolean check wink
    ActiveAnimations["..."] returns true in every case! In the following example active animation "name" don't exist and "waterwheel" exist. But the "print" command is executed in both cases:
    local x = ActiveAnimations["name"]
    if x then print(x) end
    local x = ActiveAnimations["waterwheel"]
    if x then print(x) end
    

    result:
    14:32:32: ---Empty---
    14:32:32: waterwheel (26,33)
    

    I need a type check of the variable x, but I am not fit with LUA...

    Key Killer

    621 Posts

  • #16, by afrlmeSunday, 10. May 2015, 15:16 9 years ago
    Wait, are you wanting to know if it exists or does not exist?
    if not ActiveAnimations["name"]:isEmpty() then
     -- if not empty (nil) then do something
    else
     -- if empty (nil), then do something else
    end
    

    isEmpty() checks if it returns a table / object or nil or something like that, I forget the specifics off the top of my head. What you were returning in the prints were the table name & the id's.

    Imperator

    7278 Posts

  • #17, by LebosteinSunday, 10. May 2015, 15:53 9 years ago
    Ah! Thats it! Thanks smile

    Key Killer

    621 Posts