fade in - fade out on passing event point

Get help using Construct 2

Post » Fri Jan 27, 2012 12:15 am

Here is my solution for an info text fading in and out on passing by an infopoint in game.


Perhaps its usefull for someone:
fade.capx
B
14
S
2
G
6
Posts: 110
Reputation: 3,849

Post » Fri Jan 27, 2012 1:22 am

sorry but there is a simpler way!


[edit] just realised the 'trigger once' isn't necessary.. also needs dtkeepee2012-01-27 01:23:56
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Fri Jan 27, 2012 2:22 am

Fade in, fade out

Multi-implementations are cool
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Fri Jan 27, 2012 3:37 am

in two events yeah :D
shortFade.capx
Last edited by Yann on Sun Sep 14, 2014 9:49 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 27, 2012 8:53 am

I was so proud of finding a solution for that. Now I feel stupid. You guys are great!

btw: When do you sleep?TastyBytes2012-01-27 08:54:15
B
14
S
2
G
6
Posts: 110
Reputation: 3,849

Post » Fri Jan 27, 2012 11:15 am

[QUOTE=Yann] in two events yeah :D
http://dl.dropbox.com/u/23551572/C2/shortFade.capx[/QUOTE]

@Yann - I see your code, but I dont understand why this fades so smooth. Can you explaine you two lines a bit for stupid little me? Please! Weishaupt2012-01-27 11:55:55
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Jan 27, 2012 11:50 am

between 00h34 and 00h43 why ?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 27, 2012 11:56 am

@Weishaupt

if the player overlap the sprite, every tick you do a lerp(currentOpacity, 100, 5*dt)
(forget the min and max function they are useless... just to scare some n00bs)

basically while you are overlapping the sprite, every tick you travel a little percentage of the distance between your current Opacity and 100.
But this percentage is fixed and is equal to 5*dt.
So as the distance decrease, the same fraction of this distance decrease, so you basically ease in the value

the primary goal of lerp() isn't to be used like that. You usually have a starting point, an end point and a percentage (from 0 to 1)
so you usually do lerp(start,end,percent) and you make the percent value evolve to create movement.
But here the percent is fixed and you apply the result of the lerp to the start value, so the distance between start and end decrease... etc I explained that already.

And you do exaclty the same when you don't overlap. But toward 0 instead of 100
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 27, 2012 11:59 am

That's pretty awesome. I was just about to need something like this for explaining controls as you move around, and to make the storyline happen.

Question though. Is there a way to have this work when passing different instances of an object, such as multiple signs, to have it say different things without using a separate event for each one? This of course ties back into my lack of understanding with instances, and desire to learn them.
B
6
Posts: 10
Reputation: 445

Post » Fri Jan 27, 2012 12:15 pm

@Yann - Thanks pal!
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Next

Return to How do I....?

Who is online

Users browsing this forum: Colorfish, Waltuo and 4 guests