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:
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;
});
Here's an update and answer. My code above is correct and the issue seen isn't actually an issue.
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 accurate. Turns out it's not! Chrome dev tools doesn't send a mouse down event on touch and thus doesn't accurately emulate a touch device.
The code above, therefore works fine, but needs to be run directly on a touch device.