The “type” attribute of “touxiang.lbn” is undefined when loading script.
cc.Class({
extends: cc.Component,
properties: {
lbn:{
default:null,
type:cc.Lable
},
touxiang:{
default:null,
type:cc.Sprite
},
tupian:{
default:[],
type:cc.SpriteFrame
}
},
onLoad: function () {
function gettouxiang(min,max){
var ma=cc.random0to1();
return min+Math.floor((max-min)*ma);
}
var maa=gettouxiang(1,this.tupian.lenth);
this.lbn.String=maa.toString();
this.touxiang.SpriteFrame=tupian[maa];
},
});