Transition Effect

0 favourites
  • 6 posts
From the Asset Store
A total of 214 high quality and unique magic sound effects suitable for RPG, Battle Arena and more!
  • 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.

    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.

  • Hey Twinblake,

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

    [attachment=0:18sq3bug][/attachment:18sq3bug]

    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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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...

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)