// Learn cc.Class:
// - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
// - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
// - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
// - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
showMessage:function(msg){
if(msg==null)return
this.speedtimes = 30
this.data = msg //
this.init(this.data)
//var data ={type:1,str=""}
//cc.hb.eventMgr.emit("kkkkk",data);
},
init:function(string,time){//初始化函数
cc.log("tip string", string)
if(string){
this.node.getChildByName("label").getComponent(cc.Label).string = string
}
if(time){
this.node.getChildByName("label").getComponent(cc.Label).string = string
}
var newsonitem = this.node
newsonitem.getComponent(cc.Mask).unscheduleAllCallbacks()
newsonitem.heightsave = 380//newsonitem.height//高度记录
newsonitem.height = 0
var self = this
self.doing = true
newsonitem.getComponent(cc.Mask).schedule(function() {
newsonitem.height += newsonitem.heightsave/(self.speedtimes/2)
if(Math.abs(newsonitem.height-newsonitem.heightsave)<1){
self.doing = true
newsonitem.getComponent(cc.Mask).schedule(function() {
newsonitem.height -= newsonitem.heightsave/(self.speedtimes/2)
if(Math.abs(newsonitem.height)<1){
self.doing = false
}
}, 0.01, self.speedtimes/2 -1, 1)
}
}, 0.01, self.speedtimes/2 -1, 0)
},
// update (dt) {},
});