I haven’t done this in code, but I am thinking that something like this may work if you would like to test:
app.assets.loadFromUrl('../assets/textures/newImage.png', 'textureatlas', function (err, asset) {
// now use the new asset received in your sprites
spriteAsset.resource.atlas = asset.resource;
// or on your SpriteComponent
myEntity.sprite.sprite.atlas = asset.resource;
});
app.assets.loadFromUrl(url, “texture”, function (err, asset) {
//load atlas if no override is found
var assets = app.assets.findByTag(tag);
var assetsLoaded = 0;
var assetsTotal = assets.length;
var atlas = assets[0];
if(err !== null && err !== undefined) {
console.log('No replacement texture found for ' + tag + ' atlas!');
//load atlas if no override is found
var onAtlasReady = function() {
self.onAssetsLoaded();
};
atlas.ready(onAtlasReady);
app.assets.load(atlas);
}
else {
console.log('Replacement texture found for ' + tag + ' atlas!');
// Callback function when an asset is loaded
var onAtlasReady2 = function() {
atlas.resources[0].texture = asset.resource;
self.onAssetsLoaded();
};
atlas.ready(onAtlasReady2);
app.assets.load(atlas);
}
});
it works really well!
The problem I have now, when Im looking for a file using loadFromUrl and is not found, I get an error. I it possible to disable it? I tried to try/catch it, but I always get the error. Maybe loadFromUrl is not the right way to go? Its a valid case for me to not find a file if it wasnt overriden.
In my case, If I dont find anything to be used as an override (texture and localization), I fallback to default. So I would like to disable the errors.