Displaying points given to player

Get help using Construct 2

Post » Sat Jul 06, 2013 11:39 am

I have already set up a 'gold' text object on the layout. Also, the object 'Player' has a variable of 'gold'.
At the start of layout, I would like to give the player 100 gold as the initial gold, but in a way that the 'gold' text display start adding 1 every 0.05 seconds and stop at 100.
I've tried using the 'wait' action but it failed... I don't know if 'Every x seconds' should be use in other way as well.
The concept is simple and is kind of a noob question but I just don't know how to do it in this event sheet format. Thanks.
B
4
Posts: 5
Reputation: 210

Post » Sat Jul 06, 2013 11:49 am


I would make a boolean variable called start as well so that when 100 gold is reached you could set start to false and add that to the condition. Else during the game everytime it gets below 100 this event would fire.

Every 0.05 seconds - if gold is < 100 - start = true - add 1 to gold
if gold = 100 - set start to false

System every tick - Set text to "gold :"&player.goldLittleStain2013-07-06 11:50:36
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 06, 2013 11:52 am

You will need 2 variables : currentDisplayedGold and currentGold
When you give gold to the player, set currentGold to currentGold + newGold, and call a function "displayGold"
This function will just check if the currentDisplayedGold is < to currentGold, then add 1 to display (and update the display itself ^^), wait 0.05s, and call the same function again.
Here is the capx doing so : capx
B
17
S
8
G
4
Posts: 473
Reputation: 6,211

Post » Sat Jul 06, 2013 4:55 pm

Thanks for yours replies :)
This community is looking good already :D
B
4
Posts: 5
Reputation: 210

Post » Sat Jul 06, 2013 5:47 pm

Here's the simplest way I could think of:
B
14
S
4
G
4
Posts: 19
Reputation: 3,211

Post » Sat Jul 06, 2013 6:18 pm

@darktoad

You'd still want another condition in there to make sure that during game-play gold could get under 100 without the while loop starting to run.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jul 06, 2013 7:39 pm

@LittleStain
Good point. I've updated the example, with something more generally useful to reference.



And the capx:
https://dl.dropboxusercontent.com/u/4881441/C2/changeValuebyTime.capx
B
14
S
4
G
4
Posts: 19
Reputation: 3,211

Post » Sat Jul 06, 2013 7:40 pm

Probably not a perfect example, but someone might find something useful in it...
B
14
S
4
G
4
Posts: 19
Reputation: 3,211

Post » Mon Jul 08, 2013 7:29 am

Thank you :)
B
4
Posts: 5
Reputation: 210


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 49 guests