Make a message show up when overlapping/colliding object?

Get help using Construct 2

Post » Thu May 11, 2017 8:10 am

How to make a message/text show up when overlapping/colliding object?

Like:
In platform game, there is a "sign" object which will show up a message if you walk to it.
That's what I meant.
B
5
Posts: 9
Reputation: 243

Post » Thu May 11, 2017 8:57 am

There are a couple of ways. But I think the best one would be to have just one generic message object(s). I imagine you would want a speech bubble or box or something and on top of it a spritefont or regular text object that from this point on I will simply call a label. Alternatively if you use sprite fonts and have one with outlines (to make it more readable against differently coloured backgrounds) you would need the label alone (typical floating text like in lucas arts adventure games of old).

Now these objects (label and message box) should be invisible at layout start. What you would do is move these to the desired position (above the sign or player, I recommend using an image point for this) on collision, changing the text to the desired message and then making both objects visible.

The message itself should be stored in each sign object as text variable. That way when the collision event with the sign happens, it would pick the right text (so long as the player does not overlap or collide with multiple signs simultaneously).

All you would need to do now is to create an event as below:

Conditions:
On Player collision with Sign

Actions:
Move Label to sign image point (1)
Set Label text to Sign.text
Set Label visible

Of course now you also need a way to make the message invisible either when the player stops colliding with it or after a given time (possibly both). For the former a simple inverted "player overlaps sign" event would be enough, as it would trigger when the player is not overlapping the sign. For the latter a timer and/or fade behaviour can be used (but then you need to remember to set opactity to 100% in addition to making the Label object visible when moving the sign).
B
15
S
6
Posts: 85
Reputation: 1,195


Return to How do I....?

Who is online

Users browsing this forum: Xh3maa and 4 guests