Jump to content

Texture sourceSize same as frame size?


Recommended Posts

How would i make the sourceSize (width and height) the same as the trimmed size when making a PIXI.Texture.from() ?

Because my sprite gets kinda messed up when the sourceSize is {w: 614, h: 564} and the trim is {width: 286, height: 481}, and i couldnt change the width and height on the texture directly either, soo not really sure.

Link to comment
Share on other sites

You have to edit it manually.

var baseTex = PIXI.BaseTexture.from(...);
var tex = new PIXI.Texture(baseTex, frame, orig, trim, 0);

As what is frame/orig/trim, you have to look in 


Yes, I can give you some wise words about meaning of those rects: "frame" is what is in atlas, "orig" is what was original image (0,0,w,h), "trim" is that "frame" inside "orig": (x,y,w2,h2) - must fit inside orig. However its easy to mistake in parsing that explanation, so you have to look in the sources :)

Link to comment
Share on other sites

yes, single "frame" is enough. If you need more then you need to pass two more rects. That also looks like cloning, you'll get same texture. Don't forget that when you modify it later, like "n.frame.x+=1", you'll have to do "n.updateUvs()" to notify texture that something inside was changed.

Welcome to the forums!

Edited by ivan.popelyshev
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...