Picking SpriteFont objects by Text instance var

0 favourites
  • 4 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Something that I thought would be trivial has taken me some trouble to work out. I have a number of SpriteFont objects in a layout and I'm trying to set their text individually. I have a Text instance variable in my SpriteFont object called something like WhatTextIsThis and setting each instance to "score1", "score2" or similar. When I try and pick an instance by evaluating SpriteFont.WhatTextIsThis = "score1" (for example) I get no objects picked. I tried lots of things and finally decided to use a simple numbering scheme, which worked immediately. What would be the problem with using Text in this case? I double checked that I'm comparing the correct text. Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure what the problem is but using text works so you have overlooked something.

    Did you add the instance variable as a "string" since "score1" is not a number if you use =score1 and add the instance variable as a number it won't be equal.

    A version working using "score1" as a variable.

    [attachment=0:29ykiom3][/attachment:29ykiom3]

  • Thanks for that. Yes definitely a Text instance variable, just double checked. I'll check your sample and post back if and when I work out what I've done wrong. BTW as a test I changed the evaluation to use <> instead of = and *all* instances were picked.

    Edit: Ok looking closer at your sample, I noticed that you don't have quotes around your text in the initial values. To me it was intuitive to use quotes as it's a string, but anyway! Thanks for helping me see this.

    Edit 2: And also I had a redundant 'pick by evaluate' condition instead of a simple Compare Instance Variable condition.

  • Just a final note.. The Construct editor puts an initial value of "" for Text instance variables, which is obviously misleading and should probably be removed.

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