Having trouble with getting my character to move the right way

so basically im just recreating the game snake for practice so that i can learn a few things and well im having trouble with actually getting my snake character to move the way i need it to, im using “transition.to” to initially move my object but i cant figure out how to break it from one transition to another

the layout of the game is simple all i have is 4 arrows and each arrow is facing the way that it tells the snake to move

my issue is when i click the arrow it moves where i want it at first, but if i click another arrow in a different direction then it wont execute the movement until the other transition is done

how can i get it to break form the original transition and start the new one?

i can provide code if needed but honestly the code isnt much right now and its not a bug or anything so im notn sure if it would be helpful at all

and i have added a screenshot of the game just to give you an idea of the layout and maybe it will help you understand what i am trying to do

Instead I would use an enterframe listener to handle movement. Store the movement speed and direction in some variables, and then every frame change the x or y position of your snake’s head accordingly.

If you are doing like this: transition.to(snake, {time=x, x = movex, y = movey})

I suggest you to make that a variable like this: local trans1 = transition.to(snake, {time=x, x = movex, y = movey})

And you can cancel the one that is moving my typing transition.cancel(trans1) or transition.pause(trans1) I dont remember which one it was…

Instead I would use an enterframe listener to handle movement. Store the movement speed and direction in some variables, and then every frame change the x or y position of your snake’s head accordingly.

If you are doing like this: transition.to(snake, {time=x, x = movex, y = movey})

I suggest you to make that a variable like this: local trans1 = transition.to(snake, {time=x, x = movex, y = movey})

And you can cancel the one that is moving my typing transition.cancel(trans1) or transition.pause(trans1) I dont remember which one it was…