Commit 697e8d0e authored by 任建锋's avatar 任建锋

--

parent 2604b128
This diff is collapsed.
This diff is collapsed.
declare function getAssetByUUID(uuid: string);
declare function getAssetByName(name: string);
<<<<<<< HEAD
declare function getProps():any;
=======
declare function getProps():any;
>>>>>>> dev
/**
* 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');
}, 1000);
});
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": "雨滴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"
}
];
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
},
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 100
},
"playerWidth": {
"alias": "玩家宽度",
"type": "number",
"default": 100
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"boomPosition2Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"boomPosition3Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-100,-100"
}
},
"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"
}
],
"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 + props.boomPosition1Offset[0];
this.stoneSvga.y = this.player.height / 2 - this.stoneSvga.height/2 + props.boomPosition1Offset[1];
this.waterSvga.x = this.player.width / 2 - this.waterSvga.width/2+ props.boomPosition2Offset[0];
this.waterSvga.y = this.player.height / 2 - this.waterSvga.height/2 + props.boomPosition2Offset[1];
this.boomSvga.x = this.player.width / 2 - this.boomSvga.width/2+ props.boomPosition3Offset[0];
this.boomSvga.y = this.player.height / 2 - this.boomSvga.height/2 + props.boomPosition3Offset[1];
// this.stoneSvga.x=props.boomPositionOffset[0]
// this.stoneSvga.y=props.boomPositionOffset[1]
// this.waterSvga.x=props.boomPositionOffset[0]
// this.waterSvga.y=props.boomPositionOffset[1]
// this.boomSvga.x=props.boomPositionOffset[0]
// this.boomSvga.y=props.boomPositionOffset[1]
},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.NpcBg.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) {
let playerH=a.height
let playerW=a.width
let playerX=a.x
console.log("props",props.playerHeight)
if(props.playerHeight){
playerH=props.playerHeight
}
if(props.playerWidth){
playerW=props.playerWidth
playerX=a.x+(a.width-props.playerWidth)/2
}
if (
Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 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 + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
private onDownStage = (e) => {
this.moveCatchX = e.localX;
this.playerCatchX = this.player.x
}
private onMoveStage = (e) => {
let maxStageBound=props.maxStageBound;
if (this.gameIng) {
let playerX=this.playerCatchX + (e.localX - this.moveCatchX)
if(playerX<maxStageBound){
this.player.x=maxStageBound
}else if(playerX+this.player.width+maxStageBound>750){
this.player.x=750-maxStageBound-this.player.width
}else{
this.player.x=playerX
}
}
}
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();
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);
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(engine.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);
}
......@@ -14,8 +14,11 @@
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
return getTexture(getAssetByName(name).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ export function getTexture(uuid) {
}
export function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
return getTexture(getAssetByName(name).uuid);
}
export function playSound(name) {
......
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