Are we ok to build our own timers ?

JamJarRiotJamJarRiot Member Posts: 62
edited November -1 in Working with GS (Mac)
Here's my latest query, I'd really like to get something definitive on this as I plan on using it a lot.

WIll I be ok to run my own looping timers within GS? I have one up and running (an Attribute named Count1), it simply increments by 1 each time the System/Game Time reaches a 2 second period. From there, each time Count1 reaches a defined limit (i.e 4), a second counter attribute (Count2) increments and Count1 resets to zero and begins incrementing again and so on. I plan on using these different times for triggering various game objects and events and I don't want more than one GS Timer running as they are often singled out as a processor-intensive feature if overused.

Will these alternative timers be less of a burden on the iPhone than multiple Game Salad Timers? Your thoughts ?

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi jamma, yes, you're right, the more timers you have in your game, the more processor hungry it is. An alternative, where possible, is to check states when you need them, with boolean attributes or variables.

    ;-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • jstrahanjstrahan Member Posts: 498
    not sure if it would work but i think you could set an att. to game.time at the start and then use math to calculate your counts because you will know the start time from the att. and the current time from game.time
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    I need a rule in my game to execute every 2 second. I anticipate that having a "counter" that cycles 0 thru 9 at one second intervals may help my game later on as well.

    Here's my plan. I haven't tested this in GS yet, but I imagine it will work, and I think it may have even been discussed before.

    - Create a Game integer attribute (I'll call it `10SecTimer`)

    - Constrain `floor(game.time)%10` to `10SecTimer`

    This should give you a counter that cycles 0-9 over ten seconds.

    In my rule(set to "any") I check for `10SecTimer` = 0,2,4,6,8 and get an operation that can execute every 2 seconds.

    To change the frequency of the operation I just change which values of `10SecTimer` can satisfy my rule's conditions...

    I'll let you all know if it works. I think this would be a great way to phase out a lot of my timers, as long as they use whole seconds and don't last longer than 10 seconds. Although, this logic could be easily modified to work with tenths of a second... ;-)
  • JamJarRiotJamJarRiot Member Posts: 62
    Bark, I have a very simple Timer that you can set to any No of seconds which doesn't use a Constrain and takes up just a single rule (Two rules if you'd like a 2nd Timer triggered from the first). Let me know how yours goes, and if you'd like my version.
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    @jamma,

    I would love to see your's. email (my gamesalad username)@gmail.com I'm at work now, so I won't be able to test anything until I get home.
  • JamJarRiotJamJarRiot Member Posts: 62
    Ok, I'll try and get it done but now I've got busy... if not I'll put it up here tomorrow with a screenshot and explained.
Sign In or Register to comment.