import Common from '../common/Common'; import Define from '../common/Define' cc.Class({ extends: cc.Component, properties: { bg:cc.Sprite, liug1:cc.Prefab, liug2:cc.Prefab, liug3:cc.Prefab, liug4:cc.Prefab, }, // LIFE-CYCLE CALLBACKS: onLoad () { }, randomNum(minNum,maxNum){ switch(arguments.length){ case 1: return parseInt(Math.random()*minNum+1,10); break; case 2: return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); break; default: return 0; break; } }, clickTable(sender) { console.log("clickTable") this.parentNode.clickHall(sender,this.gameid) }, setGameData(x,y,data,parentNode) { var subhall= [ [1 , "hall/cpdd.png"], [2 , "hall/qpdd.png"], [3 , "hall/dzyy.png"], [4 , "hall/agzr.png"], [5 , "hall/dzjj.png"], [6 , "hall/bydd.png"], [7 , "hall/tydd.png"] ] var tempIndex = this.randomNum(1,4) var liug = cc.instantiate(this["liug"+tempIndex]) this.node.addChild(liug) var myhallMap = new Map(subhall); var self = this; this.node.y = y; this.node.x = x; this.gameid = data.id this.parentNode = parentNode var self = this; cc.loader.loadRes(myhallMap.get(data.id), cc.SpriteFrame, function (err, spriteFrame) { self.bg.getComponent(cc.Sprite).spriteFrame = spriteFrame; }); //是否使用本地图片 if (data.iconUrl) { Common.loadImage(Define.GameHttpUrl+data.iconUrl,function(texture){ var sprite = new cc.SpriteFrame(texture); self.bg.getComponent(cc.Sprite).spriteFrame = sprite; }) } // this.node.on(cc.Node.EventType.TOUCH_END, this.clickTable.bind(this)); }, // update (dt) {}, });