Any advice on disambig between a touchstart and dragstart? Essentially canceling the touchStart and touchEnd events when a dragstart begins?
Basically i check the delta value by logging x pos(y pos) on TouchStart and TouchEnd. If delta value is lower than n pixel, it's a touch, otherwise it's drag.
^ yes this. I've been working on a sideways pivot VS list control and that's how I did it as well.
koen bok has an example project somewhere here that demos this.
You also have dragStart vs. touchStart. I think you can tie your behaviors to the relevant one and they won't collide with each other.
Hi, I'm trying to log a variable on TouchStart and then get the difference on TouchEnd. Do you know why I get this error? Is this a variable scope issue?
'ReferenceError: Can't find variable: ystart'?
layerB.on Events.TouchStart, -> ystart = layerB.y
layerB.on Events.TouchEnd, -> if layerB.y > 0 layerB.states.switch("1") Diffy = layerB.y - ystart print "Diffy" + Diffy
you have to declare ystart first. put something like this above Event codeblock. "ystart = 0"
Oh that works! Thank you!!
More lines than i wanted but thanks for the advice guys. I tried using calculatevelocity but that obviously didn't give me what i wanted and then tried watching for change:x on the drag panel but then that was limiting also so i went back to what was suggested. Here it is:
containerStart = 0numpadContainer.on Events.TouchStart, -> containerStart = numpadContainer.x
numpadContainer.on Events.DragMove, -> containerEnd = numpadContainer.x xDelta = Math.abs(containerEnd - containerStart) disambig = if xDelta > 15 then "drag" else "touch"
John Anthony Evans yea couldn't dragstart vs touchstart because of the nature of the button firing on touchEnd, so i need to tell touchEnd not to fire if dragStart/Move occurs
I would also suggest deactivating the touch action as soon as a drag is qualified.