<template>
  <section class="test">
    <canvas id="gameCanvas" width="375" height="520"></canvas>
  </section>
</template>

<script>

  export default {
    mounted () {
      let that = this;
      that.$nextTick(() => {
        cc.game.onStart = function(){
          //load resources
          cc.LoaderScene.preload([], function () {
            var MyScene = cc.Scene.extend({
              onEnter:function () {
                this._super();
                var size = cc.director.getWinSize();
                // var sprite = cc.Sprite.create("HelloWorld.png");
                // sprite.setPosition(size.width / 2, size.height / 2);
                // sprite.setScale(0.8);
                // this.addChild(sprite, 0);

                var label = cc.LabelTTF.create("Hello World", "Arial", 40);
                label.setPosition(size.width / 2, size.height / 2);
                label.setColor(cc.color(255,0,0,255));
                this.addChild(label, 1);
              }
            });
            cc.director.runScene(new MyScene());
          }, this);
        };
        cc.game.run("gameCanvas");
      });
    },
    beforeDestroy () {
      
    }
  };
</script>