Day & Night Cycle?

  • I just found out about construct 2 and started scraping some kind of mini survival game from scratch with little to no tutorials.

    So far I've made a good progress but got stuck on day&night cycle for a long time, because I use a black layer on top of everything as pure night and an black object with destination out blend mode as a sun in order to get a player light range around my character sprite at night , so a fade behaviour was not a way to go and while loops kept crashing my stuff even with stop loop action and changing booleans , so this is my outcome which actually works as intended and even tells me when it's actually full night (night = 1 , not counting day -> night transition) in order to spawn enemies and stuff at night. Any ideas how else could this been done or improwed?

    also: the opacity goes from 100 to 10 that's why its +9 and -9 repeating 10 times instead of +&-10

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Had some fun coming up with this one because there's a lot of ways to do this.

    This is what I came up with it is very simple and versatile and can be changed on the fly, it uses a simple timer and then sets the Opacity every tick with a simple ratio.

    Timer.CurrentTime / Timer.Duration * desired opacity[/code:v7jov4dx] 
    Then at the end of the timer it sets a global variable to night. 
    
    Then for transitioning to day we do is this
    [code:v7jov4dx]desired opacity -Timer.CurrentTime / Timer.Duration * desired opacity[/code:v7jov4dx] 
    
    This is what it looks like in the editor [img="http://puu.sh/rwBKx/c68b5dedd9.png"]
    
    Anyways here's the example if you have any other questions just ask, and if you have any future problems feel free to contact me. 
    Good luck on your project <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">
    [url=https://www.dropbox.com/s/ex1i40l9l0afqxx/day%20and%20night%20example.capx?dl=0]https://www.dropbox.com/s/ex1i40l9l0afq ... .capx?dl=0[/url]
    
    How timers work [url]https://www.scirra.com/manual/167/timer[/url]
  • I PMed you a bit ago so here's an example cooked up for you:

    https://dl.dropboxusercontent.com/u/589 ... ystem.capx

  • Thanks for your variations guys

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