Commit b182001e authored by wildfirecode's avatar wildfirecode

1

parent f1e47180
No preview for this file type
......@@ -12,8 +12,14 @@
{
"name": "playBg",
"url": "//yun.duiba.com.cn/aurora/assets/76b9491f50eaf51ae2becf9958d96a93770854ee.jpg",
"uuid": "888",
"uuid": "1e7dd156-b59a-491d-8154-af2ecf425a8b",
"ext": ".jpg"
},
{
"name": "idlerWheel",
"url": "//yun.duiba.com.cn/aurora/assets/2a06e8c7b49d8e53955359f7a6dc5bd887978c21.png",
"uuid": "c21d9b0f-1aec-40c8-bb2b-7e674506b833",
"ext": ".png"
}
],
"events": {
......@@ -51,5 +57,5 @@
}
},
"id": "recycling",
"code": "\"use strict\";var tslib=require(\"tslib\");function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var GameView=function(t){function e(){var e=t.call(this)||this;return e._timeCounter=0,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.start=function(){var e=new engine.Sprite(getTextureByName(\"playBg\"));this.addChild(e)},e.prototype.getSecond=function(){return 0},e.prototype.onTimer=function(){engine.globalEvent.dispatchEvent(\"recycling-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(\"recycling-game-fail\",{reason:1}))},e.prototype.stop=function(){},e.prototype.createRects=function(){},e.prototype.setup=function(){console.log(\"onSteup\",props);var e=new engine.Sprite;this.addChild(e)},e.prototype.onDown=function(e){},e.prototype.stageOnUp=function(e){},e.prototype.onSuccess=function(){},e.prototype.onMove=function(e){},e}(engine.Container),GameWrapper=function(n){function e(){var e=n.call(this)||this;engine.globalEvent.addEventListener(\"recycling-start\",e.start,e),engine.globalEvent.addEventListener(\"recycling-stop\",e.stop,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,n),e.prototype.start=function(e){injectProps(e.data),this._gameView.start()},e.prototype.stop=function(e){this._gameView.stop()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index;\n"
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global.recycling = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tvar uiConfig = (function () {\n\t return [\n\t {\n\t id: 'playBg',\n\t texture: 'playBg'\n\t },\n\t {\n\t id: 'idler0',\n\t texture: 'idlerWheel',\n\t pos: [75, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler1',\n\t texture: 'idlerWheel',\n\t pos: [175, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler2',\n\t texture: 'idlerWheel',\n\t pos: [275, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler3',\n\t texture: 'idlerWheel',\n\t pos: [375, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler4',\n\t texture: 'idlerWheel',\n\t pos: [475, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler5',\n\t texture: 'idlerWheel',\n\t pos: [575, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler6',\n\t texture: 'idlerWheel',\n\t pos: [675, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t ];\n\t});\n\t//# sourceMappingURL=uiConfig.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this._timeCounter = 0;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.configUI = function () {\n\t var config = uiConfig();\n\t for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {\n\t var item = config_1[_i];\n\t var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;\n\t var sp = new engine.Sprite(getTextureByName(texture));\n\t this.addChild(sp);\n\t if (anchor) {\n\t sp.anchorX = anchor[0];\n\t sp.anchorY = anchor[1];\n\t }\n\t if (pos) {\n\t sp.x = pos[0];\n\t sp.y = pos[1];\n\t if (anchor) {\n\t sp.x = pos[0] - sp.anchorX;\n\t sp.y = pos[1] - sp.anchorY;\n\t }\n\t }\n\t }\n\t };\n\t GameView.prototype.start = function () {\n\t return;\n\t };\n\t GameView.prototype.getSecond = function () { return 0; };\n\t GameView.prototype.onTimer = function () {\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\n\t second: this.getSecond(),\n\t });\n\t if (this.getSecond() == 0) {\n\t this.stop();\n\t engine.globalEvent.dispatchEvent('recycling-game-fail', {\n\t reason: 1\n\t });\n\t }\n\t };\n\t GameView.prototype.stop = function () {\n\t };\n\t GameView.prototype.createRects = function () { };\n\t GameView.prototype.setup = function () {\n\t console.log('onSteup', props);\n\t this.configUI();\n\t };\n\t GameView.prototype.onDown = function (e) {\n\t };\n\t GameView.prototype.stageOnUp = function (e) {\n\t };\n\t GameView.prototype.onSuccess = function () {\n\t };\n\t GameView.prototype.onMove = function (e) {\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('recycling-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.stop = function (event) {\n\t this._gameView.stop();\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
"use strict";var tslib=require("tslib");function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var GameView=function(t){function e(){var e=t.call(this)||this;return e._timeCounter=0,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.start=function(){var e=new engine.Sprite(getTextureByName("playBg"));this.addChild(e)},e.prototype.getSecond=function(){return 0},e.prototype.onTimer=function(){engine.globalEvent.dispatchEvent("recycling-time-update",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent("recycling-game-fail",{reason:1}))},e.prototype.stop=function(){},e.prototype.createRects=function(){},e.prototype.setup=function(){console.log("onSteup",props);var e=new engine.Sprite;this.addChild(e)},e.prototype.onDown=function(e){},e.prototype.stageOnUp=function(e){},e.prototype.onSuccess=function(){},e.prototype.onMove=function(e){},e}(engine.Container),GameWrapper=function(n){function e(){var e=n.call(this)||this;engine.globalEvent.addEventListener("recycling-start",e.start,e),engine.globalEvent.addEventListener("recycling-stop",e.stop,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,n),e.prototype.start=function(e){injectProps(e.data),this._gameView.start()},e.prototype.stop=function(e){this._gameView.stop()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.recycling = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
//# sourceMappingURL=utils.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var uiConfig = (function () {
return [
{
id: 'playBg',
texture: 'playBg'
},
{
id: 'idler0',
texture: 'idlerWheel',
pos: [75, 1038],
anchor: [20, 21.5]
},
{
id: 'idler1',
texture: 'idlerWheel',
pos: [175, 1038],
anchor: [20, 21.5]
},
{
id: 'idler2',
texture: 'idlerWheel',
pos: [275, 1038],
anchor: [20, 21.5]
},
{
id: 'idler3',
texture: 'idlerWheel',
pos: [375, 1038],
anchor: [20, 21.5]
},
{
id: 'idler4',
texture: 'idlerWheel',
pos: [475, 1038],
anchor: [20, 21.5]
},
{
id: 'idler5',
texture: 'idlerWheel',
pos: [575, 1038],
anchor: [20, 21.5]
},
{
id: 'idler6',
texture: 'idlerWheel',
pos: [675, 1038],
anchor: [20, 21.5]
},
];
});
//# sourceMappingURL=uiConfig.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this._timeCounter = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.configUI = function () {
var config = uiConfig();
for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {
var item = config_1[_i];
var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;
var sp = new engine.Sprite(getTextureByName(texture));
this.addChild(sp);
if (anchor) {
sp.anchorX = anchor[0];
sp.anchorY = anchor[1];
}
if (pos) {
sp.x = pos[0];
sp.y = pos[1];
if (anchor) {
sp.x = pos[0] - sp.anchorX;
sp.y = pos[1] - sp.anchorY;
}
}
}
};
GameView.prototype.start = function () {
return;
};
GameView.prototype.getSecond = function () { return 0; };
GameView.prototype.onTimer = function () {
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
engine.globalEvent.dispatchEvent('recycling-game-fail', {
reason: 1
});
}
};
GameView.prototype.stop = function () {
};
GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () {
console.log('onSteup', props);
this.configUI();
};
GameView.prototype.onDown = function (e) {
};
GameView.prototype.stageOnUp = function (e) {
};
GameView.prototype.onSuccess = function () {
};
GameView.prototype.onMove = function (e) {
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('recycling-start', _this.start, _this);
engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
This diff is collapsed.
......@@ -7,17 +7,23 @@
"type": "number",
"default": 3
}
},
"assets": [{
"name": "playBg",
"url": "//yun.duiba.com.cn/aurora/assets/76b9491f50eaf51ae2becf9958d96a93770854ee.jpg",
"uuid": "888",
"ext": ".jpg"
}],
"name": "playBg",
"url": "//yun.duiba.com.cn/aurora/assets/76b9491f50eaf51ae2becf9958d96a93770854ee.jpg",
"uuid": "1e7dd156-b59a-491d-8154-af2ecf425a8b",
"ext": ".jpg"
},
{
"name": "idlerWheel",
"url": "//yun.duiba.com.cn/aurora/assets/2a06e8c7b49d8e53955359f7a6dc5bd887978c21.png",
"uuid": "c21d9b0f-1aec-40c8-bb2b-7e674506b833",
"ext": ".png"
}
],
"events": {
"in": {
"recycling-start": {
"alias": "开始",
"data": {
......@@ -50,4 +56,6 @@
}
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
import { getTextureByName } from "../../../recycling/src/game/utils";
import { props } from "../props";
import uiConfig from "./uiConfig";
export default class GameView extends engine.Container {
private _timer;
......@@ -14,9 +15,35 @@ export default class GameView extends engine.Container {
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
configUI() {
const uiMap: any = {};
const config = uiConfig();
for (const item of config) {
const { id, texture, pos, anchor } = item;
const sp = new engine.Sprite(getTextureByName(texture));
this.addChild(sp);
if (anchor) {
sp.anchorX = anchor[0];
sp.anchorY = anchor[1];
}
if (pos) {
sp.x = pos[0];
sp.y = pos[1];
if (anchor) {
sp.x = pos[0] - sp.anchorX;
sp.y = pos[1] - sp.anchorY;
}
}
}
}
start() {
const bg = new engine.Sprite(getTextureByName('playBg'));
this.addChild(bg);
// const bg = new engine.Sprite(getTextureByName('playBg'));
// this.addChild(bg);
return;
console.log('on start')
......@@ -52,11 +79,10 @@ export default class GameView extends engine.Container {
createRects() { }
setup() {
console.log('onSteup', props);
const parent = new engine.Sprite();
this.addChild(parent);
this.configUI();
}
onDown(e: engine.MouseEvent) {
......
......@@ -9,11 +9,6 @@ import { injectProps } from "../props";
export class GameWrapper extends engine.Container {
// private _status;
private _gameView: GameView;
constructor() {
super();
......
export default () => {
return [
{
id: 'playBg',
texture: 'playBg'
},
{
id: 'idler0',
texture: 'idlerWheel',
pos: [75, 1038],
anchor: [20, 21.5]
},
{
id: 'idler1',
texture: 'idlerWheel',
pos: [175, 1038],
anchor: [20, 21.5]
},
{
id: 'idler2',
texture: 'idlerWheel',
pos: [275, 1038],
anchor: [20, 21.5]
},
{
id: 'idler3',
texture: 'idlerWheel',
pos: [375, 1038],
anchor: [20, 21.5]
},
{
id: 'idler4',
texture: 'idlerWheel',
pos: [475, 1038],
anchor: [20, 21.5]
},
{
id: 'idler5',
texture: 'idlerWheel',
pos: [575, 1038],
anchor: [20, 21.5]
},
{
id: 'idler6',
texture: 'idlerWheel',
pos: [675, 1038],
anchor: [20, 21.5]
},
]
}
\ No newline at end of file
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