[Solved]How do I - Set individual text per object?

0 favourites
  • 6 posts
From the Asset Store
Per Pixel Destruction like in "Worms" (perfect performance, no third party plugins)
  • On start of layout, I spawn text for each object

    How do I, for each object, set the text individually?

    I can't seem to find anything relating to "for each unique IID".

    Is this something where I would need to use an array, loop, or a function? (I'm not too keen on either one of those, so I assume that might be where my problem lies)

  • I don't know if this is the best way to solve it, but it was how I manage to pull this off.

    Every time you are going to change the text, check if it's overlapping the object it's related to. This will select the text instance that is related to this particular object.

    Hope it helps o/

  • Thanks RayKi!

    I'll try that. I hope I can figure out how to make it spawn each units variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another way would be designating each instance of the text object with an instance variable set as a string, with it's value containing the text to be spoken, then you can have a blanket event essentially saying "let all 'text.objects' text = instance variable:'text'".

    Then you can use the "pick nth instance" (I think that's what's used) and change the variables themselves to change each individual instance's text.

    Hopefully that helps some, good luck SwatHound.

    Regards,

    Gideon.

    Also, can I just say RayKi , massive respect for the Scott Pilgrim avatar man, thumbs up for awesome taste.

  • You lost me, GideonG D:

    'with an instance variable set as a string' ....

    Uhm.. Haha whats a string xD. Looked it up, found no definition for solely string, just a lot of other definitions using it!

    Edit: Nevermind, found it under expressions, was looking under system expressions -

    'Text is also known as strings in programming, and Construct 2 also sometimes uses this naming convention.

    Text in expressions should be surrounded by double-quotes, e.g. "Hello" '

    Anyway uhh. Thanks guys, I was kind of dumb and hastey. - All I had to do was add another condition to pick the nearest sprite. (Thanks RayKi, I couldn't find "if overlapping object" so used this instead, thanks for the idea)

    --System - On start of layout

    Sprite - Spawn text on layer x imagepoint y

    -- Sub event -- System for each sprite --

    ---------------------text - pick nearest to (sprite.x, sprite.y)

    ---Action----

    ----Set text to sprite.units

    I still wish I could understand what you were trying to suggest Gideon D: - reading these things are hard, I think I'm more of a visual learner (images and videos, not so much text) Heehee probably why I failed math twice -- thanks again for the help guys

  • OH! Don't stress man, that's totally my bad on that one, it's listed as 'text' in C2, 'string' is more of a code term than C2 properties. I'm glad you found a solution!

    If you're interested, this is what I meant - variable type can be set to text, which you can use to store data (like something to say) unique to each instance of an object.

    Also, don't worry about no understanding everything people offer as advice, everyone has to start somewhere and as a fellow beginner, I've found the community here is more than happy to try and explain stuff if you need it. In no time you'll be following along with more complex stuff before you even realise you've picked anything up.

    Hope all goes well with your game.

    Regards,

    Gideon

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