Commit 7a96d016 authored by pengruiyang's avatar pengruiyang

update

parent f0684238
{
"liveServer.settings.port": 5501
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -25,7 +24,6 @@ ...@@ -25,7 +24,6 @@
inst.source = 'asset://' + engine.getAssetByName(name).uuid; inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst; return inst;
} }
//# sourceMappingURL=utils.js.map
var Goods = (function (_super) { var Goods = (function (_super) {
tslib.__extends(Goods, _super); tslib.__extends(Goods, _super);
...@@ -94,7 +92,6 @@ ...@@ -94,7 +92,6 @@
}); });
return Goods; return Goods;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Goods.js.map
var ObjectPool = engine.ObjectPool; var ObjectPool = engine.ObjectPool;
var PoolName = 'goods'; var PoolName = 'goods';
...@@ -103,7 +100,6 @@ ...@@ -103,7 +100,6 @@
}, function (item, data) { }, function (item, data) {
item.reset(); item.reset();
}); });
//# sourceMappingURL=object-pool-init.js.map
var ObjectPool$1 = engine.ObjectPool; var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) { var GameView = (function (_super) {
...@@ -345,7 +341,6 @@ ...@@ -345,7 +341,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -353,7 +348,6 @@ ...@@ -353,7 +348,6 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
This diff is collapsed.
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'food-fell2';
(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,
}
}],
customs: []
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": "0.8,0.1,0.1",
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (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: red;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></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/engine.fbc60c6d3cb30e5ab97e82d392d9efeee91b8581.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": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"ext": ".png"
},
{
"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",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a",
"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/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
// {
// "name": "炸弹",
// "url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
// "uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
// "ext": ".svga"
// },
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
// {
// "name": "玩家",
// "url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
// "uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
// "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": "口红机模块",
"props": {
"playerPositionY": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 900
},
"rainScore": {
"alias": "接中雨滴获得分数",
"type": "number",
"default": 1
},
"stoneScore": {
"alias": "接中石块获得分数",
"type": "number",
"default": -1
},
"speed": {
"alias": "道具掉落初始速度",
"type": "number",
"default": 10
},
"maxSpeed": {
"alias": "道具掉落速度上限",
"type": "number",
"default": 3
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
}
},
"assets": [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"ext": ".png"
},
{
"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",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a",
"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/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"
}
],
"events": {
"in": {
"food-fell-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed":"道具掉落加速度(单位:每秒)"
}
},
"food-fell-start": {
"alias": "开始"
},
"food-fell-revive": {
"alias": "复活"
},
"food-fell-pause": {
"alias": "暂停"
},
"food-fell-resume": {
"alias": "恢复"
},
"food-fell-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"food-fell-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"food-fell-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"food-fell-game-over": {
"alias": "游戏结束",
"data": {
"score":"分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { playSound, createSvga } from "./utils";
import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils";
import { Goods } from "./Goods";
import { PoolName } from "./object-pool-init";
export default class GameView extends engine.Container {
private _hasSetup;
//玩家
private player: engine.Container;
//触摸层
// private rectBg: engine.Rect;
private rectBg: engine.Container;
//npc层
private NpcBg: engine.Container;
//当前分数
private score
//游戏状态
private gameIng;
//npc出身计时器
private timer
//倒计时计时器
private countdownTimer: any
//倒计时
private countdown: number
//当前速度
private speed: number
// 当前场景上面的物品
private goodsItems = []
private _goods: Goods;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
private waterSvga
private stoneSvga
private boomSvga
private playerSvga
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg)
this.player = new engine.Container();
this.player.mouseEnabled = false;
// this.player.fillColor="rgba(0, 0, 0,1)"
//console.log(this.player.fillColor)
this.addChild(this.player);
this.waterSvga=createSvga("水花")
this.stoneSvga=createSvga("石头svga")
// this.playerSvga=createSvga("玩家")
this.playerSvga= new engine.Sprite(getTextureByName('玩家'))
this.boomSvga=createSvga("炸弹svga")
this.player.addChild(this.playerSvga);
this.player.addChild(this.stoneSvga);
this.player.addChild(this.waterSvga);
this.player.addChild(this.boomSvga);
// this.playerSvga.gotoAndPlay(1);
this.waterSvga.visible = false
this.stoneSvga.visible = false
this.boomSvga.visible = false
this.visible=false;
setTimeout(()=>{
this.visible=true;
this.player.anchorY = this.player.height / 2;
this.player.anchorX = this.player.width / 2;
this.player.x = 375 - this.player.width / 2;
this.player.y = props.playerPositionY;
this.stoneSvga.x = this.player.width / 2 - this.stoneSvga.width/2;
this.stoneSvga.y = 110;
this.waterSvga.x = this.player.width / 2 - this.waterSvga.width/2;
this.waterSvga.y = 110;
},300)
this.rectBg = new engine.Container();
this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.addChild(this.rectBg)
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);
}
/**
* 重置场景
*/
reset() {
this.recycleGoods()
}
/**
* 开始
*/
start() {
this.score = 0;
this.speed = 1
this.gameIng = true;
this.creatNpc()
this.beginNpc()
this.countdown = props.countDown;
this.countdownTimer = setInterval(() => {
if (this.gameIng) {
if (this.countdown > 0) {
engine.globalEvent.dispatchEvent('food-fell-time-update', {
time: this.countdown,
});
this.countdown -= 1
} else {
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: this.score,
reason: 1
});
this.died()
}
}
}, 1000)
}
/**
* npc开始掉落
*/
beginNpc() {
this.timer = setTimeout(() => {
if (this.gameIng) {
this.speed += props.acceleratedSpeed;
this.creatNpc()
}
//递归执行
this.beginNpc()
}, 2000 / this.speed)
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
resume() {
this.reset()
this.start()
}
/**
* 创建NPC
*/
private creatNpc() {
let goods = this._goods = <Goods>ObjectPool.getObject(PoolName);
this.goodsItems.push(goods)
console.log(goods);
this.NpcBg.addChild(goods);
goods.addEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"] = () => {
if (goods.y > 1624) {
this.removeNpc(goods)
} else {
if (this.gameIng) {
//速度叠加
goods.y += (4 * this.speed)
//如果玩家和物品发生碰撞
if (this.hasHit(this.player, goods)) {
if (goods["npcType"].indexOf("rain") > -1) {
console.log("碰到雨滴")
this.score += props.rainScore
this.waterSvga.visible=true;
this.waterSvga.x= goods.x - this.player.x;
this.waterSvga.play(false, false)
this.waterSvga.once(engine.Event.END_FRAME, ()=>{
this.waterSvga.visible=false;
}, this);
} else if (goods["npcType"] == "stone") {
console.log("碰到石头")
this.score += props.stoneScore
this.stoneSvga.visible=true;
this.stoneSvga.play(false, false)
this.stoneSvga.once(engine.Event.END_FRAME, ()=>{
this.stoneSvga.visible=false;
}, this);
} else if (goods["npcType"] == "boom") {
console.log("碰到炸弹")
this.boomSvga.visible=true;
this.boomSvga.play(false, false)
this.boomSvga.once(engine.Event.END_FRAME, ()=>{
this.boomSvga.visible=false;
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: this.score,
reason: 2
});
this.died()
}, this);
}
engine.globalEvent.dispatchEvent('food-fell-score-update', {
score: this.score,
});
this.removeNpc(goods)
}
}
}
}, this);
}
/**
* 玩家死亡
*/
private died() {
this.score = 0
this.pause()
}
/**
* 回收指定物品
* @param goods 物品
*/
private removeNpc(goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
let index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
}
/**
* 回收对象
*/
private recycleGoods() {
clearTimeout(this.timer)
clearInterval(this.countdownTimer)
for (let goods of this.goodsItems) {
if (goods) {
this.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = []
}
private moveCatchX = 0
private playerCatchX = 0
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
if (
Math.abs((a.x + a.width / 2) - (b.x + b.width / 2)) < a.width / 2 + b.width / 2
&&
// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2
Math.abs((a.y + a.height / 1.3 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
private onDownStage = (e) => {
this.moveCatchX = e.localX;
this.playerCatchX = this.player.x
}
private onMoveStage = (e) => {
if (this.gameIng) {
this.player.x = this.playerCatchX + (e.localX - this.moveCatchX)
}
}
private onOutStage = (e) => {
this.moveCatchX = 0
}
}
/**
* 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();
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);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
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);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
// 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'));
rain["npcType"]="rain0"
rain1["npcType"]="rain1"
rain2["npcType"]="rain2"
let stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"]="boom"
rain.visible=false;
rain1.visible=false;
rain2.visible=false;
stone.visible=false;
boom.visible=false;
body.addChild(rain)
body.addChild(rain1)
body.addChild(rain2)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750-120)*Math.random()+30;
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)
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
/**
* Created by rockyl on 2020-01-21.
*/
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;
}
\ 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);
}
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -38,7 +37,6 @@ ...@@ -38,7 +37,6 @@
function playSound(name) { function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true }); engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
} }
//# sourceMappingURL=utils.js.map
var Block = (function (_super) { var Block = (function (_super) {
tslib.__extends(Block, _super); tslib.__extends(Block, _super);
...@@ -98,7 +96,6 @@ ...@@ -98,7 +96,6 @@
}; };
return Block; return Block;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Block.js.map
var Background = (function (_super) { var Background = (function (_super) {
tslib.__extends(Background, _super); tslib.__extends(Background, _super);
...@@ -127,7 +124,6 @@ ...@@ -127,7 +124,6 @@
}; };
return Background; return Background;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Background.js.map
var svgaAssets = { var svgaAssets = {
aniReady: { name: '准备立正', dir: 1 }, aniReady: { name: '准备立正', dir: 1 },
...@@ -340,7 +336,6 @@ ...@@ -340,7 +336,6 @@
}; };
return Player; return Player;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Player.js.map
var Base = (function (_super) { var Base = (function (_super) {
tslib.__extends(Base, _super); tslib.__extends(Base, _super);
...@@ -355,7 +350,6 @@ ...@@ -355,7 +350,6 @@
}; };
return Base; return Base;
}(engine.Image)); }(engine.Image));
//# sourceMappingURL=Base.js.map
var GuideLayer = (function (_super) { var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super); tslib.__extends(GuideLayer, _super);
...@@ -408,7 +402,6 @@ ...@@ -408,7 +402,6 @@
}; };
return GuideLayer; return GuideLayer;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GuideLayer.js.map
var GoldBag = (function (_super) { var GoldBag = (function (_super) {
tslib.__extends(GoldBag, _super); tslib.__extends(GoldBag, _super);
...@@ -447,7 +440,6 @@ ...@@ -447,7 +440,6 @@
}; };
return GoldBag; return GoldBag;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GoldBag.js.map
var ObjectPool = engine.ObjectPool; var ObjectPool = engine.ObjectPool;
var PoolName = 'gold-bag'; var PoolName = 'gold-bag';
...@@ -900,7 +892,6 @@ ...@@ -900,7 +892,6 @@
}; };
return JumpHigh; return JumpHigh;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=JumpHigh.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -908,7 +899,6 @@ ...@@ -908,7 +899,6 @@
var instance = new JumpHigh(); var instance = new JumpHigh();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created by renjianfeng on 2020-03-13.
*/
//这里需要修改
const customId = 'jump-more';
(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('jump-more-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('jump-more-start');
// engine.globalEvent.dispatchEvent('jump-more-play-music');
}, 500);
});
engine.globalEvent.addEventListener('jump-more-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-score-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-game-over', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-score-update', (e) => {
});
}
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: red; */
}
</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>
window.requestAnimFrame = (function() {
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60);
}
);
})();
</script>
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"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/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家abc",
"url": "//yun.duiba.com.cn/aurora/assets/41aab15126a106fb7b4083fbc50f9bcea5b3a090.svga",
"uuid": "613125b7-f199-4aa1-860a-9243fc16c4eb",
"ext": ".svga"
},
{
"name": "玩家右",
"url": "//yun.duiba.com.cn/aurora/assets/85af8997aa6dd1aa47011ea843302a4a072f2efd.png",
"uuid": "09e76db2-db0f-46e0-803a-998b1895a027",
"ext": ".png"
},
{
"name": "台阶",
"url": "//yun.duiba.com.cn/aurora/assets/e37ef0563103ffd582d787d36032d7262a3dce47.png",
"uuid": "db411686-ad6b-4bed-81b5-b844715e2882",
"ext": ".png"
},
{
"name": "青团",
"url": "//yun.duiba.com.cn/aurora/assets/14bfed9ab0c2f995b1ca34a5ca0116e8d155012d.png",
"uuid": "84b0849b-7417-4322-b4a3-f7d1a38b15c3",
"ext": ".png"
},
{
"name": "大灰狼",
"url": "//yun.duiba.com.cn/aurora/assets/25a1b525af1daeab062565c2c2c9737957ce4be3.svga",
"uuid": "eae1241a-d133-4816-9496-a2850e7e2d8f",
"ext": ".svga"
}, {
"name": "得分",
"url": "//yun.duiba.com.cn/aurora/assets/88e5d349a8829ddd2b0f608da4d2d537db4bad54.png",
"uuid": "8d9cfa4e-18f9-43a4-8f8e-6996577482b6",
"ext": ".png"
}, {
"name": "加分",
"url": "//yun.duiba.com.cn/aurora/assets/b534a5f50ccc7eeca9ea4f0d4dea78430b8dec9b.png",
"uuid": "6dcb1e61-95e2-4841-8b71-7152f8d6cb37",
"ext": ".png"
},
{
"name": "游戏背景音乐",
"url": "//yun.duiba.com.cn/aurora/assets/7c955f550176b8ea2797b5555c30f1dfc9a770c1.mp3",
"uuid": "da826400-c835-4b75-8991-a29b64c5ac0b",
"ext": ".mp3"
},
{
"name": "吃道具音效",
"url": "//yun.duiba.com.cn/aurora/assets/a9e40a494d33b2c2a5c70ad93090efb4b36cb55d.mp3",
"uuid": "6b809f4e-1712-4201-beed-a683294ded02",
"ext": ".mp3"
},
{
"name": "碰到怪物掉落死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/e7f28dbc188c24613dccd11690a6f2e66bd00caa.mp3",
"uuid": "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
"ext": ".mp3"
},
{
"name": "跳起死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/5603f0353a3eeea305c7398bd17f993be7474641.mp3",
"uuid": "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
"ext": ".mp3"
}
];
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": "跳一跳模块",
"props": {
"prizeScore": {
"alias": "接中奖品获得分数",
"type": "number",
"default": 3
},
"prizeOdds": {
"alias": "奖品出现概率",
"type": "number",
"default": 0.3
},
"ghostOdds": {
"alias": "怪物出现概率",
"type": "number",
"default": 0.3
}
},
"assets": [
{
"name": "玩家abc",
"url": "//yun.duiba.com.cn/aurora/assets/41aab15126a106fb7b4083fbc50f9bcea5b3a090.svga",
"uuid": "613125b7-f199-4aa1-860a-9243fc16c4eb",
"ext": ".svga"
},
{
"name": "玩家右",
"url": "//yun.duiba.com.cn/aurora/assets/85af8997aa6dd1aa47011ea843302a4a072f2efd.png",
"uuid": "09e76db2-db0f-46e0-803a-998b1895a027",
"ext": ".png"
},
{
"name": "台阶",
"url": "//yun.duiba.com.cn/aurora/assets/e37ef0563103ffd582d787d36032d7262a3dce47.png",
"uuid": "db411686-ad6b-4bed-81b5-b844715e2882",
"ext": ".png"
},
{
"name": "青团",
"url": "//yun.duiba.com.cn/aurora/assets/14bfed9ab0c2f995b1ca34a5ca0116e8d155012d.png",
"uuid": "84b0849b-7417-4322-b4a3-f7d1a38b15c3",
"ext": ".png"
}, {
"name": "大灰狼",
"url": "//yun.duiba.com.cn/aurora/assets/25a1b525af1daeab062565c2c2c9737957ce4be3.svga",
"uuid": "eae1241a-d133-4816-9496-a2850e7e2d8f",
"ext": ".svga"
}, {
"name": "得分",
"url": "//yun.duiba.com.cn/aurora/assets/88e5d349a8829ddd2b0f608da4d2d537db4bad54.png",
"uuid": "8d9cfa4e-18f9-43a4-8f8e-6996577482b6",
"ext": ".png"
},{
"name": "加分",
"url": "//yun.duiba.com.cn/aurora/assets/b534a5f50ccc7eeca9ea4f0d4dea78430b8dec9b.png",
"uuid": "6dcb1e61-95e2-4841-8b71-7152f8d6cb37",
"ext": ".png"
},
{
"name": "游戏背景音乐",
"url": "//yun.duiba.com.cn/aurora/assets/7c955f550176b8ea2797b5555c30f1dfc9a770c1.mp3",
"uuid": "da826400-c835-4b75-8991-a29b64c5ac0b",
"ext": ".mp3"
},
{
"name": "吃道具音效",
"url": "//yun.duiba.com.cn/aurora/assets/a9e40a494d33b2c2a5c70ad93090efb4b36cb55d.mp3",
"uuid": "6b809f4e-1712-4201-beed-a683294ded02",
"ext": ".mp3"
},
{
"name": "碰到怪物掉落死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/e7f28dbc188c24613dccd11690a6f2e66bd00caa.mp3",
"uuid": "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
"ext": ".mp3"
},
{
"name": "跳起死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/5603f0353a3eeea305c7398bd17f993be7474641.mp3",
"uuid": "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
"ext": ".mp3"
}
],
"events": {
"in": {
"jump-more-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed": "道具掉落加速度(单位:每秒)"
}
},
"jump-more-start": {
"alias": "开始"
},
"jump-more-revive": {
"alias": "复活"
},
"jump-more-pause": {
"alias": "暂停"
},
"jump-more-resume": {
"alias": "恢复"
}
},
"out": {
"jump-more-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"jump-more-game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
}
}
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();
engine.globalEvent.addEventListener('jump-more-reset', this.reset, this);
engine.globalEvent.addEventListener('jump-more-start', this.start, this);
// engine.globalEvent.addEventListener('jump-more-pause', this.pause, this);
engine.globalEvent.addEventListener('jump-more-resume', this.resume, this);
engine.globalEvent.addEventListener('jump-more-revive', this.revive, this);
// engine.globalEvent.addEventListener('jump-more-play-music', this.playMusic, this);
// engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);
// engine.globalEvent.addEventListener('jump-more-score', ()=>{
// } , this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
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.gameRevive();
}
// playMusic(){
// this._gameView.playMusic()
// }
// clear() {
// this._gameView.visible = false;
// }
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
let rain = new engine.Sprite(getTextureByName('雨滴'));
rain["npcType"]="rain"
let stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"]="boom"
rain.visible=false;
stone.visible=false;
boom.visible=false;
body.addChild(rain)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750-120)*Math.random()+30;
this.rotation = 0;
let random=Math.random()
if(random<props.goodsProbability[0]){
this.showNpc("rain")
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
import { getTextureByName } from './utils';
import { props } from '../props';
import { createSvga } from './utils';
interface PlatformProps {
width: number;
height: number;
x: number;
y: number;
count: number;
}
export class Platform extends engine.Container {
private _body: engine.Rect;
// private _toY;
flag;
state;
moved;
vx;
type;
x = 0;
y = 0;
prizeOdds = props.prizeOdds;
ghostOdds = props.ghostOdds;
prizeFlag: boolean;
ghostFlag: boolean;
isNew: boolean;
addStatus: boolean;
prizeIcon: engine.Sprite;
ghostIcon;
constructor() {
super();
this.width = 224;
this.height = 56;
this.flag = 0;
this.state = 0;
this.moved = 0;
this.vx = 1;
this.type = 1;
this._body = new engine.Rect();
this.isNew = true
this.addStatus = false
this.addChild(new engine.Sprite(getTextureByName('台阶')));
this.prizeIcon = new engine.Sprite(getTextureByName('青团'));
this.prizeIcon.x = this.x + this.width / 2 - this.prizeIcon.width / 2;
this.prizeIcon.y = this.y - this.height + 10;
this.ghostIcon = createSvga('大灰狼');
this.ghostIcon.gotoAndPlay(1);
setTimeout(() => {
this.ghostIcon.y = -this.height * 2 - 10;
this.ghostIcon.x = this.width / 2 - this.ghostIcon.width / 2;
}, 10);
this.prizeIcon.visible = false;
this.ghostIcon.visible = false;
this.addChild(this.ghostIcon);
this.addChild(this.prizeIcon);
this.prizeFlag = Math.random() < this.prizeOdds ? true : false;
if (this.prizeFlag) {
this.ghostFlag = false;
this.prizeIcon.visible = true;
} else {
// this.ghostFlag = Math.random() < this.ghostOdds ? true : false;
// if (this.ghostFlag) this.ghostIcon.visible = true;
}
// let platform = new engine.Sprite(getTextureByName('台阶'));
}
getStatus() {
this.prizeIcon.visible = false;
this.ghostIcon.visible = false;
this.prizeFlag = Math.random() < this.prizeOdds ? true : false;
if (this.prizeFlag) {
this.ghostFlag = false;
this.prizeIcon.visible = true;
} else {
this.ghostFlag = Math.random() < this.ghostOdds ? true : false;
if (this.ghostFlag) this.ghostIcon.visible = true;
}
}
}
import {getTextureByName} from "./utils";
import {props} from "../props";
export class PrizeGood extends engine.Container {
private _body:engine.Rect
// private _toY;
x = 0;
y = 0;
id = 0;
state: number
constructor() {
super();
this.width = 146
this.height = 52
this.state = 0
this.addChild(new engine.Sprite(getTextureByName('青团')));
}
}
\ No newline at end of file
export default class SoundMgr {
private static _instance: SoundMgr = null;
public static get instance(): SoundMgr {
if (!this._instance) {
this._instance = new SoundMgr();
}
return this._instance;
}
public get enabled() {
return engine.env.soundEnabled;
}
public playEffect(name: string, loop: boolean = false) {
//if (!this.enabled) return;
engine.playSound(getAssetByUUID(nameToUuid[name]).uuid, {
loop,
keep: true
}, name);
}
public stopEffect(name: string){
engine.stopSound(name);
engine.destroySound(name);
}
}
const nameToUuid = {
bgm: "da826400-c835-4b75-8991-a29b64c5ac0b",
prize: "6b809f4e-1712-4201-beed-a683294ded02",
ghost: "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
jumpdied: "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
}
\ No newline at end of file
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import {Platform} from "./Platform";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
/**
* Created by rockyl on 2020-01-21.
*/
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;
}
\ 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