createTips(str) {
let spineNode = new cc.Node();
spineNode.name = 'tipsNode';
spineNode.setPosition(0, 0);
// spineNode.parent = this.node;
spineNode.parent = cc.find("Canvas");
/* let sprite = spineNode.addComponent(cc.Sprite);
sprite.spriteFrame = this.tipsBg;*/
let ctx = spineNode.addComponent(cc.Graphics);
ctx.fillColor = new cc.Color().fromHEX('#00000066');
let width = str.length * 50;
if (width < 300) {
width = 300;
}
ctx.rect(-(width / 2), -50, width, 100);
ctx.fill();
let node = new cc.Node;
node.parent = spineNode;
let label = node.addComponent(cc.Label);
label.string = str;
spineNode.opacity = 0;
cc.tween(spineNode).by(0.5, {opacity: 255}).delay(0.5).to(0.5, {y: 50, opacity: 0}).call(() => {
console.log("完事")
spineNode.removeFromParent(true);
}).start();
/* spineNode.runAction(cc.sequence(cc.fadeIn(0.1), cc.delayTime(0.5), cc.spawn(cc.moveBy(0.5, 0, 50), cc.fadeOut(0.5)), cc.callFunc(() => {
spineNode.removeFromParent(true)
})));*/
},
本文由 biezhi 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:
2020/06/02 10:20