Displaying coins.

RosalinaGalaxer

  • Posts: 239
Hi. I am making a game with coins. I know how to count the coins, but I do not know how to display the amount collected in a HUD. Please help.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

gurigraphics

  • Posts: 688
The image hud  -> Attach to screen
The points hud  -> Draw in screen


RosalinaGalaxer

  • Posts: 239
Yes I have. But I do not know how to make it display the right number at the right time.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

mebloo

  • Posts: 128
Just keep track of the current amount of coins with a Game Attribute and display that value on screen.

RosalinaGalaxer

  • Posts: 239
Like this...?

If
coins = 1 draw 1 with XXXX font at x XX and y XX

And so on so forth?
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

Frostfire

  • Posts: 23
Hm. Not quite.  And I don't know if you're using the code base or the drag and drops, but I'll give a simple drag and drop procedure:

The basics:  Coins collected will be an number attribute stored in the scene behavior.  When you pick up a coin, this attribute will be increased by one.  In that scene behavior, you simply display the number.  You can apply fonts to it after you're done.

We'll let the scene behavior know that a coin was picked up using a trigger,  (some engines call it a message).  A trigger calls out a name.   Anybody set to listen for that name initiate whatever logic you set up for it.

What you'll need:
-Coin actor (Make collectible only to player.  Best if not effected by gravity currently because we're setting it with collide with anything)
-Player actor

Behaviors you'll need
-Actor behavior: Caught Coin.  Attach to Coin actor
-Scene behavior: Score. Attach to scene

Caught Coin:
=Event:When collides with something else
-Trigger event gotCoin in behavior Score for this scene
-Kill self

Score:
*Attributes:
 -Coins: Type number.
=Event: (Custom Event, down at the bottom).  When gotCoin occurs:
-set Coins to Coins+1
=Event: Drawing
-Apply Font
-Draw Coins at x and y (where x and y in this case will be the screen coordinates)


If you want to get fancy, you can go into the numbers and text->text and get a text concatonator (a plus). Write coins on one side with a colon, put the Coins attribute into the other side.   Put in an "As text" block,  and put that in to your draw.  You'll have to modify the x and y because now it will be longer.   

This can be extendable to make it so that if it only collides with the actor, modification of the score can make it so that if something hits you, you loose all your coins.  It's about how you want to do it.

That should be it.  Me thinks.

RosalinaGalaxer

  • Posts: 239
K. Will that code attach it to the screen as part of the HUD?
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz

yoplalala

  • *
  • Posts: 1530
"Draw Coins at x and y (where x and y in this case will be the screen coordinates)"

Drawing always happens at the top of the screen, so it we part of the HUDD

YoshiToad

  • Posts: 1
But then won't it be anchored to the screen off-screen?

RosalinaGalaxer

  • Posts: 239
Whoops, that was me, but on a different account.
Ģ̷̓l̴̥̒͑̕͝ì̷̘͈̬͈̖̂͂̔̕t̷͔͇̯̥̬̀̽̓͜͝c̵͇̦̼̮̉̐̈́̕͝ͅͅḣ̵̡̫̞͚̐̅ͅë̶̗̦̪̖͚̜́͊̄͑s̵̺̹̖̼̥̃.̴̮̫͐ ̶̛̓̇̾̎

“I have never seen a more heated discussion about context, jazz, and cats.” - VanillaButterz