scoots Posted February 17, 2014 Share Posted February 17, 2014 I'm having a bit of an issue figuring out tile properties in 1.1.5. My understanding is that each tile in a map has an individual set of properties, which can be set in the tile map editor such as Tiled. Here's what I'm doing, screenshots are of Tiled and my game objects being output to the Chrome developer console. I set the properties for each tile in the tileset in Tiled In my game, I can then see the tile properties at the Phaser.TileSet.tileProperties object, which I did not find on the documentation. But the tile properties are not available for each Phaser.Tile object Are the tile properties from the tile set not supposed to transfer to each individual tile object? I would like to be able to change the values for the properties on each tile as the game is played, so if not I suppose I'll need to set this up myself. Thanks! Link to comment Share on other sites More sharing options...
scoots Posted February 18, 2014 Author Share Posted February 18, 2014 I've done some work to make a generic example of this. The basic question still is, should each Tile object have the properties set in the editor (Tiled in this case) on the tilesheet? Am I attempting to access the Tile properties correctly? Example: http://scottedwardcummings.com/phaser-examples/tile-properties/ Open the dev console and note that I've logged a TileMap.TileSet.tileProperties array. You can open this up and see that the tile map has properties set on several tile types such as the mushroom, coin, floor and empty sky. If you click on any of these, the console will log the tile object of the tile clicked. If you inspect the "properties" object of the tile, nothing will be there. I would expect the tileset properties to get transfered to these tiles so they can be manipulated, but perhaps I am mistaken. Is there another way to set properties on individual tiles in Tiled that is the preferred method? Here is the source:<html> <head> <script src="js/phaser/phaser.js"></script> <script type="text/javascript"> var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); function preload() { game.load.tilemap('mario', 'assets/tilemaps/maps/super_mario.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tiles', 'assets/tilemaps/tiles/super_mario.png'); } var map; var layer; var p; var cursors; var marker; function create() { game.stage.backgroundColor = '#787878'; map = game.add.tilemap('mario'); map.addTilesetImage('SuperMarioBros-World1-1', 'tiles'); layer = map.createLayer('World1'); layer.resizeWorld(); marker = this.game.add.graphics(); marker.lineStyle(2, 0x000000, 1); marker.drawRect(0, 0, 16, 16); console.log("TileMap.Tilesets[0].tileProperties") console.log(map.tilesets[0].tileProperties); } function update() { marker.x = layer.getTileX(game.input.activePointer.worldX) * 16; marker.y = layer.getTileY(game.input.activePointer.worldY) * 16; if (game.input.mousePointer.isDown){ var currentTile = map.getTile(layer.getTileX(marker.x), layer.getTileY(marker.y), 'World1'); console.log("Phaser.Tile Object"); console.log(currentTile); console.log("Phaser.Tile.properties - attemting to access property \'type\'"); console.log(currentTile.properties.type); } } </script> </head> <body> <div id="phaser-canvas"></div> </body></html> Link to comment Share on other sites More sharing options...
hellbinder Posted April 22, 2014 Share Posted April 22, 2014 Have you figured this out? I am also having issues with this when checking if a tile that has collided is destroyable or no. Link to comment Share on other sites More sharing options...
Reign_of_Light Posted July 15, 2014 Share Posted July 15, 2014 I'm having this issue as well. "properties" on Tile.js never contains any tile-properties. Thank you for poiting to Phaser.TileSet.tileProperties. Hopefully I can find a workaround as well. Link to comment Share on other sites More sharing options...
beeglebug Posted August 8, 2014 Share Posted August 8, 2014 I've just noticed this same issue. Not sure why the data never goes anywhere, it looks like a bit of an oversight. I might do a pull request to copy the data over, as it seems useful. P.Uri.Tanner 1 Link to comment Share on other sites More sharing options...
jloa Posted August 8, 2014 Share Posted August 8, 2014 And i've just answerd this issue here -> http://www.html5gamedevs.com/topic/8415-tiled-tile-properties/ Link to comment Share on other sites More sharing options...
jloa Posted August 8, 2014 Share Posted August 8, 2014 Btw, there are other properties that are not copied from the json. For example Phaser.TilemapLayer is not copying opactiy and visible properties, so i had to make a dirty fixvar layer = this.map.createLayer(layerName, undefined, undefined, layerGroup);// @FIX not implemented - the 'alpha' and 'visible' inheritance, nor the 'name'layer.alpha = layer.layer.alpha;layer.visible = layer.layer.visible;layer.name = layer.layer.name;Check out the source if you don't believe me http://docs.phaser.io/TilemapLayer.js.html#sunlight-1-line-1 Ps: there are tons of such weird things (and bugs! btw), i've already got a "phaser-fix.js" with tons of overrides/extends, will push it to the repo later when i got time. Link to comment Share on other sites More sharing options...
beeglebug Posted August 26, 2014 Share Posted August 26, 2014 As promised, I opened a pull request for copying the tile properties over, it makes accessing them much easier IMHO: https://github.com/photonstorm/phaser/pull/1126 Link to comment Share on other sites More sharing options...
Recommended Posts