giorg Posted October 2, 2018 Share Posted October 2, 2018 Hi, I have 3 scenes, with different animations inside the create() of each one. When I do the launch of the second scene from the first one, all is ok, but when I try to launch 3rd scene, in console I get: Invalid Animation Key, or Key already in use for each of the animation of that scene, as if they were already created, then the 3rd scene is not working. Also I might need to start the same scene again, how to achieve this? thanks Link to comment Share on other sites More sharing options...
rich Posted October 2, 2018 Share Posted October 2, 2018 Animations are stored global, not just for a specific Scene, hence the error with the key. I would recommend creating the animations up front, as part of your preload process if possible, then each Scene can use them whenever they like. If you can't do that for some reason, check to see if the animation already exists and if so, skip creating it again when you return to a Scene. blackhawx 1 Link to comment Share on other sites More sharing options...
giorg Posted October 2, 2018 Author Share Posted October 2, 2018 hey rich, thanks for your answer. I'm trying to create the animations in the preload function of my Boot scene, where I load all the assets. But when I do: this.anims.create({ key: 'cassa0', frames: this.anims.generateFrameNames('cassa_attesa', { start: 0, end: 59, prefix: 's4b2cassaattesa_', zeroPad: 4 }), repeat: -1, }); in there (ofc before I do this.load.multiatlas('cassa_attesa', 'cassa_attesa.json'); which works), when I enter my scene I try this.add.sprite(510, 450).play('cassa0'); but I get TypeError: Cannot read property 'frame' of undefined. so I don't know how to access the animation... thanks for any help Link to comment Share on other sites More sharing options...
rich Posted October 2, 2018 Share Posted October 2, 2018 You can't create them in a preload function if they require a texture that preload is trying to load. What I meant was a Preload Scene, i.e. a Scene entirely dedicated to loading your assets, creating animations, etc. Link to comment Share on other sites More sharing options...
giorg Posted October 2, 2018 Author Share Posted October 2, 2018 got it, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts