Gradual Transparency Changes

Learn how to start making games.

Gradual Transparency Changes

Postby PerrySteven » Wed Feb 03, 2016 8:07 am

Hello, I'm wondering how I can accomplish a gradual transparency change of an actor in Game Editor?
User avatar
PerrySteven
 
Posts: 46
Joined: Sun Jan 25, 2015 4:29 am
Location: Malaysia
Score: 1 Give a positive score

Re: Gradual Transparency Changes

Postby simranjit » Wed Feb 03, 2016 11:11 am

If you mean how to smoothly change the transparency value of an actor during runtime, you can increase/decrease the transparency of an actor in the draw actor event controlled by appropriate script.
Use Actor variable 'transp'

From Script Reference:-
transp:The Actor'stransparency setting (0.0 - 1.0)

Use something like
Code: Select all
if (varX == 1)
{
Player.transp += 0.1;
}



[And hey guys I'm back]
simranjit
 
Posts: 88
Joined: Thu Jan 08, 2015 10:43 am
Location: Earth, The Solar System, Local Interstellar Cloud, Local Bubble, Orion–Cygnus Arm, Milky Way
Score: 21 Give a positive score

Re: Gradual Transparency Changes

Postby MrJolteon » Wed Feb 03, 2016 12:40 pm

simranjit wrote:
Code: Select all
if (varX == 1)
{
Player.transp += 0.1;
}


Or you can try
Code: Select all
while(Actor.transp != 1)
{
    Actor.transp += 0.1;
}

This should work in a Create Actor event.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Gradual Transparency Changes

Postby simranjit » Wed Feb 03, 2016 1:44 pm

Yeah thats better if you want the actor to disappear smoothly.
Last edited by simranjit on Tue Mar 01, 2016 8:53 am, edited 1 time in total.
Everyone is bound to one's sphere of knowledge.
What he finds inside it, terms it as reality. And what is far beyond his reach, an illusion for him. But sometimes illusions can be a reality and reality merely an illusion.
simranjit
 
Posts: 88
Joined: Thu Jan 08, 2015 10:43 am
Location: Earth, The Solar System, Local Interstellar Cloud, Local Bubble, Orion–Cygnus Arm, Milky Way
Score: 21 Give a positive score

Re: Gradual Transparency Changes

Postby lcl » Thu Feb 04, 2016 7:09 pm

MrJolteon wrote:Or you can try
Code: Select all
while(Actor.transp != 1)
{
    Actor.transp += 0.1;
}

This should work in a Create Actor event.

Using that code will freeze Game Editor. :P
while is a keyword that repeats the same code over and over again during the same frame as long as the condition is true. And transp, being a double variable, will never be exactly 1, so the condition is never false and so the frame the actor gets created will never end - in other words, the program will freeze.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Gradual Transparency Changes

Postby MrJolteon » Fri Feb 05, 2016 8:27 am

lcl wrote:Using that code will freeze Game Editor. :P
while is a keyword that repeats the same code over and over again during the same frame as long as the condition is true. And transp, being a double variable, will never be exactly 1, so the condition is never false and so the frame the actor gets created will never end - in other words, the program will freeze.

Well I tried at least... :|
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Gradual Transparency Changes

Postby lcl » Fri Feb 05, 2016 2:27 pm

MrJolteon wrote:Well I tried at least... :|

Yes you did and it's a good thing. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Gradual Transparency Changes

Postby PerrySteven » Sat Feb 06, 2016 12:49 am

I tried what was suggested, but I didn't get to testing without coming up with compiler errors: Illegal Operations
So, I had one actor named intro, and in the code I tried to increment intro.transp but the compiler told me it was an illegal operation.
I think I have one idea I could try, perhaps to have a variable incrementation within one of the ChangeTransparency's function fields.
User avatar
PerrySteven
 
Posts: 46
Joined: Sun Jan 25, 2015 4:29 am
Location: Malaysia
Score: 1 Give a positive score

Re: Gradual Transparency Changes

Postby lcl » Sat Feb 06, 2016 5:59 am

PerrySteven wrote:I tried what was suggested, but I didn't get to testing without coming up with compiler errors: Illegal Operations
So, I had one actor named intro, and in the code I tried to increment intro.transp but the compiler told me it was an illegal operation.
I think I have one idea I could try, perhaps to have a variable incrementation within one of the ChangeTransparency's function fields.

That's weird. Try it with an actor with a different name. It could be that the name 'intro' is reserved for something in Game Editor itself.

A code like this should work with any actor if put into Draw Actor. It will fade out the actor.
Code: Select all
myActor.transp += 0.05;


Edit: And welcome back, simranjit! :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Gradual Transparency Changes

Postby PerrySteven » Mon Feb 08, 2016 6:30 am

I tried again with a different actor called "player", and this time it came up with no errors. But the game froze when I ran it.
User avatar
PerrySteven
 
Posts: 46
Joined: Sun Jan 25, 2015 4:29 am
Location: Malaysia
Score: 1 Give a positive score

Re: Gradual Transparency Changes

Postby lcl » Mon Feb 08, 2016 2:43 pm

PerrySteven wrote:I tried again with a different actor called "player", and this time it came up with no errors. But the game froze when I ran it.

What code you used? And what GE version are you using? My code should not freeze GE.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Gradual Transparency Changes

Postby Opium » Mon Feb 29, 2016 8:53 pm

You guys are slow to extent that makes it seem rather amusing.

@OP
Click the actor you wish to go transparent and Add a Draw Actor event and select the Script Editor action.
And paste this code:
Code: Select all
transp += 0.01;

First off, the transp member variable per se is of dynamic type and it cannot go higher than 1. And that means the condition is redundant.
0.01 is the factor. If you want it faster, lower the value with say the half of it.

If you want to abort the transition disable the draw actor event of the actor from the Event Disable event or from some Script Editor.

You must elaborate what you mean by "changing" on the other side. What I show'd you is technically "changing", but it appears to be not so useful.
It may be useful to you, so it depends on information you didn't provide.
Opium
 
Posts: 2
Joined: Wed Aug 12, 2015 2:13 pm
Score: 0 Give a positive score

Re: Gradual Transparency Changes

Postby PerrySteven » Thu Apr 21, 2016 10:54 am

Opium wrote:You guys are slow to extent that makes it seem rather amusing.

@OP
Click the actor you wish to go transparent and Add a Draw Actor event and select the Script Editor action.
And paste this code:
Code: Select all
transp += 0.01;

First off, the transp member variable per se is of dynamic type and it cannot go higher than 1. And that means the condition is redundant.
0.01 is the factor. If you want it faster, lower the value with say the half of it.

If you want to abort the transition disable the draw actor event of the actor from the Event Disable event or from some Script Editor.

You must elaborate what you mean by "changing" on the other side. What I show'd you is technically "changing", but it appears to be not so useful.
It may be useful to you, so it depends on information you didn't provide.


Oh, I see. Well thanks for that information. I will try that out sometime. Also, I'm very slow to reply because I'm currently studying for my exams.
User avatar
PerrySteven
 
Posts: 46
Joined: Sun Jan 25, 2015 4:29 am
Location: Malaysia
Score: 1 Give a positive score

Re: Gradual Transparency Changes

Postby Sarmad786 » Mon Sep 03, 2018 8:11 am

You can do something like this
Global Code
Code: Select all
float GradualChange = 0.05;

Actor>DrawActor
Code: Select all
transp += GradualChange;
if(transp >=1)
  transp = 1;
Working on SpaceShooter :D
User avatar
Sarmad786
 
Posts: 12
Joined: Sat Sep 01, 2018 8:19 am
Score: 0 Give a positive score


Return to Getting Started

Who is online

Users browsing this forum: No registered users and 1 guest