Project1
标题:
多次创建同一精灵怎么使其不累加
[打印本页]
作者:
玄羽
时间:
2018-10-23 16:30
标题:
多次创建同一精灵怎么使其不累加
多次创建同一精灵怎么使其不累加,或者说把之前创建的移除
创建精灵的函数绑定了命令窗口,会反复调用
作者:
yang1zhi
时间:
2018-10-23 16:53
创新的肯定是新的。
既然你有旧的,为什么不用旧的。
移除精灵的代码是
.removeChild(精灵);
作者:
玄羽
时间:
2018-10-24 12:53
yang1zhi 发表于 2018-10-23 16:53
创新的肯定是新的。
既然你有旧的,为什么不用旧的。
移除精灵的代码是
removeChild该放到哪里,我之前试的都不管用
Scene_BattleMenu.prototype.createBattleChapter = function(){
var T_Buttons= [
'001',
'002',
'003'
];
var clicks=[
function(){nowLookingChapter=1; this.createBattleLevel();},
function(){nowLookingChapter=2; this.createBattleLevel();},
function(){nowLookingChapter=3; this.createBattleLevel();}
];
this._T_Buttons=[];
for(var i in T_Buttons){
var sprite=new Sprite_Button();
sprite.bitmap=ImageManager.loadBitmap('img/battlechapter/',T_Buttons[i]);
sprite.x=100;
sprite.y=100+i*50;
sprite.setClickHandler(clicks[i].bind(this));
this._T_Buttons.push(sprite);
this.addChild(sprite);
};
};
Scene_BattleMenu.prototype.createBattleLevel = function(){
var T_Buttons;
switch(nowLookingChapter){
case 1:
T_Buttons= ['001_1','001_2','001_3','001_4'];
break;
case 2:
T_Buttons= ['002_1','002_2','002_3','002_4'];
break;
case 3:
T_Buttons= ['003_1','003_2','003_3','003_4'];
break;
}
var clicks=[
this.createBattlelevel,
this.createBattlelevel,
this.createBattlelevel,
this.createBattlelevel
];
this._T_Buttons=[];
for(var i in T_Buttons){
var BattleChapter=new Sprite_Button();
BattleChapter.bitmap=ImageManager.loadBitmap('img/battlechapter/',T_Buttons[i]);
var xzb = [700,1000,700,1000];
var yzb = [200,200,360,360];
BattleChapter.x=xzb[i];
BattleChapter.y=yzb[i];
BattleChapter.setClickHandler(clicks[i].bind(this));
this._T_Buttons.push(BattleChapter);
this.addChild(BattleChapter);
};
};
Scene_BattleMenu.prototype.createBattlelevel = function(){
};
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1