# Phaser isometric walk problem

## Recommended Posts

Hello my players how to move it in the right isometric does not move in a proper manner?

It will act as the library

Quote
```
var pokemon = function (game) { };

var isoGroup, water = [],cursorPos, cursor, player, x_point;

pokemon.game = {
game.stage.disableVisibilityChange = false;

game.iso.anchor.setTo(0.5, 0.2);

},
create: function () {

isoGroup.enableBody = true;

var tileArray = [];
tileArray[0] = 'water';
tileArray[1] = 'sand';
tileArray[2] = 'grass';
tileArray[3] = 'stone';
tileArray[4] = 'wood';
tileArray[5] = 'watersand';
tileArray[6] = 'grasssand';
tileArray[7] = 'sandstone';
tileArray[8] = 'bush1';
tileArray[9] = 'bush2';
tileArray[10] = 'mushroom';
tileArray[11] = 'wall';
tileArray[12] = 'window';

var tiles = [
2, 2, 1, 1, 4, 4, 1, 6, 2, 10, 2,
2, 6, 1, 0, 4, 4, 0, 0, 2, 2, 2,
6, 1, 0, 0, 4, 4, 0, 0, 8, 8, 2,
0, 0, 0, 0, 4, 4, 0, 0, 0, 9, 2,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0,
11, 11, 11, 11, 3, 3, 11, 11, 11, 11, 11,
3, 7, 3, 3, 3, 3, 3, 3, 7, 3, 3,
7, 1, 7, 7, 3, 3, 7, 7, 1, 1, 7
];

this.spawnTiles(tiles, tileArray);

cursorPos = new Phaser.Plugin.Isometric.Point3();

player = game.add.isoSprite(32, 32, -40, 'player', 0, isoGroup);
player.anchor.set(0.5);
player.body.collideWorldBounds = true;
game.camera.follow(player);
player.body.gravity.z = -900;

this.cursors = game.input.keyboard.createCursorKeys();

isoGroup.enableBody = true;

},
update: function () {
game.iso.simpleSort(isoGroup);

// collision detection?

//* player
var speed = 73;
if (this.cursors.up.isDown) {
this.playerMovement(0, -speed);
player.animations.play('up');
} else if (this.cursors.down.isDown) {
this.playerMovement(0, speed);
player.animations.play('down');
} else if (this.cursors.left.isDown) {
this.playerMovement(-speed, 0);
player.animations.play('left');
} else if (this.cursors.right.isDown) {
this.playerMovement(speed, 0);
player.animations.play('right');
} else if (game.input.mousePointer.isDown) {
game.input.mouse_x = game.input.mousePointer.position['x'];
game.input.mouse_y = game.input.mousePointer.position['y'];
game.input.mouse_z = game.input.mousePointer.position['z'];
} else if (
Math.abs(player.position.x - game.input.mouse_x) > 5 ||
Math.abs(player.position.y - game.input.mouse_y) > 5
) {
} else {
this.playerMovement(0,0);
player.animations.stop();
}

game.iso.unproject(game.input.activePointer.position, cursorPos);

isoGroup.forEach(function (tile) {
var inBounds = tile.isoBounds.containsXY(cursorPos.x, cursorPos.y);
if (!tile.selected && inBounds) {
tile.selected = true;
tile.tint = 0x86bfda;
}
else if (tile.selected && !inBounds) {
tile.selected = false;
tile.tint = 0xffffff;
}
});

},
render: function () {
isoGroup.forEach(function (tile) {
//game.debug.body(tile, 'rgba(189, 221, 235, 0.6)', false);
});
game.debug.text("FPS: "+game.time.fps || '--', 5, 14, "#a7aebe");
},
spawnTiles: function (tiles, tileArray) {
var size = 32;

var i = 0, tile;
for (var y = size; y <= game.physics.isoArcade.bounds.frontY - size; y += size) {
for (var x = size; x <= game.physics.isoArcade.bounds.frontX - size; x += size) {

tile = game.add.isoSprite(x, y, tileArray[tiles[i]].match("water") ? 0 : game.rnd.pick([0]), 'tileset', tileArray[tiles[i]], isoGroup);
tile.anchor.set(0.5, 0);

tile.body.immovable = true;

if (tiles[i] <= 10 && (tiles[i] < 5 || tiles[i] > 6)) {
tile.scale.x = game.rnd.pick([-1, 1]);
}
if (tiles[i] === 11) {
tile.isoZ += 45;
}
i++;
}
}

},
playerMovement: function(x, y) {
var x = x || 0;
var y = y || 0;

player.body.velocity.x = x;
player.body.velocity.y = y;
}

};```

##### Share on other sites

what exactly are you trying to achieve...

##### Share on other sites

As you walk the red line painted yellow spot

##### Share on other sites

20 minutes ago, TickleMeElmo said:

what exactly are you trying to achieve...

..