游戲是圍住神經貓型別的,原本游戲是繪制矢量形狀,然后我現在想改成bitmap圖片型別的,研究了一天了,不知道怎么弄,官方檔案感覺寫的很簡單。求大佬幫忙解決一下~~~
下面是原始碼:
circle.js 檔案
function Circle () {
createjs.Shape.call(this);
this.setCircleType = function (type) {
console.log(type);
this._circleType = type;
switch (type) {
case Circle.TYPE_UNSELECTED:
this.setColor("#cccccc");
break;
case Circle.TYPE_SELECTED:
this.setColor("#ff6600");
break;
case Circle.TYPE_CAT:
this.setColor("#0000ff");
break;
}
}
this.setColor = function (colorString) {
this.graphics.beginFill(colorString);
this.graphics.drawCircle(0,0,15);
this.graphics.endFill();
}
this.getCircleType = function () {
return this._circleType;
}
this.setCircleType(1);
}
Circle.prototype = new createjs.Shape();
Circle.TYPE_UNSELECTED = 1;
Circle.TYPE_SELECTED = 2;
Circle.TYPE_CAT = 3;
app.js 檔案主要代碼
function addCircles(){
for(var indexY=0;indexY<9;indexY++){ //設定橫向圓圈個數
for(var indexX = 0;indexX<9;indexX++){ //縱向圓圈個數
var c = new Circle();
// console.log(c);
gameView.addChild(c);
circleArr[indexX][indexY] = c;
c.indexX = indexX;
c.indexY = indexY;
c.x = indexY%2?indexX*35 + 18:indexX*35; //設定橫向圓圈之間的間隔
c.y = indexY*35; //設定縱向圓圈之間的間隔
if(indexX==4&&indexY==4){ //設定逃跑圓圈初始位置
c.setCircleType(3);
currentCat = c;
}else if(Math.random()<0.2){ //通過亂數來調整游戲難度小數越靠近1,難度越低
c.setCircleType(Circle.TYPE_SELECTED);
}
c.addEventListener("click",circleClicked);
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/105350.html
標籤:JavaScript
