问题
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