Setting an infinite time

Hi,

I'm in a bit of a pickle. I'm trying to setup a scene whereby the user can set how long they play for. However, I want one of the options to be infinite i.e. if they select this, then the game wouldn't 'end', as it were. Also, if they simply jumped into the game without attempting to set a time, then the default would be to infinite.

So, any suggestions/help for setting an infinite time would be greatly appreciated!

Thanks in advance.

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2013
    A game won't end unless you tell it to end, so there's nothing you really need to do for a game to continue forever.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    A game won't end unless you tell it to end, so there's nothing you really need to do for a game to continue forever.
    8-X
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    A game won't end unless you tell it to end, so there's nothing you really need to do for a game to continue forever.
    Except maybe make sure the device is on continuous charge.

  • DaveGWelshDaveGWelsh Member Posts: 60
    Back on this one i'm afraid.

    I want to allow the user to set a number of set time pieces ; infinite, 2 minutes etc. I have the 2 minutes working but how do you get an infinite timer setup?

    Thanks in advance!
  • bjandthekatzbjandthekatz Orlando, FlMember Posts: 1,375
    I dont really know what you mean but I'll try to help.
    2 Minutes- Set timer to 120 (60*2)
    5 Minutes- Set timer to 300 (60*5)
    Infinite- Dont use a timer
    When time = 0 change scene finish.

    or simply remove the every .1 seconds remove .1 second from the timer for infinite.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Maybe you can explain why you think you need an infinite timer. Because otherwise, this:
    A game won't end unless you tell it to end, so there's nothing you really need to do for a game to continue forever.
    Do you actually mean that you want to display a timer that never stops? To do that, add a Timer behavior set to Every 0.1 seconds change attribute game.theTimer to game.theTimer + 0.1 and then use a DisplayText behavior with game.theTimer in the expression editor to show the timer.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • DaveGWelshDaveGWelsh Member Posts: 60
    Kinda.

    It runs like this. The user can select infinite, 2, 5 or 10 minutes of play. I've got the 2, 5 and 10 working now but not sure how to get the infinite working. SO basically, if the user selects infinite (which is default) the game would never stop.

  • DaveGWelshDaveGWelsh Member Posts: 60
    Thanks @bjandthekatz. I initially had this but it would never kick in when using a timer over 500 seconds for some reason.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Thanks @bjandthekatz. I initially had this but it would never kick in when using a timer over 500 seconds for some reason.
    In your other thread, I offered to help figure out why your longer timers are not working. Let me know if I can be of assistance.

    But as @bjandthekatz stated, if you want an infinitely long game then you don't need a timer at all. By definition, every single game on the app store is "infinitely long" until you die/lose, unless that game has some sort of timer counting down.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • DaveGWelshDaveGWelsh Member Posts: 60
    Hi Tatiang,

    Your solution in the other thread worked perfectly! The problem is though I have this logic.

    I set up a boolean check to see if the user has selected a time. if they do, it sets this to 'True'. Within this rule is the timer i.e when TimerActive = TimeSelected (600 seconds for example) do this (which is load another scene).

    This works fine for infinite (which sets the Timer to False), 2 and five but its the 10 minutes that just seems to cause it to fail.

    So, I pulled the timer out of the rule and it works fine but this means that the game doesn't run when set to infinite.

    Urgh :)

    Thanks so much for your help though, it's much appreciated!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I'm guessing, then, that your boolean is getting set back to false at some point. Try checking "Run to completion" in your timer and see if that helps. Otherwise, without seeing the file I don't have any more guesses.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • DaveGWelshDaveGWelsh Member Posts: 60
    Ok, this is weird.

    I just deleted it and re-did it from scratch and now it seems to work!

    Weird/crazy.

    however, thanks again though, your help was awesome!
  • SocksSocks London, UK.Member Posts: 12,822
    Do you actually mean that you want to display a timer that never stops? To do that, add a Timer behavior set to Every 0.1 seconds change attribute game.theTimer to game.theTimer + 0.1 and then use a DisplayText behavior with game.theTimer in the expression editor to show the timer.
    Could you not simply have a display text that read: prec( game.Time ,1) ?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @Socks, yes but not if you want the timer to start at some time other than when the app or scene begins. Hence the custom attribute. And I didn't get into prec() but it's useful for the custom attribute as well.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @tatiang
    @Socks, yes but not if you want the timer to start at some time other than when the app or scene begins. Hence the custom attribute. And I didn't get into prec() but it's useful for the custom attribute as well.
    Ah ! Yes, of course, you could use: prec( self.Time ,1) or like you say a custom 'time' attribute which gives you a lot more options.

    You know I get easily confused if you don't put 'sin' or 'cos' in your posts. ;)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You seem to have a singular focus 'cos that's what you keep sayin'.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited January 2014
    @tatiang
    You seem to have a singular focus 'cos that's what you keep sayin'.
    You are aware that the NSA have a bad pun department aren't you ?
Sign In or Register to comment.