When I swipe left to right and go across the middle “boundary” (WIDTH / 2)of the screen the sprite just keeps on moving instead of stopping like it should. What is wrong? Thanks!
video of problem: https://www.dropbox.com/s/eom2hvzs7crwjl3/IMG_0186.MOV
-- test
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
sx = WIDTH / 2
sy = HEIGHT / 2
x,y = 0,0
tx, ty = 0,0
end
-- This function gets called once every frame
function draw()
background(127, 127, 127, 255)
fill(0, 0, 0, 255)
player()
if move then
sx=sx+(tx - x)/25
sy=sy+(ty - y)/25
end
end
function touched(t)
if t.x < WIDTH / 2 then
if t.state == BEGAN then
x = t.x
y = t.y
tx = x
ty = y
move = true
elseif t.state == MOVING then
tx = t.x
ty = t.y
move = true
elseif t.state == ENDED then
x,y = 0, 0
tx, ty = 0,0
move = false
end
elseif t.x > WIDTH / 2 then
print "Right"
end
end
function player()
playerc = physics.body(CIRCLE, 50)
playerc.x = sx
playerc.y = sy
playerc.info = "player"
sprite("Platformer Art:Guy Standing", playerc.x, playerc.y)
sprite("Platformer Art:Guy Standing",playerc.x,playerc.y)
end