在iOS上显示Starling-触摸事件处理程序“死亡" [英] Starling on iOS - Touch event handler "dies off"
本文介绍了在iOS上显示Starling-触摸事件处理程序“死亡"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一种在Box2d中向球施加力的方法.
I have a method that applies force to a ball in Box2d.
在台式机上进行本地测试可以正常运行,但在iPad(ios7)上可以正常运行 该方法仅执行到一半!
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);
}
}
推荐答案
对我来说,它看起来像Multitouch.inputMode = MultitouchInputMode.GESTURE;导致此问题.
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.
这篇关于在iOS上显示Starling-触摸事件处理程序“死亡"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文