@skycreat 写道:
源码如下:
cc.Class({
extends: cc.Component,properties: { lbn:{ default:null, type:cc.Label }, 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.length); this.lbn.String=maa.toString(); this.touxiang.SpriteFrame=this.tupian[maa]; cc.log(this.lbn.String); cc.log(this.touxiang.SpriteFrame); },
});
控制台log如下:
6(未知)
Object { _name: "6", _objFlags: 0, _rawFiles: null, _capturingListeners: null, _bubblingListeners: null, _rect: Object, _offset: Object, _originalSize: Object, _rotated: false, insetTop: 0, 等 7 项… }控制台log说明label和Sprite的值都已经改变了,为什么更新label的string和Sprite新的图片?
帖子: 2
参与者: 1