Starling on iOS - Touch event handler “dies off”

别说谁变了你拦得住时间么 提交于 2019-12-11 21:22:23

问题


I have a method that applies force to a ball in Box2d.

Testing it locally on desktop it works fine, but on iPad (ios7) the method get executed only until the half!

I never came accross such a weird error, what is wrong here:

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);





    }

}

回答1:


To me it looks like Multitouch.inputMode = MultitouchInputMode.GESTURE; causes this problem.

I had the same issue and commented out this line and it works now.



来源:https://stackoverflow.com/questions/19122226/starling-on-ios-touch-event-handler-dies-off

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