How to access iOS clock?

J1000

  • Posts: 24
I tried this code from another thread, but I don't know how the AS and the Stencyl pieces interact.

coleislazy

  • *
  • Posts: 2607
That's AS3 code, and won't work with an iOS game. I don't know the Objective-C code, sorry.

Play

  • Posts: 165
Bumping this thread cause what I'm currently working on completely depends on bein able to access the clock as well. Hopefully there is a way -- if not, I'm sure it wouldn't be difficult to implement in a future update.

Photics

  • *
  • Posts: 718
Bumping this thread cause what I'm currently working on completely depends on bein able to access the clock as well. Hopefully there is a way -- if not, I'm sure it wouldn't be difficult to implement in a future update.

Here's the Xcode document...
http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html

Ideally, there would be a StencylWorks block that would let developers grab a UNIX timestamp. That means strategy games like FarmVille could be created.
Michael Garofalohttp://photics.com – Author of The Interactive Stencyl Textbook 8)

Jon

  • *
  • Posts: 17524
http://community.stencyl.com/index.php/topic,3129.0.html

Time support is trivial to add - it's just a matter of providing it in the format you need.

Play

  • Posts: 165
http://community.stencyl.com/index.php/topic,3129.0.html

Time support is trivial to add - it's just a matter of providing it in the format you need.

This format would be the most versatile:

I'm thinking a block with a dropdown that contains:

ms (maybe not?)
seconds (within current minute)
minutes (within current hour)
hours (within current day)
day of year (out of 365)
week (out of however many there are)
year

Then some seperate blocks for

"Current Day" (reports saturday, sunday etc)
"Current Month" (reports april, may etc)
"Current Season" (Winter, Spring, Summer and Fall/Autumn. Fall should probably be used.)

In my case, the simpler and more straight forward a method the better. I have practically no programming experience so even using something as intuitive as Stencyl has been a strenuous (and rewarding) learning process.

Innes

  • *
  • Posts: 1960
I think that Current Day and Current Month should return integers. This has numerous benefits including resolving language issues, allowing calculations dependant on month of year, etc.

If required, the name of the day / month could be pulled from global attribute lists using the integer of the day / month to return the appropriate text.

I'm not sure how returning a 'season' could work because seasons vary depending on the part of the world in which you live. I think it's the sort of thing that would be determined by the designer, rather than being an inherent part of Stencyl. It would be very easy to code, e.g.

[if month > 12 and month < 2 then season = "summer"], etc.

Jon, with regards to the code being 'trivial to add', when do you think you could implement this? By the end of this week would be great, as I have a couple of applications I would like to create using the system time / date. Only joking of course; I was thinking of maybe allowing you two weeks!
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Photics

  • *
  • Posts: 718
Time in a human readable format is good, but just a generic UNIX timestamp is also good. That makes it easier to do calculations.

If I planted a tomato now, do I want to know that it was Tuesday, February 7 at 7:00 AM? That's nice for the player to know, but if I wanted to calculate the harvest time, using timestamps is easier...

http://www.4webhelp.net/us/timestamp.php?action=date&day=07&month=02&year=2012&hour=12&minute=00&second=00&timezone=-5
1328634000 gives me a starting point.

All I need to do is figure out how many seconds that tomato needs to grow. It could be a year, a day, 60 seconds, it doesn't matter. I just give it a number in seconds. I don't have to worry about New Year's Day, leap year or any of the complicated calendar stuff.

The only problem with timestamps is that I think iOS is 32-BIT, so this might be a problem in the year 2038  :P
Michael Garofalohttp://photics.com – Author of The Interactive Stencyl Textbook 8)

applaud

  • Posts: 370
@Photics - if your tomatoes haven't grown by 2038 I would give up and go back to your games ;-)

Basseman

  • Posts: 208
Please add the trivial things like iOS time & date, keyboard asap and maybe tables ??

Cheers !!

Play

  • Posts: 165
Time in a human readable format is good, but just a generic UNIX timestamp is also good. That makes it easier to do calculations.

If I planted a tomato now, do I want to know that it was Tuesday, February 7 at 7:00 AM? That's nice for the player to know, but if I wanted to calculate the harvest time, using timestamps is easier...

http://www.4webhelp.net/us/timestamp.php?action=date&day=07&month=02&year=2012&hour=12&minute=00&second=00&timezone=-5
1328634000 gives me a starting point.

All I need to do is figure out how many seconds that tomato needs to grow. It could be a year, a day, 60 seconds, it doesn't matter. I just give it a number in seconds. I don't have to worry about New Year's Day, leap year or any of the complicated calendar stuff.

The only problem with timestamps is that I think iOS is 32-BIT, so this might be a problem in the year 2038  :P


I agree, it would be best to be able to access both.

And like the above poster I would also really like access to the keyboard. I am making progress on my game but will want to implement both time based and keyboard based features for sure, both will be very important, so if it is true they are rather simple to add I'm sure most would agree the sooner the better.

By the way I apologize for being so insistent, especially as just a lite user. Just want to make sure I'll be able to do all I will need to to flesh out my game concepts before I purchase pro!

« Last Edit: February 07, 2012, 10:03:59 am by Play »