How do I update text box dynamically?

0 favourites
  • 2 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • Hey C3 World!

    Got a little turn-based game here and I'm trying to create a "summary" sprite font box which includes what actions will take place when "end turn" is pressed.

    Field 1 (Orchard) - list

    If apples is selected, I'd like the summary box to show "+2 apples". If oranges is selected, "+2 oranges" would appear.

    I've tried a couple different methods and the screenshot shows the latest trial. It adds the +2 for whatever is selected however if I change the selection, the previous choice isn't replaced. Not sure how to clear the previous choice and use the current option. There are a few fields/lists that will be adding to this summary box.

    Any help would be appreciated! Thanks all.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Once you append some string to the summary text, it's difficult to remove it. So I suggest storing all parts of the summary text in different variables. And then assemble the summary text from those variables.

    Also, all your events are running on every tick, this is not a great way to do things in Construct. You need to use "ListBox On Selection Changed" event, and compare selected item in sub-events. And remove all "trigger once"

    AppleOrOrangeList On Selection Changed
    
    ...AppleOrOrangeList selected item=0 : Set fruitVar to "+2 Apples"
    
    ...AppleOrOrangeList selected item=1 : Set fruitVar to "+2 Oranges"
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)