mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交捕捉
This commit is contained in:
54
JisolGameCocos/assets/script/ui/Consts/Game/ModeRender.ts
Normal file
54
JisolGameCocos/assets/script/ui/Consts/Game/ModeRender.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { app } from '../../../App';
|
||||
import GRoleDefault from '../../../battle/base/role/GRoleDefault';
|
||||
import { GData } from '../../../consts/GData';
|
||||
import { v2 } from 'cc';
|
||||
import { Prefab } from 'cc';
|
||||
import { instantiate } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { ModeRenderHitText } from './ModeRenderHitText';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
export enum ModeRenderEvent{
|
||||
//受击
|
||||
HIT = "ModeRenderEvent_HIT"
|
||||
}
|
||||
|
||||
@ccclass('ModeRender')
|
||||
export class ModeRender extends Component {
|
||||
|
||||
//受击预制体
|
||||
@property(Prefab)
|
||||
hitPrefab:Prefab;
|
||||
|
||||
onLoad(){
|
||||
|
||||
app.event.on(ModeRenderEvent.HIT,this.onHit,this);
|
||||
|
||||
}
|
||||
|
||||
protected onDestroy(): void {
|
||||
|
||||
app.event.off(ModeRenderEvent.HIT,this.onHit,this);
|
||||
|
||||
}
|
||||
|
||||
//受击
|
||||
onHit(role:GRoleDefault,hit:number){
|
||||
|
||||
if(!role.get()) return;
|
||||
|
||||
let rolePos = GData.WorldCanvas.camera.worldToScreen(role.node.worldPosition);
|
||||
|
||||
let hitNode = instantiate(this.hitPrefab);
|
||||
|
||||
this.node.addChild(hitNode);
|
||||
hitNode.position = rolePos.add(v3(0,100,0));
|
||||
|
||||
hitNode.getComponent(ModeRenderHitText).setText(hit);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "00e93335-8301-435f-83b1-b83f29e48e8b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
import { tween } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { Label } from 'cc';
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('ModeRenderHitText')
|
||||
export class ModeRenderHitText extends Component {
|
||||
|
||||
@property(Label)
|
||||
hitLabel:Label;
|
||||
|
||||
setText(hit:number){
|
||||
|
||||
this.hitLabel.string = `${hit}`;
|
||||
|
||||
this.setAnimation();
|
||||
|
||||
}
|
||||
|
||||
//设置动画
|
||||
setAnimation(){
|
||||
|
||||
this.node.scale = v3(0,0,0);
|
||||
|
||||
tween(this.node)
|
||||
.to(.5,{position:this.node.position.clone().add(v3(0,100,0)),scale:v3(1,1,1)},{
|
||||
onComplete:() => {
|
||||
this.node.destroy();
|
||||
},
|
||||
easing:"quadInOut"
|
||||
})
|
||||
.start();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "fad17282-4ea6-418f-89c6-09bff1b47c62",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user