In fact, if your code is the one
here and you display the time remaining, the direction of the dot on your bar would be from right to left (since remaining time would be decreasing). In that code and if time remaining is the case (since balala covered the elapsed time case), if you:
- comment out the
Measure=Time line from
[MeasureNow], and, just to simulate this faster, add to it:
Code: Select all
Measure=Calc
Formula=((MeasureNow+3600)%86400)
- add this to your code, assuming you have a 32x32 pixels "1.png" image in your skin's @Resources folder (feel free to adjust this to your disk):
Code: Select all
[MeterBar]
Meter=Image
Y=10R
W=600
H=32
SolidColor=255,128,0,255
[MeterDot]
Meter=Image
ImageName=#@#1.png
X=((([MeasureSecondsRemaining]>[MeasureSecondsRemaining:MaxValue]?[MeasureSecondsRemaining:MaxValue]:[MeasureSecondsRemaining])-[MeasureSecondsRemaining:MinValue])/([MeasureSecondsRemaining:MaxValue]-[MeasureSecondsRemaining:MinValue])*[MeterBar:W]-16)
Y=0r
W=32
H=32
DynamicVariables=1
then you'll achieve what you want. Bar the DynamicVariables=1 line in the 2nd meter that's required when using changing variables in such a section, it's only a matter of arithmetics, and things become quite easy if you break the X formula into parts:
- the
([MeasureSecondsRemaining]-[MeasureSecondsRemaining:MinValue])/([MeasureSecondsRemaining:MaxValue]-[MeasureSecondsRemaining:MinValue]) part will get you a number between 0 and 1 representing the fraction of remaining time from the
total time
- to span the above to the desired width, we have to
*[MeterBar:W] aka multiply with the total
width of the bar meter
- to prevent displaying the dot outside the bar from 22:00 to 08:00, we add a
numerical conditional like
([MeasureSecondsRemaining]>[MeasureSecondsRemaining:MaxValue]?[MeasureSecondsRemaining:MaxValue]:[MeasureSecondsRemaining]) instead of simply
[MeasureSecondsRemaining] in the fraction formula above (balala solved this by
clamping a value, it achieves the same thing)
- to prevent displaying the dot outside the bar when at its maximum position, we do
-16 aka subtract half of the dot's width (32 in my implementation) from the overall result, in order to "center" it on the value it's illustrating