SteveB Posted March 16, 2014 Share Posted March 16, 2014 I have a tilemap that's working fine. What I want to do is to create a Sprite that can be based on the same tileset as the tilemap uses so I can create dynamic tiles. I've extracted some of my code from some objects below to make what I'm effectively doing at the moment a bit clearer.var map = game.add.tilemap(mapId);map.addTilesetImage(tilesetName, imageId);var carriedTile = new Phaser.Sprite(game, 100, 64, imageId);game.add.existing(carriedTile);What I get, as expected, is a Sprite that displays the entire tileset image. What I need to do is to get a Sprite that only displays one tile from the Tileset. How do I achieve that? I've tried setting the textureRegion, but that doesn't seem to do anything. Thanks. Link to comment Share on other sites More sharing options...
Karma Octopus Posted March 16, 2014 Share Posted March 16, 2014 Maybe this is what you are looking for? http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=blank+tilemap.js&t=blank%20tilemap Link to comment Share on other sites More sharing options...
SteveB Posted March 16, 2014 Author Share Posted March 16, 2014 Thanks Karma Octopus. Unfortunately, not quite. The tileStrip is a sprite using the same tileset image as the map, but the individual tiles on mouse down are created using the index into the tileStrip rather than creating new Sprites; the tileStrip is still the size of the entire tileset image. My problem would be a bit like trying to make the tileStrip the size of one tile and then able to change the tile it shows. Mind you the example showed me a couple of other things I didn't know. Link to comment Share on other sites More sharing options...
satana Posted April 15, 2014 Share Posted April 15, 2014 Hello there. I'm too want to do the same.There is an option of loading your tilemap's tileset as a spritesheet: game.load.spritesheet("tilesetname", "tileset_path", tilewidth, tileheight, frameMax) and then referring to it while creating the sprite like: game.add.sprite(x, y, "tilesetname", frameIndex) However this seems to be more of a workaround than a proper solution. Link to comment Share on other sites More sharing options...
Recommended Posts