Jump to content

How to create many textures from a sprite sheet?


Recommended Posts

Hi all,

I have a sprite sheet, I want to make many sprites from this sprite sheet. Here is my implementation:


var ASSET_PATHS: string[] = [


var texture1 = PIXI.utils.TextureCache["assets/roguelikeSheet_transparent.png"];

var rect1 = new PIXI.Rectangle(0*17,0*17,16,16);

texture1.frame = rect1;

var sprite1 = new PIXI.Sprite(texture);

var texture2 = PIXI.utils.TextureCache["assets/roguelikeSheet_transparent.png"];

var rect2 = new PIXI.Rectangle(3*17,5*17,16,16);

texture2.frame = rect2;

var sprite2 = new PIXI.Sprite(texture);

The code above is me trying to load two different sections of the same sprite sheet and make sprites from those sections. What happens is that:

texture2.frame = rect2;

overwrites sprite1's texture, thus both sprites become rect2's section.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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