Mobianhero
Mobianhero

Reputation: 279

Real Time timing for iPhone game

I'm making a game like the game Evony for iPhone but instead of being an MMO it is single player. For those of you that don't know about Evony, in the game you upgrade your own buildings and the buildings take a certain amount of time in real life to upgrade. Evony runs off a server but I want my iPhone game to run off of the app. Which leads me to my problem of the game needing to continuously update the time while not running. I'm new to using the clock system in programming and was wondering if any of you could help me.

Upvotes: 0

Views: 135

Answers (1)

Crake
Crake

Reputation: 1679

When the building object is created, mark it with a created time stamp. Then, whenever the view is loaded, or it awakes, compare the current date and time to the created time stamp, giving you the 'lifetime' of the building.

Here is how to get the current date and time in iOS sdk:

[NSDate  date]

Upvotes: 3

Related Questions