Adding health to an actor. Pick up items/health ammo etc.

SpacefaceSpaceface Member Posts: 15
edited November -1 in Working with GS (Mac)
Can anyone tell me how to create a health attribute for my actor?

I'd like to have a healthbar at the top that takes decreases each time an enemy attacks and increase when picking up health items eg. food.

Also how can I create items for my actor to pick up. for example. coins, food for health, poison.

Sorry for the loaded question.

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    there is a good section in the wiki on how to create a health bar:
    http://gamesalad.com/wiki/how_tos:gsc_health_bar?s[]=health

    as far as creating collectables that's easy. you just need to create an actor & attribute for each type, coin, food, poison. then in each actor create a rule:

    Coins
    when actor overlaps or collides with actor of type Player
    change attribute game.Coins to game.Coins+1
    destroy actor

    Food:
    when actor overlaps or collides with actor of type Player
    change attribute game.Health to game.Health+1
    destroy actor

    Poison:
    when actor overlaps or collides with actor of type Player
    change attribute game.Health to game.Health-1
    destroy actor

    Make sure you use the expression editor to select the attributes or it won't work.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
Sign In or Register to comment.