AS3 hittestobject不工作,不明白为什么 [英] as3 hittestobject not working, dont understand why

查看:370
本文介绍了AS3 hittestobject不工作,不明白为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

碰撞不工作,我不能明白为什么,我把碰撞影片剪辑中的对象,它似乎犯规认识的人,但不与其他,遗憾的指出问题的混乱方式,如果你玩游戏,你会理解。即时开来改变截击的方式工作过,只要它的作品生病是超开心

the collision not working i cant understand why, i put collision movieclips in the object and it doesnt seem to recognise one of the but does with the other, sorry for the confusing way of stating the problem if you play the game you will understand. im open to changing the way collision works too as long as it works ill be super happy

推荐答案

我会尽力解释。当您点击向下或向上英雄(box_mc的)碰撞两扇门Top_Door和Bottom_Door。里面砰的功能,在第一次检查与Bottom_Door的碰撞,所以,英雄总是往下走(.Y + = 100)和第二个条件(Top_Door)永远不会是真实的。如何解决这一问题?添加变量 VAR lastAction:字符串; 。这个变量将保存最后一个动作:向上或向下。里面的down_MC_P功能由降初始化这个变量。里面的up_MC_P - 涨。接下来,替换第一个条件,这个如果(box_MC.hitTestObject(周期[I] .Bot​​tom_Door)及和放大器; lastAction ==下)二:如果(box_MC.hitTestObject(周期[I] .Top_Door)及和放大器; lastAction ==达)。这一切。

I'll try to explain. When You click "Down" or "Up" hero (box_MC) collide with both doors "Top_Door" and "Bottom_Door". Inside "bang" function at first checking collision with "Bottom_Door", so, hero always go down (.y += 100) and second condition (Top_Door) never will be true. How to fix this? Add variable var lastAction:String;. This variable will store last action: "up" or "down". Inside "down_MC_P" function initialize this variable by "down". Inside "up_MC_P" — "up". Next, replace the first condition to this if (box_MC.hitTestObject(cycle[i].Bottom_Door) && lastAction == "down") and second: if(box_MC.hitTestObject(cycle[i].Top_Door) && lastAction == "up"). That's all.

这篇关于AS3 hittestobject不工作,不明白为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆