Commit 6c7611b1 authored by wildfirecode's avatar wildfirecode

1

parent 5e341b08
This diff is collapsed.
......@@ -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 });
......
......@@ -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
......@@ -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;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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"
}
],
......
......@@ -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)
......
......@@ -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")
}
}
......
......@@ -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);
//创建实例
......
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()
})
})
......
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;
......
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 })
......
......@@ -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)
}
}
......
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