Commit a9eac5bb authored by wildfirecode's avatar wildfirecode

1

parent 63f061c8
This diff is collapsed.
......@@ -5102,6 +5102,7 @@ declare module engine {
}
export class DisplayObject extends EventDispatcher {
parent;
/**
* 基础信息
*/
......@@ -5121,7 +5122,7 @@ declare module engine {
* @member {Container}
* @readonly
*/
parent: any;
wrapper: any;
/**
* 舞台
*/
......
......@@ -34,8 +34,8 @@ export default class GameView extends engine.Container {
if (this.pictures) {
for (const pic of this.pictures) {
if (pic && pic.parent)
pic.parent.removeChild(pic);
if (pic && pic.wrapper)
pic.wrapper.removeChild(pic);
}
}
......
......@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 200, speed: 3 });
engine.globalEvent.dispatchEvent('recycling-start', { time: 200, maxScore: 6 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
......@@ -58,7 +58,7 @@ function launchWithCustomModule(customModule) {
// }, 1000 * 10);
});
engine.globalEvent.addEventListener('recycling-time-update', (e) => {
console.log(e.type, e.data);
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-score-update', (e) => {
console.log(e.type, e.data);
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,24 +15,36 @@ export default class Conveyor extends engine.Sprite {
const sp = new engine.Sprite(getTextureByName('conveyor'));
this.addChild(sp);
this.idx0 = this.createItem(75,50);
this.idx1 = this.createItem(225,50);
this.idx2 = this.createItem(375,50);
this.idx3 = this.createItem(525,50);
this.idx4 = this.createItem(675,50);
this.idx0 = this.createItem(75, 50);
this.idx1 = this.createItem(225, 50);
this.idx2 = this.createItem(375, 50);
this.idx3 = this.createItem(525, 50);
this.idx4 = this.createItem(675, 50);
}
createItem(x,y) {
clear() {
this.clearItem(this.idx0)
this.clearItem(this.idx1)
this.clearItem(this.idx2)
this.clearItem(this.idx3)
this.clearItem(this.idx4)
}
private clearItem(idx: engine.Sprite) {
if (idx.children.length > 0)
idx.removeChildAt(0)
}
private createItem(x, y) {
const sp = new engine.Sprite();
this.addChild(sp);
sp.x = x - 50;
sp.y = y- 50;
const g = new engine.Graphics;
g.beginFill(0xff0000);
g.drawRect(0,0,100,100);
g.endFill();
sp.addChild(g);
sp.x = x;
sp.y = y;
// const g = new engine.Graphics;
// g.beginFill(0xff0000);
// g.drawRect(0,0,100,100);
// g.endFill();
// sp.addChild(g);
return sp
}
......
This diff is collapsed.
......@@ -5,11 +5,11 @@
import { getTextureByName } from "../../../recycling/src/game/utils";
import { props } from "../props";
import Conveyor from "./Conveyor";
import Conveyors from "./Conveyors";
import uiConfig from "./uiConfig";
import getGuideInfo, { setGuide } from "./utils/getGuideInfo";
import CountDownGroup from "./views/CountDownGroup";
import GuideView from "./views/guideView";
import Conveyors from "./Conveyors";
export default class GameView extends engine.Container {
private _timer;
......@@ -125,8 +125,8 @@ export default class GameView extends engine.Container {
await this.guide.startGuide();
setGuide();
}
await this.countdown.startCountDown();
// await this.countdown.startCountDown();
this.startGame();
......@@ -162,7 +162,7 @@ export default class GameView extends engine.Container {
if (this.getSecond() == 0) {
this.stop();
this.conveyors.timeout();
engine.globalEvent.dispatchEvent('recycling-game-end', {});
}
}
......
import { GarbageTypes } from './GarbageTypes';
export default class Garbage extends engine.Sprite {
constructor(texture) {
super(texture);
}
public type: GarbageTypes;
public isWrong: boolean = false;
public isRight: boolean = false;
public
}
\ No newline at end of file
export enum GarbageTypes {
recoverableWaste,
harmfulWaste,
wetWaste,
dryWaste
}
\ No newline at end of file
recoverableWaste='recoverableWaste',
harmfulWaste='harmfulWaste',
wetWaste='wetWaste',
dryWaste='dryWaste'
}
import { GarbageTypes } from "./GarbageTypes"
export default (list: any[]) => {
return list.map(i => {
return {
'targetName': getTargetName(i.targetType),
'isCorrect': i.targetType == i.itemType,
'itemName': i.itemName
}
})
}
const getTargetName = (type: GarbageTypes) => {
switch (type) {
case GarbageTypes.recoverableWaste:
return '可回收物'
break;
case GarbageTypes.harmfulWaste:
return '有害垃圾'
break;
case GarbageTypes.wetWaste:
return '湿垃圾'
break;
case GarbageTypes.dryWaste:
return '干垃圾'
break;
default:
break;
}
}
\ No newline at end of file
export default (view, rect: engine.Rectangle) => {
const { x, y } = view;
const { width, height } = view.texture
if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {
return true
}
return false;
}
export default (d:engine.DisplayObject)=>{
if(d && d.parent) {
d.parent.removeChild(d)
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ class RedPack extends engine.Image {
this.x = this._pos.x += speedX;
this.y = this._pos.y += speedY;
this.parent.localToGlobal(this._pos, this._globalPos);
this.wrapper.localToGlobal(this._pos, this._globalPos);
const {_globalPos: {x, y}} = this;
if (y < -height || y > this.stage.height) {
return true;
......
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