Move object and drawing sprite issue

  • #1, by Lord7evenThursday, 28. May 2015, 08:22 9 years ago
    Recently I had the problem, that moved objects are not drawn at the correct place after switching the scene.
    If you move an object with the action part (4.1.) or with a tween, by revisiting the scene, it's rendered at the basic position, not the position it was moved to. However, if you then move the object again, it first jumps in one frame to the correct position and moves from there to the new position. But it's still drawn at the very first basic position, if you leave the scene and visit it again.

    I guess the engine first draws the sprite and then looks where the position should be. Or something with the drawing order is wrong, when you load scenes from RAM, because if a startscript sets positions, it works the very first time you visit that scene.

    Is this a knowing issue? I tested it both with scenes and menues and with different actionparts to switch scenes.

    I have workaround it by first moving the object in 0 or 1ms to the basic position (in my case 0,0), then pause for 1ms (another moving issue that is reported.) and then move the object to or by whatever you want.

    Newbie

    40 Posts


  • #2, by afrlmeThursday, 28. May 2015, 12:13 9 years ago
    I think it's because it still remembers the last offset value & by default on scene load it probably uses the actual objects position instead.

    If the object is non-interactive & has no object polygon, then may I suggest creating the sprite as an animation & using Lua script to set the animation position instead as it will allow you to specify the exact coordinate to move / set the animation to instead of using an offset from the actual position.

    Using that method, you could set a condition or even better a value, which can be used in an if query inside of an at begin of scene action to determine which position the animation should be set to at the beginning of the scene...

    for instance a value of 0 could be the original position. 1 could be 300x500 or something etc. etc.
    ActiveAnimations["bird"].AnimationCurrentPosition = {x = 0, y  =0} -- instantly update animation position of "bird"
    

    ActiveAnimations["bird"]:to(3000, { AnimationCurrentPosition = {x = 300, y = 500}, easeQuintOut) -- move "bird" to 300 by 500 over 3000ms with smooth ending
    

    Imperator

    7278 Posts

  • #3, by Lord7evenMonday, 01. June 2015, 14:59 9 years ago
    Works perfect, thank you very much!
    by the way: you missed a "}" after the coordinates wink

    correct:
    ActiveAnimations["bird"]:to(3000, { AnimationCurrentPosition = {x = 300, y = 500} }, easeQuintOut) -- move "bird" to 300 by 500 over 3000ms with smooth ending
    

    Newbie

    40 Posts

  • #4, by afrlmeMonday, 01. June 2015, 15:13 9 years ago
    Aye, yeah sorry. grin

    Imperator

    7278 Posts