1、Prefab制作
->制作教程:https://docs.cocos.com/creator/manual/zh/asset-workflow/prefab.html
2、编写一个预制板脚本绑定
/*
通用提示框
*/
cc.Class({
extends: cc.Component,
properties: {
Text: { default: null, type: cc.Label },
showTimes: 1, //隐藏时间
jumpHeight: 100, //跳跃高度
_isShow:false,
},
// LIFE-CYCLE CALLBACKS:
setLabelString: function( str )
{
//這邊直接將我們的Label字串設定為 No.#
//this.Text.string = ( str );
//cc.find("background/textCount").getComponent(cc.Label).string = str;
this.node.getChildByName("Text").getComponent(cc.Label).string = str;
},
//按钮点击回调
onConfirBtn:function(callback){
console.log("发布按钮点击回调事件");
this.node.getChildByName("btnconfir").on('click',function(event){
console.log("点击到按钮");
callback();
},this);
},
onLoad:function () {
cc.log("showTips.onLoad")
window.showtips = this;
// 初始化计时器
this.timer = 0;
this.node.active = true;
this.node.getChildByName("layout").on('