如何使用if语句删除if语句? AS3 [英] How to remove if statement with an if statement? as3
本文介绍了如何使用if语句删除if语句? AS3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做一个游戏,角色必须拿到钥匙后通过大门 所以当他得到密钥的门想走开,我用
I'm making a game where the character has to pass through the gate after getting the key so when he gets the key the gate is suppose to go away, i used
if(character.hitTestObject(gate))
{character.visible = false;
youLose_text.visible = true; }
但是,当他得到的关键是:这是
if(character.hitTestObject(key))
{
gate.visible = false; }
现在,当我穿过大门,我明明再次获得被杀 现在我该怎样删除previous如果通过函数的下一个IF函数?
NOW when i pass through the gate, i obviously get killed again now how do i remove the previous if function through the next if function?
推荐答案
如果门被认为实际上是走开,你应该彻底清除它,而不是只让看不见的...例如:
If the gate is supposed to actually "go away", you should completely remove it, not just make it invisible... e.g.:
if(character.hitTestObject(key)) {
//don't forget to remove event listeners on the gate as well, if it had any
removeChild(gate);
gate = null;
} else if(gate != null) {
if(character.hitTestObject(gate)) {
character.visible = false;
youLose_text.visible = true;
}
}
这篇关于如何使用if语句删除if语句? AS3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文