【发布时间】:2020-06-11 02:23:40
【问题描述】:
我在 Animate CC 中创建了一个 html5 画布文件,但在触摸屏设备上运行时,我似乎无法让它响应触摸。我创建了一个精简文件来演示这个问题。
我在网上找到的所有其他帖子都已使用 createjs.Touch.enable(stage) 解决,但是,这并没有为我启用触控(并且它返回 false)。我还添加了一个 touchstart 事件侦听器,但这也无济于事。
我也尝试过this,但没有效果。
为了在控制台中进行调试,我在设备仿真模式下使用 chrome。在 Animate CC 中,centre stage 和 make responsive 在发布设置中均处于关闭状态。
以下示例代码的结果:
- 启用触摸返回 false(所以这可能是问题所在)
- 按下鼠标按钮返回“鼠标向下”并移动球。
- 按下触摸不起作用
- 释放触摸返回“鼠标向下”并移动球。
知道我哪里出错了吗? Animate CC 完全是最新的,createJS 是 v1.0.0
预期的行为是在触摸开始时触发 touchstart 或 mousedown 处理程序,就像使用鼠标时一样。
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;
});
【问题讨论】:
标签: javascript touch createjs easeljs animate-cc