[add] first
This commit is contained in:
29
assets/script/ui/common/tips.ts
Normal file
29
assets/script/ui/common/tips.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { _decorator, Component, LabelComponent, Vec3, UITransform, Size, isValid, AnimationComponent } from 'cc';
|
||||
import {PoolManager} from '../../framework/poolManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Tips')
|
||||
export class Tips extends Component {
|
||||
@property(LabelComponent)
|
||||
lbTips: LabelComponent = null!;
|
||||
targetPos: any;
|
||||
|
||||
show (content: string, callback?: Function) {
|
||||
this.targetPos = new Vec3(0, 0, 0);
|
||||
this.node.setPosition(this.targetPos);
|
||||
this.lbTips.string = content;
|
||||
let size: Size = this.lbTips.node.getComponent(UITransform)?.contentSize as Size;
|
||||
if (!isValid(size)) {
|
||||
PoolManager.instance.putNode(this.node);
|
||||
return;
|
||||
}
|
||||
this.node.getComponent(UITransform)?.setContentSize(size.width + 100 < 240 ? 240 : size.width + 100, size.height + 30);
|
||||
|
||||
let animation: AnimationComponent = this.node.getComponent(AnimationComponent) as AnimationComponent;
|
||||
animation.play();
|
||||
animation.once(AnimationComponent.EventType.FINISHED, () => {
|
||||
callback && callback();
|
||||
PoolManager.instance.putNode(this.node);
|
||||
})
|
||||
}
|
||||
}
|
11
assets/script/ui/common/tips.ts.meta
Normal file
11
assets/script/ui/common/tips.ts.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a91d7339-e96d-451b-8be6-e1c5dbf91132",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"simulateGlobals": []
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user