Commit e9058992 authored by wildfirecode13's avatar wildfirecode13

1

parent f38ea68d
{
"pages": [
"pages/pagefrontpage/pagefrontpage"
],
"window": {
"enableSkia": "true",
"allowsBounceVertical":"NO"
}
}
\ No newline at end of file
<view class="rulepanel ">
<image class="image2 " src={{resList['eb602b5e-fd36-4968-bed0-ec786cd8e1c0'].url}} />
</view>
\ No newline at end of file
'use strict';
import resList from '../../resconfig/resList';
Component({
props: {},
data: {},
methods: {},
onInit(props) {
this.setData({
resList: resList
});
}
});
\ No newline at end of file
{
"name": "",
"version": "1.0.0",
"main": "",
"license": "MIT",
"dependencies": {
"@tbmp/mp-cloud-sdk": "*"
}
}
.frontpage {
width: 750rpx;
height: 1624rpx;
display: block;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
left: 228rpx;
top: 146rpx;
}
.frontpage .div {
width: 300rpx;
height: 300rpx;
opacity: 1;
display: block;
position: absolute;
background-color: #ff6600;
transform-origin: 0rpx 0rpx 0rpx;
top: 278rpx;
left: -142rpx;
}
.frontpage .image {
width: 276rpx;
height: 275rpx;
opacity: 1;
display: block;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
left: -184rpx;
top: -134rpx;
}
<view class="frontpage ">
<view class="div " />
<image class="image " src={{resList['eb602b5e-fd36-4968-bed0-ec786cd8e1c0'].url}} />
</view>
\ No newline at end of file
const resList = {
'eb602b5e-fd36-4968-bed0-ec786cd8e1c0': {
name: '资源',
ext: '.png',
url: '//yun.duiba.com.cn/spark-prod/assets/资源.7ec4dc0a776a20da7e58e0cee4fab560dea0ec76.png',
uuid: 'eb602b5e-fd36-4968-bed0-ec786cd8e1c0',
},
};
export default resList;
const resCanvasList = {};
const resCanvasList = {
'4ee17a9c-5deb-43be-b205-16fb7593d172': {
name: 'spark',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/spark.810e94665ad6f7d7684f9b25b764e040a0cce7bf.png',
uuid: '4ee17a9c-5deb-43be-b205-16fb7593d172'
},
'cb54f3b5-0469-46d1-99ea-734153b92078': {
name: 'bg',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/bg.c4359b9ea9e843cd8d929567b2fb52ed5518e105.png',
uuid: 'cb54f3b5-0469-46d1-99ea-734153b92078'
},
'593e9d74-4944-496a-b6c1-8316756f8bf7': {
name: '宝箱2',
ext: '.png',
uuid: '593e9d74-4944-496a-b6c1-8316756f8bf7',
url: '//yun.duiba.com.cn/spark/assets/022e25a3984ff122fbf960bd0cb87bff48f8c3bf.png'
}
};
export default resCanvasList;
......@@ -8,6 +8,7 @@ import { destroyNetData } from "./TaoBaoNet";
import resCanvasList from '../resCanvasList';
import { setStage } from "./scenes/stage";
/**
......@@ -40,6 +41,7 @@ export class Main {
FYGE.RENDERER_TYPE.CANVAS
);
this.stage = stage;
setStage(stage);
//开始循环
// FYGE.Stage.flushAll();
//stage初始化
......
......@@ -2,12 +2,58 @@ export const ResJson = {
"groups": [
{
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
"name": "common",
"atlas": {
"comCloseBtn.png": {
"x": 646,
"y": 60,
"w": 48,
"h": 48,
"ox": 0,
"oy": 0,
"sw": 48,
"sh": 48,
"ro": false
},
"toastBg.png": {
"x": 184,
"y": 2,
"w": 460,
"h": 130,
"ox": 0,
"oy": 0,
"sw": 460,
"sh": 130,
"ro": false
},
"waitingBg.png": {
"x": 2,
"y": 2,
"w": 160,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 160,
"sh": 180,
"ro": true
},
"waitingRot.png": {
"x": 646,
"y": 2,
"w": 56,
"h": 56,
"ox": 0,
"oy": 0,
"sw": 56,
"sh": 56,
"ro": false
}
}
},
{
"keys": "map_bg1.jpg",
"name": "startScene"
}
],
"path": "./resource/"
"path": "https://yun.duiba.com.cn/db_games/activity/babycare_xiaoxiao/1600243346/resource/"
}
\ No newline at end of file
import { RES } from "../../module/RES";
import resCanvasList from "../../resCanvasList";
export default class DropItem extends FYGE.Sprite {
constructor() {
super();
this.texture = RES.getRes(
resCanvasList["593e9d74-4944-496a-b6c1-8316756f8bf7"].url
);
this.y = 0;
}
updatePosition() {
this.y += 10;
}
}
import Root from "./Root";
import { getStage } from "./stage";
import DropItem from "./DropItem";
export default class DropsCtrl {
_root: Root;
_drops: DropItem[];
constructor(root) {
this._root = root;
}
start() {
getStage().addEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
for (let index = 0; index < 10; index++) {
setTimeout(() => {
this.addDropItem();
}, 1000 * index);
}
}
addDropItem() {
this._drops = this._drops || [];
const drop = new DropItem();
this._root.addChild(drop);
drop.x = Math.random() * 400 + (750 - 400) / 2;
this._drops.push(drop);
}
onEnterFrame() {
if (this._drops) this._drops.forEach((drop) => drop.updatePosition());
}
destroy() {
getStage().removeEventListener(
FYGE.Event.ENTER_FRAME,
this.onEnterFrame,
this
);
}
}
import { RES } from "../../module/RES";
import resCanvasList from "../../resCanvasList";
import DropsCtrl from "./DropsCtrl";
export default class Root extends FYGE.Container {
constructor() {
super();
this.once(FYGE.Event.ADDED_TO_STAGE, this.onAddToStage, this);
var bg: FYGE.Sprite = new FYGE.Sprite();
bg.x = 0;
bg.y = 0;
bg.texture = RES.getRes(
resCanvasList["cb54f3b5-0469-46d1-99ea-734153b92078"].url
);
this.addChild(bg);
console.log('fuck')
const ctrl = new DropsCtrl(this);
ctrl.start();
// SvgaParser.loadSvga(
// "//yun.duiba.com.cn/spark/assets/open_effect.b997f18f52ca96abb0913ca32fdce6f22ad9bcf7.svga",
// (v:any) => {
// console.log(v)
// this.addChild(v)
// },
// () => {}
// );
}
onAddToStage() {
this.y = this.stage.viewRect.height / 2 - 1624 / 2;
}
}
import { Scene } from '../../module/views/Scene';
import { RES } from '../../module/RES';
import resCanvasList from '../../resCanvasList';
export class StartScene extends Scene {
initUi() {
super.initUi();
var gamecanvas: FYGE.Container = new FYGE.Container();
gamecanvas.position.set(0, 0);
this.addChild(gamecanvas);
console.log('hello canvas ')
}
}
import { Scene } from "../../module/views/Scene";
import { RES } from "../../module/RES";
import Root from "./Root";
export class StartScene extends Scene {
initUi() {
super.initUi();
var canvas: FYGE.Container = new FYGE.Container();
canvas.position.set(0, 0);
this.addChild(canvas);
}
start() {
this.addChild(new Root());
}
}
let _stage;
export const getStage = ():FYGE.Stage => _stage;
export const setStage = (stage) => {
_stage = stage;
};
server/
.tea/
\ No newline at end of file
# taobaominiDemo
.DS_Store
node_modules/
.tea/
\ No newline at end of file
......@@ -14,4 +14,4 @@ const apiList = Object.assign(Object.assign({}, capi), apicfg_1.default);
// 生成API
const API = generateAPI(apiList, request);
exports.default = API;
//# sourceMappingURL=api.js.map
\ No newline at end of file
//# sourceMappingURL=api.js.map1
\ No newline at end of file
......@@ -14,6 +14,7 @@ App({
activityId: "",
onLaunch(options) {
this.handleQuery(options.query || {});
console.log('onLauch')
},
onShow(options) {
// 从后台被 scheme 重新打开
......
{
"pages": ["pages/pagecanvas/pagecanvas", "pages/pagemycanvaspage/pagemycanvaspage"],
"window": {
"enableSkia": "true",
"allowsBounceVertical":"NO"
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
"dependencies": {
"@tbmp/mp-cloud-sdk": {
"version": "1.4.2",
"resolved": "http://npm.dui88.com:80/@tbmp%2fmp-cloud-sdk/-/mp-cloud-sdk-1.4.2.tgz",
"resolved": "https://registry.npm.taobao.org/@tbmp/mp-cloud-sdk/download/@tbmp/mp-cloud-sdk-1.4.2.tgz",
"integrity": "sha1-/49BtdDaNJ6H9+f9DDBMPgt/BbQ="
}
}
......
{
"name": "",
"version": "1.0.0",
"main": "",
"license": "MIT",
"dependencies": {
"@tbmp/mp-cloud-sdk": "*",
"fyge-tbmini": "^1.3.7"
}
}
This diff is collapsed.
.canvas {
width:100%;
height:100%;
}
.page-game {
/* position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
min-height: 100vh; */
width:100%;
height:100vh;
flex: 1;
display: flex;
flex-direction: column;
}
<view disable-scroll="true" class="page-game">
<canvas disable-scroll="true" id="canvas" type="2d" class="canvas" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady">
</canvas>
</view>
\ No newline at end of file
'use strict';
import { Main } from './output';
//import API from '../../api';
Page({
data: {},
onLoad(props) {
this.setData(this.data || {});
},
onReady() {
console.log('on ready')
// let main = this.spark_startEngine(); //main.addEventListener....
},
spark_startEngine() {
console.log('spark_startEngine')
var self = this;
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 + dpr; //重新修改会有误差
ccc.height = windowHeight * dpr + dpr;
if (!this.main) {
this.main = new Main(ccc); //添加事件,为了和main里的通信
this.main.addGlobalEvent("onMessage", self.onMessage, self);
}
}
});
},
onCanvasReady() {
console.log('onCanvasReady')
this.spark_startEngine();
},
postMessage(netName, data) {
this.main.dispatchGlobalEvent({
type: netName
}, data); //以防复用事件event串了,就用这种方式
},
//和main通信的方法,接收main的信息
onMessage(e) {
//接口名字
let netName = e.data.netName; //接口参数
let parameter = e.data.parameter; //暂时发现3个需要用户操作的接口
//定制的授权
if (netName.indexOf("mine") == 0) {
var data = {
success: true
};
switch (netName) {
case "mine.getAppData":
//获取信息
let tmpApp = getApp();
console.log('app信息', tmpApp);
data = {
success: true,
data: {
activityId: tmpApp.activityId,
//|| "5e7c40e98564b57d7fb95812",
nickName: tmpApp.nickName,
avatar: tmpApp.avatar,
openId: tmpApp.openId,
isFocusShop: tmpApp.isFollow || false
}
};
break;
case 'test':
console.log('测试一下', parameter.hint);
break;
}
this.postMessage(netName, data);
} else {
var app = getApp(); //获取后端接口
const {
function: fc
} = app.cloud;
const [myCloudName, handler] = netName.split("."); //待写,
fc.invoke(myCloudName, parameter, handler).then(res => {
this.postMessage(netName, res);
});
}
},
//鼠标事件
onMouseEvent(e) {
if (this.main) this.main.stage.onMouseEvent(e);
},
onShow() {
// 页面显示
if (this.main) {
this.main.run();
this.main.dispatchGlobalEvent("onShow");
}
},
onHide() {
// 页面隐藏
if (this.main) {
this.main.pause();
this.main.dispatchGlobalEvent("onHide");
}
}
});
\ No newline at end of file
.rulepanel {
.mycanvaspage {
top: 0rpx;
left: 0rpx;
width: 750rpx;
......@@ -6,7 +6,7 @@
display: block;
position: absolute;
}
.rulepanel .image2 {
.mycanvaspage .canvas {
width: 300rpx;
height: 300rpx;
opacity: 1;
......@@ -14,5 +14,4 @@
left: 0rpx;
top: 0rpx;
position: absolute;
transform-origin: 0rpx 0rpx 0rpx;
}
<view class="mycanvaspage">
<view>
<canvas id="canvas" type="2d" class="canvas" disable-scroll="true" onTouchStart="onMouseEvent" onTouchMove="onMouseEvent" onTouchEnd="onMouseEvent" onReady="onCanvasReady"></canvas>
</view>
</view>
\ No newline at end of file
......@@ -6,7 +6,7 @@ Page({
data: {},
onLoad(props) {
this.setData({
this.setData(this.data || {
resList: resList
});
}
......
const resList = {
'4ee17a9c-5deb-43be-b205-16fb7593d172': {
name: 'spark',
ext: '.png',
url: '//yun.duiba.com.cn/spark/assets/spark.810e94665ad6f7d7684f9b25b764e040a0cce7bf.png',
uuid: '4ee17a9c-5deb-43be-b205-16fb7593d172'
}
};
export default resList;
This diff is collapsed.
{
"cloud": {
"type": "CLOUDAPP"
},
"miniprogramRoot": "./client"
}
{
"lockfileVersion": 1
}
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