Transition Effect

Get help using Construct 2

Post » Mon Oct 20, 2014 1:16 am

I'm trying to create a generic function that will slowly transition the screen from visible to black. The premise is that the "Fade" function will accept two parameters. The first parameter will determine how much the fade will decrease by and the 2nd parameter determines how many times it will cycle through/repeat until it is done.

When I run this block of code though, the effect is instant and I eventually appear on Layout 2. What I'd hope would happen is that you'd see the screen gradually fade and then you'd emerge on Layout 2.

Image

Any help on what I've done wrong would be greatly appreciated! I tried adding Wait in the loop various times with no success. I also had originally tried Repeat (Function.Param(1) times as opposed to the for loop but it made no difference.
B
3
Posts: 6
Reputation: 187

Post » Mon Oct 20, 2014 3:01 am

Hey Twinblake,

i am trying to achive the same, but i am stuck as you are...
fader.PNG

it seems like the *dt not work within functions. if i leave the function away and just do the script so it fades in and out again smoothly as it should. but as soon as i put the action within the function it stops to work, even if i call the function. however wenn i set a total value of opacity in the function it also works...

to be hornest i have no idea whats going on there O_o
You do not have the required permissions to view the files attached to this post.
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » Mon Oct 20, 2014 9:23 am

Hey, thanks for the response. I'm glad its not just me, but it seems really strange to me. I'm no expert programmer by any means, but I'd think that functions here work just like Methods in Java not sure why it's failing. I was hoping to teach students how functions can be useful using this easy block of code.

In debug mode, somehow the fade variable gets set to -809 almost instantly. I have no idea how it could've ever get to -809 using this code.
B
3
Posts: 6
Reputation: 187

Post » Mon Oct 20, 2014 5:56 pm

@TWINBLAKE @J0schi check out the example CAPX's that come default with the Construct 2 download. They have some transition effect examples that you can tweak, those may help you achieve what you are looking for.
B
13
S
5
G
1
Posts: 119
Reputation: 2,292

Post » Mon Oct 20, 2014 6:05 pm

Thanks for pointing this out, i will have a look at it :)
but it would anyway interest me why the function dont work at this place...
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » Mon Oct 20, 2014 11:30 pm

So what I did (on my phone so no links or pics sorry):
1. Create a black tililing background object the size of the screen.
2. Set it to global and place it on another layout (where I usually keep all my objects tidy)
3. Add the fade behavior twice to it and set its opacity to 0
4. Set one behavior with a fade in time, and the other with a fade out time, disable both at start, and tell only the fade out behavior to destroy after fading out
5. When I want to transition, I call a function to:
5A. Create and place my black tiling object inside and on the top layer and at position 0,0.
5B. Start the fade in behavior (which fades the object to black)
6. Add event that only fires when our black object has an opacity of 100 (fully black) (I think there may have been another condition but I can't remember at the moment):
6A. Transition to your target layout
6B. Begin the fade out behavior (which will fade out the black object and reveal your new layout)
7. The object, because you set it to destroy on fade out, will be gone!
8. ???
9. Profit
ImageImageImageImage
B
62
S
19
G
51
Posts: 633
Reputation: 30,816


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, MaxxMunnn and 5 guests