saibotlive Posted October 15, 2013 Share Posted October 15, 2013 Whenever I create an external js class object for my sprites or create states, the performance of my game becomes unusable on mobile but if I have all my code in one js file without the use of creating states or any class object, it works very well. I have no idea why it does this on just mobile (IOS and Android). Is there something I could be missing? Link to comment Share on other sites More sharing options...
rich Posted October 15, 2013 Share Posted October 15, 2013 All our games (client and personal) use one JS file per class/State and lots of external objects without issue, so I'd really need to see what is going on in your specific case before I could offer any suggestions as to what might be causing it. Link to comment Share on other sites More sharing options...
saibotlive Posted October 15, 2013 Author Share Posted October 15, 2013 This is the link here: http://saibotconcepts.co.uk/testgame/ Thanks for your help. Link to comment Share on other sites More sharing options...
saibotlive Posted October 15, 2013 Author Share Posted October 15, 2013 This is without class objects or states: http://saibotconcepts.co.uk/testgame/test2.html Link to comment Share on other sites More sharing options...
onedayitwillmake Posted October 15, 2013 Share Posted October 15, 2013 The reason is probably related to cleaning up after yourself, not the fact that you're using external files.How are you removing the sprites? Are you sure you're clearing up any references you have to objects once you change states? You're likely running out of memory, use the chrome dev tools profiler to check your heap allocations. I am currently working on a game, and it runs fine on mobile with ~250 objects at once, dying and creating new ones such that after a minute it probably has spawned over 4000 objects.I had an issue at first until I found out the correct way to remove a sprite:// View is a Phaser.Sprite if( this._view.input ) { this._view.input.destroy(); } this._view.kill(); if (this._view.group) { this._view.group.remove(this._view); } else if (this._view.parent) { this._view.parent.removeChild(this._view); }I added the "this._view.input.destroy" part as an assurance, but I'm not sure if that bit is required. Anyway without that kill + remove bit that your memory usage will go up and up until the framerate on mobile is unplayable Hsaka 1 Link to comment Share on other sites More sharing options...
saibotlive Posted October 15, 2013 Author Share Posted October 15, 2013 Thanks onedayitwillmake, I noticed I mistakenly added 1000 bubble objects in my external xml file which affected the performance. I've also added that function and it makes it even a lot faster now :-). RestingCoder 1 Link to comment Share on other sites More sharing options...
Recommended Posts