how to make a health bar individual for each enemy?

3gfisch3gfisch Member Posts: 12
edited November -1 in Working with GS (Mac)
Hi
I would like to make a game like towerdefense, the enemys spawn each second from right and move to left and they have a selfe.health that becomes less if i shoot and if=0 they destroy but how to make a health bar that moves with the enemy and shows the individual health of each?
thx
3gFisch

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Not going to be easy. You would need a game attribute for the health of each enemy. Then have a health bar actor for each enemy that uses that global attribute and you would have to constrain its X and Y to the enemy actor. So that would be a lot of attributes, actors, and constrains (oh my!). May work on the iPad or newest iPhone, but even a 3Gs will struggle with this.
  • haim96haim96 Member Posts: 87
    it's tricky to create in gamesalad but one way i can think of is to create series of images
    with different stat of the health bar then create set of rules that say:

    if 100= health >90 change to image1 (with full health)
    if 90 > health > 80 change to image2 (with a bit less health)
    if 80 > health > 70 change to image3 (with a bit less health)...

    etc...

    this is one way to do that without manage X,Y position for each enemy actor...

    it's a lot of graphics works and not very Accurate way to display health
    but should be enough...

    hope this is help...
  • peachpellenpeachpellen Member Posts: 977
    Some of the best TD games I've played haven't actually had a health bar for individual enemies - just a thought.

    You're going to struggle with this in GS unfortunately :(
  • 3gfisch3gfisch Member Posts: 12
    scitunes said:
    Not going to be easy. You would need a game attribute for the health of each enemy. Then have a health bar actor for each enemy that uses that global attribute and you would have to constrain its X and Y to the enemy actor. So that would be a lot of attributes, actors, and constrains (oh my!). May work on the iPad or newest iPhone, but even a 3Gs will struggle with this.

    for each enemy a global variable? i dont think that that is the solution
  • 3gfisch3gfisch Member Posts: 12
    haim96 said:
    if 100= health >90 change to image1 (with full health)
    if 90 > health > 80 change to image2 (with a bit less health)
    if 80 > health > 70 change to image3 (with a bit less health)...

    but if i make the rule under my health actor i can't access the individual health of the Enemy because its an Attribute of the enemy and in the rule i can only access global and health actor attributes
    can i make a group or some thing which has "global" attributes only in the group and then spawn this group for each enemy, in the group is the enemy and the health bar...
    or can the spawn create an attribute for life,X and Y and if the enemy is destroyed delete this Attributes?
    thx
  • 3gfisch3gfisch Member Posts: 12
    peachpellen said:
    Some of the best TD games I've played haven't actually had a health bar for individual enemies - just a thought.

    and this is the reason why my game will be better ^^
    with out health bar is no good solution
  • haim96haim96 Member Posts: 87
    3gfisch said:
    but if i make the rule under my health actor i can't access the individual health of the Enemy because its an Attribute of the enemy and in the rule i can only access global and health actor attributes
    can i make a group or some thing which has "global" attributes only in the group and then spawn this group for each enemy, in the group is the enemy and the health bar...
    or can the spawn create an attribute for life,X and Y and if the enemy is destroyed delete this Attributes?
    thx

    you should have health attribute for each enemy actor
    so enemy.health <100 should work for each enemy...

    the graphics should contain an enemy image+ status health bar in all stats from empty to full.
    so when you replace the image you replace the enemy and the status bat at onces...
  • 3gfisch3gfisch Member Posts: 12
    haim96 said:
    you should have health attribute for each enemy actor
    so enemy.health <100 should work for each enemy...

    for each enemy a single attribute? but i don't know how much enemys i have they spawn each 2sec and that better you are that more enemys will come.. 100...1000 ...
    or one attribute for all enemys? but i think that are global variables and so all enemys have the same life or no?
    thx
  • haim96haim96 Member Posts: 87
    the attribute is an actor attribute not global.
    so when you spawn an enemy actor he got his own health attribute.

    when you create the rules then check on the "local" actor health.
    this way you don't need global health or global XY attributes...

    that's why i think it's the best solution...but i didn't test it my self. :)
  • 3gfisch3gfisch Member Posts: 12
    haim96 said:
    the attribute is an actor attribute not global.
    so when you spawn an enemy actor he got his own health attribute.

    when you create the rules then check on the "local" actor health.
    this way you don't need global health or global XY attributes...

    that's why i think it's the best solution...but i didn't test it my self. :)

    ah
    the enemy has the health bar in his pic and loads an other pic if his live is less
    yes not very nice but should work
    thx
  • haim96haim96 Member Posts: 87
    yes... it kind of ugly. but should work if your enemies travel from right to left...
    i think there is a method to add image on image without replacing the base actor image...
    could be better solution...
  • 3gfisch3gfisch Member Posts: 12
    hey i have found a solution that works grate! don't ask me why it work's but it does *happy*
    set the attributes as real atribues and dont use change attirbut use Constrain Attribut and it work's well but only if things collide and this will make less HP
    if you make, if you click on the enemy to less HP it doesn't work??? crazy
    but for me works grate
    pic's of settings
    the new global but aren't global variables
    http://img684.imageshack.us/f/hpbar3.png/
    constrain not change
    http://img444.imageshack.us/f/hpbar1.png/
    http://img145.imageshack.us/f/hpbar2.png/
    ant so it looks
    http://img196.imageshack.us/i/bildschirmfoto20100627u.png/
    only if collide, if mouse down doesn't work
    http://img715.imageshack.us/f/hpbar4.png/

    ok thx to all
    3gFisch
  • 3gfisch3gfisch Member Posts: 12
    if you want to see i uploaded the test file that works for me
    http://www.mediafire.com/?ynmznzjgomz
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    What about changing the alpha of the enemy.

    Rule

    When overlaps with bullet change self.Health to self.Health-1
    Change self.colorAlpha to Self.colorAlpha-0.1

    Rule
    When self.Health = 0
    Destroy actor

    This way you get a visual idea of how close the enemy is to being destroyed, but you don't need constrains or a ton of images. The other thing you could change would be the actual color values instead of the alpha. Maybe make it get more and more red before destroying it. There would be a slight learning curve for the player, but after awhile you would figure out which shades of red meant near death.
  • peachpellenpeachpellen Member Posts: 977
    Thanks for sharing, great to see :)
  • 3gfisch3gfisch Member Posts: 12
    scitunes said:
    What about changing the alpha of the enemy.

    Rule

    When overlaps with bullet change self.Health to self.Health-1
    Change self.colorAlpha to Self.colorAlpha-0.1

    Rule
    When self.Health = 0
    Destroy actor

    This way you get a visual idea of how close the enemy is to being destroyed, but you don't need constrains or a ton of images. The other thing you could change would be the actual color values instead of the alpha. Maybe make it get more and more red before destroying it. There would be a slight learning curve for the player, but after awhile you would figure out which shades of red meant near death.

    thx for your answer but i have found a solution look about
    i think it shouldn't work but it does ^^
  • 3gfisch3gfisch Member Posts: 12
    peachpellen said:
    Thanks for sharing, great to see :)

    does it work if you open this?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    @3gfisch - have you tested it on a device when a lot of enemies are on screen? My experience is that iTouches and iphones start to really lag when there are 20-30 moveable actors and if those actors each have constrains then you may not even get to 20 before the FPS becomes unacceptable. Just a warning.
  • 3gfisch3gfisch Member Posts: 12
    scitunes said:
    @3gfisch - have you tested it on a device when a lot of enemies are on screen? My experience is that iTouches and iphones start to really lag when there are 20-30 moveable actors and if those actors each have constrains then you may not even get to 20 before the FPS becomes unacceptable. Just a warning.

    no i can't test it i, have only the demo version
    if i have a grate game i'll buy the full version
    can gamesald make the ios4 Apps?? multitasking...
  • haim96haim96 Member Posts: 87
    not yet... :)
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Eastbound has a TD demo...

    It focuses on setting up the weapon's "sensors". He uses "particles" to display the weapon's graphic, while the actual actor is an invisible arm that swings around in a circle.

    I'm thinking you could use that same logic to display the HP above the baddies.

    Rule
    When self.Health >=75
    EB's particle logic with "Full" HP image

    Image = `<||||||||>`

    Rule
    When self.Health >=50 AND <75
    EB's particle logic with "3/4" HP image

    Image = `<||||||-->`

    Rule
    When self.Health >=25 AND <50
    EB's particle logic with "1/2" HP image

    Image = `<||||---->`

    Rule
    When self.Health >=12 AND <25
    EB's particle logic with "1/4" HP image

    Image = `<||------>`

    Rule
    When self.Health >=1 AND <12
    EB's particle logic with "1/8" HP image

    Image = `<|------->`
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    wow! that's interesting
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    @ 3gfisch - I think the reason people are continuing to give you ideas is that putting a constrain on that many actors is very unlikely to work on any device. I know you don't have the GSviewer app on a device for testing, but I think most of us have all been in the situation where we get something to work on the mac in preview (using the mac's processor and ram) and then put it on an iPhone and it really lags or just plain crashes. I'd hate to see you work like crazy on this project and then have it crash.
  • 3gfisch3gfisch Member Posts: 12
    scitunes said:
    @many actors is very unlikely to work on any device.

    only two more is this to much?

    thx all
Sign In or Register to comment.