我目前正在为Android开发空气曲棍球模拟.对于多人游戏模式,我正在跟踪屏幕上的两个触摸事件,只要触摸点不能关闭,它就能很好地工作.

当两个手指关闭时,android仅在两个点的中间识别一个触摸事件.

更糟糕的是,安卓有时会在碰撞后弄乱ID.

我已经考虑过估计下一个接触点和手动分配ID,有没有人知道更好的方法,或者知道有人已经以编程方式解决了这个问题?
注意:我正在测试三星Galaxy S 3
我有一个关于跟踪iPhone上的触摸的快速问题,我似乎无法得出结论,所以任何建议/想法都非常感谢:
我希望能够跟踪和识别iPhone上的触摸,即.基本上每个触摸都有一个起始位置和一个当前/移动位置.触摸存储在std :: vector中,一旦结束,它们将从容器中删除.他们的位置一旦移动就会更新,但我仍然想跟踪他们最初开始的位置(手势识别).
我从[event allTouches]获得了接触,事实上,NSSet是未排序的,我似乎无法识别已存储在std :: vector中的触摸并引用NSSet中的触摸(所以我知道哪些已经结束,将被删除,或被移动等.)
这是我的代码,当然,它只能在触摸屏上只用一根手指完美地工作,但是不止一个,我确实得到了不可预知的结果......
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
[self handleTouches:[event allTouches]];
}
- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
[self handleTouches:[event allTouches]];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
[self handleTouches:[event allTouches]];
}
- (void) touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event
{
[self handleTouches:[event allTouches]];
}
- (void) handleTouches:(NSSet*)allTouches
{
for(int i = 0; i < (int)[allTouches count]; ++i)
{
UITouch* touch = [[allTouches allObjects] objectAtIndex:i];
NSTimeInterval timestamp = [touch timestamp];
CGPoint currentLocation = [touch locationInView:self];
CGPoint previousLocation = [touch previousLocationInView:self]; …Run Code Online (Sandbox Code Playgroud) 当您在iPhone触摸屏上拖动手指时,它会touchesMoved以漂亮的常规60Hz 生成事件.
但是,从初始touchesBegan事件到第一个事件的转换touchesMoved不太明显:有时设备会等待一段时间.
还等什么呢?更大的时间/距离增量?更多接触到这个事件?
有人知道吗?
重要的是,这种延迟不会发生在随后的手指上,这使得第一次触摸处于明显的劣势.对于需要精确输入的应用程序,如游戏和乐器,这是非常不对称和坏消息.
要看到这个错误/现象在行动
慢慢将iPhone屏幕解锁滑块向右拖动.注意突然跳跃并注意如果你的另一个手指放在屏幕上的任何其他位置,它是如何不发生的
尝试在任意数量的3D游戏中穿过狭窄的桥梁"爬行".令人沮丧!
尝试一个双虚拟操纵杆游戏并注意到效果得到缓解,因为你不得不结束任何可以缓解不愉快的触摸.
应该在8个月前将其记录为一个bug.
我想在我的Android应用程序中处理pinch事件以放大和缩小.
我相信Android 2.0具有多点触控功能,并且听说Android 1.6可能支持也可能不支持它,具体取决于设备.
检测夹点事件的最佳方法是什么,而对于不支持它的设备则优雅地降级?我的目标是Android 1.5向上.
我现在正在全屏显示图像,我想要放大或缩小图像.关于如何实现多点触控图像缩放的任何指南?
我使用的是2.1 sdk版本.
我如何验证该设备是否支持多点触控事件?如果设备具有抗拒显示,则无法进行多点触控.是这样找出来的,设备中有什么样的显示器,或者设备是否支持多点触控?
谢谢.
以下两种方法有什么区别?
int action1 = event.getAction() & MotionEvent.ACTION_MASK;
int action2 = event.getAction();
Run Code Online (Sandbox Code Playgroud) 我正在努力识别iOS应用程序中的触摸,我有这个简单的代码
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"%lu",(unsigned long)[touches count]);
[touches enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
UITouch *touch = obj;
CGPoint touchLocation = [touch locationInNode:self.scene];
NSLog(@"B x:%f - y:%f",touchLocation.x,touchLocation.y);
}];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[touches enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
UITouch *touch = obj;
CGPoint touchLocation = [touch locationInNode:self.scene];
NSLog(@"E x:%f - y:%f",touchLocation.x,touchLocation.y);
}];
}
Run Code Online (Sandbox Code Playgroud)
touchesBegan被称为罚款,如果我同时从屏幕上的1个手指放到5个手指,我看到它被正确的信息调用
同样的情况不会发生touchesBegan,很多时候如果我在屏幕上有3个手指并同时移除它们,我只看到2个触摸的信息被结束(有时甚至1个).如果我一次取出一个手指,该方法通常也会被调用2次(有时为1次,虽然很少会被称为正确的3次)随着触摸次数的增加,一些信息的可能性也不大在touchesEnded方法中显示
方法touchesMoved:withEvent:和touchesCancelled:withEvent:同样实施,同样的逻辑
有人可以解释这种行为吗?有什么我想念的吗?
CSS-scroll-snap运行良好。但是,当您用一根手指在移动设备上滚动时,将这根手指保持在屏幕上并用另一根手指向相反方向滚动(例如缩放?),然后滚动快照会卡住。(无论在哪个浏览器上)
当您在滚动时按住 Ctrl 键时,它甚至可以在桌面上运行。
我不知道这是否是一个常见问题,但我找不到针对此问题的任何修复程序或变通方法。
有什么建议?
自己试试:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<title></title>
<style media="screen">
.container{
scroll-snap-type: y mandatory;
height: 50vh;
width: 50%;
overflow-y: scroll;
}
.content {
scroll-snap-align: center;
height: 50vh;
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<div class="content" style="background:blue;">
1
</div>
<div class="content" style="background:red;">
2
</div>
<div class="content" style="background:green;">
3
</div>
<div class="content" style="background:orange;">
4
</div>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
一个有利的结果是防止这种例外,最好是,或至少优雅地处理它.
我在 Microsoft代码中抛出一个异常.最重要的是,抛出异常的方法是System.Windows.Input.Manipulations.ManipulationSequence.ProcessManipulators我在Microsoft Reference Source中找不到的.
抛出异常时,我可以在它引用的Call Stack窗口中看到一行Windows.Input.Manipulations.ManipulationProcessor2D.ProcessManipulators,这在Microsoft Reference Source中确实存在.
但正如您所看到的,它没有一个名为的兄弟类ManipulationSequence.
至于异常本身,它System.Argument.OutOfRangeException的值是Timestamp values must not decrease. Parameter name: timestamp Actual value was 6590630705479.
抛出异常的方法的完全限定签名是 System.Windows.Input.Manipulations.ManipulationSequence.ProcessManipulators(long timestamp, System.Collections.Generic.IEnumerable<System.Windows.Input.Manipulations.Manipulator2D> manipulators, System.Windows.Input.Manipulations.ManipulationSequence.ISettings settings)
似乎宇宙中的另一个人遇到了这个问题,但根据唯一的评论它无法复制.
我MediaElement在画布上有6个对象在操作时都运行视频,所以我觉得它可能与CPU被征税和减速有关,可能会使时间戳无序地发送到方法中(尽管使用Image而不是MediaElement)时会出现同样的问题.异常偶然发生,有时它会在几秒钟之后乱搞对象,有时可能需要几分钟或更长时间来操作对象.
我在其中执行实际操作的代码ManipulationDelta 如下所示:
//Get current values to manipulate
TransformGroup group = (TransformGroup)element.RenderTransform.Clone();
TranslateTransform translate = (TranslateTransform)group.Children[0].Clone();
ScaleTransform scale = (ScaleTransform)group.Children[1].Clone();
RotateTransform rotate = (RotateTransform)group.Children[2].Clone();
//...does manipulations on each by …Run Code Online (Sandbox Code Playgroud) multi-touch ×10
android ×5
iphone ×2
uikit ×2
.net ×1
c# ×1
cocoa-touch ×1
css ×1
html ×1
imageview ×1
ios ×1
motionevent ×1
pinch ×1
windows ×1
wpf ×1