How do I make a coin, hitpoints, and flowerpoints counter?

Just started using Construct 2? Post your questions here

Post » Tue Jun 20, 2017 9:15 pm

*If it helps I have a spritefont that I'm using to help with hitpoints coins and flowerpoints*

So here's what I need help with, how do I set up the hitpoints where it's in this format (n stands for number): nn/nn? The first 2 n's are how many hitpoints the character has currently and the last 2 n's are how many hitpoints the player can have up to? Same format applies to flowerpoints.

And then I need to have a way to count all the coins the player collects

Can anyone help me?!
B
10
S
2
Posts: 11
Reputation: 572

Post » Wed Jun 21, 2017 11:39 am

The best way to do this would be to store the maximum and current hitpoints in an (instance) variable and use the variables to display it.

Set the text to "[currentHP] & "/" & [maxHP]"
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Jun 24, 2017 10:23 am

In short, your answer is Variables. you can use Instance or global variables, though instance variables are geared more towards hoards of enemies. if its player vs player, you can get away with using global variables.

once you create the global or instance (Numerical) variable , your code would look something like :

Player- On hit - subtract X from HealthVariable.

you can use the same logic in reverse.

player-on collision w item - add X to HealthVariable

To kill player when life is at 0 or below (in case player is at 1 health and is hit twice at once)

If HealthVariable = equal or less than 0, player = destroy

Similarly, If They Pick Up Health, Instead of Stacking 999999/100 health, You can cut it off at a maximum.

If HealthVariable = Greater than MaxHealth, Set HealthVariable to MaxHealth

The same with 'FlowerPoints'. Create A Variable named Flowerpoints.

Player - On Collision - Add X To Flowerpoints.

Every Tick - Set FPText To - "Flowerpoints : "&Flowerpoints
- Set HPText To -"Health : "&HealthVariable" / "&MaxHealth

You can then create pickups that allow for More than Max Health.
B
22
S
12
G
1
Posts: 108
Reputation: 2,774

Post » Sat Jun 24, 2017 10:27 am

*special pickups. if you havent figured it out yet, you can also create a variable, an call it "Coins". player-on collision-add 1 to Coins. every tick - set cointext to -"Coins : "&Coins
B
22
S
12
G
1
Posts: 108
Reputation: 2,774

Post » Mon Jun 26, 2017 12:05 am

Ok, so I did everything you said, or tried to do everything you said and so far it's not working. How do I attach the .capx file to here?
B
10
S
2
Posts: 11
Reputation: 572

Post » Mon Jun 26, 2017 1:11 am

Share on dropbox or google drive!
B
46
S
16
G
76
Posts: 2,150
Reputation: 45,313

Post » Mon Jun 26, 2017 1:26 am

Message: Raynethemagi can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
https://www.dropbox.com/s/l0fgdlpspojl9gc/PaperMarioGame.capx.autosave?dl=0

Here it is....I hope this is the correct file.
Last edited by Raynethemagi on Mon Jun 26, 2017 1:36 am, edited 1 time in total.
B
10
S
2
Posts: 11
Reputation: 572

Post » Mon Jun 26, 2017 1:33 am

That's a broken link and looks like a pdf file which won't be the correct capx file.
B
46
S
16
G
76
Posts: 2,150
Reputation: 45,313

Post » Mon Jun 26, 2017 1:37 am

Try it now.
B
10
S
2
Posts: 11
Reputation: 572

Post » Mon Jun 26, 2017 1:46 am

If you check out my edit on event 13, I fixed the health. https://www.dropbox.com/s/rqxcattwlkygt ... .capx?dl=0

When referencing a variable you need to do object.variable. In quotations "" that is just text.
B
46
S
16
G
76
Posts: 2,150
Reputation: 45,313

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests