Change color on one of the spritefont objects using UID in eventsheet?

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi! I'm trying to make a color change in my main menu when I mouse hover over the text. I want to create as few spritefont objects as possible, so I'm trying to change the color of one and not all instances of the spritefont. Is this even possible?

    To change the color is easy enough, but it changes colors on all instances of the sprite font, and not the one with UID 45 (in my case). Is there a way to specify the UID on the object I want to change the color, so I don't have to create lots of separate sprite font objects in my project? I would hope something like "SpriteFont.UID.45,rgbEx(155, 188, 15)" would work, but I get an error as I am still a n00b.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found the solution! Stupid me... I of course needed to specify the UID of the spriteFont in the events too.

  • Using UIDs like this is not a very good practice. Because in a couple of weeks or months time you won't remember what UID 45 means. Also, UIDs may change, for example if you decide to copy and paste these buttons. It's always better to use instance variables to identify instances.

  • Thank you for answering! I didn't think of that. Do you have a simple example on how this could be done?

  • Add an instance variable to the Button sprite, for example "tag". Then you can assign a unique tag for each button and pick buttons by these tags.

    For example:

    Cursor is over Button
     Button compare variable tag="Settings"
     ....
    
     Button compare variable tag="Quit"
     ....
    
  • Thank you! I will change my method from now on! ;)

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