Making a day/night button issue

I'm trying to make my game have a brightness setting.

I have an actor than covers the entire screen (Black)...I set another actor (sun image) to interpolate to zero when "sun" is true....if touched change attributes "sun" to false and "night to true (interpolate to .5). It starts in game in "sun" mode....I can touch and it goes to half bright but will not change back to full...in fact it flickers until I release touch.

During daytime I want it full bright...when laying in bed playing or couch I want it to not be a bright flashlight in their face.

Thanks if you think you know a quick fix to this.

Comments

  • ArmellineArmelline Member, PRO Posts: 5,456

    Three questions:

    1. Are you saying you want pressing the button to interpolate the alpha value of the black image to 0.5, and if you continue to hold the button without releasing it, interpolate the image alpha back to 0?

    2. What is intended to happen if you just touch the button?

    3. What is intended to happen if you hold the button down, but release it before 0.5 is reached?

    I'm not entirely clear on how you are wanting the button to function, and understanding that is key to helping you.

  • Thunder_ChildThunder_Child Member Posts: 2,343
    edited August 2014

    @Armelline‌

    Thanks for replying.

    I want a single touch to change from "day" (interpolated to 0 by default) to change to "night" (interpolated to .5)

    Then if touched again....holding not necessary....to then change back to "day"....full bright.

    Day=0
    Night=.5

    On...off....on...off

  • zweg25zweg25 Member Posts: 738
    edited August 2014

    I don't really understand, but I think you could have an attribute called InterpolateTo and then say

    RULE: if touch is pressed

    {

     change attribute InterpolateTo to (0.5-InterpolateTo)
    
     interpolate to InterpolateTo 
    

    }

  • Thunder_ChildThunder_Child Member Posts: 2,343
    edited August 2014

    Maybe if I said it in layman's terms.

    I want to touch a little icon that looks like a sun and it change to a moon and dims the screen brightness by 1/2....then if I touch the moon it changes to a sun again and makes the brightness full.

    :-)

    I was trying to do it with this is true and that is false. And this is false and that is true...dint work.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited August 2014

    @zweg25 said:
    I don't really understand, but I think you could have an attribute called InterpolateTo and then say

    RULE: if touch is pressed

    {

     change attribute InterpolateTo to (0.5-InterpolateTo)
    
     interpolate to InterpolateTo 
    

    }

    @Thunder_Child‌ Did you try this? It should work. You would interpolate self.color.Alpha to InterpolateTo.

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited August 2014

    Use a Boolean for sun,

    If touch is pressed and sun is true

    Change sun to false

    If touch is pressed and sun is false change to true

    Then ,are your rules if sun is true

    Interpolate alpha to 0

    If false interpolate alpha to .5

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    You don't need a second Boolean for night

  • Thunder_ChildThunder_Child Member Posts: 2,343

    Ahhhh

    Thanks @tatiang‌ @zweg25‌ @RossmanBrothersGames‌

    Yea I had a second Boolean. I like and understand the single Boolean. Makes sense. Thanks guys.

  • Thunder_ChildThunder_Child Member Posts: 2,343

    hmmm....this does not work still...absolutely to function happens...

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    @Thunder_Child‌ does it still flicker? I think it is just going back and forth between each rule quickly as the set of rules become true. Maybe have a display text that displays the game.DayBright to see if it is changing to true and false correctly.
    You may need another boolean you can call press_ready.

    In both those rules for the button, add if press_ready is true

    then after it changes game.daybright have it change press_ready to false

    then make another rule,

    when press is released

    change press_ready to true

    this way it only lets you do one of the actions per press

    I'm not sure actually how the pressed actions works, but that might be what is going on if it flickers between each setting

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    Will the attached demo help?

  • Thunder_ChildThunder_Child Member Posts: 2,343

    @RossmanBrothersGames‌

    It's not flickering. I was able...after my post to get it to at least dim like I want...but not full bright again.

    I can't try again until tonight...that dang day job thing :-(. Lol.

    @RThurman‌
    I will check out your demo this evening. Thank you both for your help and goin the extra distance. Even a demo.

  • ArmellineArmelline Member, PRO Posts: 5,456
    edited August 2014

    Without trying to read through every detail in this thread and look at every example and demo, I will mention one thing you should be aware of.

    GameSalad suffers from a floating point rounding error when decreasing a number from 1 to 0. I'm not sure if it's been explored on the forums before, but it's demonstrated in the project I've attached.

Sign In or Register to comment.