我正在做一个游戏,角色在拿到钥匙后必须穿过大门,所以当他拿到钥匙时,大门就应该消失了,我用
if(character.hitTestObject(gate))
{character.visible = false;
youLose_text.visible = true; },但当他拿到钥匙时:这是
if(character.hitTestObject(key))
{
gate.visible = false; }现在,当我通过大门时,我显然又被杀死了,,现在我如何通过下一个if函数删除以前的if函数?
发布于 2014-08-19 12:41:50
如果大门真的要“走开”,你应该把它完全移开,而不是让它看不见.例如:
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;
}
}发布于 2014-08-19 07:12:20
只需设置/检查布尔值即可。其中一个已经存在于gate.visible中。
// If gate is visible and character hitTests gate then..
if(gate.visible && character.hitTestObject(gate)) {
character.visible = false;
youLose_text.visible = true;
}https://stackoverflow.com/questions/25377459
复制相似问题