Skip to content
On this page

@go/flash

flash 组件库。

安装

$ npm install @go/flash

说明

  1. 导出文件默认命名可以设置为 game,可以直接导出到 src/ 目录下,资源文件导入至 src/assets/ 文件内;

引入

index.html 引入全局 Create.js:

<body>
  <!-- flashCDN -->
  <script src="https://go.163.com/f2e/common/createjs.min.js"></script>
</body>

导入组件:

// 导入 Flash 组件
import { Flash } from '@go/flash';

// 导入 FlashScroller 组件
import { FlashScroller } from '@go/flash';

方法

Flash 组件初始化:

<script setup lang="ts">
import {onMounted, ref, inject} from 'vue';
import { Flash } from '@go/flash';
import gameJsUrl from './game.js?raw'; //flash 导出的js

// App.vue 图片 loading 完成后的对象
const imgData = inject('imgData'); 
// HTMLCanvasElement
const canvas = ref(null);

onMounted(()=>{
  let flash = new Flash(
    gameJsUrl,
    canvas.value,
    imgData.value,
    {
      webgl:false, //使用webgl
      autoplay: false,//是否自动播放
    }
  );
  flash.ready.then((flash)=>{
  
  });
});
</script>

FlashScroller 组件初始化:

<script setup lang="ts">
import {onMounted, ref, inject} from 'vue';
import { FlashScroller } from '@go/flash';
import gameJsUrl from './game.js?raw'; //flash 导出的js

// App.vue 图片 loading 完成后的对象
const imgData = inject('imgData');  
// HTMLCanvasElement
const canvas = ref(null);

onMounted(()=>{
  let flash = new FlashScroller(
    gameJsUrl,
    canvas.value,
    imgData.value,
    {
      scroll: 'y',//touch方向(相对于flash来说)
      webgl:false, //使用webgl
      autoplay: false,//是否自动播放
    }
  );
  flash.ready.then((flash)=>{

  });
});
</script>

代码片段

更新日志

Released under the MIT License.