私はCordova Phaserゲームを開発しました。 AndroidとiOS端末で動作します。Cordovaを使用してフェイザーゲームで高いメモリ使用量を避けるには?
ゲームには7つのレベルがあり、各レベルにはいくつかのスプライト(背景、プレイヤー)とグループ(弾丸、敵)があります。レベルは、私がそうでstartlevel(2)
とを呼び出す終了すると
はpreload
機能では、私はすべての画像をロードしてatlasJSONHash
function preload(){
game.load.atlasJSONHash('anim', 'anim.png', 'anim.json');
//and so on
}
function create(){
var star = game.add.sprite(160, 32, 'level1bg');
star.x = 0;
star.y = 0;
star.height = game.height;
star.width = game.width;
bullets = game.add.group();
bullets.enableBody = true;
bullets.physicsBodyType = Phaser.Physics.ARCADE;
bullets.createMultiple(30, 'bullet');
bullets.setAll('anchor.x', 0.5);
bullets.setAll('anchor.y', 1);
bullets.setAll('outOfBoundsKill', true);
bullets.setAll('checkWorldBounds', true);
//and so on
}
function startlevel(level)
{
var star = game.add.sprite(160, 32, 'level1bg');
star.x = 0;
star.y = 0;
star.height = game.height;
star.width = game.width;
bullets = game.add.group();
bullets.enableBody = true;
bullets.physicsBodyType = Phaser.Physics.ARCADE;
bullets.createMultiple(30, 'bullet');
bullets.setAll('anchor.x', 0.5);
bullets.setAll('anchor.y', 1);
bullets.setAll('outOfBoundsKill', true);
bullets.setAll('checkWorldBounds', true);
//and so on
}
ています。
ブラウザでは正常に動作しますが、モバイルメモリでは各レベルで倍増し、最終的にアプリがクラッシュします。このメモリの問題を回避するにはどうしたらいいですか?