Commit 3d62bb2f authored by 任建锋's avatar 任建锋

--

parent 697e8d0e
No preview for this file type
This diff is collapsed.
......@@ -2,7 +2,7 @@
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'food-fell2';
const customId = 'dragon-boat-race';
(async function () {
let customModule = await fetch(`../meta.json`);
......@@ -46,21 +46,21 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": "0.8,0.1,0.1",
engine.globalEvent.dispatchEvent('dragon-boat-race-reset', {
"goodsProbability": "0.3,0.2,0.3,0.2",
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
engine.globalEvent.dispatchEvent('dragon-boat-race-start');
}, 1000);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
engine.globalEvent.addEventListener('dragon-boat-race-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
engine.globalEvent.addEventListener('dragon-boat-race-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (e) => {
engine.globalEvent.addEventListener('dragon-boat-race-game-over', (e) => {
console.log(e.type, e.data);
});
}
......
......@@ -3,60 +3,84 @@
*/
const assets = [
{
"name": "雨滴0",
"url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "雨滴1",
"url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "雨滴2",
"url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
"uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
"uuid": "846a139d-0990-4db4-a323-f22379932ee4",
"ext": ".svga"
},
{
"name": "炸弹svga",
"url": "//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
// {
// "name": "循环背景1",
// "url": "//yun.duiba.com.cn/aurora/assets/a57af3e2092f421ebbb47ee7a3d30f4326b5b7cd.jpg",
// "uuid": "d95a5911-1c7c-4b60-9ff1-5cb179738e91",
// "ext": ".jpg"
// },
// {
// "name": "循环背景2",
// "url": "//yun.duiba.com.cn/aurora/assets/489de78a248456d9dee74d8106da3dae40c0268b.jpg",
// "uuid": "2222b6d9-17cb-42a6-a0f2-54c390522ca5",
// "ext": ".jpg"
// },
// {
// "name": "雨滴0",
// "url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
// "uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
// "ext": ".png"
// },
// {
// "name": "雨滴1",
// "url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
// "uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
// "ext": ".png"
// },
// {
// "name": "雨滴2",
// "url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
// "uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
// "ext": ".png"
// },
// {
// "name": "炸弹",
// "url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
// "uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
// "ext": ".png"
// },
// {
// "name": "石块",
// "url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
// "uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
// "ext": ".png"
// },
// {
// "name": "水花",
// "url": "//yun.duiba.com.cn/aurora/assets/ac85f46bd6e47b729a4d16f91696e12d273cdc75.svga",
// "uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
// "ext": ".svga"
// },
// {
// "name": "石头svga",
// "url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
// "uuid": "846a139d-0990-4db4-a323-f22379932ee4",
// "ext": ".svga"
// },
// {
// "name": "炸弹svga",
// "url": "//yun.duiba.com.cn/aurora/assets/862802a8173acc1bde28dd603c7ffd2ccc426700.svga",
// "uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
// "ext": ".svga"
// },
// {
// "name": "玩家翻船",
// "url": "//yun.duiba.com.cn/aurora/assets/1615916b51ec577afd09e2392ac8ee3fa32e6891.svga",
// "uuid": "6338498f-78ba-4d4b-a172-85755646baf7",
// "ext": ".svga"
// },
// {
// "name": "玩家滑动",
// "url": "//yun.duiba.com.cn/aurora/assets/790b67abcc05f1690dde2edae058d865ceb1fe6f.svga",
// "uuid": "59920d79-e5bf-46e0-a753-f4e7a1315a97",
// "ext": ".svga"
// },
// {
// "name": "玩家静止",
// "url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
// "uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
// "ext": ".png"
// }
];
function loadAssets(customModuleAssets, onProgress, onComplete){
......
This diff is collapsed.
......@@ -7,15 +7,20 @@
"type": "number",
"default": 900
},
"rainScore": {
"alias": "接中雨滴获得分数",
"runScore": {
"alias": "每前进1米加分(不能小于1)",
"type": "number",
"default": 1
},
"stoneScore": {
"alias": "接中石块获得分数",
"rainScore": {
"alias": "接金币获得分数",
"type": "number",
"default": 5
},
"rain2Score": {
"alias": "接粽子获得分数",
"type": "number",
"default": -1
"default": 10
},
"speed": {
"alias": "道具掉落初始速度",
......@@ -43,127 +48,157 @@
"type": "number",
"default": -20
},
"maxNpcBound": {
"alias": "道具随机出现的边距",
"type": "number",
"default": 100
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"default": "-80,-200"
},
"boomPosition2Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"default": "-80,-200"
},
"boomPosition3Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"alias": "障碍爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,-100"
},
"playerRunPosition3Offset": {
"alias": "玩家滑动位置偏移",
"type": "array<number>",
"default": "-100,-120"
},
"playerOverPosition3Offset": {
"alias": "玩家翻船位置偏移",
"type": "array<number>",
"default": "-100,-100"
"default": "-100,-120"
}
},
"assets": [
{
"name": "雨滴0",
"url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
"name": "循环背景1",
"url": "//yun.duiba.com.cn/aurora/assets/a57af3e2092f421ebbb47ee7a3d30f4326b5b7cd.jpg",
"uuid": "d95a5911-1c7c-4b60-9ff1-5cb179738e91",
"ext": ".jpg"
},
{
"name": "雨滴1",
"url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"name": "循环背景2",
"url": "//yun.duiba.com.cn/aurora/assets/489de78a248456d9dee74d8106da3dae40c0268b.jpg",
"uuid": "2222b6d9-17cb-42a6-a0f2-54c390522ca5",
"ext": ".jpg"
},
{
"name": "金币",
"url": "//yun.duiba.com.cn/aurora/assets/6d2719418a59a95fc0db0c0b761d00b4b4519b81.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "雨滴2",
"url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
"uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
"name": "粽子",
"url": "//yun.duiba.com.cn/aurora/assets/89ec786e36cd306225502b384ddb7550d79166c2.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/13efce5d31f114e2db9c9b0baac057bc1baf89d2.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"name": "木头",
"url": "//yun.duiba.com.cn/aurora/assets/3071bf51a8cc4e1733fe7ab6549206d27be15e7c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga",
"name": "碰到金币svga",
"url": "//yun.duiba.com.cn/aurora/assets/ebd0dc01e7154970bc2b1e65a6a3641aec0e319c.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
"uuid": "846a139d-0990-4db4-a323-f22379932ee4",
"name": "碰到粽子svga",
"url": "//yun.duiba.com.cn/aurora/assets/b9d21ca9758a8503dc5271949924f7cb08adcdf2.svga",
"uuid": "ce252ae3-9cc5-490b-9c18-a4111317c473",
"ext": ".svga"
},
{
"name": "炸弹svga",
"url": "//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"name": "碰到石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/862802a8173acc1bde28dd603c7ffd2ccc426700.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"name": "玩家翻船",
"url": "//yun.duiba.com.cn/aurora/assets/4dd3f3d80c8560d534abfd4c55f4ed758fd9c6f1.svga",
"uuid": "6338498f-78ba-4d4b-a172-85755646baf7",
"ext": ".svga"
},
{
"name": "玩家滑动",
"url": "//yun.duiba.com.cn/aurora/assets/83c888fcce01d2202a9b4ab73090b3f9e2bc11cd.svga",
"uuid": "59920d79-e5bf-46e0-a753-f4e7a1315a97",
"ext": ".svga"
},
{
"name": "玩家静止",
"url": "//yun.duiba.com.cn/aurora/assets/9e1d76f3ce486edd17c81e97782ed8afe3f66c0b.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
],
"events": {
"in": {
"food-fell-reset": {
"dragon-boat-race-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"goodsProbability": "[0.2,0.2,0.3,0.3]道具概率(金币、粽子、木头、石块),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed":"道具掉落加速度(单位:每秒)"
}
},
"food-fell-start": {
"dragon-boat-race-start": {
"alias": "开始"
},
"food-fell-revive": {
"dragon-boat-race-revive": {
"alias": "复活"
},
"food-fell-pause": {
"dragon-boat-race-pause": {
"alias": "暂停"
},
"food-fell-resume": {
"dragon-boat-race-resume": {
"alias": "恢复"
},
"food-fell-clear": {
"dragon-boat-race-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"food-fell-score-update": {
"dragon-boat-race-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"food-fell-time-update": {
"dragon-boat-race-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"food-fell-game-over": {
"dragon-boat-race-game-over": {
"alias": "游戏结束",
"data": {
"score":"分数",
......
......@@ -12,14 +12,12 @@ export class GameWrapper extends engine.Container {
constructor() {
super();
alert(123)
engine.globalEvent.addEventListener('food-fell-reset', this.reset, this);
engine.globalEvent.addEventListener('food-fell-start', this.start, this);
engine.globalEvent.addEventListener('food-fell-pause', this.pause, this);
engine.globalEvent.addEventListener('food-fell-resume', this.resume, this);
engine.globalEvent.addEventListener('food-fell-revive', this.revive, this);
engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);
engine.globalEvent.addEventListener('dragon-boat-race-reset', this.reset, this);
engine.globalEvent.addEventListener('dragon-boat-race-start', this.start, this);
engine.globalEvent.addEventListener('dragon-boat-race-pause', this.pause, this);
engine.globalEvent.addEventListener('dragon-boat-race-resume', this.resume, this);
engine.globalEvent.addEventListener('dragon-boat-race-revive', this.revive, this);
engine.globalEvent.addEventListener('dragon-boat-race-clear', this.clear, this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
......
......@@ -19,25 +19,32 @@ export class Goods extends engine.Container {
// let randomNum = Math.floor(Math.random() * 3)
// console.log('雨滴' + randomNum);
let rain = new engine.Sprite(getTextureByName('雨滴0'));
let rain1 = new engine.Sprite(getTextureByName('雨滴1'));
let rain2 = new engine.Sprite(getTextureByName('雨滴2'));
let rain = new engine.Sprite(getTextureByName('金币'));
let rain1 = new engine.Sprite(getTextureByName('粽子'));
rain["npcType"]="rain0"
rain1["npcType"]="rain1"
rain2["npcType"]="rain2"
let stone = new engine.Sprite(getTextureByName('石块'));
let stone = new engine.Sprite(getTextureByName('木头'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
let boom = new engine.Sprite(getTextureByName('石块'));
boom["npcType"]="boom"
rain.visible=false;
rain1.visible=false;
rain2.visible=false;
stone.visible=false;
boom.visible=false;
rain.anchorX=rain.width/2
rain1.anchorX=rain1.width/2
stone.anchorX=stone.width/2
boom.anchorX=boom.width/2
rain.anchorY=rain.height/2
rain1.anchorY=rain1.height/2
stone.anchorY=stone.height/2
boom.anchorY=boom.height/2
body.addChild(rain)
body.addChild(rain1)
body.addChild(rain2)
body.addChild(stone)
body.addChild(boom)
......@@ -53,24 +60,33 @@ export class Goods extends engine.Container {
}
reset() {
this["lifeState"]=true;
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
if(this.width<=0){
this.anchorX=50;
}else{
this.anchorX=this.width/2;
}
this.anchorY=this.height/2;
this.scaleX=this.scaleY=1;
this.y = 0;
this.x = (750-120)*Math.random()+30;
this.x = ((750-props.maxNpcBound)-120)*Math.random()+30+props.maxNpcBound;
this.rotation = 0;
let random=Math.random()
if(typeof (props.goodsProbability) == 'string'){
props.goodsProbability=props.goodsProbability.split(',').map((i: string) => +i)
console.log(props.goodsProbability);
}
if(random<props.goodsProbability[0]){
let randomNum = Math.floor(Math.random() * 3)
this.showNpc("rain" + randomNum)
this.showNpc("rain0")
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("rain1")
}else if(random>=(props.goodsProbability[0]+props.goodsProbability[1])&&random<=(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){
this.showNpc("boom")
}
}
......
......@@ -17,7 +17,6 @@
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
......
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