Day/Night Cycle

0 favourites
From the Asset Store
Setup and ready for your art, animations and story. Viral Storybook App Template.
  • Hello all,

    I have been creating a day/night cycle for my game and have run into one issue. First, let me explain how I did it.

    I have one instance called Day_Night. It is as big as the width of the viewport and square. One corner has the sun, the other has the moon and the image point is in the middle. It has the rotate behavior and is on a layer called Sun/Moon with parallax 0,0. Then is the Darkness object. It has the fade behavior and is programmed to fade in or out to match the sun/moon. It is also on layer 'Darkness,' which has 'force own texture' enabled and is parallax 100,100. This all works fine.

    The problem is that the darkness layer is higher than the Sun/Moon layer and covers up the sun and moon. I have light instances that work like the 'Simple lighting example' project on the start page. They are on layer 'Darkness' so they pierce the darkness. I cannot get them to stay at the sun and moon, because they are on different layers with different parallaxes. I have tried the 'Every tick set position' and the pin behavior. Keep in mind that the sun and moon are one object and that I cannot move the layers around due to how my game works.

    Any help with this will be appreciated.

    Thanks, Give me a Pixel

    Sun_Moon object:

  • you can get from a position on one layer to that position on another layer using "LayerToCanvasX" and then "CanvasToLayerX"

    so, you might want to put image points on your Sun-Moon...

    it was easier to make a sample than try to explain it.

    https://www.rieperts.com/games/forum/sunmoon.c3p

    the sun/moon are on the "Game" layer because the free edition only allows 2 layers, but you should get the idea.

  • Thanks I will try it out. :)

  • You could also use imagepoints to mark the exact position of the sun and the moon, instead of the position of the whole imagem.

    Cheers!

  • AllanR

    Thank you it works! Now I just have to figure out how to get the light to be behind the ground.

    brunopalermo

    I have image points in the middle of the sun and moon. If you look at the picture you can see them in the image points bar on the left.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry for the double post but I don't know how the best way to put the light behind the ground is. The ground layer is behind the darkness layer.

  • have the sky (sun/moon) and darkness layers behind (lower than) the ground layer.

  • I'm afraid I cannot move the layers around or it will mess up my game. Any other suggestions?

  • Can you share a file? It's very hard to help without knowing your whole setup...

  • a good rule of thumb is to always reference layers by name instead of the number - just so you can add or move layers without trouble...

    how many events do you have? it might be easier to replace all layer references with a name

  • My game programming I would like to keep private, but I can share a screenshot and information that you need.

    AllanR

    I always do reference layers by name rather than number. . . and I have almost 300 events!

  • ok, then there should be no problem to move the sky and darkness levels to the bottom.

    normally, the bottom layer is set to not be transparent, so make it transparent. And then set the sky layer to not be transparent...

    are there other reasons why you don't think you can move the layers? 300 events isn't too bad to fix issues to make it do what you want!

  • I want the darkness to cover the ground, player, enemies, etc. The light should be able to shine through the darkness and reveal the objects underneath. The player can also hold torches to provide light. I don't want to move the layer to the bottom.

  • ok, the darkness can stay above the ground, maybe just move the sky to the bottom.

    see this example I made several months ago...

    the moon is on the bottom layer, but has a light on the darkness (MaskLight) layer. the torches, player and fireflies all have their own light too...

    https://www.rieperts.com/games/forum/LightMask.capx

  • Very cool example, but how can I use this to make the sun/moon light stay on layer 'darkness' and stay behind the ground?

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