【bug】使用pixi做虚拟摇杆时候发现的bug-不同的touch事件最后都可以出发touchend,即使没有touchstart先
2016-02-26 17:21
856 查看
资料
[这一篇有价值:Multitouch (Joystick + Button) not working, only repsonding to latest touch #1979](https://github.com/pixijs/pixi.js/issues/1979)
UncleAcid commented on 16 Jul 2015 v3's interaction manager is not allowing me to have a joystick with a button in my game (run and jump). I touch the joystick and it's fine, as soon as I touch anywhere else as well the joystick starts responding to where the latest moved touch is. Am I just missing something or is this a bug in the interaction manager ? In my touch start I'm setting this.data = event.data and in my touch moved I'm using this.data.getLocalPosition ... I am aware of #1917, but I can't figure out how to implement it (I've tried so many ways and nothing works), and I'm not even sure that will solve my problem because there's no demo or anything.
englercj commented on 16 Jul 2015 or is this a bug in the interaction manager ? That, multitouch support doesn't work in the current Interaction manager.
UncleAcid commented on 16 Jul 2015 Ah, lame. I'm just going to try @weepy's hack from #1917 once he posts it and see if that works for now. You may want to remove the comment "This manager also supports multitouch." from the interaction manager's constructor for now (until it actually does support multitouch) as it's misleading.
GoodBoyDigital commented 25 days ago closing this as multitouch support is working in dev branch. (using data.identifier) thanks!
Multitouch behaviour #2338
好了,摘要如下:
stdiopt commented 22 days ago Hi I was trying to create a pinch to scale feature, and come to realize that Event is being fired for every finger independently causing some excessive calls tho performance issues on mobile phones. is there any plans in this matter? I've seen in code the InteractionManager "//TODO POOL"
fs-manabu-iwata commented 20 days ago Hi. This library works fine for me. https://github.com/dekimasoon/pixi-simple-gesture[/code]stdiopt commented 20 days ago Hi, Thanks for the suggestion It seems that, that lib uses pixijs on('touchmove') which is the same called once per finger in a pinch its called twice, I ended up implementing gesture myself using default touchmove event from html5 and some pixijs internals to map touch to local, this way is called less frequent (pool) even if two fingers moved @stdiopt stdiopt commented 20 days ago Sample tests: https://jsfiddle.net/jorg6zt9/1/ https://www.youtube.com/watch?v=cqemvQwzglsstdiopt commented 20 days ago Sample tests: https://jsfiddle.net/jorg6zt9/1/ https://www.youtube.com/watch?v=cqemvQwzgls
另一篇资料:
Multitouch Interaction Manager #1917weepy commented on 24 Jun 2015 I was under the impression that PIXI v3 was "multitouch ready". However looking at the InteractionManager, it seems that there's a single .eventData property that holds the state of the various touches. Its properties get overwritten when various touches get updated - meaning it's impossible to reason about the state of the touches. It seems to me that to fix this we should make eventData an object using the key of each touch ? Does this seem like a sensible approach ? JRoryPicko commented on 24 Jun 2015 @weepy I have managed a multitouch PinchGesture using e.data.originalEvent.touches within one touch 'touchstart' event on a Container, is this what you mean?weepy commented on 24 Jun 2015 I mean that this.eventData is essentially the last touch event, but this isn't very useful if you want to process another touch that was previous to this. I'm trying out a hack that swaps this.eventData to the current touch in each of the handlers like so : this.eventData = this.eventDataObject[touchData.identifier] = this.eventDataObject[touchData.identifier] || this.createNewEventData()UncleAcid commented on 16 Jul 2015 I'm having an issue (#1979) that sounds like your hack would work but I can't figure out how to implement it, or if I did implement it properly it didn't work. Because I'm not sure if this will solve my issue, I'm not sure if I implemented it correctly. Do you have a jsfiddle or something with your fix in place ?weepy commented on 16 Jul 2015 Yes my fix has been working for me. I can upload soon...weepy commented on 16 Jul 2015 so I replaced : this.eventData = { stopped: false, target: null, type: null, data: this.mouse, stopPropagation:function(){ this.stopped = true; } }; with this.eventDataObject = {} this.createNewEventData = function() { return { stopped: false, target: null, type: null, data: this.mouse, stopPropagation:function(){ this.stopped = true; } }; } this.eventData = this.createNewEventData() and added this.eventData = this.eventDataObject[touchData.identifier] = this.eventDataObject[touchData.identifier] || this.createNewEventData() after each (3 of): touchData.originalEvent = event; here's the latest version of pixi + my changes https://gist.github.com/weepy/73354fb4e0022ce12939[/code]UncleAcid commented on 16 Jul 2015 Thanks for posting, that's exactly what I had done when trying to implement this however there is no change to the behavior for me. I start dragging the joystick and all is well and then as soon as I touch anything else the joystick is now responding to that touch, and then whatever touch is the most recently updated ... I don't know what I'm missing here.SirKnightDragoon commented on 6 Aug 2015 Actualy, you can do multitouch with Pixi v3, but you need to build your own EventManager to control the touches id in memory, the order to know the first, second touch etc. My events tested: start, move, end, endout, endorout, tap, doubletap, pinchstart, pinchmove, pinchend, hold, holdlong. I'm working on a editor, with move, zoom, multitouch pinch like googlemap, so yes that's work ! You need: e.data.originalEvent.timeStamp e.data.originalEvent.touches e.data.originalEvent.changedTouches changedTouches[i].identifier (i == index) changedTouches[i].clientX ... Y With all these data, you should do it easily!Friksel commented 3 days ago Hum... I was hoping multitouch was working out of the box too, like the repository of pixi v3 there says. There is an example on http://www.goodboydigital.com/pixijs/examples/8/ where it does work, but that's still build on pixi version 1 wich isn't compatible with v3. With the growing number of mobile/touch devices and the growing use of multitouch as intuitive interaction an easy way of handling multitouch would be nice inside the standard pixi lib in my opinion. Any chance this will be implemented any time soon? Or will this work in v4?
第三篇资料
Multitouch: objects receive wrong touchend event #2309alclub commented on 23 Jan BUG: If two sprites are handling touchstart and touchend events, sometimes one sprite receives BOTH touchend events, and the other sprite does not receive any touchend events. Here is a gif demonstrating the effect: https://gfycat.com/PleasingIncompleteAardwolf As you can see in the console, a sprite will receive a touchstart event, then remember the touch 'identifier' that is embedded in the event. All sprites receive ALL unrelated touchmove events, therefore the sprite must filter out events which pertain to itself by checking the identifier in each event (not printed to console). However, sometimes one sprite receives all the touchend events, including those that contain identifiers associated with the other sprites. These other sprites don't get their touchend events. SOLUTION: The workaround stated here involving adding checks to the processTouchStart and processTouchEnd: http://www.html5gamedevs.com/topic/19273-can-container-get-touchup-event-when-touchdown-of-other-container-press/ Alternatively, perhaps all sprites should receive all touchend events, just like they receive all touchmove events, and allow each sprite to remember its own touchstart identifier, and then listen for a touchend which has the same identifier.
相关文章推荐
- getline()之前存在cin时的使用
- 【Elasticsearch】深入Elasticsearch集群
- JavaScript之贪吃蛇
- 浅谈Android开发中内存泄露与优化
- 利用Spark Streaming来实现实时的数据管道服务
- iOS开发之微信聊天工具栏的封装
- Html 链接、图像、表格、表单、背景
- Java 多线程:多线程产生的原因
- 百度地图API地理位置和坐标转换
- iOS项目的完整重命名方法图文教程
- Android模糊效果总结
- 【转】Activity启动模式图文详解:standard, singleTop, singleTask 以及 singleInstance
- angular 的广义回调管理
- 001_Http之客户端-服务端-servlet
- 菜鸟学SSH(十八)——Hibernate动态模型+JRebel实现动态创建表
- bzoj 1007 : [HNOI2008]水平可见直线 计算几何
- 关于vba读取excel文件
- Java中String和List的引用
- Sql Server 实现 Mysql Limit 功能
- Java 多线程:volatile 多线程同步关键字