Start a new topic

AR.CONST.CLICK_BEHAVIOR.TOUCH_UP fires automatically

AR.CONST.CLICK_BEHAVIOR.TOUCH_UP fires automatically


Hi,I am trying to create a finger twister game.

I want to catch the event when the user release his finger on the screen. However, as soon as the drawable is seen, it fires automatically. Here is my code.

 

var imgOne = new AR.ImageResource("fingertwisterimages/FingerTwisterMarker.jpg");

var overlayOne = new AR.ImageDrawable(imgOne, 1, {

offsetX: 0,

offsetY: 0,

enabled: false

});

 


var pageOne = new AR.Trackable2DObject(this.tracker, "FingerTwisterMarker", {

drawables: {

cam: overlayOne

}, 

onEnterFieldOfVision: function () {

if(AR.CONST.CLICK_BEHAVIOR.TOUCH_UP){

alert('released');

}

}

});

 

Is this a bug on the method? Or is it wrong that I put it in onEnterFieldofVision? I want to detect if the user touched a drawable and detect if the finger is not touching the drawable anymore. Although my question has been answered that I can't assign it on a drawable, is it possible now? Or are there any workrounds? Thanks.

Hi Miguel,

Setting the click behavior only controls when the platform should fire the onClick event when the user has pressed/released the touch screen.

In your code, you listen on the onEnterFieldOfVision of the target, which will be fired as soon as the Target is recognized, so the behavior you described is expected behavior.

You need to set an onClick event on the Drawable (or the Trackable2DObject) instead. This event will only be triggered when the user presses/releases his/her finger. When you also set the click behavior to TOUCH_UP, the onClick event will be triggered when the user releases his finger.

Best,

Martin
Login or Signup to post a comment