I have prepared for you an example of how this can work.
// Project: Test
// Created: 2019-07-09
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "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( 60, 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
#constant true = 1
#constant false = 0
type data_texture
id as integer
data as string
endtype
global texture as data_texture[]
type sprite
id as integer
x as float
y as float
currentX as float
currentY as float
width as float
height as float
currentWidth as float
currentHeight as float
angle as float
currentangle as float
alpha as integer
currentAlpha as integer
visible as integer
currentVisible as integer
endtype
global dim all_objects[] as integer
myPic as sprite
myPic = newSprite("img.png")
myPic.x = 100
myPic.y = 200
myPic.alpha = 150
myPic.angle = 270
setSprite(myPic)
do
//print all id
for i=0 to all_objects.length
print(all_objects[i])
next i
Sync()
loop
function newImage( _file as string )
result = -1
for i=0 to texture.length
if texture[i].data = _file
result = i
exit
endif
next i
if result = -1
texture.length = texture.length +1
result=texture.length
texture[result].id = LoadImage(_file)
texture[result].data = _file
endif
endfunction texture[result].id
function newSprite( _file as string )
obj as sprite
obj.id = CreateSprite(newImage(_file))
all_objects.insert(obj.id)
obj.width = GetSpriteWidth(obj.id)
obj.height = GetSpriteHeight(obj.id)
obj.currentWidth = obj.width
obj.currentHeight = obj.height
obj.angle = 0
obj.currentAngle = 0
obj.x = 0
obj.y = 0
obj.currentX = 0
obj.currentY = 0
obj.alpha = 255
obj.currentAlpha = 255
obj.visible = 1
obj.currentVisible = 1
endfunction obj
function setSprite(obj as sprite)
if obj.width <> obj.currentWidth
SetSpriteSize(obj.id, obj.width, GetSpriteHeight(obj.id) )
obj.currentWidth = obj.width
endif
if obj.height <> obj.currentHeight
SetSpriteSize(obj.id, GetSpriteWidth(obj.id), obj.height )
obj.currentHeight = obj.height
endif
if obj.angle <> obj.currentAngle
SetSpriteAngle(obj.id, obj.angle )
obj.currentAngle = obj.angle
endif
if obj.alpha <> obj.currentAlpha
SetSpriteColorAlpha(obj.id,obj.alpha )
obj.currentAlpha = obj.alpha
endif
if obj.visible <> obj.currentVisible
SetSpriteVisible(obj.id, obj.visible)
obj.currentVisible = obj.visible
endif
if obj.x <> obj.currentX
SetSpriteX(obj.id,obj.x)
obj.currentX=obj.x
endif
if obj.y <> obj.currentY
SetSpriteY(obj.id,obj.y)
obj.currentY=obj.y
endif
endfunction
https://www.instagram.com/qugurun/