0
私は、左から右へ、またはその逆の2種類のブロックを生成するグループがあります。それは本当に重要ではありません。私のランダム化はうまくいくようですが、ゲームをリフレッシュするだけで問題は変わります。しかし、それをそのまま実行すると、リフレッシュするまでは常に同じ種類のブロックになります。これをどうすれば解決できますか?グループ内のスプライトのフェーザランダム生成
createOnebloque: function() {
this.bloquecs = ["bloqueSprite", "bloquelSprite"]; ////// Here are the 2 sprites
this.bloquesr = this.bloquecs[Math.floor(Math.random() * 2)]; /// Here I randomize, but it only works when I refresh.
this.bloque = this.game.add.group();
this.bloque.createMultiple(5, this.bloquesr);
this.bloque.setAll('anchor.x', 0.5);
this.bloque.setAll('anchor.y', 0.5);
this.bloque.setAll('outOfBoundsKill', true);
this.bloque.setAll('checkWorldBounds', true);
},
makeBloques: function() {
this.bloques = this.bloque.getFirstExists(false);
if (this.bloques) {
this.bloques.reset(1440, 1400);
this.game.physics.arcade.enable(this.bloques);
this.bloques.enableBody = true;
this.bloques.body.immovable = true;
this.bloques.body.velocity.x = -2000;
}
}
これは、以下の作成目的球に行く:
this.game.physics.arcade.collide(this.bullets, this.bloque, this.collisionBulletBloque, null, this);
おかげさまで私はテストして元気に帰ってきました。 – Rafahc
私は2つの要素(this.bloquecs)を1と2を繰り返し表示していますが、3つのモアを追加して配列内に5つの要素を作成すると、3つの要素がシャッフルされます。共通の行動? – Rafahc