It is wierd because if you call it straight then it works...
SetDisplayAspect( 4.0/3.0 )
SetSyncRate(60,1)
Type _myType
spriteID
EndType
Dim balls[100] as _myType
Global ballCounter = 0
ballImage = LoadImage("small_ball.png")
do
if GetPointerPressed() = 1
createBall(GetPointerX(), GetPointerY())
EndIf
Sync()
loop
Function createBall(xPos#, yPos#)
if GetSpriteExists(balls[ballCounter].spriteID) = 0
balls[ballCounter].spriteID = createSprite(LoadImage("small_ball.png"))
SetSpritePositionByOffset(balls[ballCounter].spriteID, xPos#, yPos#)
INC ballCounter
If ballCounter > 4 Then ballCounter = 0
EndIf
EndFunction
or if you try this
SetDisplayAspect( 4.0/3.0 )
SetSyncRate(60,1)
ballImage = LoadImage("small_ball.png")
do
if GetPointerPressed() = 1
createSprite(ballImage)
EndIf
Sync()
loop
.... it works as well.
So something is going wrong in the array or the user type.
Edit
The problem seems to be with the create sprite
This code gave an error message that the image did not exist
SetDisplayAspect( 4.0/3.0 )
setvirtualresolution(640,480)
SetSyncRate(60,1)
Type _myType
spriteID
EndType
Dim balls[100] as _myType
Global ballCounter = 0
ballImage = LoadImage("small_ball.png")
createSprite(1, ballImage)
do
if GetPointerPressed() = 1
createBall(GetPointerX(), GetPointerY())
EndIf
Sync()
loop
Function createBall(xPos#, yPos#)
if GetSpriteExists(balls[ballCounter].spriteID) = 0
balls[ballCounter].spriteID = createSprite(1)
SetSpritePositionByOffset(balls[ballCounter].spriteID, xPos#, yPos#)
INC ballCounter
If ballCounter > 4 Then ballCounter = 0
EndIf
EndFunction
It says that image 1 does not exist at line 30 but we know that it does.
Then if I used clonesprite it worked...
SetDisplayAspect( 4.0/3.0 )
setvirtualresolution(640,480)
SetSyncRate(60,1)
Type _myType
spriteID
EndType
Dim balls[100] as _myType
Global ballCounter = 0
ballImage = LoadImage("small_ball.png")
createSprite(1, ballImage)
do
if GetPointerPressed() = 1
createBall(GetPointerX(), GetPointerY())
EndIf
Sync()
loop
Function createBall(xPos#, yPos#)
if GetSpriteExists(balls[ballCounter].spriteID) = 0
balls[ballCounter].spriteID = cloneSprite(1)
SetSpritePositionByOffset(balls[ballCounter].spriteID, xPos#, yPos#)
INC ballCounter
If ballCounter > 4 Then ballCounter = 0
EndIf
EndFunction
Not sure if this will help any but here it is anyway.