Damage Display [SOLVED>PROBLEM WITH AZU]

For questions about using Classic.

Post » Sat May 21, 2011 9:52 am

Hello everyone !

Can someone help me ? I want to make a damage display like this game :

[url:3454ogze]http://youtu.be/EIIWQ-E2MVM[/url:3454ogze]

Here is the numbers picture to use :


I have a global variable called "Factor".
When "Factor" is equal to 1.0, to 0.75 or 1.25 -> Normal damage
When "Factor" is equal to 2.0 -> Critical damage
When "Factor" is equal to -1.0 -> Healing damage

First line is for normal damage
Second line is for critical damage
Third line is for "healing" damage

I also have a global variable called "Damage".
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Sat May 21, 2011 11:00 am

So your main problem is how to use your bitmap font in the game to display the actual damage? I suppose you might have heard of the SpriteFont plugin, which does a good job in many cases, but it sometimes also does crash I'm afraid.

I would suggest you do it simply with events. Using some text expressions and a comparison string it's not that hard to get a custom bitmap font working (check this older thread).

When you are dealing only with numbers, you could do it even simpler. Just iterate over the individual characters, and spawn the number sprite on the respective frame.

Like that for example: DMG 135, taken apart to 1, 3, 5. Now you could just create three instances of the number sprite in order. One on frame 2, the second on frame 4 and the third on frame 6. Assuming you have your frames in order 0, 1, 2, 3, 4... which you should have of course. You have to add +1 cause frames aren't 0-based and start with the first frame on 1.

I realize this probably sounds terribly theoretical. If needed I will cook up a proper example of what I mean when I have time later.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat May 21, 2011 2:11 pm

Actually, I don't get it :(. It looks complicated... Can you make a cap file with using my bitmap font please ? The MAX Damage is 999999 (6 digits).
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Sat May 21, 2011 6:39 pm

[quote="Shiru":3gkfimj7]Actually, I don't get it :(. It looks complicated... Can you make a cap file with using my bitmap font please ? The MAX Damage is 999999 (6 digits).[/quote:3gkfimj7]

No worries, I'll make an example cap for you. Just be a little patient, this weekend seems to be a bit busy.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue May 24, 2011 9:12 pm

Okay, I decided to make this into another blog post. This one was particularly exhausting, I didn't realize there was so much to explain, haha. :)

We Construct Blog - Forum rescue #004: Bitmap font damage

I hope you'll be able to grasp the concept from this (cap files are included).
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed May 25, 2011 6:21 pm

Yes ! Thanks a lot ! It works perfectly ;-). I also join your blog as a member (Shiru). You're a god !

> You should add your tutorial to the Tutorial List here : viewtopic.php?f=8&t=8169
B
6
S
1
G
3
Posts: 61
Reputation: 1,072

Post » Thu May 26, 2011 3:57 am

Wouldn't you have to make different loops per enemy?
Also, I tired typing in numbers instead of the what the edit box says And it didn't work=/

+ MouseKeyboard: On Left Clicked on BadGuy
-> Function: Add parameter 12
-> Function: Call function "DMG" (and Forget picked objects)
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Thu May 26, 2011 7:11 am

My pc went to nirwana so I can't use Construct, but from what I saw on the blog, the function expects a string, not a number. Do

-> Function: Add parameter "12"

EDIT: And if you intend to use numbers instead of text, inside the function "DMG" just replace [u:xyjod7h6]every[/u:xyjod7h6]
Function.param(1)
with
str(Function.param(1))
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu May 26, 2011 11:05 am

Worked, but what about creating on different enemies? Would I have to make different "bmg" functions per enemy?
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

Post » Thu May 26, 2011 1:53 pm

No.
All that the function needs is a position to start at. In the example it is the horizontal center of BadGuy and the vertical top.
To make this function work independent of BadGuy, just add 2 parameters to the function, the x and y of the starting point. Let's say you have a sprite named "anotherBadGuy". When calling the function, do this:
-> Function: Add Parameter someDamage
-> Function: Add Parameter anotherBadGuy.Left + anotherBadGuy.Width / 2
-> Function: Add Parameter anotherBadGuy.Top
-> Function: Call function "DMG"

Now change the function itself to work with the new parameters.

Change the following:
-> System: Create object "numbers" on layer 1 at (BadGuy.Left+BadGuy.Width/2-Global('width')/2+Global('temp'), BadGuy.Top)

into:
-> System: Create object "numbers" on layer 1 at (Function.param(2) - Global('width') / 2 + Global('temp'), Function.param(3))

Whenever you want to display damage near an object, just pass an x and y value as parameters 2 and 3 like in the "anotherBadGuy" example above.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests