I have made a simple mobile game following this tutorial:
The only major difference is that I used Phaser.CANVAS instead of Phaser.AUTO as Phaser.AUTO doesn’t work on my phone for some reason, neither does Phaser.WEBGL.
The problem is that the game crashes within half a minute if you move and shoot continuously. It even crashes if you pause between shoots and then continue, although then the game works for a little bit longer.
I have tried decreasing bullet life time and increasing the duration between shots but this only helped to extend play time by a few seconds.
Also the joysticks freeze when both of them are used simultaneously in non-fullscreen mode as this triggers the fullscreen call and on entering fullscreen mode they freeze. You can safely enter full screen mode by double tapping the game or single tapping the background.
Everything freezes. The joystick, player and bullets freeze. The game takes no more input. Even the scaling gets messed up when entering full screen and then rotating the device.
Thanks, that solves the problem of the joysticks getting stuck on going full screen but the game still freezes within 15~20 seconds of continuous moving and shooting.
I’ll make a separate button to call full screen.
Commenting out the below two lines in the update loop seems to fix the problem.
I think it’s because of the way shooting was implemented in the tutorial. They made a class Bullet and kept creating objects of that every time I shoot. Is there a fix to this? Or is there a better way to implement shooting?
Even if i destroy the bullets as soon as they leave the screen, the game still freezes within 15 seconds. This is how I am deleting them in the update loop.
this.bullets.children.each(function(b){
if (!this.cameras.main.worldView.contains(b.x,b.y))
b.destroy();
},this);
The game runs anywhere between 15~30 seconds no mater what I try.
I tried this on my laptop as well and it didn’t freeze on that. Maybe its just my old phone. But is there a better way to implement shooting? Or should I just use my laptop for testing?