So I had a look, and I think its because you're calling getspritehit every frame, which slows things down.
I added in the beginning of your do loop:
if not spritehit
spritehit = getspritehit(getpointerx(),getpointery())
endif
and when you reset your timer:
Full code:
// Project: mouse long press
// Created: 19-04-24
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle("mouse long press")
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)
Global presstime as float = 0.5
Global lastx as float
Global lasty as float
Global sp1 as integer
Global sp2 as integer
global rotate as integer = 15
sp1 = LoadImage("s3.png")
CreateSprite(sp1)
SetSpritePosition(sp1,656,135)
sp2 = LoadImage("s4.png")
CreateSprite(sp2,sp2)
SetSpritePosition(sp2,340,175)
do
if not spritehit
spritehit = getspritehit(getpointerx(),getpointery())
endif
if spritehit > 0
if GetRawMouseRightPressed() // rightclick
SetSpriteAngle(spritehit,GetSpriteAngle(spritehit)+rotate)
elseif GetPointerState() = 1
if getspritex(spritehit) <> lastx or getspritey(spritehit) <> lasty
lastx = getspritex(spritehit)
lasty = getspritey(spritehit)
resettimer()
endif
SetSpritePosition(spritehit,GetPointerX()-(GetSpriteWidth(spritehit)/2), GetPointerY()-(GetSpriteHeight(spritehit)/2)) //set puzzle piece center of mouse cursor
if Timer() > presstime // longpressclick
SetSpriteAngle(spritehit,GetSpriteAngle(spritehit)+rotate)
resettimer()
endif
else
ResetTimer()
spritehit = 0
endif
endif
print("Left Click and Drag Sprite")
print("Right Click to Rotate OR")
print("Left Click with No Drag to Rotate")
Sync()
loop
It looks like it works, have a try