Hi Mitaten, thanks for the reply. Yes, I did this but I think I found the problem, although I don’t know the solution. Let me explain: I have a function that is called every time I press a button:
function go()
while canWalk \> 0 do
if isAllowed( boardRow, boardColumn+1) then
move( boardRow, boardColumn+1)
else
canWalk = 0
end
end
end
function isAllowed(allowedX,allowedY)
if board[allowedX][allowedY].isObstacle == 1 then
print(" can't walk anymore. ")
return false
end
return allowedX \< numOfRows and allowedY \< numOfColumns
end
function move(moveX,moveY)
coordinateX = board[moveX][moveY].x + (openTileWidth/2)
coordinateY = board[moveX][moveY].y + (openTileHeight/2)
transition.to(ball, {time=movementTime, x=coordinateX, y=coordinateY, onComplete=changeCoordinates})
end
function changeCoordinates()
ball.x = coordinateX
ball.y = coordinateY
end
Situation 1: If I remove the while canWalk > 0 it works.
Situation 2: If I keep the “while” Corona stays inside the loop forever.
Situation 3: If I keep the “while” but remove the “transition.to”, and only update the ball coordinates directly it works.
--Situation 3:
function move(moveX,moveY)
ball.x = board[moveX][moveY].x + (openTileWidth/2)
ball.y = board[moveX][moveY].y + (openTileHeight/2)
end
It seems that there is something with transition. Is there a way to wait for transition before the while loop run again?
Thanks! [import]uid: 159026 topic_id: 34485 reply_id: 137104[/import]