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
{"version":3,"file":"index.js","sources":["src/custom/recycling/src/game/utils.ts","src/custom/recycling/src/props.ts","src/custom/recycling/src/game/GameView.ts","src/custom/recycling/src/game/GameWrapper.ts","src/custom/recycling/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { getTextureByName } from \"../../../recycling/src/game/utils\";\nimport { props } from \"../props\";\n\nexport default class GameView extends engine.Container {\n private _timer;\n private _timeCounter = 0;\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n start() {\n const bg = new engine.Sprite(getTextureByName('playBg'));\n this.addChild(bg);\n return;\n console.log('on start')\n\n engine.globalEvent.dispatchEvent('recycling-time-update', {\n second: this.getSecond(),\n });\n\n this._timer = setInterval(() => {\n this.onTimer();\n }, 1000)\n }\n\n getSecond() { return 0 }\n\n onTimer() {\n engine.globalEvent.dispatchEvent('recycling-time-update', {\n second: this.getSecond(),\n });\n\n if (this.getSecond() == 0) {\n // GAME_TIME = props.GAME_TIME\n this.stop();\n engine.globalEvent.dispatchEvent('recycling-game-fail', {\n reason: 1\n });\n }\n }\n\n stop() {\n\n\n }\n\n\n createRects() { }\n setup() {\n console.log('onSteup', props);\n\n const parent = new engine.Sprite();\n this.addChild(parent);\n }\n\n onDown(e: engine.MouseEvent) {\n\n }\n\n stageOnUp(e) {\n\n\n }\n\n private onSuccess() {\n\n\n }\n\n onMove(e: engine.MouseEvent) {\n\n }\n\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('recycling-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('recycling-stop', this.stop, this);\n\n\t\t//创建实例\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\tthis._gameView.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t\tthis._gameView.stop();\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\t\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UAIgB,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;UAEe,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACrD,CAAC;;;CCNM,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCPD;KAAsCA,kCAAgB;KAIpD;SAAA,YACE,iBAAO,SA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W,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACzE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGvE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA7BgC,MAAM,CAAC,SAAS,GA6BhD;;;iBC9BwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/recycling/src/game/utils.ts","src/custom/recycling/src/props.ts","src/custom/recycling/src/game/uiConfig.ts","src/custom/recycling/src/game/GameView.ts","src/custom/recycling/src/game/GameWrapper.ts","src/custom/recycling/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","export default () => {\n return [\n {\n id: 'playBg',\n texture: 'playBg'\n },\n {\n id: 'idler0',\n texture: 'idlerWheel',\n pos: [75, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler1',\n texture: 'idlerWheel',\n pos: [175, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler2',\n texture: 'idlerWheel',\n pos: [275, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler3',\n texture: 'idlerWheel',\n pos: [375, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler4',\n texture: 'idlerWheel',\n pos: [475, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler5',\n texture: 'idlerWheel',\n pos: [575, 1038],\n anchor: [20, 21.5]\n },\n {\n id: 'idler6',\n texture: 'idlerWheel',\n pos: [675, 1038],\n anchor: [20, 21.5]\n },\n ]\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { getTextureByName } from \"../../../recycling/src/game/utils\";\nimport { props } from \"../props\";\nimport uiConfig from \"./uiConfig\";\n\nexport default class GameView extends engine.Container {\n private _timer;\n private _timeCounter = 0;\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n configUI() {\n\n const uiMap: any = {};\n const config = uiConfig();\n for (const item of config) {\n const { id, texture, pos, anchor } = item;\n const sp = new engine.Sprite(getTextureByName(texture));\n this.addChild(sp);\n if (anchor) {\n sp.anchorX = anchor[0];\n sp.anchorY = anchor[1];\n }\n if (pos) {\n sp.x = pos[0];\n sp.y = pos[1];\n if (anchor) {\n sp.x = pos[0] - sp.anchorX;\n sp.y = pos[1] - sp.anchorY;\n }\n }\n }\n\n }\n\n start() {\n\n // const bg = new engine.Sprite(getTextureByName('playBg'));\n // this.addChild(bg);\n\n return;\n console.log('on start')\n\n engine.globalEvent.dispatchEvent('recycling-time-update', {\n second: this.getSecond(),\n });\n\n this._timer = setInterval(() => {\n this.onTimer();\n }, 1000)\n }\n\n getSecond() { return 0 }\n\n onTimer() {\n engine.globalEvent.dispatchEvent('recycling-time-update', {\n second: this.getSecond(),\n });\n\n if (this.getSecond() == 0) {\n // GAME_TIME = props.GAME_TIME\n this.stop();\n engine.globalEvent.dispatchEvent('recycling-game-fail', {\n reason: 1\n });\n }\n }\n\n stop() {\n\n\n }\n\n\n createRects() { }\n\n setup() {\n console.log('onSteup', props);\n this.configUI();\n }\n\n onDown(e: engine.MouseEvent) {\n\n }\n\n stageOnUp(e) {\n\n\n }\n\n private onSuccess() {\n\n\n }\n\n onMove(e: engine.MouseEvent) {\n\n }\n\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('recycling-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('recycling-stop', this.stop, this);\n\n\t\t//创建实例\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\tthis._gameView.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t\tthis._gameView.stop();\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepare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rD;;CCjGD;KAAiCA,qCAAgB;KAGhD;SAAA,YACC,iBAAO,SASP;SAPA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACzE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGvE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CAxBgC,MAAM,CAAC,SAAS,GAwBhD;;;iBCzBwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
......@@ -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