
如圖的兩只東西是游戲里面的炸彈,它們是我的類Bomb的實體化的物件,不過有個問題,假設我在舞臺上new炸彈A,再new炸彈B,也就是如以下代碼:
main.js檔案:
var noBrain = new Bomb(“nobrain”);
gameView.addChild(noBrain);
var noHappy = new Bomb("nohappy");
gameView.addChild(noHappy);
Bomb.js檔案(定義Bomb類):
function Bomb(type){
this.buildBomb(type);
}
Bomb.prototype = new createjs.Container();
Bomb.prototype.Mbody = new createjs.Sprite();
Bomb.prototype.buildBomb = function(type){
switch (type){
case "nohappy":
var spritesheet = new createjs.SpriteSheet({
"images": ["./img/mainPage/character_1.png"],
"frames": {
"height": 313,
"count": 10,
"width": 277
},
framerate:30,
animations: {
stand: 0,
run0: [0,9],
}
});
this.Mbody = new createjs.Sprite(spritesheet, 'run0');
this.Mbody.gotoAndPlay(parseInt(Math.floor(Math.random()*10)));
break;
case "nobrain":
var spritesheet = new createjs.SpriteSheet({
"images": ["./img/mainPage/character_2.png"],
"frames": {
"height": 560,
"count": 10,
"width": 284
},
framerate:30,
animations: {
stand: 0,
run0: [0,9],
}
});
this.Mbody = new createjs.Sprite(spritesheet, 'run0');
this.Mbody.gotoAndPlay(parseInt(Math.floor(Math.random()*10)));
break;
default:
break;
}
this.addChild(this.Mbody);
}
就會出現這樣的情況,我不知道是不是SpriteSheet(精靈表)的問題,求大神指教。。。
(亂@了系統推薦的五位大神,若有打擾,在下在這里陪個不是 T-T)
uj5u.com熱心網友回復:
@lanix516 求大神指教~
uj5u.com熱心網友回復:
而且,精靈的速度隨著這個Bomb類 new出的物件增加而增倍,new一個物件增一倍,new兩個增兩倍,new三個增三倍,不管建構式傳入的type是“nobrain”還是“nohappy” ~~uj5u.com熱心網友回復:
就是繪制物件時,精靈圖累計繪制的問題~ 你看 兩個物體重疊了轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/74307.html
標籤:其它游戲引擎
