In my game I want my character to instantly move to predetermined points at the press of the left and right arrow keys. The player starts at x coordinate of 0. Here is my current code:
var n = 0;
cursors = game.input.keyboard.createCursorKeys();
var coordinates = [{x: 0}, {x: 100}, {x: 200}, {x: 300}, {x: 400}];
if (cursors.left.isDown && player.position.x != 0)
{
n -= 1;
player.position.x = coordinates[n].x;
}
if (cursors.right.isDown && player.po