Jump to content

Creating sprites using a portion of a texture ?


Alain91
 Share

Recommended Posts

Hello Pixi.js :)

 

I have a png image with all my sprite animations.

 

I would like to use it like an atlas, so a spritesheet in Pixi terms.

 

It seems that everyone use texturepacker from code'n'web.

 

The problem is that you have to split every anim piece in multiple files, then import it in texturepacker :/

 

Is there a way to

 

- load the entire anim file

- get textures via code ?

 

like

 

load picture("anims.png")

anim1 = gettexture(0,0,16,16)

anim2 = gettexture(16,0,16,16)

anim3 = gettexture(32,0,16,16)

 

thanks for your help,

Alain

 

Link to comment
Share on other sites

Yup, look at the atlas loader. It does exactly this.

 

Every texture has a "frame" which is a rectangle that defined the part of the image file to use for that Texture. Basically just create a texture using that image and specify the frame (rectangle) to use.

 

Notice you can pass a frame object as the second parameter to a Texture: http://www.goodboydigital.com/pixijs/docs/classes/Texture.html

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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