Having a bar increase over time?

I have a meter which decreases by 1 every time you press on the screen for a total of 5 presses and after every 1.5 seconds +1 is added to the maximum of 5 but it does this in blocks is there anyway to make it so it shows the bar slowly increasing/growing instead of it just appearing and disappearing etc?

Regards!

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited July 2013
    You need to make it so the bar knows that it is not the correct width and 'interpolate' down until it matches the needed with... So rather than use change attribute and size, use interpolate size. Interpolate is your friend when you want smooth movements, you can also have linear or easy ease movements to create a softer animation finish.

    Ok.. here goes...

    I'm assuming the bar is a health bar... and its 100px wide for ease and you want it broken down to 5 options.. I'll also assume you can do you own rules for reducing the number when the screen is touched.

    The rules I've done are not the clearest to understand but require the least number of rules and so should be the most efficient.

    I'll also assume you can do you own rules for reducing the 'game.health' number when the screen is touched.

    Create 2 game attributes:
    • Create a game attribute called game.health that starts at 5
    • Create a game attribute called 'game.health_max_value' (doing this makes it easier if you decide to change values later.) Set this to you maximum value... which is '5'

    Create rules inside your health bar
    If 'self.width' does not equal '(self.width/game.health_max_value)*game.health'

    Interpolate self width to (self.width/game.health_max_value)*game.health


    Offset:
    You may decide you want the health bar to align to the left or the right, at which point you need to add an offset but adjusting the health bars current position to its initial position +/- the width of the bar... you'll probably need to use 'constrain attribute' for this.

    Hope it helps... I've just written he above off the top of my head but I think it should work fine.
  • CoolBeeCoolBee Member Posts: 81
    @StormyStudio Great stuff thanks for that I'll let you know how I get on when I get home!
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    cool.. good luck.. I've just edited my post as I'd missed out a couple of brackets.
  • McSparklesMcSparkles Member, PRO Posts: 16
    @StormyStudio I was having similar difficulty & that also helped me out, thanks.
  • CoolBeeCoolBee Member Posts: 81
    @StormyStudio Hey man I only just got around to trying this however I'm having problems! The bar goes from the full length down to about 10% of the height after 2 clicks then after 2 more clicks or so it goes down to 10% of the 10% in height so ends up about 1mm then never goes up :( I've attached a picture of the rules if you can help?

    Screen Shot 2013 07 31 at 09 06 50
    windows screen capture


  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Hey there - heres some videos that might help.

    This is one that I used to make my own bars.

    Another one that's different, the reverse.

    @tshirtbooth is the man. Helping us out. Lots of good videos from him. And the new guys at GS Helper. Braydon and Uptimistik etc. All good dudes. Respect.

  • CoolBeeCoolBee Member Posts: 81
    Hi @Matarua I already have the bar working as the second video, what I need is instead of it taking a big chunk of pixels at a time but to smoothly go up as the bar regens
  • CoolBeeCoolBee Member Posts: 81
    @StormyStudio When I did try this I had a similar effect but moving in the opposite direction than what I needed (So moved down slowly instead of upwards)
Sign In or Register to comment.