Hi there,
I wanted to replace my spine image, which is defined in the atlas, with any other image (from a remote location) but during runtime.
This is how I load and use spine:
// preload():
this.load.spine('fish', 'fish.json', 'fish.atlas.txt', true);
// ... create():
this.add.spine(450, 300, "fish", "animationName", true);
Now I get an event that a user has uploaded an image on my server and I simply want to apply all the spine data to that image.
onImageUploaded(image_url) {
// Take image_url as graphic and apply it to my fish spine
}
The problem is that the image name is defined in the atlas file.
Is there any way to dynamically create or alter the atlas file?
I don’t want and can’t create a new atlas file for every upload on the server!
I tried already to create a Blob() on the fly with the edited atlas content and then load it, but that didn’t work out:
var atlas_content = `
http://example.com/img/new-img.png
size: 1024,1024
format: RGBA8888
filter: Linear,Linear
repeat: none
fish
rotate: false
xy: 2, 2
size: 961, 582
orig: 961, 582
offset: 0, 0
index: -1
`;
var data = new Blob([atlas_content], { type: 'text/plain'} );
var atlas_file = window.URL.createObjectURL(data);
this.load.spine('fish', 'export/fish.json', atlas_file, true);
Or in other words: I want to have a “skeleton” and simply apply any image I want to it during run time:
var spine = this.add.spine(450, 300, "fish", "animationName", true);
spine.image = "http://example.com/my-new-image.png"
Thanks a lot for any ideas and help!
Using Phaser 3.5.0