Timer with display
Player_E
Member, PRO Posts: 604
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?
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
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
What do you think.
"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.
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?