BlockSkillBombView.ts
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { GlobalEvent } from "../Global";
import { getGlobalNode } from "../kernel/battle/BattleConst";
import { MapView } from "../kernel/battle/map/MapView";
import GlobalNode from "../kernel/GlobalNode";
import { BlcokSkillViewBase } from "./BlockSkillViewBase";
import BlockView from "./BlockView";
export class BlockSkillBombView extends BlcokSkillViewBase {
private _spIdleNode: cc.Node;
private _spBoomNode: cc.Node;
constructor(owner: BlockView, mapView: MapView) {
super(owner, mapView);
this._spIdleNode = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('game_bomb01'));
this._spBoomNode = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('game_boom01'));
this.onPositionChange(this._owner.owner.pixelPos.x, this._owner.owner.pixelPos.y);
this._spBoomNode.active = false;
this._spIdleNode.active = true;
mapView.effectLayer.addChild(this._spBoomNode);
mapView.effectLayer.addChild(this._spIdleNode);
this._spIdleNode.getComponent(sp.Skeleton).setAnimation(0, 'animation', true);
}
onPositionChange(x: number, y: number): void {
this._spBoomNode.setPosition(x, y);
this._spIdleNode.setPosition(x, y);
}
onDead(): void {
super.onDead();
this._spIdleNode.destroy();
this._spBoomNode.active = true;
this._spBoomNode.getComponent(sp.Skeleton).setCompleteListener(() => {
this._spBoomNode.destroy();
});
this._spBoomNode.getComponent(sp.Skeleton).setAnimation(0, 'animation', false);
//震屏
getGlobalNode().emit(GlobalEvent.SHAKE, true);
getGlobalNode().getComponent(GlobalNode).scheduleOnce(() => { getGlobalNode().emit(GlobalEvent.SHAKE, false); }, 0.3); //0.5秒后关闭
}
}