Turn day on and off

0 favourites
  • 11 posts
From the Asset Store
Action packed 2 track pack for use in your projects
  • Hi guys, I'm trying to change from night to day using layers and only one key (shift key). I already did it using shift key for turning day on and ctrl key for turn it off, but I just want to make it happen when I press (shift key) on.

    Here the event sheet.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set a variable like IsNight to either true or false and have the button toggle that value then set day or night based on the current setting.

  • Hi Klkitchens, when I try to add a variable in the event sheet, it only let me put the variable type in number or text, I don't see the Boolean option so I can turn it true or false.

  • Got it, but even using numbers is not working for me, I dont know why. Anyway, there is no way that I can make an event that toggle on and off layers? I can make them invisible but the collisions of the objects are still there, so it seems the layers even if they are invisible, they are still active. Maybe if I play with layouts it might be easy?

  • What is changing between day and night?

  • I had a menu I made appear and disappear by putting all the parts in a family called "Menu" and setting the Y location of the family to -Menu.Y

    as the toggle.

    When the menu had a Y location of 400 on screen, toggling it was setting to -400. Which moved it off screen.

    When it was -400, off screen, it was the same toggle which set it negative it's current location of -400, which was 400.

    When it was at -400, it was off screen, so nothing could be clicked.

    So basically, it hides the whole thing in an unclickable way in one event.

    Edit: Made an example Capx:


  • Hi Paradox, this example helps me a lot with my situation. I have another problem, now that I set the platforms to move out of the layout, I want my character to stay in the layout but this is not possible since the character is standing with the behavior (platformer) and is on the top of a platform that is solid. So every time the whole layer with the platforms move outside, it also brings the character. I know this is the problem because when I press the key to move the platforms outside while I'm jumping, it did not put the character outside. Sorry for my English, hope you understand what I'm saying.

  • Nevermind, is now working, here the test already done, thanks a lot Paradox and klkitchens. giovannyarce.com/day_and_night for toggle the day and night, press the "ctrl" key and move using keyboard arrows. The blue platforms that are in day can be moved with touch drag and drop. giovannyarce.com/day_and_night

  • If you want specifically to use the Boolean Function, Another option is that you could make a null object called "Day_Night_Toggle" and assign it a Boolean instance Variable that you call when you want in the Event sheet..or just assign the Variable to an existing object in the layer you want to toggle

    Null objects are common usage in Games Design.

    Null object can be a small invisible or Transparent Sprite created the usual way and has the added benefits of being an entity that you can easily access with other function calls..or implement other EFFECTS to like WEBGL

    Often I find Simple Color Overlays are good for Day/Night Transitions..

    and also allow lighting FX

    <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I don't know how you fixed this, but for future reference:

    create global variable: Toggle_Daylight (set initial value to 0)

    On SHIFT key pressed: -> set Toggle_Daylight to 1-Toggle_Daylight

    Toggle_Daylight = 1 -> Set Daylight to Day

    Toggle_Daylight = 0 -> Set Daylight to Night

    This should work for any "toggle" type situation


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