Commit 84f68537 authored by 汪欢's avatar 汪欢

拼图计时器bug

parents ac73e807 9663a003
No preview for this file type
This diff is collapsed.
......@@ -47,7 +47,8 @@ function launchWithCustomModule(customModule) {
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
blockUrl: "888",
});
const d = engine.gameStage.sceneContainer.getChildAt(0);
......@@ -57,11 +58,12 @@ function launchWithCustomModule(customModule) {
setTimeout(() => {
engine.globalEvent.dispatchEvent('pictures-start', {
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
blockUrl: "888"
});
}, 10*1000);
}, 5*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
......
......@@ -6,7 +6,7 @@ const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"uuid": "888",
"ext": ".png"
},
{
......
......@@ -67,12 +67,6 @@
});
//# sourceMappingURL=qietu.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function getIndexFromRC(row, col, maxCol) {
var index;
index = row * maxCol + col;
......@@ -104,6 +98,11 @@
}
GameView.prototype.start = function () {
var _this = this;
if (!this.guideHole) {
this.guideHole = new engine.Image();
this.guideHole.source = 'asset://' + props.blockUrl;
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
}
if (this.pictures) {
for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) {
var pic = _a[_i];
......@@ -143,7 +142,6 @@
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME;
}
console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
second: this.getSecond(),
});
......@@ -171,8 +169,6 @@
};
GameView.prototype.createRects = function () { };
GameView.prototype.setup = function () {
this.guideHole = new engine.Image(getTextureByName('遮罩'));
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
GAME_TIME = props.GAME_TIME;
......
This diff is collapsed.
......@@ -48,7 +48,7 @@
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"uuid": "888",
"ext": ".png"
}
],
......@@ -58,7 +58,8 @@
"pictures-start": {
"alias": "开始",
"data": {
"picUrl":"图片路径"
"picUrl":"图片路径",
"blockUrl":"blockUrl"
}
},
"pictures-stop": {
......
......@@ -4,7 +4,7 @@
import { props } from "../props";
import qietu from "./qietu";
import { getIndexFromRC, getRandomArray, getTextureByName } from "./utils";
import { getIndexFromRC, getRandomArray, getTexture } from "./utils";
import ObjectPool = engine.ObjectPool;
// let OFFSET_X;
......@@ -24,6 +24,12 @@ export default class GameView extends engine.Container {
private _timeCounter = 0;
start() {
if (!this.guideHole) {
this.guideHole = new engine.Image();
this.guideHole.source = 'asset://' + props.blockUrl;
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
}
if (this.pictures) {
for (const pic of this.pictures) {
if (pic && pic.parent)
......@@ -77,10 +83,10 @@ export default class GameView extends engine.Container {
GAME_TIME -= 0.01
GAME_TIME = this.afterPointTwo(GAME_TIME);
GAME_TIME = GAME_TIME.toFixed(2)
if(GAME_TIME < 10){
if (GAME_TIME < 10) {
GAME_TIME = '0' + GAME_TIME
}
console.log(GAME_TIME);
// console.log(GAME_TIME);
engine.globalEvent.dispatchEvent('pictures-time-update', {
......@@ -96,12 +102,12 @@ export default class GameView extends engine.Container {
}
afterPointTwo(n) {
var floatN = parseFloat(n);
if (isNaN(floatN)) {
return;
}
floatN = Math.round(floatN * 100) / 100;
......@@ -148,12 +154,10 @@ export default class GameView extends engine.Container {
private picturesWrapper: engine.Sprite;
private guideHole: engine.Sprite;
private guideHole: engine.Image;
createRects() { }
setup() {
this.guideHole = new engine.Image(getTextureByName('遮罩'));
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
MAX_COL = props.MAX_COL;
MAX_ROW = props.MAX_ROW;
......@@ -237,10 +241,10 @@ export default class GameView extends engine.Container {
}
listenStageOn=1;
listenStageOn = 1;
stageOnUp(e) {
this.stage.removeEventListener(
engine.MouseEvent.MOUSE_MOVE,
this.onMove,
......@@ -318,7 +322,7 @@ export default class GameView extends engine.Container {
this.dragPic.y = this.distanceY
}
}
private onSuccess() {
......@@ -329,7 +333,7 @@ export default class GameView extends engine.Container {
onMove(e: engine.MouseEvent) {
// 当前图片的位置
this.dragPic.x = e.stageX - this.localPicX - (750-props.W)/2;
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
console.log('fuck on this.stage.height', this.stage.height)
// console.log(this.dragPic.x, this.dragPic.y)
......
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