Commit 90249662 authored by Vũ Gia Vương's avatar Vũ Gia Vương

add vibratePhone

parent ab2834e3
...@@ -129,12 +129,20 @@ export default class HuController extends cc.Component { ...@@ -129,12 +129,20 @@ export default class HuController extends cc.Component {
eventTarget.emit(PLAY_ROLLING_SOUND); eventTarget.emit(PLAY_ROLLING_SOUND);
cc.tween(this.node) cc.tween(this.node)
.repeat(5, cc.tween(this.node) .repeat(5, cc.tween(this.node)
.call(() => this.vibratePhone())
.to(0.2, { position: cc.v3(40, this.randomY(), 0) }) .to(0.2, { position: cc.v3(40, this.randomY(), 0) })
.to(0.2, { position: cc.v3(-40, this.randomY(), 0) })) .to(0.2, { position: cc.v3(-40, this.randomY(), 0) })
)
.to(0.2, { position: cc.v3(0, 0, 0) }) .to(0.2, { position: cc.v3(0, 0, 0) })
.start(); .start();
} }
private vibratePhone() {
if ("vibrate" in navigator) {
navigator.vibrate(200);
}
}
private randomY(): number { private randomY(): number {
return Math.random() * 100 - 50; return Math.random() * 100 - 50;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment