Fix vibration on iphone

This commit is contained in:
schmelczerandras 2020-10-28 16:34:11 +01:00
parent 7162dc69b9
commit 45b6588701
4 changed files with 16 additions and 10 deletions

View file

@ -1,10 +1,9 @@
import { vec2 } from 'gl-matrix';
import { Renderer } from 'sdf-2d';
import { Circle, Id, PlayerCharacterBase, CharacterTeam, settings } from 'shared';
import { OptionsHandler } from '../options-handler';
import { BlobShape } from '../shapes/blob-shape';
import { SoundHandler, Sounds } from '../sound-handler';
import { VibrationHandler } from '../vibration-handler';
import { ViewObject } from './view-object';
export class PlayerCharacterView extends PlayerCharacterBase implements ViewObject {
@ -52,8 +51,8 @@ export class PlayerCharacterView extends PlayerCharacterBase implements ViewObje
public step(deltaTimeInSeconds: number): void {
if (this.previousHealth > this.health) {
if (this.isMainCharacter && OptionsHandler.options.vibrationEnabled) {
navigator.vibrate(Math.min(200, (this.previousHealth - this.health) * 4));
if (this.isMainCharacter) {
VibrationHandler.vibrate(Math.min(200, (this.previousHealth - this.health) * 4));
}
this.previousHealth = this.health;