Pop ups for sprites -- collision detection for text label

0 favourites
  • 6 posts
From the Asset Store
Relax and relieve stress by popping bubbles in Fidget Anti- Stress Releaser!
  • Hello,

    I am implementing a pop up label for a sprite -- e.g. to visually indicate that it received an event.

    A text label is displayed for 3 seconds, 20 pixels below it.

    Trouble right now is how to position another label beside the sprite without obscuring first labels already showing -- i.e. each additional label shown needs to be displaced another 20 pixels below.

    One idea was to detect if there is a collision between labels and if so, move the last one further below. However, text labels don't have collision detection -- can it be added?

  • You're right that you can't do collision detection on text objects.

    If you just want to add extra text you can use the "append text" action in the text object, and use '& newline'.

    If you want to add a new text instance and position it next to the other, assuming you have the origin point on the top left, you can pick the text object and then create another text object at X=text.BBoxLeft, Y=BBoxbottom+20.

    This will create another text object 20px below the one that is picked.

  • Thank you.

    Getting to the previous one is somewhat non-trivial, since its a "floating" instance that has to be detected through some pick expression.

    Also, initially, there no other one, so this condition has to be checked as well.

    It looks like I need to keep a (tight) record of a mapping:

    - each vehicle can have zero to n text pop-up associated -- created in some sequence.

    - each pop-up is dynamically destroyed after x seconds

    I, btw, tried to keep a record how many pop ups were created as an instance variable in vehicle -- but ended up with a bug to keep this instance synchronized with the actual number of pop ups ---

    i still don't know what the bug is -- its not obvious --

  • Kinda hard to say from what you've mentioned, but there are plenty of ways you could keep track of which text instances are associated with a certain sprite.

    Have a look at this example. It passes the cars UID to a instance variable on the text, then that is passed to a function to handle moving and deleting the text instances. The text instances are all added as children to the car that is their parent and they follow it etc.

    1drv.ms/u/s!AkmrWgxeuxlKhId3JV3j_rkStx0kjA

  • Thank you.

    I will look at your example -- this is, btw, what i sort of tried to do, but ran into a bug i couldnt figure out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your code is really great. I am learning a lot, including the use of hierarchy, the ability to pick spatially close or far, the use of timer, etc.

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