valueerror Posted April 29, 2014 Share Posted April 29, 2014 lets say i have a sprite sheet with 20 frames and i create my animations out of it.. now i want to change the look of the player completely - i want to change the spritesheet to another one with the exaxt same amount of frames so all my animations would also work with the new spritesheet... but look differently. for now i kill my player and recreate it on the same position.. this seems like a very dirty hack to me.. how to do it right? Link to comment Share on other sites More sharing options...
rich Posted April 29, 2014 Share Posted April 29, 2014 Sprite.loadTexture Link to comment Share on other sites More sharing options...
valueerror Posted April 29, 2014 Author Share Posted April 29, 2014 thx rich.. so i change the player sprite to 'skin2' instead of the initial 'skin1' (key) but that changes the sprite for about a milisecond until the next animation is called (for example 'walk') and since the animations are set up for the player at a time where it had 'skin1' the player changes back immediately.. i thought that maybe there is a way to reinitialize the base spritesheet so everything else would change according to it.. i know this is not trivial since phaser would probably throw lots of errors if the other/new spritesheet is not exactly the same in terms of size, framenumber and so on.. i of course could pack both skins in one spritesheet and define ALL animations twice and then check for a custom variable and play either skin1 animations or skin2 animations.. but changing the base sprite and nothing else seems so much easier.. Link to comment Share on other sites More sharing options...
rich Posted April 29, 2014 Share Posted April 29, 2014 Sorry should have been more clear, you need to set-up the animations again after loading the new texture as each frame is linked to the pixi texture cache. Link to comment Share on other sites More sharing options...
valueerror Posted April 30, 2014 Author Share Posted April 30, 2014 ok thx... i guess it's still better than calling destroy() and reinitialize everything Link to comment Share on other sites More sharing options...
rich Posted April 30, 2014 Share Posted April 30, 2014 I'll have a look into it, it may not be that much work to be able to add a texture parameter to an animation (so it uses the frame data + texture, rather than the default Sprite texture). valueerror 1 Link to comment Share on other sites More sharing options...
valueerror Posted April 30, 2014 Author Share Posted April 30, 2014 this would be great and save several lines of code (not in phaser but in the games of course ^^) Link to comment Share on other sites More sharing options...
Recommended Posts