totallybueno Posted September 12, 2014 Share Posted September 12, 2014 Hi there,I guess I´m missing something, I don´t know how to change the texture to a sprite if I need to load it... Ok, so I have a sprite with a texture, and then I have like 400 images (not preloaded) and I need to change the texture of that sprite with one of those not preloaded images, how can I do that? I tried with this.game.load.image("newTexture", path) and this.imagenZapa.loadTexture("newTexture"); but is giving me an error because is not in the cache. How can I fix that, I´m pretty sure there´s a super-basic-way to do it but it seems that my brain is like Intenert Explorer today... Link to comment Share on other sites More sharing options...
JUL Posted September 12, 2014 Share Posted September 12, 2014 http://examples.phaser.io/_site/view_full.html?d=animation&f=load+texture.js&t=load%20texture function changeTexture() {if (sprite.key === 'monster'){sprite.loadTexture('mummy', 0, false);}else{sprite.loadTexture('monster', 0, false);}// sprite.smoothed = false;} Link to comment Share on other sites More sharing options...
totallybueno Posted September 12, 2014 Author Share Posted September 12, 2014 And where are the images preloaded? In the preload function of the state. I need to load those images later, runtime... I´m not gonna preload 400 images to use 2 or 3 Link to comment Share on other sites More sharing options...
totallybueno Posted September 12, 2014 Author Share Posted September 12, 2014 Fixed, thanks to this post: http://www.html5gamedevs.com/topic/6053-dynamic-load-image/ Link to comment Share on other sites More sharing options...
Recommended Posts