fatmatt's Forum Posts

  • 1 posts
  • Looks like lennaert's answer covers only the health variable itself. Here is how you would do a proper health bar:

    1. Just like lennaert suggested, add an instance variable "health" and give it some default value, e.g. 10

    2. Create a tiled background 1x1 which is just a red dot.

    3. (Do this step if there are multiple animals planned) Click on your animal object and in the left menu select "Container" Create. Select the red dot. Containers tie objects to each other, so when a new animal is created, it will have a red dot created as well and assigned to that particular instance.

    Let's say the sprite of animal is called "Animal" and the red-dot tiled background is "animalHealth".

    4. In the event sheet add a new event "For every" - select Animal; with two action, action 1: animalHealth - set position - X: Animal.X Y:Animal.Y; action 2: animalHealth - Set width - Animal.health variable*5. This way the health bar will always follow its animal and display its health.

    5. Add another event "Every X seconds"; action 1: Subtract from - Animal.health variable - 2.

    Afterwards it depends on how would you like to feed your animals. Perhaps, simply clicking on it would do the job.

    Event: Mouse - On object clicked - Animal; action: Animal - Add to - health variable - 5.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1 posts