[SOLVED] Moving an interface

  • #1, z sebastianSunday, 04. September 2016, 00:59 hodinky 8 years ago
    Hey there,

    i know that i read that one line i need here in the forum but can't find it anymore (damn search function).
    I need to animate an interface. Kind of the sliding interfaces stuff but not so bloated and more dynamic.
    Is it possible to do something like a one liner as it is possible with moving animations with easing?

    like

    Interfaces["MyInterface"]:to(0, { InterfacePosition = {x = 72, y = 69} }, easingstufff) 
    


    Thanks in advance

    Sebastian

    PS: If not: feature request for 4.3 wink

    Kapitán

    2346 Posts


  • #2, z afrlmeSunday, 04. September 2016, 01:21 hodinky 8 years ago
    Yes it's possible & I shared the method multiple times throughout the forum already. I probably should add it as an alternative method in the sliding interface script on the wiki, no?
    local int = Interfaces["name"]
    
    if int.InterfaceOffset.x == 0 then
     int:to(1000, { InterfaceOffset = {x = -200, y = int.InterfaceOffset.y } }, easeQuintIn)
    elseif int.InterfaceOffset.x == -200 then
     int:to(1000, { InterfaceOffset = {x = 0, y = int.InterfaceOffset.y } }, easeQuintOut)
    end
    

    ... what we have here is a simple 2 query that checks if interface is at one position or another or neither (if it's neither then it's because it's currently moving). One position will make it slide back to the default position & the other will make it slide out to the target position.

    This method is a lot faster than the Deponia interface script I wrote a while back, but we didn't have the tweening functions or Lua shorthand back when I wrote that.

    P.S: this script is kind of basic as it prevents the player from cancelling the slide in/out order & they will have to wait until it's reached its destination before they can slide it back in or out, unlike the deponia interface script I wrote, because I used various math equations to calculate the needed pixels / speed it would need to make it slide in/out at the same speed regardless of the current position it was at.

    Imperátor

    7285 Posts

  • #3, z sebastianSunday, 04. September 2016, 01:25 hodinky 8 years ago
    yes, that was the thing i searched for
    Thanks =)

    Kapitán

    2346 Posts

  • #4, z sebastianThursday, 08. September 2016, 20:18 hodinky 8 years ago
    Works like a charm =)

    Kapitán

    2346 Posts