Jump to content

Wrong astarNode.x and astarNode.y when using the AStar Plugin


lucasfevi
 Share

Recommended Posts

Hi! I was having a little trouble trying to use AStar + Phaser. I debugged it a bit and discovered a little bug. The X and Y of the astarNode property are wrong, when I set my AStar map, the x and y of all tiles are the same, so the findPath() doesn't work. I'm still trying to fix it, but you guys maybe help me to find the problem faster.
 
Phaser v2.1.1
tilemap.json ( http://pastebin.com/bQJBxMm7 )
 
Code:
preload: function() {    this.game.load.tilemap('map', 'assets/tilemap.json', null, Phaser.Tilemap.TILED_JSON);    this.game.load.image('RPGPackSheet', 'assets/sprites/RPGPackSheet.png');},create: function() {    this.map = this.game.add.tilemap('map');    this.map.addTilesetImage('RPGPackSheet');    this.layer = this.map.createLayer('LayerName');    this.astar = this.game.plugins.add(Phaser.Plugin.AStar);    this.astar.setAStarMap(this.map, 'LayerName', 'RPGPackSheet');    console.log(this.map.layers[0].data[4][6].properties.astarNode);},
 
The output on the console should be:
f: 0,g: 0,h: 0,walkable: false,x: 6, // equals to the second index of layers[0].datay: 4  // equals to the first index of layers[0].data
 
But is giving me in every index the output above:
f: 0,g: 0,h: 0,walkable: false, // the walkable changes accordinglyx: 24,y: 13

NOTE: It may be related to the height and width of my layer or tilemap ( width: 25, height: 14), but I can't find why its doing that.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...