Efeito Dia e Noite

1

Attached Files

The following files have been attached to this tutorial:

.capx

efeito-dia-e-noite.capx

Download now 172.34 KB

Stats

2,657 visits, 3,436 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 18 May, 2017. Last updated 19 Feb, 2019

This tutorial was published in Portuguese.

This tutorial has been translated into Google Translate

In this tutorial I will show you how to make the nature phenomenon of dawn and dusk. The initial state is what you choose, whether it starts or Layout, it will start day or night.

We start by creating two variables, one to be 'Ajuste_Dia_e_Noite' And the other will be 'Tempo'.

Variables 'Ajuste_Dia_e_Noite' : Tell whether time should advance, day to night or night to day.

If it has the text "Day", the variable 'Tempo' will advance, being able to be dawn, morning ...

If it has the text "Night", the variable 'Time' will return, being it may be evening, afternoon, nightfall, night ....

Variables 'Tempo': The time it self.

If its value is '0', it will be midnight.

If the self value is '300', it will be noon.

The first thing is whether it will start day or night.

The event is: When starting the Layout, set the variable 'Ajuste_Dia_e_Noite' equal to "Day or Night"

If set to "Day", the variable, 'Tempo', must start with the value equal to' 0 ';

If set to "Night", the variable 'Tempo' will have to start with the value equal to '300'

The photo was set to "Day".

With the 'Every Tick' event, the 'Sky' background (name of the layer) will be adjusted at all times.

We put the action of adjust the background of the layer to the values of:

Red (R) = 0

Green (G)= Half of the variable 'Tempo'

Blue (B)= The variable itself 'Tempo'

Obs.:The 'text' plugin has nothing to do with the system. He is there to track the value of the variable 'Tempo' along with the change of background.

With the 'Every X seconds' event, we will make the 'Tempo' variable move forward or backward. However, we need to know, or rather, C2, whether it is day to move forward or whether it is night to retreat, as seen previously. We place a sub-event by comparing the value of the variable 'Ajuste_Dia_e_Noite'.

If you have the text "Day", it will advance from 0 ~ 300; So the action should be to add '1' of the variable 'Tempo'.

If you have the text "Night", you will return from 300 ~ 0; So the action should be to subtract '1' from the 'Tempo' variable.

Note: The value placed in X will be how long the time will advance or retreat in seconds.

Now the time (itself the 'Tempo' variable) is already advancing or retreating as it was set at the beginning. However, it will advance or retreat forever, because it does not have a limit where it says that: when it reaches the same (Limit), the opposite will happen.

We put this limit, which will be 300 itself. For, with the blue (of the 'Sky' layer) being 300, and the green (of the 'Sky' layer) being its half, 150, the background blue shown will be practically The noon time.

We added the Event:

If the variable 'Time' is equal to '0', set the variable 'Ajute_Dia_Noite' to 'Day';

If the variable 'Time' is equal to '300', set the variable 'Ajute_Dia_Noite' to 'Night';

With this, the variable 'Tempo' is advancing: ... 297,298, 299. When it reaches '300', it will begin to retract: 300, 299, 298 .. causing the blue to remain blue, but it goes dark when passing of time. When it reaches '0', the tempo will advance again, causing the midnight black to brighten to blue.

.CAPX

efeito-dia-e-noite.capx

Download now 172.34 KB
  • 0 Comments

Want to leave a comment? Login or Register an account!