Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hello I'm looking for a bit of advice in which way is the best to proceed creating my applications 'gameloop' - It doesn't want to be a game loop in the truest sense since I'm not really rendering any graphics just displaying some animated gifs.

My goal is to have a task that runs every 30 minutes that decrements pet variables

Example Method 
passTime { <pets health> = <pets health> - 1; <pets hunger> = <pets hunger> -1; <pets exp> = <pets exp> + 5; } et

c. I was wondering the best way to go about this? AsyncTask will be of no use since this ideally wants to be running even when the app isn't.

I would rather use an IntentService subclass rather than a Service subclass but I can't seem to get the IntentService to run through a pendingIntent via the AlarmManager.

So I'm asking advice on the best way to proceed from the ground up with this. Thank you!

share|improve this question
2  
Could you just record the time of the last 'feed time' or 'pass time' and on app-open check then? Or is this not okay, since the pet cannot have damage done when the phone is off? –  Vaughan Hilts Feb 23 '13 at 0:39
    
I could do this but for example if I had it running through a service I could notify the user when certain conditions are met if (pet.hunger <10) { toast,notification etc..} the idea is for the app to have its own 'digital' timeline (or loop) (starting from when user selects pet) –  Pheonix2105 Feb 23 '13 at 0:50

1 Answer 1

If you are looking for your 'tick' method to be called every X minutes, you could look at using a timerTask. This will allow for your method to be called at a specific time.

You can find some more information and an example here: http://enos.itcollege.ee/~jpoial/docs/tutorial/essential/threads/timer.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.