Index out of range on tick plus speed prob.

Discussion in 'Questions (Windows Mobile)' started by enonod, Jul 11, 2009.

  1. enonod

    enonod Well-Known Member Licensed User

    Sorry to be asking so many questions but after attempting to find the solution I see no alternative.
    The attached code illustrates my two problems.
    1. Line 53 error index out of bounds I find baffling. Removing line 73 removes the error but of course the result is incorrect.

    2. The AddSprites sub has slowed the action by say, 50%. The sprites are static and although of course repainted, I cannot see that it is likely to be the cause.
    Removing line 50 recovers the speed.
    Any help appreciated.
     
  2. agraham

    agraham Expert Licensed User

    Your Pawns have six frames which means CurrentFrame can be between 0 and 5. You are setting Pawn.Data, and hence CurrentFrame, to values higher than 5 which means Tick is trying to access non-existent frames.

    Your Timer interval is unrealistic at 1mS. Tick probably takes longer than this to run with 40 Sprites so the update speed is dependant on the number of Sprites being drawn. A value between, say, 20 and 60 would be more appropriate.
     
  3. enonod

    enonod Well-Known Member Licensed User

    Thanks and sorry. I was blinded by the Mod 3 and ignored the shifting bit.
    1ms is now obvious as too short a time, however the sub is actually part of the main app and only called once, therefore apart from repaint nothing should be happening. Changing the interval to anything upwards (to 100) makes no difference except to get slower. So I still can't see the reason for the speed cut.
     
    Last edited: Jul 11, 2009
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice