Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
6c7611b1
Commit
6c7611b1
authored
Jun 16, 2020
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
5e341b08
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
134 additions
and
43 deletions
+134
-43
recycling.json
dist/customs/recycling.json
+14
-2
app.js
src/custom/recycling/debug/app.js
+8
-2
index.html
src/custom/recycling/debug/index.html
+23
-0
main.js
src/custom/recycling/debug/main.js
+35
-20
main.js.map
src/custom/recycling/debug/main.js.map
+1
-1
meta.json
src/custom/recycling/meta.json
+13
-1
Conveyors.ts
src/custom/recycling/src/game/Conveyors.ts
+2
-0
GameView.ts
src/custom/recycling/src/game/GameView.ts
+1
-1
GameWrapper.ts
src/custom/recycling/src/game/GameWrapper.ts
+6
-0
CountDownGroup.ts
src/custom/recycling/src/game/views/CountDownGroup.ts
+15
-15
RightTips.ts
src/custom/recycling/src/game/views/RightTips.ts
+5
-1
WrongTips.ts
src/custom/recycling/src/game/views/WrongTips.ts
+5
-0
guideView.ts
src/custom/recycling/src/game/views/guideView.ts
+6
-0
No files found.
dist/customs/recycling.json
View file @
6c7611b1
...
...
@@ -17,7 +17,7 @@
},
{
"name"
:
"playBg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
76b9491f50eaf51ae2becf9958d96a93770854ee
.jpg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
2a5b5087d915c2510f1b96facdb9532798ab59cd
.jpg"
,
"uuid"
:
"1e7dd156-b59a-491d-8154-af2ecf425a8b"
,
"ext"
:
".jpg"
},
...
...
@@ -386,6 +386,18 @@
"url"
:
"//yun.duiba.com.cn/aurora/assets/d2f1d01024247ea64cf35c610fec85f19dd89c21.png"
,
"uuid"
:
"g00"
,
"ext"
:
".png"
},
{
"name"
:
"rightTipsSound"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/dbf1ec24569c939bbf599475fd49110e51951584.mp3"
,
"uuid"
:
"d7aa31a9-24b9-4082-98f5-a071e1f81a5a"
,
"ext"
:
".mp3"
},
{
"name"
:
"numCountDown"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/b7a6e76838c82ef34ed6af0e13550633910e0aec.mp3"
,
"uuid"
:
"c8bae79c-6973-4021-adc1-45db51afe93e"
,
"ext"
:
".mp3"
}
],
"events"
:
{
...
...
@@ -430,5 +442,5 @@
}
},
"id"
:
"recycling"
,
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof 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\t
function getTexture(uuid) {
\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\n\t
}
\n\t
function getTextureByName(name) {
\n\t
return getTexture(engine.getAssetByName(name).uuid);
\n\t
}
\n\t
function
createSvga(name, anchorName) {
\n\t
var inst = new svga.Svga();
\n\t
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
\n\t
return inst;
\n\t
}
\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\t
//# sourceMappingURL=props.js.map
\n\n\t
var Conveyor = (function (_super) {
\n\t
tslib.__extends(Conveyor, _super);
\n\t
function Conveyor() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.y = 904.21;
\n\t
var sp = new engine.Sprite(getTextureByName('conveyor'));
\n\t
_this.addChild(sp);
\n\t
_this.idx0 = _this.createItem(75, 50);
\n\t
_this.idx1 = _this.createItem(225, 50);
\n\t
_this.idx2 = _this.createItem(375, 50);
\n\t
_this.idx3 = _this.createItem(525, 50);
\n\t
_this.idx4 = _this.createItem(675, 50);
\n\t
return _this;
\n\t
}
\n\t
Conveyor.prototype.clear = function () {
\n\t
this.clearItem(this.idx0);
\n\t
this.clearItem(this.idx1);
\n\t
this.clearItem(this.idx2);
\n\t
this.clearItem(this.idx3);
\n\t
this.clearItem(this.idx4);
\n\t
};
\n\t
Conveyor.prototype.clearItem = function (idx) {
\n\t
if (idx.children.length > 0)
\n\t
idx.removeChildAt(0);
\n\t
};
\n\t
Conveyor.prototype.createItem = function (x, y) {
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x;
\n\t
sp.y = y;
\n\t
return sp;
\n\t
};
\n\t
return Conveyor;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=Conveyor.js.map
\n\n\t
var GarbageTypes;
\n\t
(function (GarbageTypes) {
\n\t
GarbageTypes[
\"
recoverableWaste
\"
] =
\"
recoverableWaste
\"
;
\n\t
GarbageTypes[
\"
harmfulWaste
\"
] =
\"
harmfulWaste
\"
;
\n\t
GarbageTypes[
\"
wetWaste
\"
] =
\"
wetWaste
\"
;
\n\t
GarbageTypes[
\"
dryWaste
\"
] =
\"
dryWaste
\"
;
\n\t
})(GarbageTypes || (GarbageTypes = {}));
\n\t
//# sourceMappingURL=GarbageTypes.js.map
\n\n\t
var GarbageConfig = (function () {
\n\t
function GarbageConfig() {
\n\t
}
\n\t
GarbageConfig.config = [
\n\t
{ name:
\"
保鲜盒
\"
, source:
\"
g00
\"
, type: GarbageTypes.recoverableWaste, width: 129, height: 111 },
\n\t
{ name:
\"
报纸
\"
, source:
\"
g01
\"
, type: GarbageTypes.recoverableWaste, width: 138, height: 144 },
\n\t
{ name:
\"
贝壳
\"
, source:
\"
g02
\"
, type: GarbageTypes.dryWaste, width: 79, height: 117 },
\n\t
{ name:
\"
冰箱
\"
, source:
\"
g03
\"
, type: GarbageTypes.wetWaste, width: 63, height: 151 },
\n\t
{ name:
\"
菜梗菜叶
\"
, source:
\"
g04
\"
, type: GarbageTypes.wetWaste, width: 144, height: 98 },
\n\t
{ name:
\"
残枝落叶
\"
, source:
\"
g05
\"
, type: GarbageTypes.wetWaste, width: 120, height: 99 },
\n\t
{ name:
\"
茶叶渣
\"
, source:
\"
g06
\"
, type: GarbageTypes.wetWaste, width: 86, height: 96 },
\n\t
{ name:
\"
尘土
\"
, source:
\"
g07
\"
, type: GarbageTypes.dryWaste, width: 109, height: 114 },
\n\t
{ name:
\"
创可贴
\"
, source:
\"
g08
\"
, type: GarbageTypes.dryWaste, width: 112, height: 90 },
\n\t
{ name:
\"
大骨头
\"
, source:
\"
g09
\"
, type: GarbageTypes.dryWaste, width: 89, height: 101 },
\n\t
{ name:
\"
灯泡
\"
, source:
\"
g10
\"
, type: GarbageTypes.recoverableWaste, width: 84, height: 104 },
\n\t
{ name:
\"
电池
\"
, source:
\"
g11
\"
, type: GarbageTypes.dryWaste, width: 89, height: 131 },
\n\t
{ name:
\"
方便面盒
\"
, source:
\"
g12
\"
, type: GarbageTypes.dryWaste, width: 89, height: 168 },
\n\t
{ name:
\"
废弃食用油脂
\"
, source:
\"
g13
\"
, type: GarbageTypes.wetWaste, width: 131, height: 164 },
\n\t
{ name:
\"
骨骼内脏
\"
, source:
\"
g14
\"
, type: GarbageTypes.wetWaste, width: 104, height: 82 },
\n\t
{ name:
\"
锅具
\"
, source:
\"
g15
\"
, type: GarbageTypes.recoverableWaste, width: 119, height: 149 },
\n\t
{ name:
\"
果核
\"
, source:
\"
g16
\"
, type: GarbageTypes.wetWaste, width: 99, height: 95 },
\n\t
{ name:
\"
果皮
\"
, source:
\"
g17
\"
, type: GarbageTypes.wetWaste, width: 115, height: 127 },
\n\t
{ name:
\"
化妆品
\"
, source:
\"
g18
\"
, type: GarbageTypes.harmfulWaste, width: 67, height: 151 },
\n\t
{ name:
\"
鸡蛋壳
\"
, source:
\"
g19
\"
, type: GarbageTypes.wetWaste, width: 99, height: 107 },
\n\t
{ name:
\"
剪刀
\"
, source:
\"
g20
\"
, type: GarbageTypes.recoverableWaste, width: 96, height: 127 },
\n\t
{ name:
\"
胶带
\"
, source:
\"
g21
\"
, type: GarbageTypes.dryWaste, width: 87, height: 113 },
\n\t
{ name:
\"
榴莲壳
\"
, source:
\"
g22
\"
, type: GarbageTypes.dryWaste, width: 136, height: 116 },
\n\t
{ name:
\"
毛巾
\"
, source:
\"
g23
\"
, type: GarbageTypes.recoverableWaste, width: 108, height: 96 },
\n\t
{ name:
\"
纽扣电池
\"
, source:
\"
g24
\"
, type: GarbageTypes.harmfulWaste, width: 87, height: 89 },
\n\t
{ name:
\"
破旧陶瓷罐
\"
, source:
\"
g25
\"
, type: GarbageTypes.dryWaste, width: 110, height: 125 },
\n\t
{ name:
\"
杀虫剂
\"
, source:
\"
g26
\"
, type: GarbageTypes.harmfulWaste, width: 64, height: 160 },
\n\t
{ name:
\"
剩菜剩饭
\"
, source:
\"
g27
\"
, type: GarbageTypes.wetWaste, width: 128, height: 96 },
\n\t
{ name:
\"
手机
\"
, source:
\"
g28
\"
, type: GarbageTypes.recoverableWaste, width: 82, height: 142 },
\n\t
{ name:
\"
书本
\"
, source:
\"
g29
\"
, type: GarbageTypes.recoverableWaste, width: 106, height: 132 },
\n\t
{ name:
\"
水杯
\"
, source:
\"
g30
\"
, type: GarbageTypes.recoverableWaste, width: 62, height: 119 },
\n\t
{ name:
\"
水银温度计
\"
, source:
\"
g31
\"
, type: GarbageTypes.harmfulWaste, width: 109, height: 162 },
\n\t
{ name:
\"
水银血压计
\"
, source:
\"
g32
\"
, type: GarbageTypes.harmfulWaste, width: 115, height: 147 },
\n\t
{ name:
\"
塑料桶
\"
, source:
\"
g33
\"
, type: GarbageTypes.recoverableWaste, width: 92, height: 131 },
\n\t
{ name:
\"
卫生纸
\"
, source:
\"
g34
\"
, type: GarbageTypes.dryWaste, width: 92, height: 132 },
\n\t
{ name:
\"
污染织物
\"
, source:
\"
g35
\"
, type: GarbageTypes.dryWaste, width: 128, height: 139 },
\n\t
{ name:
\"
污染纸张
\"
, source:
\"
g36
\"
, type: GarbageTypes.dryWaste, width: 96, height: 136 },
\n\t
{ name:
\"
洗衣机
\"
, source:
\"
g37
\"
, type: GarbageTypes.recoverableWaste, width: 87, height: 157 },
\n\t
{ name:
\"
烟蒂
\"
, source:
\"
g38
\"
, type: GarbageTypes.dryWaste, width: 87, height: 124 },
\n\t
{ name:
\"
药品
\"
, source:
\"
g39
\"
, type: GarbageTypes.harmfulWaste, width: 109, height: 131 },
\n\t
{ name:
\"
药品包装
\"
, source:
\"
g40
\"
, type: GarbageTypes.harmfulWaste, width: 108, height: 125 },
\n\t
{ name:
\"
椰子壳
\"
, source:
\"
g41
\"
, type: GarbageTypes.dryWaste, width: 104, height: 119 },
\n\t
{ name:
\"
衣服
\"
, source:
\"
g42
\"
, type: GarbageTypes.recoverableWaste, width: 83, height: 137 },
\n\t
{ name:
\"
衣架
\"
, source:
\"
g43
\"
, type: GarbageTypes.recoverableWaste, width: 132, height: 125 },
\n\t
{ name:
\"
易拉罐
\"
, source:
\"
g44
\"
, type: GarbageTypes.recoverableWaste, width: 65, height: 133 },
\n\t
{ name:
\"
荧光灯
\"
, source:
\"
g45
\"
, type: GarbageTypes.harmfulWaste, width: 90, height: 118 },
\n\t
{ name:
\"
油漆桶
\"
, source:
\"
g46
\"
, type: GarbageTypes.harmfulWaste, width: 65, height: 143 },
\n\t
{ name:
\"
纸杯
\"
, source:
\"
g47
\"
, type: GarbageTypes.dryWaste, width: 76, height: 116 },
\n\t
{ name:
\"
纸尿裤
\"
, source:
\"
g48
\"
, type: GarbageTypes.dryWaste, width: 93, height: 138 },
\n\t
{ name:
\"
纸箱
\"
, source:
\"
g49
\"
, type: GarbageTypes.recoverableWaste, width: 112, height: 118 },
\n\t
{ name:
\"
指甲油
\"
, source:
\"
g50
\"
, type: GarbageTypes.harmfulWaste, width: 64, height: 138 },
\n\t
];
\n\t
return GarbageConfig;
\n\t
}());
\n\t
//# sourceMappingURL=GarbageConfig.js.map
\n\n\t
var transStores = (function (list) {
\n\t
var tmp = [];
\n\t
var contains = function (val) {
\n\t
for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {
\n\t
var i = tmp_1[_i];
\n\t
if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
};
\n\t
list.forEach(function (i) {
\n\t
if (!contains(i))
\n\t
tmp.push(i);
\n\t
});
\n\t
list = tmp;
\n\t
tmp = [];
\n\t
var nameList = [];
\n\t
var contains2 = function (val) {
\n\t
for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {
\n\t
var i = tmp_2[_i];
\n\t
if (val.itemName == i.itemName) {
\n\t
nameList.push(i.itemName);
\n\t
return true;
\n\t
}
\n\t
}
\n\t
return false;
\n\t
};
\n\t
list.forEach(function (i) {
\n\t
if (!contains2(i))
\n\t
tmp.push(i);
\n\t
});
\n\t
list = tmp;
\n\t
list.forEach(function (i) {
\n\t
if (nameList.indexOf(i.itemName) != -1) {
\n\t
i.targetType = i.itemType;
\n\t
}
\n\t
});
\n\t
return list.map(function (i) {
\n\t
return {
\n\t
'targetName': getTargetName(i.targetType),
\n\t
'isCorrect': i.targetType == i.itemType,
\n\t
'itemName': i.itemName
\n\t
};
\n\t
});
\n\t
});
\n\t
var getTargetName = function (type) {
\n\t
switch (type) {
\n\t
case GarbageTypes.recoverableWaste:
\n\t
return '可回收物';
\n\t
case GarbageTypes.harmfulWaste:
\n\t
return '有害垃圾';
\n\t
case GarbageTypes.wetWaste:
\n\t
return '湿垃圾';
\n\t
case GarbageTypes.dryWaste:
\n\t
return '其他垃圾';
\n\t
}
\n\t
};
\n\t
//# sourceMappingURL=transStores.js.map
\n\n\t
var checkHit = (function (view, rect) {
\n\t
var x = view.x, y = view.y;
\n\t
var _a = view.texture, width = _a.width, height = _a.height;
\n\t
if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
});
\n\t
//# sourceMappingURL=checkHit.js.map
\n\n\t
var removeChild = (function (d) {
\n\t
if (d && d.parent) {
\n\t
d.parent.removeChild(d);
\n\t
}
\n\t
});
\n\t
//# sourceMappingURL=removeChild.js.map
\n\n\t
var removeEle = (function (e, arr) {
\n\t
var index = arr.indexOf(e);
\n\t
if (index >= 0) {
\n\t
arr.splice(index, 1);
\n\t
}
\n\t
});
\n\t
//# sourceMappingURL=removeEle.js.map
\n\n\t
var shuffle = (function (arr) {
\n\t
var _a;
\n\t
var i = arr.length;
\n\t
while (i) {
\n\t
var j = Math.floor(Math.random() * i--);
\n\t
_a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];
\n\t
}
\n\t
return arr;
\n\t
});
\n\n\t
var WrongTips = (function (_super) {
\n\t
tslib.__extends(WrongTips, _super);
\n\t
function WrongTips() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.img = new engine.Image();
\n\t
_this.img.texture = getTextureByName('wrongTips');
\n\t
_this.addChild(_this.img);
\n\t
_this.img.anchorX = 88 / 2;
\n\t
_this.img.anchorY = 85 / 2;
\n\t
_this.visible = false;
\n\t
return _this;
\n\t
}
\n\t
WrongTips.prototype.play = function (rect) {
\n\t
this.visible = true;
\n\t
var dur = 70;
\n\t
var stren = 20;
\n\t
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 1, scaleY: 1, alpha: 1 })
\n\t
.to({ x: stren }, dur)
\n\t
.to({ x: 0 }, dur)
\n\t
.to({ x: -stren }, dur)
\n\t
.to({ x: 0 }, dur)
\n\t
.wait(200)
\n\t
.to({ alpha: 0 }, 300);
\n\t
this.x = rect.x + 180;
\n\t
this.y = rect.y;
\n\t
};
\n\t
return WrongTips;
\n\t
}(engine.Sprite));
\n\t
var getTargetRect = function (targetType, gameview) {
\n\t
switch (targetType) {
\n\t
case GarbageTypes.dryWaste:
\n\t
return gameview.dryWaste;
\n\t
case GarbageTypes.wetWaste:
\n\t
return gameview.wetWaste;
\n\t
case GarbageTypes.harmfulWaste:
\n\t
return gameview.harmfulWaste;
\n\t
case GarbageTypes.recoverableWaste:
\n\t
return gameview.recoverableWaste;
\n\t
}
\n\t
};
\n\t
//# sourceMappingURL=WrongTips.js.map
\n\n\t
var Conveyors = (function (_super) {
\n\t
tslib.__extends(Conveyors, _super);
\n\t
function Conveyors(p) {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.conveyorsPool = [];
\n\t
_this.GarbageConfig = GarbageConfig.config;
\n\t
_this.datas = [];
\n\t
_this.wrapper = p;
\n\t
return _this;
\n\t
}
\n\t
Conveyors.prototype.initData = function (conveyor0, conveyor1) {
\n\t
this.conveyor0 = conveyor0;
\n\t
this.conveyor1 = conveyor1;
\n\t
};
\n\t
Conveyors.prototype.setDefault = function () {
\n\t
this.score = 0;
\n\t
this.conveyorsPool.push(this.conveyor0);
\n\t
this.conveyorsPool.push(this.conveyor1);
\n\t
var allConfigs = shuffle(this.GarbageConfig.concat([]));
\n\t
for (var i = 0; i < GarbageConfig.config.length; i++) {
\n\t
allConfigs[i].idx = i;
\n\t
allConfigs[i].isRight = false;
\n\t
allConfigs[i].isMistake = false;
\n\t
allConfigs[i].isOnStage = false;
\n\t
this.datas.push(allConfigs[i]);
\n\t
}
\n\t
for (var i = 0; i < 5; i++) {
\n\t
var data = this.datas[i];
\n\t
var view = new engine.Sprite(getTextureByName(data.source));
\n\t
view.isWrong = false;
\n\t
view.isRight = false;
\n\t
data.isOnStage = true;
\n\t
view.type = data.type;
\n\t
view.name = data.name;
\n\t
view.anchorX = data.width / 2;
\n\t
view.anchorY = data.height;
\n\t
view.x = -data.width / 2;
\n\t
view.y = -data.height + 40;
\n\t
this.conveyor1[
\"
idx
\"
+ i].addChild(view);
\n\t
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.startConveyors = function () {
\n\t
this.setDefault();
\n\t
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {
\n\t
if (this.score == (props.maxScore || 100)) {
\n\t
this.gameOver();
\n\t
this.wrapper.stop();
\n\t
}
\n\t
this.conveyorsPool.forEach(function (conveyor) {
\n\t
conveyor.x -= props.speed || 3;
\n\t
});
\n\t
if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {
\n\t
var conveyor = new Conveyor();
\n\t
conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;
\n\t
this.wrapper.addChild(conveyor);
\n\t
this.conveyorsPool.push(conveyor);
\n\t
}
\n\t
else {
\n\t
var dataList = [];
\n\t
for (var n = 0; n < this.datas.length; n++) {
\n\t
var dataItem = this.datas[n];
\n\t
if (!dataItem.isRight && !dataItem.isOnStage) {
\n\t
dataList.push(dataItem);
\n\t
}
\n\t
}
\n\t
var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];
\n\t
for (var m = 0; m < 5; m++) {
\n\t
if (!lastConveyor[
\"
idx
\"
+ m].children[0]) {
\n\t
var data = dataList.shift();
\n\t
if (data) {
\n\t
data.isOnStage = true;
\n\t
var view = new engine.Sprite(getTextureByName(data.source));
\n\t
view.isWrong = false;
\n\t
view.isRight = false;
\n\t
view.type = data.type;
\n\t
view.name = data.name;
\n\t
view.anchorX = data.width / 2;
\n\t
view.anchorY = data.height;
\n\t
view.x = -data.width / 2;
\n\t
view.y = -data.height + 40;
\n\t
lastConveyor[
\"
idx
\"
+ m].addChild(view);
\n\t
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
\n\t
}
\n\t
else {
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
if (this.conveyorsPool[0].x < -750) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx4 = this.conveyorsPool[0][
\"
idx
\"
+ 4];
\n\t
if (idx4.children[0]) {
\n\t
if (dataItem.name == idx4.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx4.removeChild(idx4.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
this.conveyorsPool.shift();
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -600) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx3 = this.conveyorsPool[0][
\"
idx
\"
+ 3];
\n\t
if (idx3.children[0]) {
\n\t
if (dataItem.name == idx3.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx3.removeChild(idx3.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -450) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx2 = this.conveyorsPool[0][
\"
idx
\"
+ 2];
\n\t
if (idx2.children[0]) {
\n\t
if (dataItem.name == idx2.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx2.removeChild(idx2.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -300) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx1 = this.conveyorsPool[0][
\"
idx
\"
+ 1];
\n\t
if (idx1.children[0]) {
\n\t
if (dataItem.name == idx1.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx1.removeChild(idx1.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -150) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx0 = this.conveyorsPool[0][
\"
idx
\"
+ 0];
\n\t
if (idx0.children[0]) {
\n\t
if (dataItem.name == idx0.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx0.removeChild(idx0.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.addscore = function () {
\n\t
this.score += (props.onceScore || 2);
\n\t
engine.globalEvent.dispatchEvent('recycling-score-update', {
\n\t
score: this.score
\n\t
});
\n\t
};
\n\t
Conveyors.prototype.gameOver = function () {
\n\t
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));
\n\t
};
\n\t
Conveyors.prototype.onDown_garbage = function (e) {
\n\t
if (this._currentDragView) {
\n\t
removeChild(this._currentDragView);
\n\t
}
\n\t
var target = e.target;
\n\t
var view = new engine.Sprite(target.texture);
\n\t
this._currentDragView = view;
\n\t
this._currentTarget = target;
\n\t
target.scaleX = target.scaleY = 0;
\n\t
this.wrapper.addChild(view);
\n\t
view.x = e.stageX - target.texture.width / 2;
\n\t
view.y = e.stageY - target.texture.height / 2;
\n\t
view.type = target['type'];
\n\t
view.name = target['name'];
\n\t
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
};
\n\t
Conveyors.prototype.onStageMouseMove = function (e) {
\n\t
var view = this._currentDragView;
\n\t
view.x = e.stageX - view.texture.width / 2;
\n\t
view.y = e.stageY - view.texture.height / 2;
\n\t
};
\n\t
Conveyors.prototype.onStageMouseUp = function (e) {
\n\t
var _this = this;
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
if (!this._currentDragView)
\n\t
return;
\n\t
var result = this.checkHitRect();
\n\t
if (result) {
\n\t
if (result == this._currentDragView['type']) {
\n\t
this.addscore();
\n\t
this.wrapper.rightTips.play(getTargetRect(result, this.wrapper));
\n\t
}
\n\t
else {
\n\t
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
\n\t
this.wrapper.wrongTips.play(getTargetRect(result, this.wrapper));
\n\t
}
\n\t
this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });
\n\t
}
\n\t
else {
\n\t
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
\n\t
}
\n\t
this._currentDragView.anchorX = this._currentDragView.texture.width / 2;
\n\t
this._currentDragView.anchorY = this._currentDragView.texture.height / 2;
\n\t
engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
\n\t
removeChild(_this._currentDragView);
\n\t
});
\n\t
};
\n\t
Conveyors.prototype.clear = function () {
\n\t
this.conveyor0.x = 0;
\n\t
this.conveyor1.x = 764;
\n\t
this.conveyorsPool.forEach(function (i) {
\n\t
i.clear();
\n\t
});
\n\t
this.conveyorsPool = [];
\n\t
this.datas = [];
\n\t
this.stores = [];
\n\t
};
\n\t
Conveyors.prototype.timeout = function () {
\n\t
if (this._currentDragView) {
\n\t
removeChild(this._currentDragView);
\n\t
}
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
this.gameOver();
\n\t
};
\n\t
Conveyors.prototype.checkHitRect = function () {
\n\t
if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {
\n\t
return GarbageTypes.wetWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {
\n\t
return GarbageTypes.harmfulWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {
\n\t
return GarbageTypes.dryWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {
\n\t
return GarbageTypes.recoverableWaste;
\n\t
}
\n\t
return null;
\n\t
};
\n\t
return Conveyors;
\n\t
}(engine.Sprite));
\n\n\t
var 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\t
var getGuideInfo = (function () {
\n\t
if (!window.localStorage) {
\n\t
return 0;
\n\t
}
\n\t
return localStorage.getItem('recyclingGuide');
\n\t
});
\n\t
var setGuide = function () {
\n\t
if (window.localStorage)
\n\t
localStorage.setItem('recyclingGuide', '1');
\n\t
};
\n\t
//# sourceMappingURL=getGuideInfo.js.map
\n\n\t
var createBg = (function (a) {
\n\t
if (a === void 0) { a = 1; }
\n\t
var rect = new engine.Graphics();
\n\t
rect.beginFill(0);
\n\t
rect.drawRect(0, 0, 750, 1624);
\n\t
rect.endFill();
\n\t
rect.alpha = a;
\n\t
return rect;
\n\t
});
\n\t
//# sourceMappingURL=createBg.js.map
\n\n\t
var createImg = (function (texture) {
\n\t
return new engine.Sprite(getTextureByName(texture));
\n\t
});
\n\t
//# sourceMappingURL=createImg.js.map
\n\n\t
var CountDownGroup = (function (_super) {
\n\t
tslib.__extends(CountDownGroup, _super);
\n\t
function CountDownGroup() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.addChild(createBg(.6));
\n\t
_this.num1 = createImg('num1');
\n\t
_this.num2 = createImg('num2');
\n\t
_this.num3 = createImg('num3');
\n\t
_this.go = createImg('go');
\n\t
_this.go.anchorX = 240;
\n\t
_this.go.anchorY = 171.5;
\n\t
_this.num1.anchorX = 125.5;
\n\t
_this.num1.anchorY = 189;
\n\t
_this.num2.anchorX = 149.5;
\n\t
_this.num2.anchorY = 191.5;
\n\t
_this.num3.anchorX = 148.5;
\n\t
_this.num3.anchorY = 191.5;
\n\t
_this.go.x = 750 / 2 - 240;
\n\t
_this.go.y = 525 - 171.5;
\n\t
_this.num1.x = 750 / 2 - 125.5;
\n\t
_this.num1.y = 529 - 189;
\n\t
_this.num2.x = 750 / 2 - 149.5;
\n\t
_this.num2.y = 526 - 191.5;
\n\t
_this.num3.x = 750 / 2 - 148.5;
\n\t
_this.num3.y = 525 - 191.5;
\n\t
_this.addChild(_this.num1);
\n\t
_this.addChild(_this.num2);
\n\t
_this.addChild(_this.num3);
\n\t
_this.addChild(_this.go);
\n\t
_this.visible = false;
\n\t
_this.reset();
\n\t
return _this;
\n\t
}
\n\t
CountDownGroup.prototype.reset = function () {
\n\t
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;
\n\t
this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
\n\t
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
\n\t
};
\n\t
CountDownGroup.prototype.startCountDown = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.reset();
\n\t
_this.visible = true;
\n\t
_this.num3.alpha = 1;
\n\t
var n3 = engine.Tween.get(_this.num3);
\n\t
n3.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num2.alpha = 1;
\n\t
var n2 = engine.Tween.get(_this.num2);
\n\t
n2.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num1.alpha = 1;
\n\t
var n1 = engine.Tween.get(_this.num1);
\n\t
n1.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.go.alpha = 1;
\n\t
var go = engine.Tween.get(_this.go);
\n\t
go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
});
\n\t
});
\n\t
});
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return CountDownGroup;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=CountDownGroup.js.map
\n\n\t
var GuideView = (function (_super) {
\n\t
tslib.__extends(GuideView, _super);
\n\t
function GuideView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.initUI();
\n\t
_this.visible = false;
\n\t
return _this;
\n\t
}
\n\t
GuideView.prototype.initUI = function () {
\n\t
this.addChild(createBg(.6));
\n\t
this.guideBg = createImg('guideBg');
\n\t
this.addChild(this.guideBg);
\n\t
this.guideEle = createImg('guideEle');
\n\t
this.addChild(this.guideEle);
\n\t
this.guideBg.x = 393;
\n\t
this.guideBg.y = 552;
\n\t
this.guideEle.x = 361;
\n\t
this.guideEle.y = 877;
\n\t
this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;
\n\t
var svga = createSvga(
\"
guideTips
\"
);
\n\t
this.svga = svga;
\n\t
this.addChild(svga);
\n\t
svga.gotoAndStop(1);
\n\t
svga.mouseEnabled = svga.mouseChildren = false;
\n\t
};
\n\t
GuideView.prototype.checkHit = function (x, y, w, h) {
\n\t
var rect = new engine.Rectangle(393, 552, 281, 320);
\n\t
if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
};
\n\t
GuideView.prototype.startGuide = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.visible = true;
\n\t
_this.svga.gotoAndStop(1);
\n\t
_this.svga.play(false, true);
\n\t
_this.guideEle.scaleX = 1;
\n\t
_this.guideEle.scaleY = 1;
\n\t
var offset = [0, 0];
\n\t
var guideOver = function () {
\n\t
_this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
};
\n\t
var onUp = function (e) {
\n\t
_this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {
\n\t
guideOver();
\n\t
}
\n\t
else {
\n\t
_this.svga.visible = true;
\n\t
_this.guideEle.x = 361;
\n\t
_this.guideEle.y = 877;
\n\t
}
\n\t
};
\n\t
var onMove = function (e) {
\n\t
_this.guideEle.x = e.stageX - offset[0];
\n\t
_this.guideEle.y = e.stageY - offset[1];
\n\t
};
\n\t
var ondown = function (e) {
\n\t
offset = [e.localX, e.localY];
\n\t
_this.svga.visible = false;
\n\t
_this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);
\n\t
_this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
};
\n\t
_this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return GuideView;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=guideView.js.map
\n\n\t
var RightTips = (function (_super) {
\n\t
tslib.__extends(RightTips, _super);
\n\t
function RightTips() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.SCORE = props.onceScore || 2;
\n\t
_this.img = new engine.Image();
\n\t
_this.img.texture = getTextureByName('rightTips');
\n\t
_this.addChild(_this.img);
\n\t
_this.img.anchorX = 88 / 2;
\n\t
_this.img.anchorY = 85 / 2;
\n\t
_this.visible = false;
\n\t
_this.txt = new engine.TextField();
\n\t
_this.addChild(_this.txt);
\n\t
_this.txt.text = '+' + _this.SCORE;
\n\t
_this.txt.size = 60;
\n\t
_this.txt.fillColor = '#437726';
\n\t
engine.playSound;
\n\t
return _this;
\n\t
}
\n\t
RightTips.prototype.play = function (rect) {
\n\t
this.visible = true;
\n\t
this.txt.x = 100;
\n\t
engine.Tween.get(this.txt).set({ y: 60, alpha: 1 })
\n\t
.to({ y: -50 }, 500)
\n\t
.to({ alpha: 0 });
\n\t
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 0, scaleY: 0, alpha: 1 })
\n\t
.to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(1))
\n\t
.wait(200)
\n\t
.to({ alpha: 0 }, 300);
\n\t
this.x = rect.x + 180;
\n\t
this.y = rect.y;
\n\t
};
\n\t
return RightTips;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=RightTips.js.map
\n\n\t
var 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 uiMap = {};
\n\t
this.uiMap = uiMap;
\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
uiMap[id] = 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
this.configConveyors();
\n\t
this.createRects();
\n\t
this.countdown = new CountDownGroup();
\n\t
this.addChild(this.countdown);
\n\t
this.guide = new GuideView();
\n\t
this.addChild(this.guide);
\n\t
this.wrongTips = new WrongTips();
\n\t
this.rightTips = new RightTips();
\n\t
this.addChild(this.wrongTips);
\n\t
this.addChild(this.rightTips);
\n\t
};
\n\t
GameView.prototype.createRects = function () {
\n\t
this.wetWaste = this.createRect(74, 552, 301, 293, 0xffffff);
\n\t
this.harmfulWaste = this.createRect(75, 247, 300, 293, 0xff0000);
\n\t
this.dryWaste = this.createRect(389, 249, 286, 291, 0x000000);
\n\t
this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);
\n\t
};
\n\t
GameView.prototype.createRect = function (x, y, w, h, c) {
\n\t
var rect = new engine.Rectangle(x, y, w, h);
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x;
\n\t
sp.y = y;
\n\t
var g = new engine.Graphics;
\n\t
g.alpha = 0.0;
\n\t
g.beginFill(c);
\n\t
g.drawRect(0, 0, w, h);
\n\t
g.endFill();
\n\t
sp.addChild(g);
\n\t
return rect;
\n\t
};
\n\t
GameView.prototype.configConveyors = function () {
\n\t
var conveyor0 = new Conveyor();
\n\t
var conveyor1 = new Conveyor();
\n\t
this.addChild(conveyor0);
\n\t
this.addChild(conveyor1);
\n\t
conveyor0.x = 0;
\n\t
conveyor1.x = 764;
\n\t
this.conveyors = new Conveyors(this);
\n\t
this.conveyors.initData(conveyor0, conveyor1);
\n\t
};
\n\t
GameView.prototype.playAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);
\n\t
});
\n\t
};
\n\t
GameView.prototype.stopAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.removeTweens(i);
\n\t
});
\n\t
};
\n\t
GameView.prototype.start = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
console.log('on start');
\n\t
this._timeCounter = 0;
\n\t
if (!!getGuideInfo()) return [3, 2];
\n\t
return [4, this.guide.startGuide()];
\n\t
case 1:
\n\t
_a.sent();
\n\t
setGuide();
\n\t
_a.label = 2;
\n\t
case 2:
\n\t
this.conveyors.clear();
\n\t
return [4, this.countdown.startCountDown()];
\n\t
case 3:
\n\t
_a.sent();
\n\t
this.startGame();
\n\t
engine.globalEvent.dispatchEvent('recycling-time-update', {
\n\t
second: this.getSecond(),
\n\t
});
\n\t
this._timer = setInterval(function () {
\n\t
_this.onTimer();
\n\t
}, 1000);
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.startGame = function () {
\n\t
this.playAni();
\n\t
this.conveyors.startConveyors();
\n\t
};
\n\t
GameView.prototype.stopGame = function () {
\n\t
this.stopAni();
\n\t
};
\n\t
GameView.prototype.getSecond = function () {
\n\t
return props.time - this._timeCounter;
\n\t
};
\n\t
GameView.prototype.onTimer = function () {
\n\t
this._timeCounter++;
\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
this.conveyors.timeout();
\n\t
}
\n\t
};
\n\t
GameView.prototype.stop = function () {
\n\t
clearInterval(this._timer);
\n\t
this.stopGame();
\n\t
};
\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\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var 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\t
function 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\t
return index;
\n\n
})));
\n
"
"code"
:
"(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof 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\t
function getTexture(uuid) {
\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\n\t
}
\n\t
function getTextureByName(name) {
\n\t
return getTexture(engine.getAssetByName(name).uuid);
\n\t
}
\n\t
function
playSound(name) {
\n\t
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
\n\t
}
\n\t
function createSvga(name, anchorName) {
\n\t
var inst = new svga.Svga();
\n\t
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
\n\t
return inst;
\n\t
}
\n\n\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\n\t
var Conveyor = (function (_super) {
\n\t
tslib.__extends(Conveyor, _super);
\n\t
function Conveyor() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.y = 904.21;
\n\t
var sp = new engine.Sprite(getTextureByName('conveyor'));
\n\t
_this.addChild(sp);
\n\t
_this.idx0 = _this.createItem(75, 50);
\n\t
_this.idx1 = _this.createItem(225, 50);
\n\t
_this.idx2 = _this.createItem(375, 50);
\n\t
_this.idx3 = _this.createItem(525, 50);
\n\t
_this.idx4 = _this.createItem(675, 50);
\n\t
return _this;
\n\t
}
\n\t
Conveyor.prototype.clear = function () {
\n\t
this.clearItem(this.idx0);
\n\t
this.clearItem(this.idx1);
\n\t
this.clearItem(this.idx2);
\n\t
this.clearItem(this.idx3);
\n\t
this.clearItem(this.idx4);
\n\t
};
\n\t
Conveyor.prototype.clearItem = function (idx) {
\n\t
if (idx.children.length > 0)
\n\t
idx.removeChildAt(0);
\n\t
};
\n\t
Conveyor.prototype.createItem = function (x, y) {
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x;
\n\t
sp.y = y;
\n\t
return sp;
\n\t
};
\n\t
return Conveyor;
\n\t
}(engine.Sprite));
\n\n\t
var GarbageTypes;
\n\t
(function (GarbageTypes) {
\n\t
GarbageTypes[
\"
recoverableWaste
\"
] =
\"
recoverableWaste
\"
;
\n\t
GarbageTypes[
\"
harmfulWaste
\"
] =
\"
harmfulWaste
\"
;
\n\t
GarbageTypes[
\"
wetWaste
\"
] =
\"
wetWaste
\"
;
\n\t
GarbageTypes[
\"
dryWaste
\"
] =
\"
dryWaste
\"
;
\n\t
})(GarbageTypes || (GarbageTypes = {}));
\n\n\t
var GarbageConfig = (function () {
\n\t
function GarbageConfig() {
\n\t
}
\n\t
GarbageConfig.config = [
\n\t
{ name:
\"
保鲜盒
\"
, source:
\"
g00
\"
, type: GarbageTypes.recoverableWaste, width: 129, height: 111 },
\n\t
{ name:
\"
报纸
\"
, source:
\"
g01
\"
, type: GarbageTypes.recoverableWaste, width: 138, height: 144 },
\n\t
{ name:
\"
贝壳
\"
, source:
\"
g02
\"
, type: GarbageTypes.dryWaste, width: 79, height: 117 },
\n\t
{ name:
\"
冰箱
\"
, source:
\"
g03
\"
, type: GarbageTypes.wetWaste, width: 63, height: 151 },
\n\t
{ name:
\"
菜梗菜叶
\"
, source:
\"
g04
\"
, type: GarbageTypes.wetWaste, width: 144, height: 98 },
\n\t
{ name:
\"
残枝落叶
\"
, source:
\"
g05
\"
, type: GarbageTypes.wetWaste, width: 120, height: 99 },
\n\t
{ name:
\"
茶叶渣
\"
, source:
\"
g06
\"
, type: GarbageTypes.wetWaste, width: 86, height: 96 },
\n\t
{ name:
\"
尘土
\"
, source:
\"
g07
\"
, type: GarbageTypes.dryWaste, width: 109, height: 114 },
\n\t
{ name:
\"
创可贴
\"
, source:
\"
g08
\"
, type: GarbageTypes.dryWaste, width: 112, height: 90 },
\n\t
{ name:
\"
大骨头
\"
, source:
\"
g09
\"
, type: GarbageTypes.dryWaste, width: 89, height: 101 },
\n\t
{ name:
\"
灯泡
\"
, source:
\"
g10
\"
, type: GarbageTypes.recoverableWaste, width: 84, height: 104 },
\n\t
{ name:
\"
电池
\"
, source:
\"
g11
\"
, type: GarbageTypes.dryWaste, width: 89, height: 131 },
\n\t
{ name:
\"
方便面盒
\"
, source:
\"
g12
\"
, type: GarbageTypes.dryWaste, width: 89, height: 168 },
\n\t
{ name:
\"
废弃食用油脂
\"
, source:
\"
g13
\"
, type: GarbageTypes.wetWaste, width: 131, height: 164 },
\n\t
{ name:
\"
骨骼内脏
\"
, source:
\"
g14
\"
, type: GarbageTypes.wetWaste, width: 104, height: 82 },
\n\t
{ name:
\"
锅具
\"
, source:
\"
g15
\"
, type: GarbageTypes.recoverableWaste, width: 119, height: 149 },
\n\t
{ name:
\"
果核
\"
, source:
\"
g16
\"
, type: GarbageTypes.wetWaste, width: 99, height: 95 },
\n\t
{ name:
\"
果皮
\"
, source:
\"
g17
\"
, type: GarbageTypes.wetWaste, width: 115, height: 127 },
\n\t
{ name:
\"
化妆品
\"
, source:
\"
g18
\"
, type: GarbageTypes.harmfulWaste, width: 67, height: 151 },
\n\t
{ name:
\"
鸡蛋壳
\"
, source:
\"
g19
\"
, type: GarbageTypes.wetWaste, width: 99, height: 107 },
\n\t
{ name:
\"
剪刀
\"
, source:
\"
g20
\"
, type: GarbageTypes.recoverableWaste, width: 96, height: 127 },
\n\t
{ name:
\"
胶带
\"
, source:
\"
g21
\"
, type: GarbageTypes.dryWaste, width: 87, height: 113 },
\n\t
{ name:
\"
榴莲壳
\"
, source:
\"
g22
\"
, type: GarbageTypes.dryWaste, width: 136, height: 116 },
\n\t
{ name:
\"
毛巾
\"
, source:
\"
g23
\"
, type: GarbageTypes.recoverableWaste, width: 108, height: 96 },
\n\t
{ name:
\"
纽扣电池
\"
, source:
\"
g24
\"
, type: GarbageTypes.harmfulWaste, width: 87, height: 89 },
\n\t
{ name:
\"
破旧陶瓷罐
\"
, source:
\"
g25
\"
, type: GarbageTypes.dryWaste, width: 110, height: 125 },
\n\t
{ name:
\"
杀虫剂
\"
, source:
\"
g26
\"
, type: GarbageTypes.harmfulWaste, width: 64, height: 160 },
\n\t
{ name:
\"
剩菜剩饭
\"
, source:
\"
g27
\"
, type: GarbageTypes.wetWaste, width: 128, height: 96 },
\n\t
{ name:
\"
手机
\"
, source:
\"
g28
\"
, type: GarbageTypes.recoverableWaste, width: 82, height: 142 },
\n\t
{ name:
\"
书本
\"
, source:
\"
g29
\"
, type: GarbageTypes.recoverableWaste, width: 106, height: 132 },
\n\t
{ name:
\"
水杯
\"
, source:
\"
g30
\"
, type: GarbageTypes.recoverableWaste, width: 62, height: 119 },
\n\t
{ name:
\"
水银温度计
\"
, source:
\"
g31
\"
, type: GarbageTypes.harmfulWaste, width: 109, height: 162 },
\n\t
{ name:
\"
水银血压计
\"
, source:
\"
g32
\"
, type: GarbageTypes.harmfulWaste, width: 115, height: 147 },
\n\t
{ name:
\"
塑料桶
\"
, source:
\"
g33
\"
, type: GarbageTypes.recoverableWaste, width: 92, height: 131 },
\n\t
{ name:
\"
卫生纸
\"
, source:
\"
g34
\"
, type: GarbageTypes.dryWaste, width: 92, height: 132 },
\n\t
{ name:
\"
污染织物
\"
, source:
\"
g35
\"
, type: GarbageTypes.dryWaste, width: 128, height: 139 },
\n\t
{ name:
\"
污染纸张
\"
, source:
\"
g36
\"
, type: GarbageTypes.dryWaste, width: 96, height: 136 },
\n\t
{ name:
\"
洗衣机
\"
, source:
\"
g37
\"
, type: GarbageTypes.recoverableWaste, width: 87, height: 157 },
\n\t
{ name:
\"
烟蒂
\"
, source:
\"
g38
\"
, type: GarbageTypes.dryWaste, width: 87, height: 124 },
\n\t
{ name:
\"
药品
\"
, source:
\"
g39
\"
, type: GarbageTypes.harmfulWaste, width: 109, height: 131 },
\n\t
{ name:
\"
药品包装
\"
, source:
\"
g40
\"
, type: GarbageTypes.harmfulWaste, width: 108, height: 125 },
\n\t
{ name:
\"
椰子壳
\"
, source:
\"
g41
\"
, type: GarbageTypes.dryWaste, width: 104, height: 119 },
\n\t
{ name:
\"
衣服
\"
, source:
\"
g42
\"
, type: GarbageTypes.recoverableWaste, width: 83, height: 137 },
\n\t
{ name:
\"
衣架
\"
, source:
\"
g43
\"
, type: GarbageTypes.recoverableWaste, width: 132, height: 125 },
\n\t
{ name:
\"
易拉罐
\"
, source:
\"
g44
\"
, type: GarbageTypes.recoverableWaste, width: 65, height: 133 },
\n\t
{ name:
\"
荧光灯
\"
, source:
\"
g45
\"
, type: GarbageTypes.harmfulWaste, width: 90, height: 118 },
\n\t
{ name:
\"
油漆桶
\"
, source:
\"
g46
\"
, type: GarbageTypes.harmfulWaste, width: 65, height: 143 },
\n\t
{ name:
\"
纸杯
\"
, source:
\"
g47
\"
, type: GarbageTypes.dryWaste, width: 76, height: 116 },
\n\t
{ name:
\"
纸尿裤
\"
, source:
\"
g48
\"
, type: GarbageTypes.dryWaste, width: 93, height: 138 },
\n\t
{ name:
\"
纸箱
\"
, source:
\"
g49
\"
, type: GarbageTypes.recoverableWaste, width: 112, height: 118 },
\n\t
{ name:
\"
指甲油
\"
, source:
\"
g50
\"
, type: GarbageTypes.harmfulWaste, width: 64, height: 138 },
\n\t
];
\n\t
return GarbageConfig;
\n\t
}());
\n\n\t
var transStores = (function (list) {
\n\t
var tmp = [];
\n\t
var contains = function (val) {
\n\t
for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {
\n\t
var i = tmp_1[_i];
\n\t
if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
};
\n\t
list.forEach(function (i) {
\n\t
if (!contains(i))
\n\t
tmp.push(i);
\n\t
});
\n\t
list = tmp;
\n\t
tmp = [];
\n\t
var nameList = [];
\n\t
var contains2 = function (val) {
\n\t
for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {
\n\t
var i = tmp_2[_i];
\n\t
if (val.itemName == i.itemName) {
\n\t
nameList.push(i.itemName);
\n\t
return true;
\n\t
}
\n\t
}
\n\t
return false;
\n\t
};
\n\t
list.forEach(function (i) {
\n\t
if (!contains2(i))
\n\t
tmp.push(i);
\n\t
});
\n\t
list = tmp;
\n\t
list.forEach(function (i) {
\n\t
if (nameList.indexOf(i.itemName) != -1) {
\n\t
i.targetType = i.itemType;
\n\t
}
\n\t
});
\n\t
return list.map(function (i) {
\n\t
return {
\n\t
'targetName': getTargetName(i.targetType),
\n\t
'isCorrect': i.targetType == i.itemType,
\n\t
'itemName': i.itemName
\n\t
};
\n\t
});
\n\t
});
\n\t
var getTargetName = function (type) {
\n\t
switch (type) {
\n\t
case GarbageTypes.recoverableWaste:
\n\t
return '可回收物';
\n\t
case GarbageTypes.harmfulWaste:
\n\t
return '有害垃圾';
\n\t
case GarbageTypes.wetWaste:
\n\t
return '湿垃圾';
\n\t
case GarbageTypes.dryWaste:
\n\t
return '其他垃圾';
\n\t
}
\n\t
};
\n\n\t
var checkHit = (function (view, rect) {
\n\t
var x = view.x, y = view.y;
\n\t
var _a = view.texture, width = _a.width, height = _a.height;
\n\t
if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
});
\n\n\t
var removeChild = (function (d) {
\n\t
if (d && d.parent) {
\n\t
d.parent.removeChild(d);
\n\t
}
\n\t
});
\n\n\t
var removeEle = (function (e, arr) {
\n\t
var index = arr.indexOf(e);
\n\t
if (index >= 0) {
\n\t
arr.splice(index, 1);
\n\t
}
\n\t
});
\n\n\t
var shuffle = (function (arr) {
\n\t
var _a;
\n\t
var i = arr.length;
\n\t
while (i) {
\n\t
var j = Math.floor(Math.random() * i--);
\n\t
_a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];
\n\t
}
\n\t
return arr;
\n\t
});
\n\n\t
var WrongTips = (function (_super) {
\n\t
tslib.__extends(WrongTips, _super);
\n\t
function WrongTips() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.img = new engine.Image();
\n\t
_this.img.texture = getTextureByName('wrongTips');
\n\t
_this.addChild(_this.img);
\n\t
_this.img.anchorX = 88 / 2;
\n\t
_this.img.anchorY = 85 / 2;
\n\t
_this.visible = false;
\n\t
return _this;
\n\t
}
\n\t
WrongTips.prototype.play = function (rect) {
\n\t
this.visible = true;
\n\t
if (props.sound) {
\n\t
window[
\"
playMusic
\"
](
\"
wrongTips
\"
);
\n\t
}
\n\t
var dur = 70;
\n\t
var stren = 20;
\n\t
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 1, scaleY: 1, alpha: 1 })
\n\t
.to({ x: stren }, dur)
\n\t
.to({ x: 0 }, dur)
\n\t
.to({ x: -stren }, dur)
\n\t
.to({ x: 0 }, dur)
\n\t
.wait(200)
\n\t
.to({ alpha: 0 }, 300);
\n\t
this.x = rect.x + 180;
\n\t
this.y = rect.y;
\n\t
};
\n\t
return WrongTips;
\n\t
}(engine.Sprite));
\n\t
var getTargetRect = function (targetType, gameview) {
\n\t
switch (targetType) {
\n\t
case GarbageTypes.dryWaste:
\n\t
return gameview.dryWaste;
\n\t
case GarbageTypes.wetWaste:
\n\t
return gameview.wetWaste;
\n\t
case GarbageTypes.harmfulWaste:
\n\t
return gameview.harmfulWaste;
\n\t
case GarbageTypes.recoverableWaste:
\n\t
return gameview.recoverableWaste;
\n\t
}
\n\t
};
\n\n\t
var Conveyors = (function (_super) {
\n\t
tslib.__extends(Conveyors, _super);
\n\t
function Conveyors(p) {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.conveyorsPool = [];
\n\t
_this.GarbageConfig = GarbageConfig.config;
\n\t
_this.datas = [];
\n\t
_this.wrapper = p;
\n\t
return _this;
\n\t
}
\n\t
Conveyors.prototype.initData = function (conveyor0, conveyor1) {
\n\t
this.conveyor0 = conveyor0;
\n\t
this.conveyor1 = conveyor1;
\n\t
};
\n\t
Conveyors.prototype.setDefault = function () {
\n\t
this.score = 0;
\n\t
this.conveyorsPool.push(this.conveyor0);
\n\t
this.conveyorsPool.push(this.conveyor1);
\n\t
var allConfigs = shuffle(this.GarbageConfig.concat([]));
\n\t
for (var i = 0; i < GarbageConfig.config.length; i++) {
\n\t
allConfigs[i].idx = i;
\n\t
allConfigs[i].isRight = false;
\n\t
allConfigs[i].isMistake = false;
\n\t
allConfigs[i].isOnStage = false;
\n\t
this.datas.push(allConfigs[i]);
\n\t
}
\n\t
for (var i = 0; i < 5; i++) {
\n\t
var data = this.datas[i];
\n\t
var view = new engine.Sprite(getTextureByName(data.source));
\n\t
view.isWrong = false;
\n\t
view.isRight = false;
\n\t
data.isOnStage = true;
\n\t
view.type = data.type;
\n\t
view.name = data.name;
\n\t
view.anchorX = data.width / 2;
\n\t
view.anchorY = data.height;
\n\t
view.x = -data.width / 2;
\n\t
view.y = -data.height + 40;
\n\t
this.conveyor1[
\"
idx
\"
+ i].addChild(view);
\n\t
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.startConveyors = function () {
\n\t
this.setDefault();
\n\t
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {
\n\t
if (this.score == (props.maxScore || 100)) {
\n\t
this.gameOver();
\n\t
this.wrapper.stop();
\n\t
if (props.sound)
\n\t
window['playMusic'](
\"
gameOver
\"
);
\n\t
}
\n\t
this.conveyorsPool.forEach(function (conveyor) {
\n\t
conveyor.x -= props.speed || 3;
\n\t
});
\n\t
if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {
\n\t
var conveyor = new Conveyor();
\n\t
conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;
\n\t
this.wrapper.addChild(conveyor);
\n\t
this.conveyorsPool.push(conveyor);
\n\t
}
\n\t
else {
\n\t
var dataList = [];
\n\t
for (var n = 0; n < this.datas.length; n++) {
\n\t
var dataItem = this.datas[n];
\n\t
if (!dataItem.isRight && !dataItem.isOnStage) {
\n\t
dataList.push(dataItem);
\n\t
}
\n\t
}
\n\t
var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];
\n\t
for (var m = 0; m < 5; m++) {
\n\t
if (!lastConveyor[
\"
idx
\"
+ m].children[0]) {
\n\t
var data = dataList.shift();
\n\t
if (data) {
\n\t
data.isOnStage = true;
\n\t
var view = new engine.Sprite(getTextureByName(data.source));
\n\t
view.isWrong = false;
\n\t
view.isRight = false;
\n\t
view.type = data.type;
\n\t
view.name = data.name;
\n\t
view.anchorX = data.width / 2;
\n\t
view.anchorY = data.height;
\n\t
view.x = -data.width / 2;
\n\t
view.y = -data.height + 40;
\n\t
lastConveyor[
\"
idx
\"
+ m].addChild(view);
\n\t
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
\n\t
}
\n\t
else {
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
if (this.conveyorsPool[0].x < -750) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx4 = this.conveyorsPool[0][
\"
idx
\"
+ 4];
\n\t
if (idx4.children[0]) {
\n\t
if (dataItem.name == idx4.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx4.removeChild(idx4.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
this.conveyorsPool.shift();
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -600) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx3 = this.conveyorsPool[0][
\"
idx
\"
+ 3];
\n\t
if (idx3.children[0]) {
\n\t
if (dataItem.name == idx3.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx3.removeChild(idx3.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -450) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx2 = this.conveyorsPool[0][
\"
idx
\"
+ 2];
\n\t
if (idx2.children[0]) {
\n\t
if (dataItem.name == idx2.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx2.removeChild(idx2.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -300) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx1 = this.conveyorsPool[0][
\"
idx
\"
+ 1];
\n\t
if (idx1.children[0]) {
\n\t
if (dataItem.name == idx1.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx1.removeChild(idx1.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -150) {
\n\t
for (var k = 0; k < this.datas.length; k++) {
\n\t
var dataItem = this.datas[k];
\n\t
var idx0 = this.conveyorsPool[0][
\"
idx
\"
+ 0];
\n\t
if (idx0.children[0]) {
\n\t
if (dataItem.name == idx0.children[0].name) {
\n\t
dataItem.isOnStage = false;
\n\t
removeEle(dataItem, this.datas);
\n\t
this.datas.push(dataItem);
\n\t
idx0.removeChild(idx0.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.addscore = function () {
\n\t
this.score += (props.onceScore || 2);
\n\t
engine.globalEvent.dispatchEvent('recycling-score-update', {
\n\t
score: this.score
\n\t
});
\n\t
};
\n\t
Conveyors.prototype.gameOver = function () {
\n\t
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));
\n\t
};
\n\t
Conveyors.prototype.onDown_garbage = function (e) {
\n\t
if (this._currentDragView) {
\n\t
removeChild(this._currentDragView);
\n\t
}
\n\t
var target = e.target;
\n\t
var view = new engine.Sprite(target.texture);
\n\t
this._currentDragView = view;
\n\t
this._currentTarget = target;
\n\t
target.scaleX = target.scaleY = 0;
\n\t
this.wrapper.addChild(view);
\n\t
view.x = e.stageX - target.texture.width / 2;
\n\t
view.y = e.stageY - target.texture.height / 2;
\n\t
view.type = target['type'];
\n\t
view.name = target['name'];
\n\t
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
};
\n\t
Conveyors.prototype.onStageMouseMove = function (e) {
\n\t
var view = this._currentDragView;
\n\t
view.x = e.stageX - view.texture.width / 2;
\n\t
view.y = e.stageY - view.texture.height / 2;
\n\t
};
\n\t
Conveyors.prototype.onStageMouseUp = function (e) {
\n\t
var _this = this;
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
if (!this._currentDragView)
\n\t
return;
\n\t
var result = this.checkHitRect();
\n\t
if (result) {
\n\t
if (result == this._currentDragView['type']) {
\n\t
this.addscore();
\n\t
this.wrapper.rightTips.play(getTargetRect(result, this.wrapper));
\n\t
}
\n\t
else {
\n\t
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
\n\t
this.wrapper.wrongTips.play(getTargetRect(result, this.wrapper));
\n\t
}
\n\t
this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });
\n\t
}
\n\t
else {
\n\t
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
\n\t
}
\n\t
this._currentDragView.anchorX = this._currentDragView.texture.width / 2;
\n\t
this._currentDragView.anchorY = this._currentDragView.texture.height / 2;
\n\t
engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
\n\t
removeChild(_this._currentDragView);
\n\t
});
\n\t
};
\n\t
Conveyors.prototype.clear = function () {
\n\t
this.conveyor0.x = 0;
\n\t
this.conveyor1.x = 764;
\n\t
this.conveyorsPool.forEach(function (i) {
\n\t
i.clear();
\n\t
});
\n\t
this.conveyorsPool = [];
\n\t
this.datas = [];
\n\t
this.stores = [];
\n\t
};
\n\t
Conveyors.prototype.timeout = function () {
\n\t
if (this._currentDragView) {
\n\t
removeChild(this._currentDragView);
\n\t
}
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
\n\t
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
\n\t
this.gameOver();
\n\t
};
\n\t
Conveyors.prototype.checkHitRect = function () {
\n\t
if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {
\n\t
return GarbageTypes.wetWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {
\n\t
return GarbageTypes.harmfulWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {
\n\t
return GarbageTypes.dryWaste;
\n\t
}
\n\t
if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {
\n\t
return GarbageTypes.recoverableWaste;
\n\t
}
\n\t
return null;
\n\t
};
\n\t
return Conveyors;
\n\t
}(engine.Sprite));
\n\n\t
var 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\n\t
var getGuideInfo = (function () {
\n\t
if (!window.localStorage) {
\n\t
return 0;
\n\t
}
\n\t
return localStorage.getItem('recyclingGuide');
\n\t
});
\n\t
var setGuide = function () {
\n\t
if (window.localStorage)
\n\t
localStorage.setItem('recyclingGuide', '1');
\n\t
};
\n\n\t
var createBg = (function (a) {
\n\t
if (a === void 0) { a = 1; }
\n\t
var rect = new engine.Graphics();
\n\t
rect.beginFill(0);
\n\t
rect.drawRect(0, 0, 750, 1624);
\n\t
rect.endFill();
\n\t
rect.alpha = a;
\n\t
return rect;
\n\t
});
\n\n\t
var createImg = (function (texture) {
\n\t
return new engine.Sprite(getTextureByName(texture));
\n\t
});
\n\n\t
var CountDownGroup = (function (_super) {
\n\t
tslib.__extends(CountDownGroup, _super);
\n\t
function CountDownGroup() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.addChild(createBg(.6));
\n\t
_this.num1 = createImg('num1');
\n\t
_this.num2 = createImg('num2');
\n\t
_this.num3 = createImg('num3');
\n\t
_this.go = createImg('go');
\n\t
_this.go.anchorX = 240;
\n\t
_this.go.anchorY = 171.5;
\n\t
_this.num1.anchorX = 125.5;
\n\t
_this.num1.anchorY = 189;
\n\t
_this.num2.anchorX = 149.5;
\n\t
_this.num2.anchorY = 191.5;
\n\t
_this.num3.anchorX = 148.5;
\n\t
_this.num3.anchorY = 191.5;
\n\t
_this.go.x = 750 / 2 - 240;
\n\t
_this.go.y = 525 - 171.5;
\n\t
_this.num1.x = 750 / 2 - 125.5;
\n\t
_this.num1.y = 529 - 189;
\n\t
_this.num2.x = 750 / 2 - 149.5;
\n\t
_this.num2.y = 526 - 191.5;
\n\t
_this.num3.x = 750 / 2 - 148.5;
\n\t
_this.num3.y = 525 - 191.5;
\n\t
_this.addChild(_this.num1);
\n\t
_this.addChild(_this.num2);
\n\t
_this.addChild(_this.num3);
\n\t
_this.addChild(_this.go);
\n\t
_this.visible = false;
\n\t
_this.reset();
\n\t
return _this;
\n\t
}
\n\t
CountDownGroup.prototype.reset = function () {
\n\t
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;
\n\t
this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
\n\t
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
\n\t
};
\n\t
CountDownGroup.prototype.startCountDown = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.reset();
\n\t
_this.visible = true;
\n\t
_this.num3.alpha = 1;
\n\t
var n3 = engine.Tween.get(_this.num3);
\n\t
if (props.sound) {
\n\t
playSound(
\"
numCountDown
\"
);
\n\t
}
\n\t
n3.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num2.alpha = 1;
\n\t
var n2 = engine.Tween.get(_this.num2);
\n\t
if (props.sound) {
\n\t
playSound(
\"
numCountDown
\"
);
\n\t
}
\n\t
n2.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num1.alpha = 1;
\n\t
var n1 = engine.Tween.get(_this.num1);
\n\t
if (props.sound) {
\n\t
playSound(
\"
numCountDown
\"
);
\n\t
}
\n\t
n1.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.go.alpha = 1;
\n\t
var go = engine.Tween.get(_this.go);
\n\t
if (props.sound) {
\n\t
if (props.sound)
\n\t
window[
\"
playMusic
\"
](
\"
go
\"
);
\n\t
}
\n\t
go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
});
\n\t
});
\n\t
});
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return CountDownGroup;
\n\t
}(engine.Sprite));
\n\n\t
var GuideView = (function (_super) {
\n\t
tslib.__extends(GuideView, _super);
\n\t
function GuideView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.initUI();
\n\t
_this.visible = false;
\n\t
return _this;
\n\t
}
\n\t
GuideView.prototype.initUI = function () {
\n\t
this.addChild(createBg(.6));
\n\t
this.guideBg = createImg('guideBg');
\n\t
this.addChild(this.guideBg);
\n\t
this.guideEle = createImg('guideEle');
\n\t
this.addChild(this.guideEle);
\n\t
this.guideBg.x = 393;
\n\t
this.guideBg.y = 552;
\n\t
this.guideEle.x = 361;
\n\t
this.guideEle.y = 877;
\n\t
this.guideEle.anchorX = 14;
\n\t
this.guideEle.anchorY = 88;
\n\t
this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;
\n\t
var svga = createSvga(
\"
guideTips
\"
);
\n\t
this.svga = svga;
\n\t
this.addChild(svga);
\n\t
svga.gotoAndStop(1);
\n\t
svga.mouseEnabled = svga.mouseChildren = false;
\n\t
};
\n\t
GuideView.prototype.checkHit = function (x, y, w, h) {
\n\t
var rect = new engine.Rectangle(393, 552, 281, 320);
\n\t
if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
};
\n\t
GuideView.prototype.startGuide = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.visible = true;
\n\t
_this.svga.gotoAndStop(1);
\n\t
_this.svga.play(false, true);
\n\t
_this.guideEle.scaleX = 1;
\n\t
_this.guideEle.scaleY = 1;
\n\t
var offset = [0, 0];
\n\t
var guideOver = function () {
\n\t
_this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
_this.guideEle.anchorX = 14;
\n\t
_this.guideEle.anchorY = 44;
\n\t
engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
};
\n\t
var onUp = function (e) {
\n\t
_this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {
\n\t
guideOver();
\n\t
}
\n\t
else {
\n\t
_this.svga.visible = true;
\n\t
_this.guideEle.x = 361;
\n\t
_this.guideEle.y = 877;
\n\t
engine.Tween.get(_this.guideEle).set({ scaleX: 0, scaleY: 0 }).to({ scaleX: 1, scaleY: 1 }, 300);
\n\t
}
\n\t
};
\n\t
var onMove = function (e) {
\n\t
_this.guideEle.x = e.stageX - offset[0];
\n\t
_this.guideEle.y = e.stageY - offset[1];
\n\t
};
\n\t
var ondown = function (e) {
\n\t
offset = [e.localX, e.localY];
\n\t
_this.svga.visible = false;
\n\t
_this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);
\n\t
_this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
};
\n\t
_this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return GuideView;
\n\t
}(engine.Sprite));
\n\n\t
var RightTips = (function (_super) {
\n\t
tslib.__extends(RightTips, _super);
\n\t
function RightTips() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.SCORE = props.onceScore || 2;
\n\t
_this.img = new engine.Image();
\n\t
_this.img.texture = getTextureByName('rightTips');
\n\t
_this.addChild(_this.img);
\n\t
_this.img.anchorX = 88 / 2;
\n\t
_this.img.anchorY = 85 / 2;
\n\t
_this.visible = false;
\n\t
_this.txt = new engine.TextField();
\n\t
_this.addChild(_this.txt);
\n\t
_this.txt.text = '+' + _this.SCORE;
\n\t
_this.txt.size = 60;
\n\t
_this.txt.fillColor = '#437726';
\n\t
engine.playSound;
\n\t
return _this;
\n\t
}
\n\t
RightTips.prototype.play = function (rect) {
\n\t
if (props.sound) {
\n\t
playSound(
\"
rightTipsSound
\"
);
\n\t
}
\n\t
this.visible = true;
\n\t
this.txt.x = 100;
\n\t
engine.Tween.get(this.txt).set({ y: 60, alpha: 1 })
\n\t
.to({ y: -50 }, 500)
\n\t
.to({ alpha: 0 });
\n\t
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 0, scaleY: 0, alpha: 1 })
\n\t
.to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(1))
\n\t
.wait(200)
\n\t
.to({ alpha: 0 }, 300);
\n\t
this.x = rect.x + 180;
\n\t
this.y = rect.y;
\n\t
};
\n\t
return RightTips;
\n\t
}(engine.Sprite));
\n\n\t
var 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 uiMap = {};
\n\t
this.uiMap = uiMap;
\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
uiMap[id] = 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
this.configConveyors();
\n\t
this.createRects();
\n\t
this.countdown = new CountDownGroup();
\n\t
this.addChild(this.countdown);
\n\t
this.guide = new GuideView();
\n\t
this.addChild(this.guide);
\n\t
this.wrongTips = new WrongTips();
\n\t
this.rightTips = new RightTips();
\n\t
this.addChild(this.wrongTips);
\n\t
this.addChild(this.rightTips);
\n\t
};
\n\t
GameView.prototype.createRects = function () {
\n\t
this.wetWaste = this.createRect(74, 552, 301, 293, 0xffffff);
\n\t
this.harmfulWaste = this.createRect(75, 247, 300, 293, 0xff0000);
\n\t
this.dryWaste = this.createRect(389, 249, 286, 291, 0x000000);
\n\t
this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);
\n\t
};
\n\t
GameView.prototype.createRect = function (x, y, w, h, c) {
\n\t
var rect = new engine.Rectangle(x, y, w, h);
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x;
\n\t
sp.y = y;
\n\t
var g = new engine.Graphics;
\n\t
g.alpha = 0.0;
\n\t
g.beginFill(c);
\n\t
g.drawRect(0, 0, w, h);
\n\t
g.endFill();
\n\t
sp.addChild(g);
\n\t
return rect;
\n\t
};
\n\t
GameView.prototype.configConveyors = function () {
\n\t
var conveyor0 = new Conveyor();
\n\t
var conveyor1 = new Conveyor();
\n\t
this.addChild(conveyor0);
\n\t
this.addChild(conveyor1);
\n\t
conveyor0.x = 0;
\n\t
conveyor1.x = 764;
\n\t
this.conveyors = new Conveyors(this);
\n\t
this.conveyors.initData(conveyor0, conveyor1);
\n\t
};
\n\t
GameView.prototype.playAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);
\n\t
});
\n\t
};
\n\t
GameView.prototype.stopAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.removeTweens(i);
\n\t
});
\n\t
};
\n\t
GameView.prototype.start = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
console.log('on start');
\n\t
this._timeCounter = 0;
\n\t
if (!!getGuideInfo()) return [3, 2];
\n\t
return [4, this.guide.startGuide()];
\n\t
case 1:
\n\t
_a.sent();
\n\t
setGuide();
\n\t
_a.label = 2;
\n\t
case 2:
\n\t
this.conveyors.clear();
\n\t
return [4, this.countdown.startCountDown()];
\n\t
case 3:
\n\t
_a.sent();
\n\t
this.startGame();
\n\t
engine.globalEvent.dispatchEvent('recycling-time-update', {
\n\t
second: this.getSecond(),
\n\t
});
\n\t
this._timer = setInterval(function () {
\n\t
_this.onTimer();
\n\t
}, 1000);
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.startGame = function () {
\n\t
this.playAni();
\n\t
this.conveyors.startConveyors();
\n\t
};
\n\t
GameView.prototype.stopGame = function () {
\n\t
this.stopAni();
\n\t
};
\n\t
GameView.prototype.getSecond = function () {
\n\t
return props.time - this._timeCounter;
\n\t
};
\n\t
GameView.prototype.onTimer = function () {
\n\t
this._timeCounter++;
\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
this.conveyors.timeout();
\n\t
if (props.sound)
\n\t
window['playMusic'](
\"
gameOver
\"
);
\n\t
}
\n\t
};
\n\t
GameView.prototype.stop = function () {
\n\t
clearInterval(this._timer);
\n\t
this.stopGame();
\n\t
};
\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\t
var 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-sound-update', _this.updateSound, _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.updateSound = function (event) {
\n\t
injectProps(event.data);
\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\n\t
function index (props) {
\n\t
prepareProps();
\n\t
injectProps(props);
\n\t
var instance = new GameWrapper();
\n\t
return instance;
\n\t
}
\n\n\t
return index;
\n\n
})));
\n
"
}
src/custom/recycling/debug/app.js
View file @
6c7611b1
...
...
@@ -46,10 +46,16 @@ function launchWithCustomModule(customModule) {
},
100
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'recycling-start'
,
{
time
:
200
,
maxScore
:
222
,
speed
:
3
});
engine
.
globalEvent
.
dispatchEvent
(
'recycling-start'
,
{
time
:
15
,
maxScore
:
2
,
speed
:
3
,
sound
:
1
});
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
},
200
);
},
2000
);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('recycling-sound-update', { sound: 1 });
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// }, 10 * 100);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('recycling-start', { time: 8, maxScore: 2 });
...
...
src/custom/recycling/debug/index.html
View file @
6c7611b1
...
...
@@ -44,7 +44,30 @@
<script
src=
"props.js"
></script>
<script
src=
"load-assets.js"
></script>
<script
src=
"main.js"
></script>
<audio
style=
"display:none;
height: 0"
id=
"wrongTips"
preload=
"auto"
src=
"https://yun.duiba.com.cn/db_games/activity/garbageSorting1.00/wrongTips.mp3"
>
</audio>
<audio
style=
"display:none;
height: 0"
id=
"go"
preload=
"auto"
src=
"https://yun.duiba.com.cn/db_games/activity/garbageSorting1.00/go.mp3"
>
</audio>
<audio
style=
"display:none;
height: 0"
id=
"gameOver"
preload=
"auto"
src=
"https://yun.duiba.com.cn/db_games/activity/garbageSorting1.00/gameOver.mp3"
>
</audio>
<script>
// localStorage.clear()
function
playMusic
(
id
=
"bgMusic"
,
isPlay
=
true
)
{
var
media
=
document
.
getElementById
(
id
);
if
(
isPlay
&&
media
.
paused
)
{
media
.
play
();
}
if
(
!
isPlay
&&
!
media
.
paused
)
{
media
.
pause
();
}
}
</script>
</body>
\ No newline at end of file
src/custom/recycling/debug/main.js
View file @
6c7611b1
...
...
@@ -10,12 +10,14 @@
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
function
createSvga
(
name
,
anchorName
)
{
var
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
return
inst
;
}
//# sourceMappingURL=utils.js.map
var
props
=
{};
function
prepareProps
()
{
...
...
@@ -25,7 +27,6 @@
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
Conveyor
=
(
function
(
_super
)
{
tslib
.
__extends
(
Conveyor
,
_super
);
...
...
@@ -61,7 +62,6 @@
};
return
Conveyor
;
}(
engine
.
Sprite
));
//# sourceMappingURL=Conveyor.js.map
var
GarbageTypes
;
(
function
(
GarbageTypes
)
{
...
...
@@ -70,7 +70,6 @@
GarbageTypes
[
"wetWaste"
]
=
"wetWaste"
;
GarbageTypes
[
"dryWaste"
]
=
"dryWaste"
;
})(
GarbageTypes
||
(
GarbageTypes
=
{}));
//# sourceMappingURL=GarbageTypes.js.map
var
GarbageConfig
=
(
function
()
{
function
GarbageConfig
()
{
...
...
@@ -130,7 +129,6 @@
];
return
GarbageConfig
;
}());
//# sourceMappingURL=GarbageConfig.js.map
var
transStores
=
(
function
(
list
)
{
var
tmp
=
[];
...
...
@@ -189,7 +187,6 @@
return
'其他垃圾'
;
}
};
//# sourceMappingURL=transStores.js.map
var
checkHit
=
(
function
(
view
,
rect
)
{
var
x
=
view
.
x
,
y
=
view
.
y
;
...
...
@@ -199,14 +196,12 @@
}
return
false
;
});
//# sourceMappingURL=checkHit.js.map
var
removeChild
=
(
function
(
d
)
{
if
(
d
&&
d
.
parent
)
{
d
.
parent
.
removeChild
(
d
);
}
});
//# sourceMappingURL=removeChild.js.map
var
removeEle
=
(
function
(
e
,
arr
)
{
var
index
=
arr
.
indexOf
(
e
);
...
...
@@ -214,7 +209,6 @@
arr
.
splice
(
index
,
1
);
}
});
//# sourceMappingURL=removeEle.js.map
var
shuffle
=
(
function
(
arr
)
{
var
_a
;
...
...
@@ -240,6 +234,9 @@
}
WrongTips
.
prototype
.
play
=
function
(
rect
)
{
this
.
visible
=
true
;
if
(
props
.
sound
)
{
window
[
"playMusic"
](
"wrongTips"
);
}
var
dur
=
70
;
var
stren
=
20
;
engine
.
Tween
.
get
(
this
.
img
).
set
({
x
:
0
,
y
:
0
,
scaleX
:
1
,
scaleY
:
1
,
alpha
:
1
})
...
...
@@ -266,7 +263,6 @@
return
gameview
.
recoverableWaste
;
}
};
//# sourceMappingURL=WrongTips.js.map
var
Conveyors
=
(
function
(
_super
)
{
tslib
.
__extends
(
Conveyors
,
_super
);
...
...
@@ -318,6 +314,8 @@
if
(
this
.
score
==
(
props
.
maxScore
||
100
))
{
this
.
gameOver
();
this
.
wrapper
.
stop
();
if
(
props
.
sound
)
window
[
'playMusic'
](
"gameOver"
);
}
this
.
conveyorsPool
.
forEach
(
function
(
conveyor
)
{
conveyor
.
x
-=
props
.
speed
||
3
;
...
...
@@ -582,7 +580,6 @@
},
];
});
//# sourceMappingURL=uiConfig.js.map
var
getGuideInfo
=
(
function
()
{
if
(
!
window
.
localStorage
)
{
...
...
@@ -594,7 +591,6 @@
if
(
window
.
localStorage
)
localStorage
.
setItem
(
'recyclingGuide'
,
'1'
);
};
//# sourceMappingURL=getGuideInfo.js.map
var
createBg
=
(
function
(
a
)
{
if
(
a
===
void
0
)
{
a
=
1
;
}
...
...
@@ -605,12 +601,10 @@
rect
.
alpha
=
a
;
return
rect
;
});
//# sourceMappingURL=createBg.js.map
var
createImg
=
(
function
(
texture
)
{
return
new
engine
.
Sprite
(
getTextureByName
(
texture
));
});
//# sourceMappingURL=createImg.js.map
var
CountDownGroup
=
(
function
(
_super
)
{
tslib
.
__extends
(
CountDownGroup
,
_super
);
...
...
@@ -659,15 +653,28 @@
_this
.
visible
=
true
;
_this
.
num3
.
alpha
=
1
;
var
n3
=
engine
.
Tween
.
get
(
_this
.
num3
);
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n3
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
num2
.
alpha
=
1
;
var
n2
=
engine
.
Tween
.
get
(
_this
.
num2
);
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n2
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
num1
.
alpha
=
1
;
var
n1
=
engine
.
Tween
.
get
(
_this
.
num1
);
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n1
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
go
.
alpha
=
1
;
var
go
=
engine
.
Tween
.
get
(
_this
.
go
);
if
(
props
.
sound
)
{
if
(
props
.
sound
)
window
[
"playMusic"
](
"go"
);
}
go
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
call
(
function
()
{
_this
.
visible
=
false
;
r
();
...
...
@@ -681,7 +688,6 @@
};
return
CountDownGroup
;
}(
engine
.
Sprite
));
//# sourceMappingURL=CountDownGroup.js.map
var
GuideView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GuideView
,
_super
);
...
...
@@ -701,6 +707,8 @@
this
.
guideBg
.
y
=
552
;
this
.
guideEle
.
x
=
361
;
this
.
guideEle
.
y
=
877
;
this
.
guideEle
.
anchorX
=
14
;
this
.
guideEle
.
anchorY
=
88
;
this
.
guideEle
.
mouseEnabled
=
this
.
guideEle
.
mouseChildren
=
true
;
var
svga
=
createSvga
(
"guideTips"
);
this
.
svga
=
svga
;
...
...
@@ -728,6 +736,8 @@
var
offset
=
[
0
,
0
];
var
guideOver
=
function
()
{
_this
.
guideEle
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
ondown
,
_this
);
_this
.
guideEle
.
anchorX
=
14
;
_this
.
guideEle
.
anchorY
=
44
;
engine
.
Tween
.
get
(
_this
.
guideEle
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(
function
()
{
_this
.
visible
=
false
;
r
();
...
...
@@ -742,6 +752,7 @@
_this
.
svga
.
visible
=
true
;
_this
.
guideEle
.
x
=
361
;
_this
.
guideEle
.
y
=
877
;
engine
.
Tween
.
get
(
_this
.
guideEle
).
set
({
scaleX
:
0
,
scaleY
:
0
}).
to
({
scaleX
:
1
,
scaleY
:
1
},
300
);
}
};
var
onMove
=
function
(
e
)
{
...
...
@@ -761,7 +772,6 @@
};
return
GuideView
;
}(
engine
.
Sprite
));
//# sourceMappingURL=guideView.js.map
var
RightTips
=
(
function
(
_super
)
{
tslib
.
__extends
(
RightTips
,
_super
);
...
...
@@ -783,6 +793,9 @@
return
_this
;
}
RightTips
.
prototype
.
play
=
function
(
rect
)
{
if
(
props
.
sound
)
{
playSound
(
"rightTipsSound"
);
}
this
.
visible
=
true
;
this
.
txt
.
x
=
100
;
engine
.
Tween
.
get
(
this
.
txt
).
set
({
y
:
60
,
alpha
:
1
})
...
...
@@ -797,7 +810,6 @@
};
return
RightTips
;
}(
engine
.
Sprite
));
//# sourceMappingURL=RightTips.js.map
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
...
...
@@ -936,6 +948,8 @@
if
(
this
.
getSecond
()
==
0
)
{
this
.
stop
();
this
.
conveyors
.
timeout
();
if
(
props
.
sound
)
window
[
'playMusic'
](
"gameOver"
);
}
};
GameView
.
prototype
.
stop
=
function
()
{
...
...
@@ -956,18 +970,21 @@
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
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-sound-update'
,
_this
.
updateSound
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'recycling-stop'
,
_this
.
stop
,
_this
);
var
gameView
=
_this
.
_gameView
=
new
GameView
();
_this
.
addChild
(
gameView
);
return
_this
;
}
GameWrapper
.
prototype
.
updateSound
=
function
(
event
)
{
injectProps
(
event
.
data
);
};
GameWrapper
.
prototype
.
start
=
function
(
event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
start
();
...
...
@@ -977,7 +994,6 @@
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
...
...
@@ -985,7 +1001,6 @@
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
...
...
src/custom/recycling/debug/main.js.map
View file @
6c7611b1
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/recycling/meta.json
View file @
6c7611b1
...
...
@@ -16,7 +16,7 @@
},
{
"name"
:
"playBg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
76b9491f50eaf51ae2becf9958d96a93770854ee
.jpg"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/
2a5b5087d915c2510f1b96facdb9532798ab59cd
.jpg"
,
"uuid"
:
"1e7dd156-b59a-491d-8154-af2ecf425a8b"
,
"ext"
:
".jpg"
},
...
...
@@ -385,6 +385,18 @@
"url"
:
"//yun.duiba.com.cn/aurora/assets/d2f1d01024247ea64cf35c610fec85f19dd89c21.png"
,
"uuid"
:
"g00"
,
"ext"
:
".png"
},
{
"name"
:
"rightTipsSound"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/dbf1ec24569c939bbf599475fd49110e51951584.mp3"
,
"uuid"
:
"d7aa31a9-24b9-4082-98f5-a071e1f81a5a"
,
"ext"
:
".mp3"
},
{
"name"
:
"numCountDown"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/b7a6e76838c82ef34ed6af0e13550633910e0aec.mp3"
,
"uuid"
:
"c8bae79c-6973-4021-adc1-45db51afe93e"
,
"ext"
:
".mp3"
}
],
...
...
src/custom/recycling/src/game/Conveyors.ts
View file @
6c7611b1
...
...
@@ -82,6 +82,8 @@ export default class Conveyors extends engine.Sprite {
if
(
this
.
score
==
(
props
.
maxScore
||
100
))
{
this
.
gameOver
();
this
.
wrapper
.
stop
();
if
(
props
.
sound
)
window
[
'playMusic'
](
"gameOver"
)
}
// console.log('this.conveyorsPool.length', this.conveyorsPool.length)
...
...
src/custom/recycling/src/game/GameView.ts
View file @
6c7611b1
...
...
@@ -172,7 +172,7 @@ export default class GameView extends engine.Container {
if
(
this
.
getSecond
()
==
0
)
{
this
.
stop
();
this
.
conveyors
.
timeout
();
if
(
props
.
sound
)
window
[
'playMusic'
](
"gameOver"
)
}
}
...
...
src/custom/recycling/src/game/GameWrapper.ts
View file @
6c7611b1
...
...
@@ -7,12 +7,18 @@ import { injectProps } from "../props";
export
class
GameWrapper
extends
engine
.
Container
{
updateSound
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
}
// private _status;
private
_gameView
:
GameView
;
constructor
()
{
super
();
engine
.
globalEvent
.
addEventListener
(
'recycling-start'
,
this
.
start
,
this
);
engine
.
globalEvent
.
addEventListener
(
'recycling-sound-update'
,
this
.
updateSound
,
this
);
engine
.
globalEvent
.
addEventListener
(
'recycling-stop'
,
this
.
stop
,
this
);
//创建实例
...
...
src/custom/recycling/src/game/views/CountDownGroup.ts
View file @
6c7611b1
import
createBg
from
"./createBg"
;
import
createImg
from
"./createImg"
;
import
{
props
}
from
"../../props"
;
import
{
playSound
}
from
"../utils"
;
export
default
class
CountDownGroup
extends
engine
.
Sprite
{
num1
:
engine
.
Sprite
;
...
...
@@ -54,33 +56,31 @@ export default class CountDownGroup extends engine.Sprite {
this
.
num3
.
alpha
=
1
;
let
n3
=
engine
.
Tween
.
get
(
this
.
num3
);
// if (GameConst.isPlayMusic) {
// playSound("numCountDown");
// }
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n3
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(()
=>
{
this
.
num2
.
alpha
=
1
;
let
n2
=
engine
.
Tween
.
get
(
this
.
num2
);
// if (GameConst.isPlayMusic) {
// playSound("numCountDown");
// }
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n2
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(()
=>
{
this
.
num1
.
alpha
=
1
;
let
n1
=
engine
.
Tween
.
get
(
this
.
num1
);
// if (GameConst.isPlayMusic) {
// playSound("numCountDown");
// }
if
(
props
.
sound
)
{
playSound
(
"numCountDown"
);
}
n1
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(()
=>
{
this
.
go
.
alpha
=
1
;
let
go
=
engine
.
Tween
.
get
(
this
.
go
);
// if (GameConst.isPlayMusic
) {
//
window["playMusic"]("go");
//
}
if
(
props
.
sound
)
{
if
(
props
.
sound
)
window
[
"playMusic"
](
"go"
);
}
go
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
call
(()
=>
{
this
.
visible
=
false
;
r
()
})
})
...
...
src/custom/recycling/src/game/views/RightTips.ts
View file @
6c7611b1
import
{
getTextureByName
}
from
"../utils"
;
import
{
getTextureByName
,
playSound
}
from
"../utils"
;
import
{
props
}
from
"../../props"
;
export
default
class
RightTips
extends
engine
.
Sprite
{
...
...
@@ -25,6 +25,10 @@ export default class RightTips extends engine.Sprite {
}
play
(
rect
:
engine
.
Rectangle
)
{
if
(
props
.
sound
)
{
playSound
(
"rightTipsSound"
);
}
this
.
visible
=
true
;
this
.
txt
.
x
=
100
;
...
...
src/custom/recycling/src/game/views/WrongTips.ts
View file @
6c7611b1
import
{
getTextureByName
}
from
"../utils"
;
import
{
GarbageTypes
}
from
"../datas/GarbageTypes"
;
import
GameView
from
"../GameView"
;
import
{
props
}
from
"../../props"
;
export
default
class
WrongTips
extends
engine
.
Sprite
{
img
:
engine
.
Image
;
...
...
@@ -18,6 +19,10 @@ export default class WrongTips extends engine.Sprite {
play
(
rect
:
engine
.
Rectangle
)
{
this
.
visible
=
true
;
if
(
props
.
sound
)
{
window
[
"playMusic"
](
"wrongTips"
);
}
const
dur
=
70
;
const
stren
=
20
;
engine
.
Tween
.
get
(
this
.
img
).
set
({
x
:
0
,
y
:
0
,
scaleX
:
1
,
scaleY
:
1
,
alpha
:
1
})
...
...
src/custom/recycling/src/game/views/guideView.ts
View file @
6c7611b1
...
...
@@ -22,7 +22,10 @@ export default class GuideView extends engine.Sprite {
this
.
guideBg
.
x
=
393
;
this
.
guideBg
.
y
=
552
;
this
.
guideEle
.
x
=
361
;
this
.
guideEle
.
y
=
877
;
this
.
guideEle
.
anchorX
=
14
;
this
.
guideEle
.
anchorY
=
88
;
this
.
guideEle
.
mouseEnabled
=
this
.
guideEle
.
mouseChildren
=
true
;
let
svga
=
createSvga
(
"guideTips"
);
...
...
@@ -51,6 +54,8 @@ export default class GuideView extends engine.Sprite {
let
offset
=
[
0
,
0
]
const
guideOver
=
()
=>
{
this
.
guideEle
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
ondown
,
this
)
this
.
guideEle
.
anchorX
=
14
;
this
.
guideEle
.
anchorY
=
44
;
engine
.
Tween
.
get
(
this
.
guideEle
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(()
=>
{
this
.
visible
=
false
;
r
();
...
...
@@ -65,6 +70,7 @@ export default class GuideView extends engine.Sprite {
this
.
svga
.
visible
=
true
;
this
.
guideEle
.
x
=
361
;
this
.
guideEle
.
y
=
877
;
engine
.
Tween
.
get
(
this
.
guideEle
).
set
({
scaleX
:
0
,
scaleY
:
0
}).
to
({
scaleX
:
1
,
scaleY
:
1
},
300
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment