How Do I Efficiently Display Text For Multiple Sprites?

0 favourites
  • 10 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hi! I have a page with many sprite boxes, whenever I hover over one of these sprite boxes the appropriate text appears.

    I can do this by creating the text and then destroying it every time I hover or simply fadein fadeout every hover.

    My issue is too many sprite boxes that require their own text and this is making event overhead a bit much!

    I can't think of a way to simplify the events. I tried using a family but that triggers it for everything in the family obviously. If you have any ideas please do throw them at me!

    This is what I have as an example for hovering over a single sprite.

  • Assuming you can only show a tooltip on one sprite at a time you can have one text object and say mouse over sprite > set text object position to sprite. The text to be shown can be a string variable on the sprite then you can also say in the same event set text object text to sprite.textvariable.

  • Assuming you can only show a tooltip on one sprite at a time you can have one text object and say mouse over sprite > set text object position to sprite. The text to be shown can be a string variable on the sprite then you can also say in the same event set text object text to sprite.textvariable.

    Thanks for the reply! I see what you're trying to say but I maybe misunderstanding.

    Does that mean I have to in anyways create an event for each sprite I hover over? Or is there a way to setup the events in a way it recognizes the hovered over sprite without creating a separate event for hovered over sprite?

  • The above is one event only that is for all sprites yes. For the above you don't create or destroy anything, you have one text object that changes position based on the object you hover over. The object is picked by mouse cursor over object condition.

  • The above is one event only that is for all sprites yes. For the above you don't create or destroy anything, you have one text object that changes position based on the object you hover over. The object is picked by mouse cursor over object condition.

    Right I see what you're saying, this will help reduce unnecessary actions and text hanging around since I can customize one text block for each sprite hovering over, thank you for pointing that out!

    What I'd also like to address is let's say I have 50 sprites I want to hover over to have their own text, does that mean each sprite will need it's own event condition "mouse over object (select sprite)"? I wanted to see if there's something else before I move forward.

  • If it's 50 instances of the same object then it is mouse over object. If it is 50 different objects then you put them in a Family and say 'mouse over Family'. The text required would be set text to family.variable, so the instance variable is at the family level for text. Either way you just need one event only for everything, with 2 actions - set position of text object to sprite/family, and text object set text to object/family.var

  • If it's 50 instances of the same object then it is mouse over object. If it is 50 different objects then you put them in a Family and say 'mouse over Family'. The text required would be set text to family.variable, so the instance variable is at the family level for text. Either way you just need one event only for everything, with 2 actions - set position of text object to sprite/family, and text object set text to object/family.var

    It is indeed 50 different objects. Edit*: And the tooltip is to show up only on the sprite that's being hovered over.

    Thank you for clarifying, since I'm a beginner I've only understood the part where mouse hovers over a family but kind of lost how an instance variable would help the actions determine which sprite it should be over. There's a lot of factors that makes me lose the train of thought.

    If it's not consuming to replicate as an example, could I ask you to show an image so I can understand the concept please? I tried to mess around with variables for the family but I can't seem to figure out what you're conveying.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The instance variable idea is only for the text, on each object you have a string variable where you type the text in the editor. Then when you play the game it will set the text to this string. No need for screenshot it is just one condition and two actions, mouse over Family : set text object position to Family.x family.y and set text to family.variable (the variable needs to be typed on the object itself in the editor). Try it and post a screenshot if it went wrong.

  • lionz I'm super grateful you were patient with me. I did not realize it was that simple. Just like you said, 1 condition and 2 actions.

    I wasn't aware if you hover over a family that it still recognizes the child of that family individually. So on my debug it showed the individual position of each family member I was hovering over.

    Your suggestion to put a variable on the family and name individually for the sprites worked beautifully also.

    I should probably review the manual on families and see if there's any mention of recognizing the individuals inside the family separately.

    Edit (for those in the future confused like I was): After reviewing the family manual, it's clear I didn't understand the concept, I thought it would apply effects to all members at the same time rather than apply effects when triggers take place. So that's a good lesson for myself. I confused Families for Containers.

  • No problem, and for Families they are used for when you want to minimize events by grouping and picking different objects as one object. To pick an individual object from the Family you should go back to the individual object as no use for Family there.

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