I could move my image but it would snap to wherever my finger was on the screen. I tried to set up a hit-box but now I can’t move the image.
imagePosition = vec2()
imageName = "SpaceCute:Beetle Ship"
imageSize = vec2(spriteSize(imageName))
function setup()
supportedOrientations(LANDSCAPE_ANY)
displayMode(FULLSCREEN)
noFill()
noSmooth()
noStroke()
pushStyle()
imagePosition = vec2(WIDTH/2, HEIGHT/2)
end
function touched(touch)
local currentTouchPosition = vec2(touch.x, touch.y)
if (touch.state == BEGAN) then
end
if (touch.state == MOVING) then
if( (imagePosition.x - imageSize.x/2) < currentTouchPosition.x and
(imagePosition.x + imageSize.x/2) > currentTouchPosition.x and
(imagePosition.y - imageSize.y/2) < currentTouchPosition.y and
(imagePosition.y + imageSize.y/2) > currentTouchPosition.y ) then
imagePosition = currentTouchPosition
end
end
if (touch.state == ENDED) then
end
end
function draw()
background(0, 0, 0, 255)
sprite("SpaceCute:Background", 512, 384, 1024, 768)
sprite(imageName, imagePosition.x, imagePosition.y)
end