Fade in/Fade out
#1
Posted 05 September 2010 - 12:00 AM
image_index 1
image_index 2
Is it possible to make 'Fade in' and 'Fade out' effect than I change that sprite image_index?
#2
Posted 05 September 2010 - 12:19 AM
im afraid theres no function for that.Hi there.I want to ask.For example I got one sprite with:
image_index 1
image_index 2
Is it possible to make 'Fade in' and 'Fade out' effect than I change that sprite image_index?
#3
Posted 05 September 2010 - 12:30 AM
You can make an image fade in by making a code that keeps on increasing its alpha. FOR EXAMPLE:
In Create Event of object that you want to fade in:
image_alpha = 0
In Step Event:
if image_alpha != 1
image_alpha += 0.1
The image would become 10% more visible every frame, until it is fully visible. COOL EH!?
#4
Posted 05 September 2010 - 02:14 AM
if image_alpha != 0
image_alpha -= 0.1
Edited by ChickenViking, 05 September 2010 - 02:14 AM.
#5
Posted 05 September 2010 - 02:26 AM
I'm just guessing here, but to fade out again, won't you need to write
if image_alpha != 0
image_alpha -= 0.1
Yes, but DO NOT put that in the same place.
If you have
if image_alpha != 0 image_alpha -= 0.1in the same place as
if image_alpha != 1 image_alpha += 0.1then the code will NOT WORK. This is because every frame, it will subtract AND add 0.1 image_alpha.
If what you want to do is make it fully fade in, then fully fade out, do this:
IN CREATE EVENT:
alarm[0] = 1 //activate alarm[0] in one frame
IN ALARM[0] EVENT:
if image_alpha != 1 //if it is not fully visible
{
image_alpha += 0.1 //make it 10% more visible
alarm[0] = 1 //repeat in 1 frame
}
else //if it IS fully visible
if image_alpha != 0 //blah blah blah
{
image_alpha -= 0.1
alarm[0] = 1
}
NOTE: Do not leave things invisible, as they take memory. Make sure to add instance_destroy whenever something finishes fading out.
Edited by skunkchop, 05 September 2010 - 02:27 AM.
#6
Posted 05 September 2010 - 04:11 AM
#7
Posted 05 September 2010 - 04:17 AM
Tell me if you need any more help.
#8
Posted 05 September 2010 - 04:18 AM
#9
Posted 05 September 2010 - 04:22 AM
image_alpha = 0;
in the step event
image_alpha += .1;
if image_alpha > 1 image_alpha = 1;
and in the room end event
image_alpha -= .1;
Edited by regniwekim, 05 September 2010 - 04:23 AM.
#10
Posted 05 September 2010 - 10:34 AM
//room end event ;)
while (image_alpha > 0) { //as long as image_alpha is greater then 0, do the following:
image_alpha -= 0.05; //subtract 0.05 from the image alpha
screen_refresh(); //refreshes the screen with the new draw events
screen_redraw(); //redraws the screen with the refreshed screen
}I hope this works
#11
Posted 05 September 2010 - 03:06 PM
alarm[9]=1;
then in alarm[9]:
if (image_alpha>0)
{
image_alpha-=0.1;
alarm[9]=1;
}
else
{
room_goto_next();
}
that will fade the player out and then goto the next room...
Hope that helped!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











