DESKTOP-5RP3AKU\Jisol 5366e3413c 提交
2023-12-25 02:06:56 +08:00

44 lines
1.0 KiB
TypeScript

import { _decorator, Component, Node } from 'cc';
import { app } from '../../../App';
import { GModeEvent } from '../../../battle/modes/GMode';
import { tween } from 'cc';
import { Vec3 } from 'cc';
import RandomUtil from '../../../../../extensions/ngame/assets/ngame/util/RandomUtil';
import { v3 } from 'cc';
const { ccclass, property } = _decorator;
//游戏震屏
@ccclass('ModeShakeScreen')
export class ModeShakeScreen extends Component {
local:Vec3;
onLoad(){
this.local = this.node.position.clone();
app.event.on(GModeEvent.HIT,this.onShakeScreen,this);
}
protected onDestroy(): void {
app.event.off(GModeEvent.HIT,this.onShakeScreen,this);
}
onShakeScreen(){
tween(this.node).
to(0.1, { position: this.local.clone().add(v3(RandomUtil.RandomInt(-5, 5), RandomUtil.RandomInt(-5, 0), 0)) })
.call(() => {
tween(this.node).to(0.1 / 2, { position: this.local.clone() }).start();
})
.start();
}
}