Jump to content

Is it possible to load TileSprite objects with the `atlas` loader?


ylluminarious
 Share

Recommended Posts

I need to load a TileSprite object in my game, but thus far I've used the `atlas` loader to load sprites in my game. I would like to keep things consistent and use the `atlas` loader, as opposed to the traditional `tileSprite` loader, but I'm not sure if this is possible. If so, how do you load a TileSprite object with the `atlas` loader?

Link to comment
Share on other sites

You don't really 'load' a TileSprite any more than you load a Sprite, a TileSprite is the application of a loaded image, spritesheet or texture atlas to a specific purpose; in this case TileSprite takes that frame and repeatedly tiles it over the size you set, and lets you pan it in the X and Y directions as you want. It's important to make the distinction between the assets you load and the containers you create to show them on the screen as they are separate things in Phaser.

 

One thing to be aware of is that TileSprites are sometimes awkward to get working if using a frame from a spritesheet or atlas on webGL, and may end up showing just the whole image rather than the frame you specified. If you find this happening, you may need to remove that image from the sprite sheet/atlas and load it separately.

 

Once you know all this, to actually set a frame as the texture for a TileSprite all you do is pass the key of the atlas and then the frame name. See this example: http://examples.phaser.io/_site/view_full.html?d=tile%20sprites&f=tiling+sprite+atlas.js&t=tiling%20sprite%20atlas

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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