Displaying points given to player

  • 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.

  • 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.gold

  • 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

  • Thanks for yours replies :)

    This community is looking good already :D

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here's the simplest way I could think of:

    <img src="https://dl.dropboxusercontent.com/u/4881441/C2/C2_ValueIncrementbyTime.png" border="0" />

  • 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.

  • LittleStain

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

    <img src="https://dl.dropboxusercontent.com/u/4881441/C2/C2_ValueIncrementbyTime-v02.png" border="0">

    And the capx:

    https://dl.dropboxusercontent.com/u/4881441/C2/changeValuebyTime.capx

  • Probably not a perfect example, but someone might find something useful in it...

  • Thank you :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)