It didn't error for me but I needed to add some environment stuff for the sprite to show
type _class_img
id as integer
x as float
y as float
curentX as float
curentY as float
alpha as integer
curentAlpha as integer
endtype
SetErrorMode(2)
// set window properties
SetWindowTitle( "sprite test" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
global obj_img as _class_img[]
global MyObj as _class_img
MyObj.id=CreateSprite(0)
//SetSpriteColor(MyObj.id,255,255,255,255)
SetSpriteSize(MyObj.id, 50, 50)
SetSpriteY(MyObj.id,100)
MyObj.x=50
MyObj.alpha=50
//all values need to be done before inserting or they aren't transferred accross
obj_img.insert(MyObj)
do
Listiner(obj_img)
print(obj_img[0].id) //-->10004
print(MyObj.id) //-->10004
Sync()
loop
function Listiner( _obj ref as _class_img[])
for i=0 to _obj.length
if _obj[i].curentX <> _obj[i].x
SetSpriteX(_obj[i].id, _obj[i].x)
_obj[i].curentX = _obj[i].x
endif
if _obj[i].curentY <> _obj[i].y
SetSpriteY(_obj[i].id, _obj[i].y)
_obj[i].curentY = _obj[i].y
endif
//-------------------------------------
if _obj[i].curentAlpha <> _obj[i].alpha
SetSpriteColorAlpha(_obj[i].id,_obj[i].alpha )
_obj[i].curentAlpha = _obj[i].alpha
endif
next i
endfunction