AS3 hittestobject不工作,不明白为什么不明白、工作、hittestobject

2023-09-08 14:57:03 作者:暖心男神。

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

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.

 
精彩推荐
图片推荐