dude78 Posted August 26, 2018 Share Posted August 26, 2018 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 More sharing options...
samme Posted August 26, 2018 Share Posted August 26, 2018 https://codepen.io/samme/pen/ybLpdJ?editors=0010 dude78 1 Link to comment Share on other sites More sharing options...
dude78 Posted August 28, 2018 Author Share Posted August 28, 2018 On 8/26/2018 at 6:57 PM, samme said: https://codepen.io/samme/pen/ybLpdJ?editors=0010 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 More sharing options...
dude78 Posted September 1, 2018 Author Share Posted September 1, 2018 @samme, as 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 More sharing options...
samme Posted September 1, 2018 Share Posted September 1, 2018 Yes, that's the idea. Did it work? Link to comment Share on other sites More sharing options...
dude78 Posted September 1, 2018 Author Share Posted September 1, 2018 @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 More sharing options...
Recommended Posts