android - Starting a while loop (game update loop) at the end of onCreate & listen to any onClick events -


i've searched on , on , couldn't find may able use. maybe keywords wrong i'm trying turn-based multiplayer game on android , activity battle occuring run battleloop() function @ end of oncreate.

this battleloop this:

  1. (while playerhp >= 0 || opponenthp >= 0), steps 2-6
  2. retrieve who's turn database
  3. if it's player's turn, allow player tap attack or defend button. while it's player's turn, nothing until player inserts action. keep information send database.
  4. if not player's turn, keep on checking who's turn it.
  5. when both done, calculate, apply , update db
  6. checkwin (to see won)

the problem while loop. can't figure out way start function battleloop() after oncreate finished. want function work similar update() function in game engines such unity function executed after oncreate finished executed.

things tried:

  1. function call @ end of oncreate
  2. threads & system.sleep (to allow pausing while player inputs action)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -