Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Touch.enable not working in CreateJS through Animate CC

Community Beginner ,
Feb 26, 2020 Feb 26, 2020

I've created an html5 canvas file in Animate CC and I can't seem to get it to respond to touches when run on a touch screen device. I've created a stripped down file to demonstrate the issue.

 

Every other post I've found online has been resolved with createjs.Touch.enable(stage), however, this doesn't enable touch for me (and it returns false). I've also included adding a touchstart event listener but this doesn't help either.

I've also attempted this to no effect.

 

To debug in the console I'm using chrome in device emulation mode. In Animate CC, centre stage and make responsive are both turned off in the publish settings.

 

Results from the example code below:

  • Enabling touch returns false (So this is likely the issue)
  • pressing the mouse button returns "mouse down" and shifts ball.
  • pressing a touch does nothing
  • releasing the touch returns "mouse down" and shifts ball.

 

Any idea where I'm going wrong? Animate CC is completely up to date and createJS is v1.0.0

Expected behaviour is that the touchstart or mousedown handler is fired when the touch starts just like when using a mouse.

 

console.log("Enable touch: "+createjs.Touch.enable(stage) );  // returns false

ball = this.ball_mc;

// mouse mouse event
ball.on("mousedown", function(event) {
    console.log("mouse down");
    ball.x += 10;
});

// finger down event
ball.addEventListener("touchstart", function mouseDownHandler(e) {
    console.log("finger down");
    ball.x += 10;
});

 

Thanks in advance! - you'll be a lifesaver if you know what's going on or a workaround!

Dale.

TOPICS
Code , Other , Publish package , Tablet
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2020 Feb 27, 2020

Hi.

 

Your code seems to be correct. Do you have a preview link or an FLA for us to investigate?

 

 

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 03, 2020 Mar 03, 2020
LATEST

Thanks JoãoCésar !

I forgot to update this, sorry.


In prepping the file for you I thought I better test it on device and it turns out that while I did my initial test on a touch device, I hadn't since, and had assumed that Chrome dev tools touch device emulator was acurate. Turns out it's not!

 

So, word of warning to anyone else, in regard to this feature, chrome dev tools doesn't send a mouse down event on touch and thus doesn't acurately emulate a touch device.

 

My file works on iPad and iPhone!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines