Timer with display

Player_EPlayer_E Member, PRO Posts: 604
edited November -1 in Working with GS (Mac)
I have a bar at the bottom of my screen that I want to relate to a timer. the bar goes the entire 480 pixels across.

I want a time limit of 6 seconds and I want that bar the represent how much time is left.

Right now I have it so every 1 sec change timer to timer-1 and a rule the constrains the images width relative to the timer, but this is too "choppy" the timer loses a chunk every second. i want it to be a more fluid drain that looks clean.

i tried every .01 second change timer to timer-1, but of course that does not last 6 seconds. so i then tried every .01 sec change timer to timer-.01, but now it does not drain.

My global attribute timer is an integer so it should be picking up the decimal numbers idk why its not.

Also another issue i'm having is that it drains from both ends to meet in the middle.
I want it to drain from the right and go left.

Any thoughts?

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Try interpolate - you can get some smooth movement from that using ease in and out.

    Edit:
    To be a bit more clear, essentially, you could have a solid bar representing time that goes across the bottom as you mentioned.

    Move it to the left every second by using interpolate. You'd use:

    Interpolate attribute: bar x position
    to: -240
    Duration: 6 seconds (or however long you want).

    That *might* help...

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Player_EPlayer_E Member, PRO Posts: 604
    Thanks QS i'll give it a try when I get off of work.
  • Player_EPlayer_E Member, PRO Posts: 604
    Hey QS thanks for the tip it works like a charm, but I still cant get it to empty from right to left it still empties from both ends to meet in the middle.

    What do you think.
  • rebumprebump Member Posts: 1,058
    You need to update the X position of the bar as it shortens to keep it left. Each time it gets shorter, you need to move it left a bit. Something like:

    "Change Attribute" or more likely "Constrain Attribute"

    `self.Position.X = self.Width/2`

    Then layer that bar actor over a full-sized frame actor if you want a frame around it to represent the full size of the bar for a reference point for the player. Be sure to set the frame to "not movable" to save some CPU processing.

    ---

    If you don't want super-fine granularity, you can get some interesting results with "Replicate" for larger chunked bar segments.
  • Player_EPlayer_E Member, PRO Posts: 604
    Thanks rebump got it working
  • SingleSparqSingleSparq Member Posts: 1,339
    Okay - I've got this working somewhat - the bar stays to the left and shrinks from the right based on time - but it doesn't match the time. It seems to get quicker as time goes on.

    here's the formula:

    The timer is set for say 6:00 minutes (but can be different depending on what was chosen) and is set as an integer attribute (game.timer)

    So the bar has:
    Change atribute self.initialXposition to: self.Position.X
    If game start
    Interpolate
    self.Position.X to self.initialXposition-190
    Duration: gameTimer - linear

    Interpolate
    self.Size.Width to 0
    Duration: gameTimer - linear

    - What have I done wrong that the bar always ends up finishing before the time ends?
Sign In or Register to comment.