Slow/Laggy response time..

Discussion in 'iOS Development' started by jdubyab, Jun 30, 2009.

  1. jdubyab

    jdubyab New Member

    Joined:
    Jun 29, 2009
    Messages:
    7
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Hey,

    I have a REALLY simple openGL app derived from the template... The animation timer interval is 1/60, and it calls my selector drawView().

    The app has 6 total sprites on the screen: 1 background image, and 5 sprites that move around the screen. For some reason, I am getting EXTREMELY slow/laggy response times from moving these sprites around. I'm wondering if its possibly because I am doing all of the updates for these sprites within the drawView() before I do the rendering.

    Do I maybe want to create a separate timer for updating these sprites, and keep the drawing on a separate timer? It's really odd behavior, sometimes its smooth and doesn't seem to get bogged down, and others, it seems to be really slow and laggy.

    It seems odd that such a simple app with very little happening would have such slow, sluggish behavior.

    Any help or possible theories would be greatly appreciated here.

    EDIT:

    One of the sprites velocity is changed based on accelerometer values... maybe that has something to do with it?
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    My best guess would be that the accelerometer is the problem, trying to update like that. Would you mind posting your drawing selector so that we can maybe spot the problem?
  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    It's more than likely your actual code. Separating your drawing out is generally a bad idea. You want to draw as much at one time as possible.

    Did you set the accelerometer to the appropriate refresh rate for your app (try setting a slower accelerometer refresh and only redrawing whatever is accelerometer based when that triggers)? How are you calculating positions? There are so many places where your code may have gone wrong.
  4. jdubyab

    jdubyab New Member

    Joined:
    Jun 29, 2009
    Messages:
    7
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    I didn't realize you could adjust the accelerometer refresh rate, I will give that a shot.

    Thanks.
  5. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    Maybe you shouldn't think and draw in the same selector, that could lag it.

    The idea of a new timer that updates the sprites location sounds good, maybe even a new thread.

Share This Page