Health Bar Limit

0 favourites
  • 4 posts
From the Asset Store
Health Bars & More
$3.60 USD
40% off
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • Hi,

    I attended a game jam in Luton last week organised by Train2Game & used Construct 2 (Free Version) to develop a prototype platform game. Haven't used construct 2 for quite a while & am at more or less beginner level with using it. However i managed to get the game working with most of the basic features, moving, interacting with objects, environments, enemies, reaching the end point of the level etc , but have spent the last few days since the game jam practicing, adding some of the items & features that i didn't get time to add due to time constraints with it being a 48 hour event...

    Most of the game is now working relatively good (I hope so) & am able to understand how to fix some niggley problems that occur but i have just 1 minor problem that i can't figure out how to solve & that's with the players health bar. It works fine as it should, have the health set at 100 & each hit reduces the bar by 25%, have also added health items that increase the bar by 25% which works fine, the only exception is when the health bar is already at 100% & a health item is picked up the bar keeps increasing,

    I'm sure that its probably a simple fix but i can't figure it out at the moment. Is there a way to stop the bar from increasing once it is at 100%?

    Again i'm just getting back into using the program, haven't used it in months so trying to understand the features etc,

    Any help would be greatly appreciated,

    Thanks

  • You just need to add condition that will either limit or reset the bar, or both.

    To limit it would go like this: If bar health < 100%, then add life

    to reset the bar, Make MaxHealth and Health instance variables and in event you would do something like this: if health > then varMaxHealth, set bar 100%, set varHealth to varMaxHealth

  • AFKATM so I have to be quick - this sounds like a job for the clamp expression!

    i.e

    clamp(playerHealth, 0, 100)

    https://www.scirra.com/manual/126/system-expressions

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks guys will check that out,

    Cheers for the info...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)