What exactly am I doing wrong with setting text every tick?

0 favourites
  • 5 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • Hey everyone! I'm currently working on my Planet Clicker game and could use some help with a specific event:

    + System: Every tick

    + Price: Matcher = Coins.Matcher

    + Coins: Matcher = Price.Matcher

    -> Price: Set text to Coins.PriceDisplay

    I've set a unique instance variable ("Matcher") on both a Sprite Font (named "Price") and a Sprite (named "Coins"), with each having the same unique number shared between one Price text object and one coin. The goal is to update the Price text every tick to display another string instance variable on the Coin called "PriceDisplay" (that is set every tick to the "Price" number variable on the coin so that I can use "Price" for calculations, and "PriceDisplay" for text Input.)

    Additionally, I've implemented logic for when the coin is tapped or clicked to perform calculations:

    + Mouse: On Left button Clicked on Coins

    + Coins: Price ≤ Coins

    -> System: Add Coins.CPSAdded to CPS

    -> System: Set CoinClickAmmount to Coins.ClickMultiplier × CoinClickAmmount

    -> System: Subtract Coins.Price from Coins

    -> Coins: Set Price to Coins.Price × Coins.PriceMultiplier

    -> System: Add Coins.ONECPSadded to OneCPS

    -> Audio: Play PurchaseComplete.webm not looping at volume -10 dB (stereo pan 0, tag "")

    -> VariableSetter2: Start Timer "Purchased" for 0.5 (Once)

    Now, when transitioning to a different shop layout, the text boxes only display "Price," which is the default text I've set in the layout editor as the text. They are supposed to dynamically change every tick based on the game logic. Both shops share the same event sheet, and all text boxes have unique numbers matching the coins Matcher variable. However, they are not being updated to display the correct text at every tick or at all. I've debugged the layouts, and the matchers seem correct, and the Price display is correctly set to the price, but the text boxes remain unchanged.

    I apologize for the lengthy post, but I would greatly appreciate any help or insights anyone can provide!

  • I would do it like this since Coins is the important object - set the Price on all Coins objects, so Coins.Price. Then if you want to display this on a related SpriteFont you say 'for each SpriteFont, if Coins.Matcher = SpriteFont.Matcher, set SpriteFont text to Coins.Price'

    Also you can avoid most of the above and have a simple event 'SpriteFont set text to Coins.Price' IF you put the SpriteFont and Coins in a 'Container' then they are related without the matcher instance variable.

  • Thanks! What exactly did you mean with the container, will they both share the same variables, or what? Also, I set it to CoinsDisplay because if I set it to the number, something would go wrong after a while and it wouldn't change the price when the price changed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Never mind, I figured it out! Thank you SOOOOO MUCH!!!

  • Nice! container just means they are related objects, when you create one, it creates the others and they are related in events to avoid the matching variable logic. More in the manual!

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