Commit 5854544b authored by 任建锋's avatar 任建锋

Merge branch 'dev' of http://gitlab2.dui88.com/laoqifeng/zeroing-libs into dev

parents e9112f73 140f0a58
This diff is collapsed.
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'pick-tea';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const { props: propsOption, assets } = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
//先抛出初始化消息
setTimeout(() => {
engine.globalEvent.dispatchEvent('event-pickTeaGame-init');
//获得引用端的篮子类型event-setBasket-Type event-setchange-TeaNum
engine.globalEvent.dispatchEvent('event-setBasket-Type');
engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
}, 500);
});
// +1显示
engine.globalEvent.addEventListener('event-add-oneScore', (e) => {
console.log(e.type, e.data);
});
// 收集茶叶
engine.globalEvent.addEventListener('event-pick-tea', (e) => {
console.log(e.type, e.data);
});
// 茶叶散开
engine.globalEvent.addEventListener('event-tea-skyup', (e) => {
console.log(e.type, e.data);
});
// 茶叶上升
engine.globalEvent.addEventListener('event-hand-grasp', (e) => {
console.log(e.type, e.data);
});
// 改变篮子里的茶叶
engine.globalEvent.addEventListener('event-change-TeaNum', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>采茶叶</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous"
src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script>
<script crossorigin="anonymous"
src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "进度条底框",
"url": "//yun.duiba.com.cn/aurora/assets/e394fce3576ddeed52fa4dceededc98820318f15.png",
"uuid": "7436ffbc-8906-4cdc-9e9a-80a3f7126e30",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/047218962662ed238192f211719c109fa107e8e1.png",
"uuid": "23e7861c-75a9-46bd-93f8-2825d4810d31",
"ext": ".png"
},
{
"name": "茶叶进度缺",
"url": "//yun.duiba.com.cn/aurora/assets/a99ad1582f44237f9391aeffa53b72c316a8ea83.png",
"uuid": "cc4f6b6c-0542-4b8d-b83d-1ee31e9c0e39",
"ext": ".png"
},
{
"name": "茶叶进度满",
"url": "//yun.duiba.com.cn/aurora/assets/7b1ac4e33309adfde360c92c1cdc8299a3e1efd0.png",
"uuid": "81728f22-c616-4133-8c78-c041cde68b79",
"ext": ".png"
},
{
"name": "小茶叶",
"url": "//yun.duiba.com.cn/aurora/assets/e938df1513919985c573128e1ed8074c9cc19dd5.png",
"uuid": "b30b3093-6097-4cc5-9364-ad1050f86c6e",
"ext": ".png"
},
{
"name": "茶叶-满",
"url": "//yun.duiba.com.cn/aurora/assets/acd219c8c8d472a3469183ba8d32568372e75797.png",
"uuid": "41431fe5-523c-4e21-a2bc-9dc4641d27e8",
"ext": ".png"
},
{
"name": "茶叶-少",
"url": "//yun.duiba.com.cn/aurora/assets/38f1874d0688fb8b621dfb1d3028d6f8ac61374d.png",
"uuid": "5765bb2b-3e7b-48fe-9e06-3c76a78c92dc",
"ext": ".png"
},
{
"name": "采茶童-纸篮子",
"url": "//yun.duiba.com.cn/aurora/assets/52f24f84d31709faea0fc35193692b134fe2e40d.svga",
"uuid": "8a7801dd-b802-4571-9f8e-e9acfb9c4527",
"ext": ".svga"
},
{
"name": "采茶童-布篮子",
"url": "//yun.duiba.com.cn/aurora/assets/7ca607d0fd5471d33a4bb58c0d92122fe4ae425f.svga",
"uuid": "ba183e10-4059-4c3e-b9ec-c78192d5e980",
"ext": ".svga"
},
{
"name": "采茶童-竹编篮",
"url": "//yun.duiba.com.cn/aurora/assets/91b8f35ce06b9c65cb504c59ac6c3961f625fb2e.svga",
"uuid": "c7414e60-5312-4586-984a-d8b45a614621",
"ext": ".svga"
},
{
"name": "采茶童-木篮子",
"url": "//yun.duiba.com.cn/aurora/assets/de210099641d4d4fb2d323cc9da17f2f4e48a038.svga",
"uuid": "c492cbd4-aa42-4425-846f-86a91fd3f198",
"ext": ".svga"
},
{
"name": "待升级",
"url": "//yun.duiba.com.cn/aurora/assets/80834a2a25aca30b79dae655003fb7d6b8dc1b49.svga",
"uuid": "eb1f7929-f812-4b88-8345-5d61977fce39",
"ext": ".svga"
},
{
"name": "+1",
"url": "//yun.duiba.com.cn/aurora/assets/72c631a1da7b7969b7995fa16ccc1f435b9b57db.svga",
"uuid": "16a57950-0201-4904-8c65-6378fab65f59",
"ext": ".svga"
},
{
"name": "采茶叶",
"url": "//yun.duiba.com.cn/aurora/assets/6b89b11a26d0f91f1dad9e14b2d099e0d8450032.svga",
"uuid": " 81428208-0274-4e73-9f5e-27bb4a57f80a",
"ext": ".svga"
},
{
"name": "茶叶向上飞",
"url": "//yun.duiba.com.cn/aurora/assets/676ff9aabe60a49ca92f6ade26e62c6bb76be922.svga",
"uuid": "de7273ab-41be-4248-9f05-cdf8a7e3585b",
"ext": ".svga"
},
{
"name": "手抓去",
"url": "//yun.duiba.com.cn/aurora/assets/6b774da91be08d1c9f773d88ace4927c3c5de583.svga",
"uuid": "f1e7a7cf-95c7-4c91-a30b-935e31ea0084",
"ext": ".svga"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete) {
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "采茶叶",
"desc": "采茶叶模左上角0,0点",
"props": {
"versePos": {
"alias": "诗句的起始位置",
"type": "array<number>",
"default": "160,360"
},
"verses": {
"alias": "诗句",
"type": "array<string>",
"default": "今宵更有湘江月,照出霏霏满碗花,雨过林霏清石气,秋将山翠入诗心"
},
"verseLabel": {
"alias": "提示语框xys",
"type": "array<number>",
"default": "396,50,22"
},
"verseColor": {
"alias": "颜色描边",
"type": "array<string>",
"default": "#33628b,#99b1c5"
},
"showFrontImg": {
"alias": "茶叶前景图1显示2隐藏",
"type": "number",
"default": "1"
},
"FrontImgPos": {
"alias": "茶叶前景图位置",
"type": "array<number>",
"default": "0,584"
},
"pickTeaSpeed": {
"alias": "采集茶叶的速度ms",
"type": "number",
"default": 1000
},
"basketSvgaPos": {
"alias": "人物的位置",
"type": "array<number>",
"default": "110,410"
},
"addOneSvgaPos": {
"alias": "+1SVGA的位置",
"type": "array<number>",
"default": "0,-100"
},
"pickTeaSvgaPos": {
"alias": "采茶叶SVGA的位置",
"type": "array<number>",
"default": "377,530"
},
"teaSkyUpSvgaPos": {
"alias": "收集茶叶SVGA的位置",
"type": "array<number>",
"default": "320,192"
},
"handGraspSvgaPos": {
"alias": "手点击SVGA的位置",
"type": "array<number>",
"default": "477,-29"
},
"handGraspMovePos": {
"alias": "手点击移动的位置",
"type": "array<number>",
"default": "372,-145"
},
"progressbarBgImgPos": {
"alias": "进度条底图的位置",
"type": "array<number>",
"default": "69,818"
},
"progressbarImgPos": {
"alias": "进度条的位置",
"type": "array<number>",
"default": "-335,4"
},
"teaStarImgPos": {
"alias": "小茶叶的位置",
"type": "array<number>",
"default": "9,7"
},
"teaHalfFlagImgPos": {
"alias": "满缺的位置",
"type": "array<number>",
"default": "-15,-15"
},
"pickTeaCountPos": {
"alias": "文本进度的位置",
"type": "array<number>",
"default": "180,10"
}
},
"assets": [
{
"name": "前景",
"url": "//yun.duiba.com.cn/aurora/assets/1da0ea14267ff35f90f49c22deb1b34181571e90.png",
"uuid": "9f5db57e-47f9-43e5-af80-adf41299280d",
"ext": ".png"
},
{
"name": "气泡框",
"url": "//yun.duiba.com.cn/aurora/assets/585743f25262b6992ac97015e22d91054d506821.png",
"uuid": "1e6c4615-e1f4-43fe-b5de-9bfdaa27888c",
"ext": ".png"
},
{
"name": "进度条底框",
"url": "//yun.duiba.com.cn/aurora/assets/e394fce3576ddeed52fa4dceededc98820318f15.png",
"uuid": "7436ffbc-8906-4cdc-9e9a-80a3f7126e30",
"ext": ".png"
},
{
"name": "进度",
"url": "//yun.duiba.com.cn/aurora/assets/afb6b2655838ea955d250663fc535cc166b466e7.png",
"uuid": "23e7861c-75a9-46bd-93f8-2825d4810d31",
"ext": ".png"
},
{
"name": "茶叶进度缺",
"url": "//yun.duiba.com.cn/aurora/assets/a99ad1582f44237f9391aeffa53b72c316a8ea83.png",
"uuid": "cc4f6b6c-0542-4b8d-b83d-1ee31e9c0e39",
"ext": ".png"
},
{
"name": "茶叶进度满",
"url": "//yun.duiba.com.cn/aurora/assets/7b1ac4e33309adfde360c92c1cdc8299a3e1efd0.png",
"uuid": "81728f22-c616-4133-8c78-c041cde68b79",
"ext": ".png"
},
{
"name": "小茶叶",
"url": "//yun.duiba.com.cn/aurora/assets/e938df1513919985c573128e1ed8074c9cc19dd5.png",
"uuid": "b30b3093-6097-4cc5-9364-ad1050f86c6e",
"ext": ".png"
},
{
"name": "茶叶-满",
"url": "//yun.duiba.com.cn/aurora/assets/acd219c8c8d472a3469183ba8d32568372e75797.png",
"uuid": "41431fe5-523c-4e21-a2bc-9dc4641d27e8",
"ext": ".png"
},
{
"name": "茶叶-少",
"url": "//yun.duiba.com.cn/aurora/assets/38f1874d0688fb8b621dfb1d3028d6f8ac61374d.png",
"uuid": "5765bb2b-3e7b-48fe-9e06-3c76a78c92dc",
"ext": ".png"
},
{
"name": "采茶童-纸篮子",
"url": "//yun.duiba.com.cn/aurora/assets/52f24f84d31709faea0fc35193692b134fe2e40d.svga",
"uuid": "8a7801dd-b802-4571-9f8e-e9acfb9c4527",
"ext": ".svga"
},
{
"name": "采茶童-布篮子",
"url": "//yun.duiba.com.cn/aurora/assets/7ca607d0fd5471d33a4bb58c0d92122fe4ae425f.svga",
"uuid": "ba183e10-4059-4c3e-b9ec-c78192d5e980",
"ext": ".svga"
},
{
"name": "采茶童-竹编篮",
"url": "//yun.duiba.com.cn/aurora/assets/91b8f35ce06b9c65cb504c59ac6c3961f625fb2e.svga",
"uuid": "c7414e60-5312-4586-984a-d8b45a614621",
"ext": ".svga"
},
{
"name": "采茶童-木篮子",
"url": "//yun.duiba.com.cn/aurora/assets/de210099641d4d4fb2d323cc9da17f2f4e48a038.svga",
"uuid": "c492cbd4-aa42-4425-846f-86a91fd3f198",
"ext": ".svga"
},
{
"name": "待升级",
"url": "//yun.duiba.com.cn/aurora/assets/80834a2a25aca30b79dae655003fb7d6b8dc1b49.svga",
"uuid": "eb1f7929-f812-4b88-8345-5d61977fce39",
"ext": ".svga"
},
{
"name": "+1",
"url": "//yun.duiba.com.cn/aurora/assets/72c631a1da7b7969b7995fa16ccc1f435b9b57db.svga",
"uuid": "16a57950-0201-4904-8c65-6378fab65f59",
"ext": ".svga"
},
{
"name": "采茶叶",
"url": "//yun.duiba.com.cn/aurora/assets/6b89b11a26d0f91f1dad9e14b2d099e0d8450032.svga",
"uuid": " 81428208-0274-4e73-9f5e-27bb4a57f80a",
"ext": ".svga"
},
{
"name": "茶叶向上飞",
"url": "//yun.duiba.com.cn/aurora/assets/676ff9aabe60a49ca92f6ade26e62c6bb76be922.svga",
"uuid": "de7273ab-41be-4248-9f05-cdf8a7e3585b",
"ext": ".svga"
},
{
"name": "手抓去",
"url": "//yun.duiba.com.cn/aurora/assets/6b774da91be08d1c9f773d88ace4927c3c5de583.svga",
"uuid": "f1e7a7cf-95c7-4c91-a30b-935e31ea0084",
"ext": ".svga"
}
],
"events": {
"in": {
"event-getchange-TeaNum": {
"alias": "茶叶数量{初始值nowNum,总量totalNum,后端时间serverData} "
},
"event-getBasket-Type": {
"alias": "获得篮子类型(纸 布 竹 木)0 1 2 3"
},
"event-hand-grasp": {
"alias": "手抓去"
},
"event-getClick-person": {
"alias": "点击人物"
}
},
"out": {
"event-setchange-TeaNum": {
"alias": "获取茶叶数量{初始值nowNum,总量totalNum,后端时间serverData}",
"data": {}
},
"event-setBasket-Typ": {
"alias": "获得篮子类型(纸 布 竹 木)0 1 2 3",
"data": {}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView;
constructor() {
super();
/*
event-pickTeaGame-init //游戏初始化
//event-wait-uplevel //待升级
event-add-oneScore //+1
event-pick-tea //采茶叶
event-tea-skyup //茶叶向上飞
event-hand-grasp //手抓去
event-change-TeaNum //茶叶数量 改变svga动画
event-getBasket-Type //获得篮子类型
event-setBasket-Type //设置篮子类型
*/
// event-getchange-TeaNum //茶叶数量{初始值totalNum,总量nowNum} 改变svga动画
// event-getBasket-Type //获得篮子类型
// event-hand-grasp //手抓去
//event-pickTeaGame-init 游戏初始化
engine.globalEvent.addEventListener('event-pickTeaGame-init', this.reset, this);
engine.globalEvent.addEventListener('event-hand-grasp', this.handGrasp, this);
engine.globalEvent.addEventListener('event-getClick-person', this.clickPerson, this);
engine.globalEvent.addEventListener('event-getchange-TeaNum', this.setTeaNum, this);
engine.globalEvent.addEventListener('event-getBasket-Type', this.setPickTeaLevel, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
}
//设置茶叶数量
setTeaNum(event: engine.Event) {
injectProps(event.data);
this._gameView.setTeaNum(event.data);
}
//设置茶蓝等级
setPickTeaLevel(event: engine.Event) {
injectProps(event.data);
this._gameView.setPickTeaLevel(event.data);
}
handGrasp() {
this._gameView.handGrasp();
}
//点击人物
clickPerson() {
this._gameView.showVerse();
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
import { getTextureByName } from "./utils";
export class Tealeaf extends engine.Container {
private _teaFull: engine.Image;
private _teaHalfFull: engine.Image;
private _teaImages: any
constructor() {
super();
this._teaFull = new engine.Image(getTextureByName('茶叶-满'));
this._teaHalfFull = new engine.Image(getTextureByName('茶叶-少'));
this._teaImages = [this._teaFull, this._teaHalfFull]
this.addChild(this._teaFull);
this.addChild(this._teaHalfFull);
}
reset() {
this.visible = true;
}
getSpriteUrl(index) {
let url = this._teaImages[index].url;
return url;
}
}
/**
* Created by rockyl on 2020-01-21.
*/
const showlog = false;
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
export function showLog(abjname, obj?) {
if (showlog) {
console.log(abjname)
if (obj)
console.log(obj)
}
// let inst = new svga.Svga();
// inst.source = 'asset://' + engine.getAssetByName(name).uuid;
// return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
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