NECTES Global Media Technology Website.

Building a Game Loop in iPhone and iPad Game Development

3 72
Read More:
1 of 119
More Publications You Missed!
1 of 119

A game loop gets your code to update the game world on your iPhone or iPad many times a second — fast enough to make it look like fluid motion to the player.
To do this, you need to update the position of all your views every time the screen is redrawn by iOS. To be notified of when this happens, you need to use a CADisplayLink class. CADisplayLink is an object that, when you create it, sends your class a message just before the screen is about to update. This gives you the opportunity to move your views around.
To set up a CADisplayLink.

  1. Create a method that gets called when the screen updates; make the method look like this:
    (void) update:(CADisplayLink*)displayLink {

  2. When your view is loaded, create and prepare a CADisplayLink object by adding this code to the viewDidLoad: method in your view controller’s .m file:
    displayLink = [CADisplayLink displayLinkWithTarget:self 
    [displayLink addToRunLoop:[NSRunLoop mainRunLoop]

When your view loads, you receive the update: message many times a second, which is your opportunity to update the game world.


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,129 other subscribers.

  1. Anonymous says

    Aw, this was an extremely good post. Taking the time
    and actual effort to create a very good article… but what can I say… I procrastinate a lot and never
    seem to get nearly anything done.streetdirectory :: :

  2. Anonymous says

    You're so awesome! I don't believe I have read something
    like this before. So wonderful to find another person with some unique thoughts on
    this subject matter. Really.. many thanks for starting this up.

    This website is something that is needed on the internet, someone with a little originality!

  3. Anonymous says

    Defіnitely bеliеve that which you ѕaid.

    Your favourite justification seemeԁ to be at the net the easіest factor to take note of.
    I sаy to you, I certainly get annoyеԁ at the same time
    as folks think аbout worries that they just do not knoω аbout.
    You mаnageԁ to hit the nail uрon the toρ and also defined out the ωhole
    thing without having sidе effeсt , people could take а signal.

    Will probably bе back to get mοre.


    my homepagе :: http://bikeraсeсheats.
    com/ ()

Leave A Reply

Your email address will not be published.