Commit 29da8486 authored by huangwenjie's avatar huangwenjie

canvas编辑器可显示

parent fa8b779c
export default { export default {
hasCanvas: false, // 是否开启游戏模块自动注入dist hasCanvas: true, // 是否开启游戏模块自动注入dist
defaultPlugins: [ defaultPlugins: [
[ [
'@pluve/taro-plugin-mars', // taro暂时未支持阿里小程序自定义插件 需要引用插件的页面需配置 '@pluve/taro-plugin-mars', // taro暂时未支持阿里小程序自定义插件 需要引用插件的页面需配置
{ {
usingComponents: {// 原生组件引入 usingComponents: { // 原生组件引入
enable: true, enable: true,
include: [ 'pages/index/index', 'pages/packagePrize/myPrize/myPrize','pages/packageGame/game/game'] include: ['pages/index/index', 'pages/packagePrize/myPrize/myPrize', 'pages/packageGame/game/game']
} }
} }
]
],
canvasPages: [
{'root': 'pages/packageGame/game/game.json', 'comRoot': 'components/_miniprogram/canvasComp/canvasComp'}, // 游戏组件
{'root': 'pages/index/index.json', 'comRoot': 'components/_miniprogram/lottieAnimation/lottieAnimation'} // Lottie组件
],// 引入cavas组件页面(更改canvas引用路径)
canvasComps: [// 拷贝相关页面和依赖到dist目录
{ from: 'minigame/node_modules', to: 'dist/node_modules'},
{ from: 'src/components/_miniprogram/canvasComp', to: 'dist/components/_miniprogram/canvasComp'}, // 游戏组建引入
{ from: 'src/components/_miniprogram/lottieAnimation', to: 'dist/components/_miniprogram/lottieAnimation'}, // lottie 动画组件
{ from: 'src/lottie', to: 'dist/lottie'},// lottie json文件
] ]
} ],
\ No newline at end of file canvasPages: [{
'root': 'pages/packageGame/game/game.json',
'comRoot': 'components/_miniprogram/canvasComp/canvasComp'
}, // 游戏组件
{
'root': 'pages/index/index.json',
'comRoot': 'components/_miniprogram/lottieAnimation/lottieAnimation'
} // Lottie组件
], // 引入cavas组件页面(更改canvas引用路径)
canvasComps: [ // 拷贝相关页面和依赖到dist目录
{
from: 'minigame/node_modules',
to: 'dist/node_modules'
},
{
from: 'src/components/_miniprogram/canvasComp',
to: 'dist/components/_miniprogram/canvasComp'
}, // 游戏组建引入
{
from: 'src/components/_miniprogram/lottieAnimation',
to: 'dist/components/_miniprogram/lottieAnimation'
}, // lottie 动画组件
{
from: 'src/lottie',
to: 'dist/lottie'
}, // lottie json文件
]
}
{
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"fyge": {
"version": "2.0.31",
"resolved": "https://registry.npmjs.org/fyge/-/fyge-2.0.23.tgz",
"integrity": "sha512-5EA6FHrwpp9sAMyctuyE+gyUH10uGT5PPp1O1gZfohJNx1/bkCPcUomnXApa8367tJ5UiPhiVi3dZeqUdJiZVQ=="
}
}
}
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
"main": "", "main": "",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"fyge": "2.0.31" "fyge": "2.0.43"
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# yarn lockfile v1 # yarn lockfile v1
fyge@2.0.31: fyge@2.0.43:
version "2.0.31" version "2.0.43"
resolved "https://registry.yarnpkg.com/fyge/-/fyge-2.0.31.tgz#49afcdfef92e23b53e42bef6a93f3b2211af281e" resolved "http://npm.dui88.com:80/fyge/-/fyge-2.0.43.tgz#0e587104e4050772014810f85d01a7bed4f1482f"
integrity sha512-HIt26NvgQ5udlI5jJwYgVSqBdfy1qX0+L1TseJNuyUVWgzkNGjQy2rGnXXA2yuWoSgWoDGtKfL94CC9FCAsNyg== integrity sha1-DlhxBOQFB3IBSBD4XQGnvtTxSC8=
<view class="farmer-container-plants canvas"> <view class="farmer-container-plants canvas">
<canvas id="canvas" type="2d" class="canvas" disable-scroll="true" <canvas id="canvas" type="webgl" class="canvas" disable-scroll="true" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady"></canvas>
onTouchStart="onMouseEvent"
onTouchMove="onMouseEvent"
onTouchEnd="onMouseEvent"
onReady="onCanvasReady"
></canvas>
</view> </view>
\ No newline at end of file
import { Main } from './output'; import {
Main
} from './output';
/** /**
* 直接取,app * 直接取,app
*/ */
...@@ -26,8 +28,8 @@ Component({ ...@@ -26,8 +28,8 @@ Component({
const dpr = my.getSystemInfoSync().pixelRatio const dpr = my.getSystemInfoSync().pixelRatio
const windowWidth = my.getSystemInfoSync().windowWidth; const windowWidth = my.getSystemInfoSync().windowWidth;
const windowHeight = my.getSystemInfoSync().windowHeight; const windowHeight = my.getSystemInfoSync().windowHeight;
ccc.width = windowWidth * dpr + dpr;//重新修改会有误差 // ccc.width = windowWidth * dpr + dpr; //重新修改会有误差
ccc.height = windowHeight * dpr + dpr; // ccc.height = windowHeight * dpr + dpr;
// console.log(Main) // console.log(Main)
console.log(ccc.width, ccc.height) console.log(ccc.width, ccc.height)
if (!this.main) { if (!this.main) {
...@@ -48,7 +50,7 @@ Component({ ...@@ -48,7 +50,7 @@ Component({
let netName = e.data.netName; let netName = e.data.netName;
//接口参数 //接口参数
let parameter = e.data.parameter; let parameter = e.data.parameter;
if(netName.indexOf("mine") == 0) { if (netName.indexOf("mine") == 0) {
// 和游戏页面通信 // 和游戏页面通信
this.props.onMessage({ this.props.onMessage({
type: 'message', type: 'message',
...@@ -61,12 +63,16 @@ Component({ ...@@ -61,12 +63,16 @@ Component({
postMessage: (netName, data) => this.postMessage(netName, data) postMessage: (netName, data) => this.postMessage(netName, data)
} }
}) })
}else { } else {
this.postMessage(netName, { success: false }) this.postMessage(netName, {
success: false
})
} }
}, },
postMessage(netName, data) { postMessage(netName, data) {
this.main && this.main.dispatchGlobalEvent({ type: netName }, data)//以防复用事件event串了,就用这种方式 this.main && this.main.dispatchGlobalEvent({
type: netName
}, data) //以防复用事件event串了,就用这种方式
}, },
//鼠标事件 //鼠标事件
onMouseEvent(e) { onMouseEvent(e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment