How to make an update loop?

Discussion in 'iOS Programming' started by gizzerd91, Jul 18, 2009.

  1. gizzerd91 macrumors newbie

    Jul 15, 2009
    I have read through the cocoa programming guide (the first half, atleast), and the "Your first iPhone App" tutorial from Apple. From what I understand so far iPhone Apps are event driven, like Flash programs (when a button is pushed, a function is called to handle it). But I want to make games, and that requires updating every frame, regardless of whether any events occurred or not. Is there an event that occurs every frame that I can use to update game sprites and run AI, etc? In Flash I would do it with a object.onEnterFrame() function, if that helps anyone understand what I'm talking about.
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    It's done with an NSTimer. You set up a timer to call back your code for each frame.
  3. Kingbombs macrumors member

    Jun 24, 2009
    The OpenGL ES template does this for you, you just have to enter your code to say what you want to draw and where

Share This Page