For the snoball game i am developing i am using matrixes for the snoball variables. This allows to create flexible code and to automatize tasks.
I tried to use the same technique with sprites, but DS LUA crashes without explanation

1) sprite loading (works ->balls appear on screen)
Sprite.LoadPalette( SCREEN_BOTTOM, PALETTE_BALL, "ball1x.pal" )
BallFrames = FrameStrip.Create( SCREEN_BOTTOM, 8, 8, "256" )
BallFrames:LoadBin( "ball1x.raw", 1 )
ball_spr = {}
for i = 1,4*BALL_NMAX do
ball_spr [ i ] = { Sprite.Create( BallFrames, 0, PALETTE_BALL, SCR_XMAX, SCR_YMAX ) }
end
2) ball variables are contained in other matrix (works -> verified by printing values on screen)
ball = {}
for i = 1,4*BALL_NMAX do
ball [ i ] = {player = 0, xpos=SCR_XMAX , ypos=SCR_YMAX, dir=0, on=BALL_OFF }
end
2) But when i try to redraw the sprites the system crashes!
for i = 1,4*BALL_NMAX do
ball_spr [ i ]:MoveTo( ball [ i ].xpos, ball [ i ].ypos )
end
Note: the same ":Move" funtion works fine with sprites that are not values inside a matrix
Any idea of what i do wrong?