Rotating interface?

  • #1, by silvanneSunday, 16. August 2015, 18:59 9 years ago
    Hi, I've recently started with Visionaire and still find Lua a little tricky.
    The thing is, I need to put a clock on my adventure game (similar to the Don't Starve clock in the top right corner).
    I was trying a simple script I saw in one of the posts in this forums; and with a scene object it worked really great, making it rotate at the speed I needed. But since I need the clock to be in all scenes, I tried to do the same with an interface, but I can't seem to find a way to do it. I would really appreciate some help here!
    Thanks!

    PS: This is what I had with the object:

    
    local obj = Scenes["Test1"].Objects["Object1"]
    
    obj.RotationCenter = {x = -1, y = -1} -- define rotation center as center of sprite
    
    obj:to(60000, {Rotation = math.rad(-360)}, easeLinearInOut, true, false)
    
    

    Newbie

    5 Posts


  • #2, by sebastianSunday, 16. August 2015, 19:23 9 years ago
    because the objects on an interface are "buttons" you could try this:
    local obj = Interfaces["intrfacename"].Buttons["buttonname"]
    

    Thread Captain

    2346 Posts

  • #3, by SimonSSunday, 16. August 2015, 19:26 9 years ago
    Rotation are not yet working for interfaces as is scaling.

    Thread Captain

    1580 Posts

  • #4, by silvanneMonday, 17. August 2015, 00:53 9 years ago
    Thank you both for the quick response :-)

    @Sebastian.204 Yes, I already tried it before posting but sadly it didn't work

    @SimonS Oops that doesn't sound like good news...

    Any idea on how to make it work? On how to make a turning clock permanently on screen?

    Thank you all!

    Newbie

    5 Posts

  • #5, by silvanneTuesday, 01. September 2015, 18:24 9 years ago
    Anyone has any idea on how to rotate an interface?

    Newbie

    5 Posts

  • #6, by sebastianTuesday, 01. September 2015, 19:29 9 years ago
    you could try making an animation with the full rotating clock and defining with lua which frames are first/last to be shown

    Thread Captain

    2346 Posts

  • #7, by silvanneSunday, 06. September 2015, 21:45 9 years ago
    Wouldn't that take a lot of space? I want to put several minutes in the clock...

    Newbie

    5 Posts

  • #8, by sebastianSunday, 06. September 2015, 23:13 9 years ago
    I dont know the clock in don't starve put you need to make a frame for each state.

    When your clock would look like a normal clock i would suggest to split it up to 3 animations. Each needs 60 frames for each pointer.
    pointer 1 for seconds
    pointer 2 for minutes
    pointer 3 ....

    Thread Captain

    2346 Posts

  • #9, by afrlmeMonday, 07. September 2015, 01:26 9 years ago
    If the image frames are small & you convert the png files to webp then I don't see any issue with using animations & controlling the displayed frame using Lua script or by using a value & adding if queries directly into the frames themselves.

    The only alternative would be to duplicate the clock objects / animations for each scene & give them the same name throughout each scene & then use Lua to affect the objects of said names in current scene only...

    game.CurrentScene.SceneObjects["c_seconds"]:to(60000, {Rotation = math.rad(-360)})
    .. etc...
    


    The only problem I see with using rotation is it's a little hard to gage the amount of time you need it to rotate around. The minute & hour hand for example you would need to minus a certain degree value every 60 seconds.

    seconds: -6 (every 1000 ms)
    minutes: -6 (every 60000ms)
    hours: -0.1 (every 60000ms)

    On top of that you would still need to use values & if queries to determine if timer has run out.

    Imperator

    7278 Posts