johncl Posted April 25, 2021 Share Posted April 25, 2021 Hi, so I am using Pixijs to load images and other assets but I also want it to load my own proprietary map format as a standard byte array. PIXI.loader .add(TILEMAP_DATA, { xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.BLOB }) .load(this.setup.bind(this)); So I have figured out you can "load" any data with the loader but it doesnt seem to actually load the data? When I check the resource data structure its just a plain Blob structure that I then have to load using this: var data = PIXI.loader.resources[tilemap].data; let fileReader = new FileReader(); fileReader.readAsArrayBuffer(data); fileReader.onload = function(event) { let arrayBuffer = fileReader.result; console.log(arrayBuffer); }; But this is another set of async loading which I don't want. I want the PIXI Loader to actually fetch the whole file data so I can get direct access to the bytes after by just looking it up from PIXI.loader.resources. Does anyone have any pointers for this? Quote Link to comment Share on other sites More sharing options...
sky Posted April 25, 2021 Share Posted April 25, 2021 Use Resource.XHR_RESPONSE_TYPE.BUFFER instead of Resource.XHR_RESPONSE_TYPE.BLOB. Quote Link to comment Share on other sites More sharing options...
johncl Posted April 26, 2021 Author Share Posted April 26, 2021 Ah thanks. Thats brilliant and I guess I should have figured that one out since I actually ask for a Blob there. Never crossed my mind that I could specify something else. Is there a good resource for Pixijs, the manual/wiki doesn't have very good examples imo. Took me quite some time to figure out how to have same sprite sheet on several sprites but still control their individual rectangles. Most of the examples are pretty hung up on the built in json tilemap feature but I want to have my own custom one if I can as I want more control over each tiles layering and effects. Quote Link to comment Share on other sites More sharing options...
sky Posted April 26, 2021 Share Posted April 26, 2021 You're welcome! Well, PixiJS's documentation is more of an API reference than a user manual. The upside is that it's always up-to-date! The Loader stuff is also a bit different as it's a third-party library, so it's even less documented on pixi's end. I did have to peek around their source code a bit in order to answer your original question. It's funny that you mention spritesheets without the built-in json format stuff though, I actually did that same thing last week! I had to look at the source code of PIXI.Spritesheet and then implemented my own version. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.