如何使用if语句删除if语句? AS3

编程入门 行业动态 更新时间:2024-10-19 13:27:05
本文介绍了如何使用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

本文发布于:2023-11-23 16:02:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   如何使用

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!