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

Added loadFramedSpriteSheet to ImageLoader, this method allows loading uniform sprite sheets that don't need a texture packer description file . #311

Closed
wants to merge 3 commits into from

Conversation

alaa-eddine
Copy link

This will allow loading frame sprite sheets and give access to each frame.
the method also allow caching of each frame

usage example

var image = new PIXI.ImageLoader('tileset.png');
image.addEventListener("loaded", function (event) { 
    var frames = event.content.frames;  //image frames are stored here

    var terrain = new PIXI.Sprite(frames[8]);  
    //var terrain = PIXI.Sprite.fromFrame('terrain-8');  //we can use this syntax too if a frame name is provided (here the frame name is 'terrain' the frame order is 8

    terrain.position.x = 0;
    terrain.position.y = 0;
    stage.addChild(terrain);

    document.body.appendChild(canvas);

    renderer.render(stage);

});
image.loadFramedSpriteSheet(92, 46);

//image.loadFramedSpriteSheet(92, 46, 'terrain'); //if a frame name is provided (here = 'terrain') then the frames will be added to PIXI.TextureCache

…g uniform sprite sheets that don't need a texture packer description file .
…g uniform sprite sheets that don't need a texture packer description file .
…g uniform sprite sheets that don't need a texture packer description file .
@englercj
Copy link
Member

englercj commented Sep 7, 2013

In the future please create PRs from the dev branch, and send them to use on that same branch. The master branch is the latest release, not necessarily the latest code. Thanks!

Code looks good at first glance, I'll try it out and get back to you soon.

@alaa-eddine
Copy link
Author

ok :)
sorry I didn't paid attention to what branch I cloned to submit my request .
I'll check that in my next contribution.

do you ant me to send another pr from dev branch ?

@englercj
Copy link
Member

englercj commented Sep 7, 2013

Nah this is clean enough that manually merging it isn't hard so don't worry about it.

Thanks again!

@englercj
Copy link
Member

manually merged!

@englercj englercj closed this Sep 28, 2013
@vgrudenic
Copy link

I don't think the merged version will work properly if the texture is not loaded yet (you are accessing this.texture.width and height at the top of the function). Original snippet was running inside the loaded handler.

Or, was this meant to be called after calling load, manually? Probably not, because there's the this.texture.baseTexture.hasLoaded check which doesn't make sense then.

@alaa-eddine
Copy link
Author

@vgrudenic you're right, there is an issue there, I'll submit a new PR with a fixed version.

@lock
Copy link

lock bot commented Feb 25, 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 25, 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

Successfully merging this pull request may close these issues.

None yet

3 participants