0

我有一种方法可以在 Box2d 中对球施加力。

在桌面上本地测试它工作正常,但在 iPad (ios7) 上,该方法只执行到一半!

我从来没有遇到过这么奇怪的错误,这里有什么问题:

function onTouch(e:TouchEvent) {

    var touch:Touch = e.getTouch(this) as Touch;



    if (touch && touch.phase == TouchPhase.ENDED) {


        //do something

        _debugT.text = "works";


            var mouseX_m:Number = touch.globalX;
    var mouseY_m:Number = touch.globalY;

    _debugT.text = "stops here...";


    var xDiff:Number = mouseX_m - (_whiteBall.GetPosition().x * WORLD_SCALE);
    var yDiff:Number = mouseY_m - (_whiteBall.GetPosition().y * WORLD_SCALE);


    var angle:Number = Math.atan2(yDiff, xDiff);
    var angleDeg:Number = angle * 180 / Math.PI;



    _debugT.text = "never gets executed"



    var len = Math.sqrt((xDiff * xDiff) + (yDiff * yDiff));






    var vx = len * Math.cos(angle);
    var vy = len * Math.sin(angle);



    var vel = _whiteBall.GetLinearVelocity();

    vel.x += (vx * 5);
    vel.y += (vy * 5);



        var force = new b2Vec2(vel.x, vel.y);
        _whiteBall.SetAwake(vel);
        _whiteBall.SetLinearVelocity(force);





    }

}
4

1 回答 1

0

对我来说,它看起来像 Multitouch.inputMode = MultitouchInputMode.GESTURE; 导致这个问题。

我有同样的问题并注释掉了这一行,它现在可以工作了。

于 2015-12-15T16:46:27.227 回答