change font color for all text objects of family

  • Hey guys!

    I have a family that contains multiple text objects.

    How do I change the font color of all visible text objects of that family at once?

    Multiple text objects are displayed on the screen, all have black as a font color initially. By tapping it, the font color of the tapped object shall turn yellow. When tapping another text object, this text objects font color shall change into yellow. There previously tapped text object shall change back to its initial font color, i.e. black.

    I have a screenshot of the code but cant figure out how to insert it here. Can anybody give me a hint, how to insert images in a post?

    Thanks

    Sophia

  • You can add Function object to your project and create a function that resets font color for all texts:

    On Function "SetAllTextBlack" -> FamilyTextObjects set Font Color to rgb(0,0,0)

    Then on tap call this function before setting yellow color to tapped text:

    Touch On Tap FamilyTextObjects

    ------------------------> Function call "SetAllTextBlack"

    ------------------------> FamilyTextObjects set Font Color to rgb(255,255,0)

    As for sharing you screenshot, you can upload it to a service like Imgur and post the link here.

  • Works like a charme! Thank you so much dop2000!

    After tap on, an audio file shall start playing. The audio file is unique to the text object in the family.

    My idea is to do it via a global variable.

    global variable: select

    on tap object "family" -> set global variable to the name of the text object (e.g. Alpha, Beta, etc...)

    If global variable is "Alpha" -> play audio file "Alpha"

    If global variable is "Beta" -> play audio file "Beta"

    ...etc

    I cant find an expression that lets me change the global variable value to the name of the text object.

    Do you have an idea, how to solve that?

    Thats how it looks so far:

    Thank you

    Sophia

  • You can't get object's name.

    You should do this with instance variables. Create an instance variable on the family - it could be "objectName" or "audioName".

    Set the correct value to this instance variable for each text instance.

    Then on tap simply play audio file FamilyTexts.audioName

    Also, I thought you have a family with multiple text objects?

    On you screenshot I see only one text object - txt_session. If you want these events to be universal (to work with all text objects), you need to replace txt_session with family name.

  • Thank you! It works!

    txt_session is the name of the family.

    Here is the code.

    Currently, there is background music playing on start of layout, as well as an additional audio file that was started by tap on one of the text objects you see on the layout (you might need to double click the img as it is large in dimension).

    If you tap on a second text object, while the audio file for the first text object hasnt finished, the first audio file should stop and the audio file for the second text object start to play. However, I would like to have the background music continue to play.

    Is there a way to stop all audio files, except one?

    Thank you!

    Sophia

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When playing audio, don't leave the tag field empty.

    Then you'll be able to stop audio with a specific tag.

    Audio tag "textSound" is playing -> Audio stop tag "textSound"

  • Great. Thank you!

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