图片的整理

//舞台节点
_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))];
//添加图片给currentUrl 
var 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
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值