Showing damager counter per hit

chongyunxiang

  • Posts: 278
Hi!

I'm trying to show a damage counter everytime player hits the enemy. I'm able to Draw the Score, however, I want my Score to appear every time I hit the enemy, then disappear after after a while. Similar to those RPG.

Tried out the opacity option, but it doesn't work.

Thanks!

t4u

  • Posts: 418
Make permanent text in enemy. When player atttacks enemy set text to value of damage in enemy object. After some time set text to empty text
USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/

hendriza01

  • *
  • Posts: 82
Some time ago I created a little demo platformer with a damage counter and what I managed to do was also "tween" the font upwards and reduce opacity over 1 sec, which is a behaviour you see in many games. But I think I used a slightly more convoluted way as I wanted to experiment with the Image API blocks.

I created each number in Inkscape and imported them into my games folder so Image API could use them, and I just created the image in the center of actor and above it's head each time it took damage from a particular bullet type. Then I tweened the number upwards and reduced opacity over time. It was just for fun to play with Image API, but probably not the recommended way to do it for your average game. Although tbh I'm a believer that it doesn't matter what method you use to create a behaviour, as long as it works efficiently and doesn't lag your game more than other suitable methods, then its all good :)

stefan

  • *
  • Posts: 2263
Ill get over this in the next tutorial when im better again. It was a pain to record yesterdays tutorial...

chongyunxiang

  • Posts: 278
Thanks guys! I'm a little confused regarding the text in enemy method.

Hendriza01, I too thought of creating an actor for each number, then label each actor with their respective number, tween the actors then play with opacity and kill self. But yes, as you mentioned, it's probably not an efficient method.

Thanks!

hendriza01

  • *
  • Posts: 82
Thanks guys! I'm a little confused regarding the text in enemy method.

Hendriza01, I too thought of creating an actor for each number, then label each actor with their respective number, tween the actors then play with opacity and kill self. But yes, as you mentioned, it's probably not an efficient method.

Thanks!
Hey chongyunxiang, well the Image API is more efficient than using an actor for each number, because essentially you are manipulating an image rather than an actor. So it doesn't use that much in terms of resources. I believe this is one of the reasons the Image API was created, so instead of having hundreds of actors on the screen at once, you can have hundreds if image instances of just one image on the screen to create various types of effects. When I was testing it, it caused almost no drop in FPS, and I had bullets flying and various actors moving around taking damage and the Image API just handled it without any issues.

But again, there could be an easier way like "t4u" mentioned above, although I am not too sure what he meant either. Maybe he meant something like creating an actor attached to your player (like a small rectangle which has opacity of zero), and then when he takes damage, you draw a font onto the actor and make it visible. And let it fade out again.

Or maybe t4u meant just having drawing a font directly onto the actor itself just above it's head. If the font is empty, it won't draw anything. When he takes damage, some font will be drawn and it will show above his head. Then you just set the font to empty / blank space again after 1 sec or something.

chongyunxiang

  • Posts: 278
Hi Hendriza01, I've not used the Image API before. I think I better give that one a try.

So basically,  t4u's method is to have an invisible actor attached to the character, then draw the fonts in the middle of the invisible actor. so every time the character gets hit, it draws the font on the invisible actor and fade. But what happens when the character gets it a second time really quickly?

Will the first "damage" that was drawn, be changed to the latest number? Considering a situation where we want to show the number of times the character gets hit, so it'll be like "1! 2! 3! etc".

stefan

  • *
  • Posts: 2263
I have eecorded the 2 part tutorial yesterday and will be onlone in about an hour.

chongyunxiang

  • Posts: 278
Thanks TheIndieStation! Always looking forward to your tutorials!

stefan

  • *
  • Posts: 2263