Jeeeze that was certainly mind boggling
// Project: spritemoveexample
// Created: 2018-07-04
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "spritemoveexample" )
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
type _button
id
x#
y#
selected
endtype
global button as _button[10]
for a=0 to button.length
button[a].id = createsprite(0)
SetSpriteSize(button[a].id,50,50)
button[a].x# = a * 2
button[a].y# = 100
SetSpritePosition(button[a].id, button[a].x# * GetSpriteWidth(button[a].id)+10, button[a].y#)
next
mouse = createsprite(0) : setspritesize(mouse,1,1)
hit=0
do
SetSpritePosition(mouse, getpointerx(), getpointery())
for a=0 to button.length
if GetSpriteCollision(mouse,button[a].id)
selectedsprite=button[a].id
endif
if GetRawMouseLeftPressed()
endif
if GetSpriteCollision(mouse, button[a].id) and GetRawMouseLeftState()
if hit=0
offsetx# = getspritex(button[a].id) - getpointerx()
offsety# = getspritey(button[a].id) - getpointery()
hit=1
endif
if selectedsprite= button[a].id
button[a].x# = getpointerx() + offsetx#
button[a].y# = getpointery() + offsety#
SetSpritePosition(button[a].id, button[a].x#, button[a].y#)
selectedsprite=button[a].id
endif
endif
if GetRawMouseLeftReleased()
hit=0
endif
next
Print( ScreenFPS() )
Sync()
loop