105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
|
|
|
|
var yingshe = {
|
|
// 10086:"zisha"
|
|
1:"text_icon1",
|
|
2:"text_icon2",
|
|
11:"text_icon11",
|
|
12:"text_icon12",
|
|
21:"text_icon21",
|
|
31:"text_icon31",
|
|
41:"text_icon41",
|
|
42:"text_icon42",
|
|
43:"text_icon43",
|
|
51:"text_icon51",
|
|
61:"text_icon61",
|
|
71:"text_icon71",
|
|
81:"text_icon81",
|
|
101:"text_icon101",
|
|
102:"text_icon102",
|
|
202:"text_icon202",
|
|
902:"text_icon902",
|
|
905:"text_icon905",
|
|
9000000:"text_icon9000",
|
|
9000001:"text_icon9001",
|
|
9000002:"text_icon9002",
|
|
9000003:"text_icon9003",
|
|
9000004:"text_icon9004"
|
|
}
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
lb_tip:{
|
|
default:null,
|
|
type: cc.RichText,
|
|
},
|
|
ndbg:{
|
|
default:null,
|
|
type: cc.Node,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
start () {
|
|
this.time = 0
|
|
},
|
|
ColorTo_RGB(color) {
|
|
var r = 0xFF & color;
|
|
var g = 0xFF00 & color;
|
|
g >>= 8;
|
|
var b = 0xFF0000 & color;
|
|
b >>= 16;
|
|
return cc.color(b, g, r, 255)
|
|
},
|
|
|
|
setdata(dat){
|
|
var str = ""
|
|
var color = 0
|
|
for(var i=0;i<dat.elements.length;i++){
|
|
if(dat.elements[i].element_type==1){
|
|
var txtdata = dat.elements[i].union_obj_1
|
|
str+="<color=#"
|
|
str+=this.ColorTo_RGB(txtdata.color).toHEX('#rrggbb')
|
|
str+=">"
|
|
str+=txtdata.text
|
|
str+="</color>"
|
|
// color = txtdata.color
|
|
}
|
|
else if(dat.elements[i].element_type==2){
|
|
var imgdata = dat.elements[i].union_obj_2.id
|
|
var imaname = yingshe[imgdata]
|
|
if(!imaname){
|
|
imaname = imgdata
|
|
}
|
|
str = str + "<img src =\"" + imaname +"\" height=28 align=center/>"
|
|
}
|
|
}
|
|
this.time = 0
|
|
// this.lb_tip.node.color = this.ColorTo_RGB(color)
|
|
this.lb_tip.string = str
|
|
// this.lb_tip._updateRenderData(true)
|
|
// this.node.width = this.lb_tip.node.width/2+10
|
|
},
|
|
|
|
update (dt) {
|
|
this.time+=dt;
|
|
this.ndbg.width = this.lb_tip.node.width/2+10
|
|
if(this.time>3){
|
|
cc.gameMgr.uic.huishoubattip(this.node)
|
|
}
|
|
},
|
|
});
|