Jump to content

load .pvr via atlas()


dude78
 Share

Recommended Posts

Hello guys. I wander if there is a way to load a spritesheet via load.atlas() using .pvr extension?

In this tutorial they show an example with load.image()

function preload () { 

    game.load.image('factory', {
        etc1: 'assets/factory_etc1.pkm',
        s3tc: 'assets/factory_dxt1.pvr',
        pvrtc: 'assets/factory_pvrtc.pvr',
        truecolor: 'assets/factory.png'
    });

    //  The old way is also still supported:
    game.load.image('factory', 'assets/textures/factory.png');
}

 

Can I do the same with load.atlas()?

Sth like
 

function preload () {

    game.load.atlas('factory', {
        pvrtc: 'assets/factory.pvr',
        truecolor: 'assets/factory.png'
    }, 'assets/factory.json');

}

If I can't then how can I load a compressed spritesheet?

I am using phaser 2.10.5 but can switch to the latest Phaser 2 version.

Thanks in advance.

 

P.S. I know there is plugin for such purposes but I wanna try without this one.

Link to comment
Share on other sites

On 8/26/2018 at 6:57 PM, samme said:

Sorry, I do not understand.

I think I should load .pvr here: @load.image 'set0', 'atlas/megasetHD-0.png'; but instead of .png I load .pvr?

If I do so, then, how can I load truecolor .png file if hardware or browser doesn't support compressed textures?

Link to comment
Share on other sites

@sammeas I understand we load image first and then create an atlas using this image? I followed the link you gave, read documentation and... Now the code looks like:

preload: function () {

    this.load.path = "assets/sprites/";

    this.load.image('MySprite-image', {

        pvrtc: 'MySprite-pvr.pvr',
        truecolor: 'MySprite-png.png'
    });

    this.load.json('MySprite-json');

},

create: function () {

    // addTextureAtlas(key, url, data, atlasData, format)
    this.cache.addTextureAtlas('MySprite', null, this.cache.getImage('MySprite-image'), this.cache.getJSON('MySprite-json'), 'json');

    this.MySprite = this.add.sprite(50, 50, "MySprite");

}

 

Is that right?

 

Thanks.

Link to comment
Share on other sites

@samme, well, I dunno is there any way to check what we loaded as of now, but I did so:

I load .pvr image_1 and load .png image_2.

Then, if I see image_2 after reloading page, that means  that .png file was loaded.

I found out that my i7 doesn't support .pvr files :)).

or probably code above is incorrect.

 

By the way, I can't load .pvr file only. I need to define truecolor. I thought I can load .pvr without truecolor. If loading .pvr without truecolor is possible, than code above is wrong for 100%.

 

Anyway your idea is superb!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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