Fix vibration bug
This commit is contained in:
parent
b8ef90c100
commit
4dd90b9860
2 changed files with 7 additions and 4 deletions
|
|
@ -25,6 +25,7 @@ export class GameObjectContainer extends CommandReceiver {
|
|||
}
|
||||
|
||||
this.player = c.character as PlayerCharacterView;
|
||||
this.player.isMainCharacter = true;
|
||||
|
||||
this.camera = new Camera(this.game);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
|
|||
private healthElement: HTMLElement = document.createElement('div');
|
||||
private previousHealth;
|
||||
|
||||
public isMainCharacter = false;
|
||||
|
||||
constructor(
|
||||
id: Id,
|
||||
name: string,
|
||||
|
|
@ -50,13 +52,13 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
|
|||
|
||||
public step(deltaTimeInSeconds: number): void {
|
||||
if (this.previousHealth > this.health) {
|
||||
this.previousHealth = this.health;
|
||||
if (OptionsHandler.options.vibrationEnabled) {
|
||||
navigator.vibrate(75);
|
||||
}
|
||||
if (this.isMainCharacter && OptionsHandler.options.vibrationEnabled) {
|
||||
navigator.vibrate(Math.min(200, (this.previousHealth - this.health) * 4));
|
||||
}
|
||||
|
||||
this.previousHealth = this.health;
|
||||
}
|
||||
}
|
||||
|
||||
public onShoot(strength: number) {
|
||||
SoundHandler.play(Sounds.shoot, (0.3 * 2 * strength) / settings.playerMaxStrength);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue