Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpriteSheetLoader and trimmed sprites #21

Closed
Nibbler999 opened this issue Mar 22, 2013 · 2 comments
Closed

SpriteSheetLoader and trimmed sprites #21

Nibbler999 opened this issue Mar 22, 2013 · 2 comments

Comments

@Nibbler999
Copy link

The code to support trimmed sprites is commented out. If I enable and complete it then it seems to work fine.

var frameData = jsondata.frames;
for (var i in frameData) 
{
    var rect = frameData[i].frame;
    PIXI.TextureCache[i] = new PIXI.Texture(this.texture, {x:rect.x, y:rect.y, width:rect.w, height:rect.h});

    if(frameData[i].trimmed)
    {
        var realSize = frameData[i].spriteSourceSize;
        PIXI.TextureCache[i].trim.x = (realSize.x / rect.w);
        PIXI.TextureCache[i].trim.y = (realSize.y / rect.h);
    }
}

Can this be enabled or is it missing something?

@GoodBoyDigital
Copy link
Member

oh nice! yes I did start to build it in... (used it for the plane in http://flashvhtml.com/) it messes with the anchor points at the moment though, so need to tweak the update transform function of the Sprites too. Along the lines of this..

this.realAnchor.x = -((realFrame.x - (this.frame.w*this.anchor.x)) / realFrame.w); 
this.realAnchor.y = -((realFrame.y - (this.frame.h*this.anchor.y)) / realFrame.h);

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants