常见问题

1、页面滚动不了?

  • 现象:在游戏区域触碰滚动无效

  • 原因:Tiny.js 将 Canavs 上的事件重置了

  • 解决方案:在主函数中加入如下代码,监听舞台的 pointermove 事件,触发 window 的 scroll,如下:

    app.stage.setEventEnabled(true);
    app.stage.hitArea = new Tiny.Rectangle(0, 0, Tiny.WIN_SIZE.width, Tiny.WIN_SIZE.height);
    app.stage.on('pointerdown', function (e) {
      this._y = e.data.global.y;
    });
    app.stage.on('pointermove', function (e) {
      try {
        window.scrollBy(0, this._y - e.data.global.y);
      } catch (e) {
      }
    });