HitTest between animated Flex components and rotated AS3 components

喜欢而已 提交于 2019-12-11 20:10:39

问题


My app use AIR for Android. I create a roulette wheel on which the ball rolls. Required to detect collition of the ball with the sectors of roulette. At the same time the wheel rotates on its axis. Everything works fine. I combine Flex components and AS3 components. To register contact I use hitTest.

If I debug on the desktop by the emulator, then everything is fine. But when I test my app on my mobile device, the hitTest occurs only at certain times. I see that the roulette wheel spins all right, the ball contact with the sectors, but the hitTest does not occur. The real wheel rotates quite other laws that I watch. And that's just on the real device.

Tell me, how do I fix it?

Here's my ball:

<s:BitmapImage id="pend"  smooth="true" source="@Embed('images/pend.png')"/>

Here's the wheel container where placed sectors, which are created as AS3 components:

stageW = stage.stageWidth;
stageH = stage.stageHeight; 
<mx:UIComponent id="con" mouseChildren="false" width="{stageW}" height="{stageW}" x="{stageW*0.5}" y="{stageH*0.5}"/>

Here I asked to issue with sectors - https://stackoverflow.com/questions/10276336/the-text-around-the-center-of-the-circle-along-the-radius.

Animation of rotation.

con.rotation = rot;
if (FlexGlobals.topLevelApplication.clockwise){
 rot++;
} else {
 rot--;
}

Collision detection:

for (var i:uint = 0; i <objArray.length; i++){
    var sector:Sector = objArray[i] as Sector;
    if (sector.hitTestPoint(pend.x + pend.width*0.5, pend.y + pend.height*0.5, true)){
        var obj:Object = new Object();
        obj.value = sector.value;
        tempArray.push(obj);
        trace (sector.value);
    }
}

来源:https://stackoverflow.com/questions/10344644/hittest-between-animated-flex-components-and-rotated-as3-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!