JokerJESUS Posted April 5, 2016 Share Posted April 5, 2016 Hello, i made tileset, and did pathfinder for it. But now how can i do that sprites, or groups of sprites will move on this path. my code for path: I used graphics -> lineTo for making path. function pathfinder(array){ var x = groupDisable.children[0].x; var y = groupDisable.children[0].y; graph = game.add.graphics(); graph.lineStyle(1, 0xffd900, 1); graph.moveTo(x,y); for(var i = 0; i < groupDisable.length; i++){ groupDisable.forEach(function(arg){ if(x + 32 == arg.x && y == arg.y && !arg.checked){ console.log('->'); x = arg.x; y = arg.y; arg.checked = 1; graph.lineTo(x, y); }else if(x == arg.x && y + 32 == arg.y && !arg.checked){ console.log('\\/'); x = arg.x; y = arg.y; arg.checked = 1; graph.lineTo(x, y); console.log('argX: '+arg.x+' argY: '+arg.y+' x: '+x+' y: '+y); }else if(x - 32 == arg.x && y == arg.y && !arg.checked){ console.log('<-'); x = arg.x; y = arg.y; arg.checked = 1; graph.lineTo(x, y); }else if(x == arg.x && y - 32 == arg.y && !arg.checked){ console.log('/\\'); x = arg.x; y = arg.y; arg.checked = 1; graph.lineTo(x, y); } }); Link to comment Share on other sites More sharing options...
Recommended Posts