fallenshadow Posted March 10, 2017 Report Share Posted March 10, 2017 Hi all, I have been trying to follow this tutorial here: https://developer.tizen.org/community/tip-tech/using-easystar.js-implement-pathfinding-tizen-game-projects However, it mentions about a 2D array and right away I'm lost. I have a game in Phaser Isometric but I don't use a 2D array at all. I just have a tile and a loop to add to a tile group. spawnTiles: function () { var tile; for (var xx = 0; xx < 400; xx += 38) { for (var yy = 0; yy < 400; yy += 38) { // Create a tile using the new game.add.isoSprite factory method at the specified position. // The last parameter is the group you want to add it to (just like game.add.sprite) tile = game.add.isoSprite(xx, yy, 0, 'tile', 0, tileGroup); tile.anchor.set(0.5, 0); } } } How do I get a 2D array for Easystar to use? Quote Link to comment Share on other sites More sharing options...
MeMyMo Posted March 10, 2017 Report Share Posted March 10, 2017 You could do something like: var tile; var map = []; var tileWidth = 38; for (var xx = 0; xx < 10; xx++) { map[xx] = []; for (var yy = 0; yy < 10; yy++) { // Create a tile using the new game.add.isoSprite factory method at the specified position. // The last parameter is the group you want to add it to (just like game.add.sprite) tile = game.add.isoSprite(xx tileWidth, yy * tileWidth, 0, 'tile', 0, tileGroup); tile.anchor.set(0.5, 0); map[xx][yy] = 1; } } console.log(map) But you should probably look into tilemaps and Tiled, it'll help a lot. Also, there's a Phaser plugin to help out with pathfinding: https://github.com/appsbu-de/phaser_plugin_pathfinding Quote Link to comment Share on other sites More sharing options...
fallenshadow Posted April 8, 2017 Author Report Share Posted April 8, 2017 So I thought I was making progress now but I'm hitting an issue when I try this: Quote Easystar - Your start or end point is outside the scope of your grid. function movePlayer() { easystar.findPath(player.isoX, player.isoY, selectedTile.isoX, selectedTile.isoY, drawPath); easystar.calculate(); } Any ideas? Quote Link to comment Share on other sites More sharing options...
hicotech Posted April 9, 2017 Report Share Posted April 9, 2017 I dont know how you have it but if you use isometric layout you probably want to recalculate it to orthogonal before you use pathfinding.. and then most likely back http://clintbellanger.net/articles/isometric_math/ Quote Link to comment Share on other sites More sharing options...
JayJay Posted February 4, 2018 Report Share Posted February 4, 2018 On 3/10/2017 at 8:35 AM, MeMyMo said: Also, there's a Phaser plugin to help out with pathfinding: https://github.com/appsbu-de/phaser_plugin_pathfinding That repo has not been updated for over 4 years Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.