

import { Main } from './Main';


Page({
  //暂时先不用吧，有问题
  data: {

  },
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
  },
  onReady() {
    return
    my.development = true;

    // my._createCanvas({
    //   id: 'canvas',
    //   success: (ccc) => {
    //     const dpr = my.getSystemInfoSync().pixelRatio
    //     const windowWidth = my.getSystemInfoSync().windowWidth;
    //     const windowHeight = my.getSystemInfoSync().windowHeight;
    //     ccc.width = windowWidth * dpr;
    //     ccc.height = windowHeight * dpr;
    //     // const context = canvas.getContext("2d");
    //     console.log(ccc.width, ccc.height, dpr)
    //     //初始化
    //     FYGE.initedByCanvas(ccc);
    //     //测试
    //     var aa = ccc.createImage();
    //     aa.src = "https://yun.duiba.com.cn/db_games/activity/etc/optionImages/%E5%8D%8E%E4%B8%BAP30.jpg";
    //     console.log(aa)
    //     //帧率控制
    //     FYGE.Stage.addFPS("canva4stats")
    //     this.main = new Main(ccc)

    //     console.log(ccc.width, ccc.height)
    //   }
    // })
  },

  onCanvasReady() {
    my.development = true;

    my._createCanvas({
      id: 'canvas',
      success: (ccc) => {
        const dpr = my.getSystemInfoSync().pixelRatio
        const windowWidth = my.getSystemInfoSync().windowWidth;
        const windowHeight = my.getSystemInfoSync().windowHeight;
        ccc.width = windowWidth * dpr;
        ccc.height = windowHeight * dpr;
        this.main = new Main(ccc)
      }
    })
  },

  onShow() {
    // 页面显示
    // FYGE.Stage.pause = false
    if (this.main) this.main.run();
  },
  onHide() {
    // 页面隐藏
    // FYGE.Stage.pause = true
    if (this.main) this.main.pause();
  },
  onUnload() {
    // 页面被关闭
    // Stage.stop()
    this.main.destroy();
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },

  log(e) {
    if (this.main) this.main.stage.onMouseEvent(e)
  },
});
