HELP! Game Timer Bar - aligned to left, jumps as it decreases, using interpolate
StormyStudio
United KingdomMember Posts: 3,989
Good evening,
Ok trying to add some polish to my game (after someone advised it on GSforum).
I have my bar which decreases over 50 seconds, and also over 50 seconds the position is moved to the left so it looks like it is shrinking from right to left. It works ok.
Annoyingly you can see the bar jump with each scale down 1 pixel then back to position, as its width changes and then its position.
I'm using interpolate which I thought would be smooth for both, but the two together cause this problem: I've seen other posts on the subject but thought I'd try this as I could not find a definate rule on how to make a good smooth timer bar.
my code:
I have in actor attributes:
original width = 390
initial x position = 0
and '190' in the code below is half the width of my time bar.
Then my rules:
........................................
Change Attribute:
initial x position = self.Position.X
Rule:
If game not failed
if game not completed
if time still active
Interpolate position:
interpolate self.Position.X to self.initial X position - 190
duration = 50 function Linear.
Interpolate width scale:
interpolate self.size.width to 0
duration = 50 function Linear.
.........................
any ideas how I can make the movement perfectly smooth?
Ok trying to add some polish to my game (after someone advised it on GSforum).
I have my bar which decreases over 50 seconds, and also over 50 seconds the position is moved to the left so it looks like it is shrinking from right to left. It works ok.
Annoyingly you can see the bar jump with each scale down 1 pixel then back to position, as its width changes and then its position.
I'm using interpolate which I thought would be smooth for both, but the two together cause this problem: I've seen other posts on the subject but thought I'd try this as I could not find a definate rule on how to make a good smooth timer bar.
my code:
I have in actor attributes:
original width = 390
initial x position = 0
and '190' in the code below is half the width of my time bar.
Then my rules:
........................................
Change Attribute:
initial x position = self.Position.X
Rule:
If game not failed
if game not completed
if time still active
Interpolate position:
interpolate self.Position.X to self.initial X position - 190
duration = 50 function Linear.
Interpolate width scale:
interpolate self.size.width to 0
duration = 50 function Linear.
.........................
any ideas how I can make the movement perfectly smooth?
Comments
if not I guess I will be covering up the left hand side with a graphic, so you can't see the jumping....may a count down clock...
Cheers
it did'nt work for me, it stopped the jumping (thankyou) but moved the whole bar 50% of the width to the right of where it needed to be.
But still it was obviosuly nearly there..
it now works with a tiny bit of adaptation
Using Constrain:
self.position.X = self.initial X position -( self.original width - self.Size.Width )/2
Many thanks
Cheers
Jon,
Now I just need to add this timer bar to each of my 20 levels. I did spend ages making level 1 before creating all the other levels, but not too much of a surprise to find myself still adding something to each level. Should not take too long though....also going to reduce the amount of play time on the levels to add to the difficulty.
Instead of "duration = 50" I'm using "duration = game.timer" and the time integer used makes the bar decrease BUT it doesn't seem to match in time. The bar is decreased completely before I reach the halfway mark on the timer (the decrease seems to speed up the longer it runs)
So how do you match the time integer with the bar decrease?