//舞台节点 _gameUI:null,_init:function(){this._gameUI = getNodeByjson(res.game_canvar_json); this.addChild(this._gameUI);//游戏界面
this._picPanel=getWidgetByName(this._gameUI,"图片"); //_picPanel 容器}//获取加载外部结构的节点 getNodeByjson = function(source){ return ccs.load(source).node; };//获取显示对象 getWidgetByName=function(par,name){ return ccui.helper.seekWidgetByName(par,name); };this._currentUrl = res["png_"+(1+parseInt(Math.random()*9))]; //添加图片给currentUrlvar texture = cc.textureCache.addImage(this._currentUrl); //将一张图片添加到缓存里 var baseSp = new cc.Sprite(this._currentUrl); baseSp.setAnchorPoint(0,0);//取得坐标baseSp.setPosition(50,(cc.winSize.height-baseSp.height)>>1);//设置坐标位置baseSp.attr({opacity:100, anchorX:0, anchorY:0, x:10, y:10}); this.addChild(baseSp);var imgWidth = baseSp.width/TOTAL; //取得一块儿的宽 imgWidth var imgHeught = baseSp.height/TOTAL; //取得一块儿的高 imgHeught for(var i = 0;i <TOTAL;i++){ for(var j = 0; j < TOTAL;j++){ var cellSp = new Cell(texture, // cell 添加类场景 cellSp 碎片 cc.rect(i*imgWidth,j*imgHeught,imgWidth,imgHeught), cc.p(baseSp.x + i*imgWidth, baseSp.y - j*imgHeught+baseSp.height), this.checkAllCellReachTarget.bind(this)设置碎步存放的位置); cellSp.setAnchorPoint(0,1); this._picPanel.addChild(cellSp,1); this._shredArr.push(cellSp);} }判断碎步的存放是否对checkAllCellReachTarget:function(){ for(var index in this._shredArr){ var ob = this._shredArr[index]; if(!ob.reachTarget) return }
图片的整理
最新推荐文章于 2022-03-20 23:51:00 发布