|
|
@@ -7,7 +7,7 @@ const { ccclass, property } = cc._decorator;
|
|
|
*/
|
|
|
export default class TipSystem extends cc.Component {
|
|
|
@property({ type: cc.Integer, displayName: "飘动时间" })
|
|
|
- tween_time: number = 3;
|
|
|
+ tween_time: number = 1;
|
|
|
@property({ type: cc.Integer, displayName: "开始坐标x" })
|
|
|
src_x: number = 0;
|
|
|
@property({ type: cc.Integer, displayName: "开始坐标y" })
|
|
|
@@ -15,7 +15,7 @@ export default class TipSystem extends cc.Component {
|
|
|
@property({ type: cc.Integer, displayName: "目标坐标x" })
|
|
|
tar_x: number = 0;
|
|
|
@property({ type: cc.Integer, displayName: "目标坐标y" })
|
|
|
- tar_y: number = 100;
|
|
|
+ tar_y: number = 200;
|
|
|
@property({ type: cc.Integer, displayName: "背景透明度" })
|
|
|
bg_opacity: number = 40;
|
|
|
@property({ displayName: "背景颜色" })
|
|
|
@@ -25,31 +25,42 @@ export default class TipSystem extends cc.Component {
|
|
|
@property({ type: cc.Integer, displayName: "文本字体" })
|
|
|
tip_size: number = 40;
|
|
|
|
|
|
- private labels: cc.Label[];
|
|
|
-
|
|
|
onLoad() {
|
|
|
mk.tip = this;
|
|
|
- this.labels = [];
|
|
|
}
|
|
|
|
|
|
start() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 弹出tips
|
|
|
+ * @param str
|
|
|
+ */
|
|
|
public async pop(str: string) {
|
|
|
let node = await mk.pool.getPrefab("game/prefab/tips");
|
|
|
let node_bg = node.getChildByName("bg");
|
|
|
let node_lbl = node.getChildByName("lbl");
|
|
|
- let bg = node_bg.getComponent(cc.Sprite);
|
|
|
let lbl = node_lbl.getComponent(cc.Label);
|
|
|
- node_bg.opacity = this.bg_opacity;
|
|
|
- // node_bg.color =
|
|
|
+ // node_bg.color = this.bg_color;
|
|
|
+ // node_bg.opacity = this.bg_opacity;
|
|
|
+ // node_lbl.color = this.tip_color;
|
|
|
+ lbl.fontSize = this.tip_size;
|
|
|
+ lbl.string = str;
|
|
|
+ node_bg.width = node_lbl.width + 20 < 200 ? 200 : node_lbl.width + 20;
|
|
|
+ node.width = node_bg.width;
|
|
|
+ node_bg.height = node_lbl.height + 2;
|
|
|
+ node.parent = this.node;
|
|
|
+ node.x = this.src_x;
|
|
|
+ node.y = this.src_y;
|
|
|
+ cc.tween(node)
|
|
|
+ .to(this.tween_time, { x: this.tar_x, y: this.tar_y })
|
|
|
+ .call(() => {
|
|
|
+ node.destroy();
|
|
|
+ mk.pool.return("tips", node);
|
|
|
+ }, this)
|
|
|
+ .start();
|
|
|
}
|
|
|
|
|
|
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-export enum TipType {
|
|
|
- label = 1,
|
|
|
}
|