Hello all, I have the following three implemented on my LayerColor:
ccTouchesBegan: function (touches) {
console.log(touches);
},
ccTouchesMoved: function (touches) {
},
ccTouchesEnded: function (touches) {
console.log(touches);
}
I then performed the following sequence and monitored my Web Inspector log.
First I touch on the left~~side of screen. Web Inspector outputs:
<pre>[
Class
*point: Object
x: 180
y: 270
proto: Object
*prevPoint: Object
*viewId: 0
proto: Class
]</pre>
So far so good, we can see the coordinates match up. Next, while still holding the initial touch, I also touch on the rightside of the screen. Web Inspector now shows: functions are supposed to only provide the touches that are actually triggering that event. In my case I did them in sequence so I was really only expecting one item
<pre>[
Class
*point: Object
x: 181
y: 276
proto: Object
*prevPoint: Object
*viewId: 0
proto: Class
,
Class
*point: Object
x: 861
y: 276
proto: Object
*prevPoint: Object
*viewId: 0
proto: Class
]</pre>
This is the touchesBegan function that is being triggered, but it is showing two touches. My understanding is that the touches
I then remove my finger on the left~~side of the screen. Web Inspector shows:
<pre>[
Class
*point: Object
x: 861
y: 278
proto: Object
*prevPoint: Object
*viewId: 0
*proto_: Class
]</pre>
Note that these coordinates correspond to the right~~side touch point but I just removed the left~~side finger. Maybe I’m misunderstanding and touches are actually what is currently active on screen? This might make sense, but I would then expect nothing returned when removing the last touch point. However…
When I remove the last, right~~side touch point, Web Inspector shows:
<pre>[
Class
*point: Object
x: 860
y: 279
proto: Object
*prevPoint: Object
*viewId: 0
proto: Class
]</pre>
This indicates that I just removed the right~~side touch, which is true; though that’s not what the event before this one indicated (removed left, touch variable contained right).
So, I’m hoping to get some guidance Maybe my understanding is wrong, or someone’s gone through this themselves and can help me out. I’ve seen mentioned in a few posts a reference to a touch sample application, but I can’t find the link. If anyone knows where it is that’d be appreciated.
My ultimate goal is to have two joysticks (one on each side of the screen), along with a few buttons. I may be able to sneak the buttons in through the cc.Menu approach that people have mentioned, but for two joysticks, I would absolutely require differentiating between touch events.
If you’re still with me here, I appreciate you giving the read. Any insight is more than welcome.
Cheers.