こんにちは私は、プレーヤーが画面に触れるたびに弾丸を生成する機能を持っています。弾丸の発射速度または生成速度位相器
弾丸の量を制限する方法はありますか?基本的に私は非常に迅速に弾丸の多くが生成されますが、私は少なくとも毎秒2または3の代わりにi
に制限したいと思います。あなた以下
私の発射機能と私の弾丸作成機能を見つけることができます。
createBullets: function(){
//Bullets
this.bullets = this.add.group();
this.bullets.enableBody = true;
this.bullets.physicsBodyType = Phaser.Physics.P2JS;
this.bullets.createMultiple(500, 'bullet', 0, false);
this.bullets.setAll('anchor.x', 0.5);
this.bullets.setAll('anchor.y', 0.5);
this.bullets.setAll('outOfBoundsKill', true);
this.bullets.setAll('checkWorldBounds', true);
},
fireBullet: function(){
this.bullet = this.bullets.getFirstExists(false);
if (this.bullet) {
this.bullet.reset(this.tanque.x, this.tanque.y - 20);
this.bullet.body.velocity.y = -500;
}
},
と私の更新機能:
if(this.input.activePointer.isDown){
if (!this.mouseTouchDown) {
this.touchDown();
}
}else {
if (this.mouseTouchDown) {
this.touchUp();
}
}
私は本当に感謝すべてのヘルプを。
- nextShotTime:ショットが
- shotDelayを焼成することができる次の時間:ショット間の遅延(
Phaser.Timer.SECOND * 2
のように設定することができます)
Iドン