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
6d7c75d5
Commit
6d7c75d5
authored
Jun 04, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://gitlab2.dui88.com/laoqifeng/zeroing-libs
into dev
parents
69017731
a0bb5b71
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
48 deletions
+106
-48
.DS_Store
dist/.DS_Store
+0
-0
pictures.json
dist/customs/pictures.json
+14
-4
app.js
src/custom/pictures/debug/app.js
+13
-2
main.js
src/custom/pictures/debug/main.js
+21
-9
main.js.map
src/custom/pictures/debug/main.js.map
+1
-1
meta.json
src/custom/pictures/meta.json
+13
-3
GameView.ts
src/custom/pictures/src/game/GameView.ts
+44
-29
No files found.
dist/.DS_Store
View file @
6d7c75d5
No preview for this file type
dist/customs/pictures.json
View file @
6d7c75d5
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
"default"
:
2
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
"default"
:
2
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -22,6 +22,16 @@
"type"
:
"number"
,
"default"
:
827
},
"OFFSET_X"
:
{
"alias"
:
"OFFSET_X"
,
"type"
:
"number"
,
"default"
:
0
},
"OFFSET_Y"
:
{
"alias"
:
"OFFSET_Y"
,
"type"
:
"number"
,
"default"
:
0
},
"GAP"
:
{
"alias"
:
"图片间隙"
,
"type"
:
"number"
,
...
...
@@ -30,7 +40,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
2
0
"default"
:
5
0
}
},
"assets"
:
[
...
...
@@ -75,5 +85,5 @@
}
},
"id"
:
"pictures"
,
"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.pictures = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\r\n\t
function prepareProps() {
\r\n\t
var metaProps = getProps();
\r\n\t
engine.injectProp(props, metaProps);
\r\n\t
}
\r\n\t
function injectProps(p) {
\r\n\t
engine.injectProp(props, p);
\r\n\t
}
\
n\n\t
var picMap = {};
\r\n\t
var posMap = {};
\r\n\t
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
\r\n\t
if (picMap[url]) {
\r\n\t
return [picMap[url], posMap[url]];
\r\n\t
}
\r\n\t
var W = props.W;
\r\n\t
var H = props.H;
\r\n\t
var GAP = props.GAP;
\r\n\t
var spr = [];
\r\n\t
var pos = [];
\r\n\t
var _loop_1 = function (row) {
\r\n\t
var _loop_2 = function (col) {
\r\n\t
var child = engine.Sprite.fromImage(url);
\r\n\t
spr.push(child);
\r\n\t
child.scaleX = 1 / MAX_COL;
\r\n\t
child.scaleY = 1 / MAX_ROW;
\r\n\t
parent.addChild(child);
\r\n\t
child.x = col * (W / MAX_COL + GAP);
\r\n\t
child.y = row * (H / MAX_ROW + GAP);
\r\n\t
pos.push([child.x, child.y]);
\r\n\t
child.addEventListener(engine.Event.COMPLETE, function () {
\r\n\t
var uvs = new Float32Array([
\r\n\t
col / MAX_COL,
\r\n\t
row / MAX_ROW,
\r\n\t
(col + 1) / MAX_COL,
\r\n\t
row / MAX_ROW,
\r\n\t
(col + 1) / MAX_COL,
\r\n\t
(row + 1) / MAX_ROW,
\r\n\t
col / MAX_COL,
\r\n\t
(row + 1) / MAX_ROW,
\r\n\t
]);
\r\n\t
child.uvs = uvs;
\r\n\t
});
\r\n\t
};
\r\n\t
for (var col = 0; col < MAX_COL; col++) {
\r\n\t
_loop_2(col);
\r\n\t
}
\r\n\t
};
\r\n\t
for (var row = 0; row < MAX_ROW; row++) {
\r\n\t
_loop_1(row);
\r\n\t
}
\r\n\t
picMap[url] = spr.concat([]);
\r\n\t
posMap[url] = pos.concat([]);
\r\n\t
return [spr, pos];
\r\n\t
});
\n\n\t
function getTexture(uuid) {
\r\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\r\n\t
}
\r\n\t
function getTextureByName(name) {
\r\n\t
return getTexture(engine.getAssetByName(name).uuid);
\r\n\t
}
\r\n\t
function getIndexFromRC(row, col, maxCol) {
\r\n\t
var index;
\r\n\t
index = row * maxCol + col;
\r\n\t
return index;
\r\n\t
}
\r\n\t
function getRandomArray(array) {
\r\n\t
array.sort(function () {
\r\n\t
return .5 - Math.random();
\r\n\t
});
\r\n\t
}
\n\n\t
var MAX_COL;
\r\n\t
var MAX_ROW;
\r\n\t
var W;
\r\n\t
var H;
\r\n\t
var GAP;
\r\n\t
var GAME_TIME;
\r\n\t
var w;
\r\n\t
var h;
\r\n\t
var GameView = (function (_super) {
\r\n\t
tslib.__extends(GameView, _super);
\r\n\t
function GameView() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this._timeCounter = 0;
\r\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameView.prototype.start = function () {
\r\n\t
console.log('on start');
\r\n\t
engine.globalEvent.dispatchEvent('pictures-time-update', {
\r\n\t
second: this.getSecond(),
\r\n\t
});
\r\n\t
var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);
\r\n\t
this.picturesWrapper.addChild(this.guideHole);
\r\n\t
console.log(this.picturesWrapper);
\r\n\t
this.pictures = result[0];
\r\n\t
this.rightList = this.pictures.concat([]);
\r\n\t
var posList = result[1];
\r\n\t
getRandomArray(this.pictures);
\r\n\t
var i = 0;
\r\n\t
var len;
\r\n\t
len = this.pictures.length;
\r\n\t
for (; i < len; i++) {
\r\n\t
this.dragPic = this.pictures[i];
\r\n\t
this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
\r\n\t
var _a = posList[i], x = _a[0], y = _a[1];
\r\n\t
this.dragPic.x = x;
\r\n\t
this.dragPic.y = y;
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.onTimer = function () {
\r\n\t
this._timeCounter += 0.01;
\r\n\t
this._timeCounter = this.afterPointTwo(this._timeCounter);
\r\n\t
console.log(this._timeCounter);
\r\n\t
engine.globalEvent.dispatchEvent('pictures-time-update', {
\r\n\t
second: this.getSecond(),
\r\n\t
});
\r\n\t
if (this.getSecond() == 0) {
\r\n\t
this.stop();
\r\n\t
engine.globalEvent.dispatchEvent('pictures-game-fail', {
\r\n\t
reason: 1
\r\n\t
});
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.afterPointTwo = function (n) {
\r\n\t
var floatN = parseFloat(n);
\r\n\t
if (isNaN(floatN)) {
\r\n\t
return;
\r\n\t
}
\r\n\t
floatN = Math.round(floatN * 100) / 100;
\r\n\t
return floatN;
\r\n\t
};
\r\n\t
GameView.prototype.getSecond = function () {
\r\n\t
return GAME_TIME - this._timeCounter;
\r\n\t
};
\r\n\t
GameView.prototype.stop = function () {
\r\n\t
this._timeCounter = 0;
\r\n\t
clearInterval(this._timer);
\r\n\t
};
\r\n\t
GameView.prototype.createRects = function () { };
\r\n\t
GameView.prototype.setup = function () {
\r\n\t
this.guideHole = new engine.Image(getTextureByName('遮罩'));
\r\n\t
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
\r\n\t
MAX_COL = props.MAX_COL;
\r\n\t
MAX_ROW = props.MAX_ROW;
\r\n\t
GAME_TIME = props.GAME_TIME;
\r\n\t
W = props.W;
\r\n\t
H = props.H;
\r\n\t
GAP = props.GAP;
\r\n\t
w = W / MAX_COL;
\r\n\t
h = H / MAX_ROW;
\r\n\t
console.log('onSteup', props);
\r\n\t
var parent = new engine.Sprite();
\r\n\t
this.picturesWrapper = parent;
\r\n\t
this.addChild(parent);
\r\n\t
};
\r\n\t
GameView.prototype.onDown = function (e) {
\r\n\t
this.dragPic = e.target;
\r\n\t
this.picturesWrapper.addChild(this.dragPic);
\r\n\t
this.localPicX = e.localX / MAX_COL;
\r\n\t
this.localPicY = e.localY / MAX_ROW;
\r\n\t
this.distanceX = this.dragPic.x;
\r\n\t
this.distanceY = this.dragPic.y;
\r\n\t
this.indexJ = Math.floor(this.distanceX / (w + GAP));
\r\n\t
this.indexI = Math.floor(this.distanceY / (h + GAP));
\r\n\t
this.index = (this.indexI) * MAX_COL + this.indexJ;
\r\n\t
this.centerX = Math.floor(e.clientX / w) * w + w / 2;
\r\n\t
this.centerY = Math.floor(e.clientY / h) * h + w / 2;
\r\n\t
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
\r\n\t
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
};
\r\n\t
GameView.prototype.stageOnUp = function (e) {
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
\r\n\t
if (this.centerY < 0 || this.centerX < 0) {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
this.picturesWrapper.addChild(this.guideHole);
\r\n\t
var curJ = Math.floor(this.centerX / (w + GAP));
\r\n\t
var curI = Math.floor(this.centerY / (h + GAP));
\r\n\t
if (curJ < (MAX_COL) && curI < (MAX_ROW)) {
\r\n\t
var index = getIndexFromRC(curI, curJ, MAX_COL);
\r\n\t
var dropPic = this.pictures[index];
\r\n\t
var dropPicX = dropPic.x;
\r\n\t
var dropPicy = dropPic.y;
\r\n\t
dropPic.x = this.distanceX;
\r\n\t
dropPic.y = this.distanceY;
\r\n\t
this.dragPic.x = dropPicX;
\r\n\t
this.dragPic.y = dropPicy;
\r\n\t
var dropPicIndex = this.pictures.indexOf(dropPic);
\r\n\t
var dragPicIndex = this.pictures.indexOf(this.dragPic);
\r\n\t
this.pictures[dropPicIndex] = this.dragPic;
\r\n\t
this.pictures[dragPicIndex] = dropPic;
\r\n\t
if (dragPicIndex === dropPicIndex) {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
var result = true;
\r\n\t
for (var j = 0; j < this.rightList.length; j++) {
\r\n\t
if (this.rightList[j] != this.pictures[j]) {
\r\n\t
result = false;
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (result) {
\r\n\t
this.onSuccess();
\r\n\t
}
\r\n\t
}
\r\n\t
else {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
};
\r\n\t
GameView.prototype.onSuccess = function () {
\r\n\t
console.log('拼图成功!');
\r\n\t
this.stop();
\r\n\t
engine.globalEvent.dispatchEvent('pictures-game-success', {});
\r\n\t
};
\r\n\t
GameView.prototype.onMove = function (e) {
\r\n\t
this.dragPic.x = e.stageX - this.localPicX;
\r\n\t
this.dragPic.y = e.stageY - this.localPicY;
\r\n\t
this.centerX = this.dragPic.x + w / 2;
\r\n\t
this.centerY = this.dragPic.y + h / 2;
\r\n\t
};
\r\n\t
GameView.prototype.onClk = function (e) {
\r\n\t
this._timeCounter = 0;
\r\n\t
this.start();
\r\n\t
};
\r\n\t
return GameView;
\r\n\t
}(engine.Container));
\n\n\t
var GameWrapper = (function (_super) {
\r\n\t
tslib.__extends(GameWrapper, _super);
\r\n\t
function GameWrapper() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
\r\n\t
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
\r\n\t
var gameView = _this._gameView = new GameView();
\r\n\t
_this.addChild(gameView);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameWrapper.prototype.start = function (event) {
\r\n\t
injectProps(event.data);
\r\n\t
this._gameView.start();
\r\n\t
};
\r\n\t
GameWrapper.prototype.stop = function (event) {
\r\n\t
this._gameView.stop();
\r\n\t
};
\r\n\t
return GameWrapper;
\r\n\t
}(engine.Container));
\n\n\t
function index (props) {
\r\n\t
prepareProps();
\r\n\t
injectProps(props);
\r\n\t
var instance = new GameWrapper();
\r\n\t
return instance;
\r\n\t
}
\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.pictures = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
var props = {};
\r\n\t
function prepareProps() {
\r\n\t
var metaProps = getProps();
\r\n\t
engine.injectProp(props, metaProps);
\r\n\t
}
\r\n\t
function injectProps(p) {
\r\n\t
engine.injectProp(props, p);
\r\n\t
}
\
r\n\t
//# sourceMappingURL=props.js.map
\n\n\t
var picMap = {};
\r\n\t
var posMap = {};
\r\n\t
var qietu = (function (parent, url, MAX_COL, MAX_ROW) {
\r\n\t
if (picMap[url]) {
\r\n\t
return [picMap[url], posMap[url]];
\r\n\t
}
\r\n\t
var W = props.W;
\r\n\t
var H = props.H;
\r\n\t
var GAP = props.GAP;
\r\n\t
var spr = [];
\r\n\t
var pos = [];
\r\n\t
var _loop_1 = function (row) {
\r\n\t
var _loop_2 = function (col) {
\r\n\t
var child = engine.Sprite.fromImage(url);
\r\n\t
spr.push(child);
\r\n\t
child.scaleX = 1 / MAX_COL;
\r\n\t
child.scaleY = 1 / MAX_ROW;
\r\n\t
parent.addChild(child);
\r\n\t
child.x = col * (W / MAX_COL + GAP);
\r\n\t
child.y = row * (H / MAX_ROW + GAP);
\r\n\t
pos.push([child.x, child.y]);
\r\n\t
child.addEventListener(engine.Event.COMPLETE, function () {
\r\n\t
var uvs = new Float32Array([
\r\n\t
col / MAX_COL,
\r\n\t
row / MAX_ROW,
\r\n\t
(col + 1) / MAX_COL,
\r\n\t
row / MAX_ROW,
\r\n\t
(col + 1) / MAX_COL,
\r\n\t
(row + 1) / MAX_ROW,
\r\n\t
col / MAX_COL,
\r\n\t
(row + 1) / MAX_ROW,
\r\n\t
]);
\r\n\t
child.uvs = uvs;
\r\n\t
});
\r\n\t
};
\r\n\t
for (var col = 0; col < MAX_COL; col++) {
\r\n\t
_loop_2(col);
\r\n\t
}
\r\n\t
};
\r\n\t
for (var row = 0; row < MAX_ROW; row++) {
\r\n\t
_loop_1(row);
\r\n\t
}
\r\n\t
picMap[url] = spr.concat([]);
\r\n\t
posMap[url] = pos.concat([]);
\r\n\t
return [spr, pos];
\r\n\t
});
\r\n\t
//# sourceMappingURL=qietu.js.map
\n\n\t
function getTexture(uuid) {
\r\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\r\n\t
}
\r\n\t
function getTextureByName(name) {
\r\n\t
return getTexture(engine.getAssetByName(name).uuid);
\r\n\t
}
\r\n\t
function getIndexFromRC(row, col, maxCol) {
\r\n\t
var index;
\r\n\t
index = row * maxCol + col;
\r\n\t
return index;
\r\n\t
}
\r\n\t
function getRandomArray(array) {
\r\n\t
array.sort(function () {
\r\n\t
return .5 - Math.random();
\r\n\t
});
\r\n\t
}
\r\n\t
//# sourceMappingURL=utils.js.map
\n\n\t
var MAX_COL;
\r\n\t
var MAX_ROW;
\r\n\t
var W;
\r\n\t
var H;
\r\n\t
var GAP;
\r\n\t
var GAME_TIME;
\r\n\t
var w;
\r\n\t
var h;
\r\n\t
var GameView = (function (_super) {
\r\n\t
tslib.__extends(GameView, _super);
\r\n\t
function GameView() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
_this._timeCounter = 0;
\r\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameView.prototype.start = function () {
\r\n\t
var _this = this;
\r\n\t
if (this.pictures) {
\r\n\t
for (var _i = 0, _a = this.pictures; _i < _a.length; _i++) {
\r\n\t
var pic = _a[_i];
\r\n\t
if (pic && pic.parent)
\r\n\t
pic.parent.removeChild(pic);
\r\n\t
}
\r\n\t
}
\r\n\t
console.log('on start');
\r\n\t
engine.globalEvent.dispatchEvent('pictures-time-update', {
\r\n\t
second: this.getSecond(),
\r\n\t
});
\r\n\t
var result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);
\r\n\t
this.picturesWrapper.addChild(this.guideHole);
\r\n\t
console.log(this.picturesWrapper);
\r\n\t
this.pictures = result[0];
\r\n\t
this.rightList = this.pictures.concat([]);
\r\n\t
var posList = result[1];
\r\n\t
getRandomArray(this.pictures);
\r\n\t
var i = 0;
\r\n\t
var len;
\r\n\t
len = this.pictures.length;
\r\n\t
for (; i < len; i++) {
\r\n\t
this.dragPic = this.pictures[i];
\r\n\t
this.pictures[i].addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown, this);
\r\n\t
var _b = posList[i], x = _b[0], y = _b[1];
\r\n\t
this.dragPic.x = x;
\r\n\t
this.dragPic.y = y;
\r\n\t
}
\r\n\t
this._timer = setInterval(function () {
\r\n\t
_this.onTimer();
\r\n\t
}, 10);
\r\n\t
};
\r\n\t
GameView.prototype.onTimer = function () {
\r\n\t
this._timeCounter += 0.01;
\r\n\t
this._timeCounter = this.afterPointTwo(this._timeCounter);
\r\n\t
engine.globalEvent.dispatchEvent('pictures-time-update', {
\r\n\t
second: this.getSecond(),
\r\n\t
});
\r\n\t
if (this.getSecond() == 0) {
\r\n\t
this.stop();
\r\n\t
engine.globalEvent.dispatchEvent('pictures-game-fail', {
\r\n\t
reason: 1
\r\n\t
});
\r\n\t
}
\r\n\t
};
\r\n\t
GameView.prototype.afterPointTwo = function (n) {
\r\n\t
var floatN = parseFloat(n);
\r\n\t
if (isNaN(floatN)) {
\r\n\t
return;
\r\n\t
}
\r\n\t
floatN = Math.round(floatN * 100) / 100;
\r\n\t
return floatN;
\r\n\t
};
\r\n\t
GameView.prototype.getSecond = function () {
\r\n\t
return GAME_TIME - this._timeCounter;
\r\n\t
};
\r\n\t
GameView.prototype.stop = function () {
\r\n\t
this._timeCounter = 0;
\r\n\t
clearInterval(this._timer);
\r\n\t
};
\r\n\t
GameView.prototype.createRects = function () { };
\r\n\t
GameView.prototype.setup = function () {
\r\n\t
this.guideHole = new engine.Image(getTextureByName('遮罩'));
\r\n\t
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
\r\n\t
MAX_COL = props.MAX_COL;
\r\n\t
MAX_ROW = props.MAX_ROW;
\r\n\t
GAME_TIME = props.GAME_TIME;
\r\n\t
W = props.W;
\r\n\t
H = props.H;
\r\n\t
GAP = props.GAP;
\r\n\t
w = W / MAX_COL;
\r\n\t
h = H / MAX_ROW;
\r\n\t
console.log('onSteup', props);
\r\n\t
var parent = new engine.Sprite();
\r\n\t
this.picturesWrapper = parent;
\r\n\t
this.addChild(parent);
\r\n\t
};
\r\n\t
GameView.prototype.onDown = function (e) {
\r\n\t
this.dragPic = e.target;
\r\n\t
this.picturesWrapper.addChild(this.dragPic);
\r\n\t
this.localPicX = e.localX / MAX_COL;
\r\n\t
this.localPicY = e.localY / MAX_ROW;
\r\n\t
this.distanceX = this.dragPic.x;
\r\n\t
this.distanceY = this.dragPic.y;
\r\n\t
this.indexJ = Math.floor(this.distanceX / (w + GAP));
\r\n\t
this.indexI = Math.floor(this.distanceY / (h + GAP));
\r\n\t
this.index = (this.indexI) * MAX_COL + this.indexJ;
\r\n\t
this.centerX = Math.floor(e.clientX / w) * w + w / 2;
\r\n\t
this.centerY = Math.floor(e.clientY / h) * h + w / 2;
\r\n\t
this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
\r\n\t
this.stage.addEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
};
\r\n\t
GameView.prototype.stageOnUp = function (e) {
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
\r\n\t
if (this.centerY < 0 || this.centerX < 0) {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
this.picturesWrapper.addChild(this.guideHole);
\r\n\t
var curJ = Math.floor(this.centerX / (w + GAP));
\r\n\t
var curI = Math.floor(this.centerY / (h + GAP));
\r\n\t
if (curJ < (MAX_COL) && curI < (MAX_ROW)) {
\r\n\t
var index = getIndexFromRC(curI, curJ, MAX_COL);
\r\n\t
var dropPic = this.pictures[index];
\r\n\t
var dropPicX = dropPic.x;
\r\n\t
var dropPicy = dropPic.y;
\r\n\t
dropPic.x = this.distanceX;
\r\n\t
dropPic.y = this.distanceY;
\r\n\t
this.dragPic.x = dropPicX;
\r\n\t
this.dragPic.y = dropPicy;
\r\n\t
var dropPicIndex = this.pictures.indexOf(dropPic);
\r\n\t
var dragPicIndex = this.pictures.indexOf(this.dragPic);
\r\n\t
this.pictures[dropPicIndex] = this.dragPic;
\r\n\t
this.pictures[dragPicIndex] = dropPic;
\r\n\t
if (dragPicIndex === dropPicIndex) {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
var result = true;
\r\n\t
for (var j = 0; j < this.rightList.length; j++) {
\r\n\t
if (this.rightList[j] != this.pictures[j]) {
\r\n\t
result = false;
\r\n\t
break;
\r\n\t
}
\r\n\t
}
\r\n\t
if (result) {
\r\n\t
this.onSuccess();
\r\n\t
}
\r\n\t
}
\r\n\t
else {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
};
\r\n\t
GameView.prototype.onSuccess = function () {
\r\n\t
console.log('拼图成功!');
\r\n\t
engine.globalEvent.dispatchEvent('pictures-game-success', { time: this._timeCounter });
\r\n\t
this.stop();
\r\n\t
};
\r\n\t
GameView.prototype.onMove = function (e) {
\r\n\t
this.dragPic.x = e.stageX - this.localPicX - (750 - props.W) / 2;
\r\n\t
this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;
\r\n\t
console.log('fuck on this.stage.height', this.stage.height);
\r\n\t
this.centerX = this.dragPic.x + w / 2;
\r\n\t
this.centerY = this.dragPic.y + h / 2;
\r\n\t
};
\r\n\t
return GameView;
\r\n\t
}(engine.Container));
\n\n\t
var GameWrapper = (function (_super) {
\r\n\t
tslib.__extends(GameWrapper, _super);
\r\n\t
function GameWrapper() {
\r\n\t
var _this = _super.call(this) || this;
\r\n\t
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
\r\n\t
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
\r\n\t
var gameView = _this._gameView = new GameView();
\r\n\t
_this.addChild(gameView);
\r\n\t
return _this;
\r\n\t
}
\r\n\t
GameWrapper.prototype.start = function (event) {
\r\n\t
injectProps(event.data);
\r\n\t
this._gameView.start();
\r\n\t
};
\r\n\t
GameWrapper.prototype.stop = function (event) {
\r\n\t
this._gameView.stop();
\r\n\t
};
\r\n\t
return GameWrapper;
\r\n\t
}(engine.Container));
\r\n\t
//# sourceMappingURL=GameWrapper.js.map
\n\n\t
function index (props) {
\r\n\t
prepareProps();
\r\n\t
injectProps(props);
\r\n\t
var instance = new GameWrapper();
\r\n\t
return instance;
\r\n\t
}
\r\n\t
//# sourceMappingURL=index.js.map
\n\n\t
return index;
\n\n
})));
\n
"
}
src/custom/pictures/debug/app.js
View file @
6d7c75d5
...
...
@@ -50,10 +50,21 @@ function launchWithCustomModule(customModule) {
picUrl
:
"http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
});
},
500
);
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
).
x
=
(
d
.
stage
.
width
-
props
.
W
)
/
2
;
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
).
y
=
(
d
.
stage
.
height
-
props
.
H
)
/
2
;
},
1500
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'pictures-start'
,
{
picUrl
:
"http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
// picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
});
},
10000
);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
//
console.log(e.type, e.data);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-game-fail'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
...
...
src/custom/pictures/debug/main.js
View file @
6d7c75d5
...
...
@@ -12,6 +12,7 @@
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
picMap
=
{};
var
posMap
=
{};
...
...
@@ -59,6 +60,7 @@
posMap
[
url
]
=
pos
.
concat
([]);
return
[
spr
,
pos
];
});
//# sourceMappingURL=qietu.js.map
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
...
...
@@ -76,6 +78,7 @@
return
.
5
-
Math
.
random
();
});
}
//# sourceMappingURL=utils.js.map
var
MAX_COL
;
var
MAX_ROW
;
...
...
@@ -94,6 +97,14 @@
return
_this
;
}
GameView
.
prototype
.
start
=
function
()
{
var
_this
=
this
;
if
(
this
.
pictures
)
{
for
(
var
_i
=
0
,
_a
=
this
.
pictures
;
_i
<
_a
.
length
;
_i
++
)
{
var
pic
=
_a
[
_i
];
if
(
pic
&&
pic
.
parent
)
pic
.
parent
.
removeChild
(
pic
);
}
}
console
.
log
(
'on start'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
...
...
@@ -111,15 +122,17 @@
for
(;
i
<
len
;
i
++
)
{
this
.
dragPic
=
this
.
pictures
[
i
];
this
.
pictures
[
i
].
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown
,
this
);
var
_
a
=
posList
[
i
],
x
=
_a
[
0
],
y
=
_a
[
1
];
var
_
b
=
posList
[
i
],
x
=
_b
[
0
],
y
=
_b
[
1
];
this
.
dragPic
.
x
=
x
;
this
.
dragPic
.
y
=
y
;
}
this
.
_timer
=
setInterval
(
function
()
{
_this
.
onTimer
();
},
10
);
};
GameView
.
prototype
.
onTimer
=
function
()
{
this
.
_timeCounter
+=
0.01
;
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
);
console
.
log
(
this
.
_timeCounter
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
});
...
...
@@ -222,19 +235,16 @@
};
GameView
.
prototype
.
onSuccess
=
function
()
{
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
this
.
_timeCounter
});
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{});
};
GameView
.
prototype
.
onMove
=
function
(
e
)
{
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
;
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
);
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
};
GameView
.
prototype
.
onClk
=
function
(
e
)
{
this
.
_timeCounter
=
0
;
this
.
start
();
};
return
GameView
;
}(
engine
.
Container
));
...
...
@@ -257,6 +267,7 @@
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
...
...
@@ -264,6 +275,7 @@
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
...
...
src/custom/pictures/debug/main.js.map
View file @
6d7c75d5
{"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getIndexFromRC, getRandomArray, getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n start() {\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper)\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n // this._timer = setInterval(() => {\r\n // this.onTimer();\r\n // }, 10)\r\n }\r\n\r\n\r\n onTimer() {\r\n // this._timeCounter++;\r\n this._timeCounter += 0.01;\r\n this._timeCounter = this.afterPointTwo(this._timeCounter);\r\n // this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;\r\n console.log(this._timeCounter)\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n){\r\n var floatN = parseFloat(n);\r\n if(isNaN(floatN)){\r\n return ;\r\n }\r\n floatN = Math.round(floatN * 100) /100;\r\n return floatN;\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME - this._timeCounter;\r\n // return GAME_TIME - this.countTime;\r\n }\r\n\r\n stop() {\r\n // this.countTime = 0\r\n\r\n this._timeCounter = 0;\r\n clearInterval(this._timer);\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures;\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n \r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Sprite;\r\n\r\n createRects() { }\r\n setup() {\r\n this.guideHole = new engine.Image(getTextureByName('遮罩'));\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n // this.indexI = this.distanceX / (w + GAP);\r\n // this.indexJ = this.distanceY / (h + GAP);\r\n // this.index = (this.indexI - 1) * MAX_COL + this.indexJ;\r\n\r\n\r\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\r\n this.indexI = Math.floor(this.distanceY / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n\r\n\r\n // 图片的中心位置\r\n // this.centerX = e.clientX + w / 2;\r\n // this.centerY = e.clientY + h / 2;\r\n\r\n this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n this.centerY = Math.floor(e.clientY / h) * h + w / 2\r\n\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n stageOnUp(e) {\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n \r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if(this.centerY < 0 || this.centerX < 0){\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP)) ;\r\n let curI = Math.floor(this.centerY / (h + GAP)) ;\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if (curJ < (MAX_COL) && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x;\r\n let dropPicy = dropPic.y;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX;\r\n this.dragPic.y = dropPicy;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if(dragPicIndex === dropPicIndex){\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n }else{\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-success', {});\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX;\r\n this.dragPic.y = e.stageY - this.localPicY;\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n\r\n }\r\n\r\n onClk(e){\r\n // 重置时间\r\n this._timeCounter = 0;\r\n //重置图片顺序\r\n this.start();\r\n \r\n }\r\n\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B;;CCZA,IAAM,MAAM,GAAG,EAAE,CAAC;CAClB,IAAM,MAAM,GAAG,EAAE,CAAC;AAClB,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAC3C,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;SACf,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;MAClC;KAED,IAAM,CA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C,GAAG,CAAC,GAAG,CAAC,CAAC;MAEvC;KAED,wBAAK,GAAL,UAAM,CAAC;SAEH,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;SAEtB,IAAI,CAAC,KAAK,EAAE,CAAC;MAEhB;KAGH,eAAC;CAAD,CAAC,CAjTqC,MAAM,CAAC,SAAS,GAiTrD;;CC5TD;KAAiCA,qCAAgB;KAQhD;SAAA,YACC,iBAAO,SASP;SAPA,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,KAAI,CAAC,KAAK,EAAE,KAAI,CAAC,CAAC;SACxE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,eAAe,EAAE,KAAI,CAAC,IAAI,EAAE,KAAI,CAAC,CAAC;SAGtE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAExB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAIxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,0BAAI,GAAJ,UAAK,KAAmB;SAEvB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;MACtB;KACF,kBAAC;CAAD,CAAC,CA/BgC,MAAM,CAAC,SAAS,GA+BhD;;iBChCwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/pictures/src/props.ts","src/custom/pictures/src/game/qietu.ts","src/custom/pictures/src/game/utils.ts","src/custom/pictures/src/game/GameView.ts","src/custom/pictures/src/game/GameWrapper.ts","src/custom/pictures/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","import { props } from \"../props\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default (parent, url, MAX_COL, MAX_ROW) => {\r\n if (picMap[url]) {\r\n return [picMap[url], posMap[url]]\r\n }\r\n\r\n const W = props.W;\r\n const H = props.H;\r\n const GAP = props.GAP;\r\n\r\n const spr = [];\r\n const pos = []\r\n\r\n for (let row = 0; row < MAX_ROW; row++) {\r\n for (let col = 0; col < MAX_COL; col++) {\r\n\r\n const child = engine.Sprite.fromImage(url);\r\n spr.push(child);\r\n\r\n child.scaleX = 1 / MAX_COL;\r\n child.scaleY = 1 / MAX_ROW;\r\n parent.addChild(child);\r\n child.x = col * (W / MAX_COL + GAP);\r\n child.y = row * (H / MAX_ROW + GAP);\r\n pos.push([child.x, child.y]);\r\n // child.texture.addEventListener('update', () => {\r\n child.addEventListener(engine.Event.COMPLETE, () => {\r\n const uvs = new Float32Array([\r\n col / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n row / MAX_ROW,\r\n (col + 1) / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n col / MAX_COL,\r\n (row + 1) / MAX_ROW,\r\n ]);\r\n\r\n child.uvs = uvs;\r\n // spr.push(child);\r\n });\r\n }\r\n }\r\n picMap[url] = spr.concat([]);\r\n posMap[url] = pos.concat([]);;\r\n // console.log(spr);\r\n return [spr, pos];\r\n};\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport function getIndexFromRC(row,col,maxCol){\r\n\tlet index;\r\n\tindex = row * maxCol + col ;\r\n\treturn index\r\n}\r\n\r\n\r\n\r\n\r\nexport function getRandomArray(array){\r\n\tarray.sort(function() {\r\n\t\treturn .5 - Math.random();\r\n\t});\r\n}","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getIndexFromRC, getRandomArray, getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\n\r\n// let OFFSET_X;\r\n// let OFFSET_Y;\r\nlet MAX_COL;\r\nlet MAX_ROW;\r\nlet W;\r\nlet H;\r\nlet GAP;\r\nlet GAME_TIME;\r\n// 每张图片宽\r\nlet w;\r\n// 每张图片高\r\nlet h;\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n start() {\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.parent)\r\n pic.parent.removeChild(pic);\r\n }\r\n }\r\n\r\n console.log('on start')\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n // 图片一维数组\r\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n console.log(this.picturesWrapper)\r\n\r\n this.pictures = result[0];\r\n this.rightList = this.pictures.concat([]);\r\n const posList = result[1];\r\n getRandomArray(this.pictures);\r\n\r\n let i = 0;\r\n let len;\r\n len = this.pictures.length;\r\n\r\n\r\n for (; i < len; i++) {\r\n this.dragPic = this.pictures[i];\r\n this.pictures[i].addEventListener(\r\n engine.MouseEvent.MOUSE_DOWN,\r\n this.onDown,\r\n this\r\n );\r\n const [x, y] = posList[i];\r\n this.dragPic.x = x;\r\n this.dragPic.y = y;\r\n\r\n }\r\n\r\n this._timer = setInterval(() => {\r\n this.onTimer();\r\n }, 10)\r\n }\r\n\r\n\r\n onTimer() {\r\n // this._timeCounter++;\r\n this._timeCounter += 0.01;\r\n this._timeCounter = this.afterPointTwo(this._timeCounter);\r\n // this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;\r\n // console.log(this._timeCounter)\r\n\r\n engine.globalEvent.dispatchEvent('pictures-time-update', {\r\n second: this.getSecond(),\r\n });\r\n\r\n if (this.getSecond() == 0) {\r\n this.stop();\r\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\r\n reason: 1\r\n });\r\n }\r\n }\r\n\r\n afterPointTwo(n) {\r\n var floatN = parseFloat(n);\r\n if (isNaN(floatN)) {\r\n return;\r\n }\r\n floatN = Math.round(floatN * 100) / 100;\r\n return floatN;\r\n }\r\n\r\n getSecond() {\r\n return GAME_TIME - this._timeCounter;\r\n // return GAME_TIME - this.countTime;\r\n }\r\n\r\n stop() {\r\n\r\n this._timeCounter = 0;\r\n clearInterval(this._timer);\r\n }\r\n\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n }\r\n\r\n //当前图片对象\r\n dragPic;\r\n // 鼠标在当前图片上的位置\r\n localPicX;\r\n localPicY;\r\n // 拖动的图片最开始的位置(左上角为准)\r\n distanceX;\r\n distanceY;\r\n // 图片中心的位置\r\n centerX: number;\r\n centerY: number;\r\n\r\n pictures: engine.Sprite[];\r\n\r\n // 点击图片时的一维数组索引\r\n index;\r\n // 计算目标图片行和列的位置\r\n indexI: number;\r\n indexJ: number;\r\n rightList: engine.Sprite[];\r\n\r\n\r\n\r\n private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Sprite;\r\n\r\n createRects() { }\r\n setup() {\r\n this.guideHole = new engine.Image(getTextureByName('遮罩'));\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n\r\n MAX_COL = props.MAX_COL;\r\n MAX_ROW = props.MAX_ROW;\r\n GAME_TIME = props.GAME_TIME;\r\n // OFFSET_X = props.OFFSET_X;\r\n // OFFSET_Y = props.OFFSET_Y;\r\n W = props.W;\r\n H = props.H;\r\n GAP = props.GAP;\r\n // 每张图片宽\r\n w = W / MAX_COL;\r\n // 每张图片高\r\n h = H / MAX_ROW;\r\n\r\n console.log('onSteup', props);\r\n\r\n const parent = new engine.Sprite();\r\n this.picturesWrapper = parent;\r\n this.addChild(parent);\r\n\r\n // this.picturesWrapper.x = OFFSET_X;\r\n // this.picturesWrapper.y = OFFSET_Y;\r\n\r\n // 添加按钮\r\n // const btn = new engine.Rect();\r\n // btn.width = 200;\r\n // btn.height = 100;\r\n // btn.stage.top = 1000;\r\n // btn.stage.left = 350;\r\n // btn.fillColor = 'cyan';\r\n // this.addChild(btn)\r\n\r\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\r\n\r\n }\r\n\r\n onDown(e: engine.MouseEvent) {\r\n // console.log(e);\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\r\n // 鼠标的偏移量\r\n this.localPicX = e.localX / MAX_COL;\r\n this.localPicY = e.localY / MAX_ROW;\r\n\r\n // 最开始图片的位置\r\n this.distanceX = this.dragPic.x;\r\n this.distanceY = this.dragPic.y;\r\n\r\n // 最开始点击的图片的索引值\r\n // this.indexI = this.distanceX / (w + GAP);\r\n // this.indexJ = this.distanceY / (h + GAP);\r\n // this.index = (this.indexI - 1) * MAX_COL + this.indexJ;\r\n\r\n\r\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\r\n this.indexI = Math.floor(this.distanceY / (h + GAP));\r\n this.index = (this.indexI) * MAX_COL + this.indexJ;\r\n\r\n\r\n\r\n\r\n // 图片的中心位置\r\n // this.centerX = e.clientX + w / 2;\r\n // this.centerY = e.clientY + h / 2;\r\n\r\n this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n this.centerY = Math.floor(e.clientY / h) * h + w / 2\r\n\r\n\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n this.stage.addEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n\r\n }\r\n\r\n stageOnUp(e) {\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\r\n );\r\n\r\n // 拖动的图片的中心位置在图片之外,回到原来的位置\r\n if (this.centerY < 0 || this.centerX < 0) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n this.picturesWrapper.addChild(this.guideHole);\r\n\r\n // 判断图片是否进入另一张图片的范围内\r\n // 要交换的图片第几行第几列\r\n let curJ = Math.floor(this.centerX / (w + GAP));\r\n let curI = Math.floor(this.centerY / (h + GAP));\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if (curJ < (MAX_COL) && curI < (MAX_ROW)) {\r\n\r\n // 获取交互图片的索引值\r\n let index = getIndexFromRC(curI, curJ, MAX_COL);\r\n // console.log(index);\r\n\r\n //要交换的图片\r\n let dropPic = this.pictures[index];\r\n\r\n let dropPicX = dropPic.x;\r\n let dropPicy = dropPic.y;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX;\r\n this.dragPic.y = dropPicy;\r\n\r\n // 交换之后索引也需要交换\r\n\r\n const dropPicIndex = this.pictures.indexOf(dropPic);\r\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\r\n\r\n this.pictures[dropPicIndex] = this.dragPic;\r\n this.pictures[dragPicIndex] = dropPic;\r\n\r\n // 图片中心还是在原来的位置\r\n if (dragPicIndex === dropPicIndex) {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n let result = true;\r\n for (let j = 0; j < this.rightList.length; j++) {\r\n if (this.rightList[j] != this.pictures[j]) {\r\n result = false;\r\n break;\r\n }\r\n }\r\n\r\n if (result) {\r\n this.onSuccess();\r\n\r\n }\r\n } else {\r\n this.dragPic.x = this.distanceX\r\n this.dragPic.y = this.distanceY\r\n }\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_UP,\r\n this.stageOnUp,\r\n this\r\n );\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: this._timeCounter });\r\n this.stop();\r\n }\r\n\r\n onMove(e: engine.MouseEvent) {\r\n // 当前图片的位置\r\n this.dragPic.x = e.stageX - this.localPicX - (750-props.W)/2;\r\n this.dragPic.y = e.stageY - this.localPicY - (this.stage.height - props.H) / 2;\r\n console.log('fuck on this.stage.height', this.stage.height)\r\n // console.log(this.dragPic.x, this.dragPic.y)\r\n\r\n // 当前图片的中心位置\r\n this.centerX = this.dragPic.x + w / 2;\r\n this.centerY = this.dragPic.y + h / 2;\r\n\r\n }\r\n\r\n // onClk(e){\r\n // // 重置时间\r\n // this._timeCounter = 0;\r\n // //重置图片顺序\r\n\r\n\r\n // }\r\n\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\r\n\r\n\t\t//创建实例\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tstop(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.stop();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;UAEX,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;UAEe,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;;CCZD,IAAM,MAAM,GAAG,EAAE,CAAC;CAClB,IAAM,MAAM,GAAG,EAAE,CAAC;AAClB,cAAe,UAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO;KAC3C,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;SACf,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;MAClC;KAED,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KAClB,IAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;KAEtB,IAAM,GAAG,GAAG,EAAE,CAAC;KACf,IAAM,GAAG,GAAG,EAAE,CAAA;6BAEL,GAAG;iCACD,GAAG;aAEV,IAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CA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;;;;;;;;"}
\ No newline at end of file
src/custom/pictures/meta.json
View file @
6d7c75d5
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
"default"
:
2
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
"default"
:
2
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -22,6 +22,16 @@
"type"
:
"number"
,
"default"
:
827
},
"OFFSET_X"
:
{
"alias"
:
"OFFSET_X"
,
"type"
:
"number"
,
"default"
:
0
},
"OFFSET_Y"
:
{
"alias"
:
"OFFSET_Y"
,
"type"
:
"number"
,
"default"
:
0
},
"GAP"
:
{
"alias"
:
"图片间隙"
,
"type"
:
"number"
,
...
...
@@ -30,7 +40,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
2
0
"default"
:
5
0
}
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
6d7c75d5
...
...
@@ -7,6 +7,8 @@ import qietu from "./qietu";
import
{
getIndexFromRC
,
getRandomArray
,
getTextureByName
}
from
"./utils"
;
import
ObjectPool
=
engine
.
ObjectPool
;
// let OFFSET_X;
// let OFFSET_Y;
let
MAX_COL
;
let
MAX_ROW
;
let
W
;
...
...
@@ -22,6 +24,13 @@ export default class GameView extends engine.Container {
private
_timeCounter
=
0
;
start
()
{
if
(
this
.
pictures
)
{
for
(
const
pic
of
this
.
pictures
)
{
if
(
pic
&&
pic
.
parent
)
pic
.
parent
.
removeChild
(
pic
);
}
}
console
.
log
(
'on start'
)
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
...
...
@@ -56,9 +65,9 @@ export default class GameView extends engine.Container {
}
//
this._timer = setInterval(() => {
//
this.onTimer();
//
}, 10)
this
.
_timer
=
setInterval
(()
=>
{
this
.
onTimer
();
},
10
)
}
...
...
@@ -67,7 +76,7 @@ export default class GameView extends engine.Container {
this
.
_timeCounter
+=
0.01
;
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
);
// this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;
console
.
log
(
this
.
_timeCounter
)
//
console.log(this._timeCounter)
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
...
...
@@ -81,12 +90,12 @@ export default class GameView extends engine.Container {
}
}
afterPointTwo
(
n
){
afterPointTwo
(
n
)
{
var
floatN
=
parseFloat
(
n
);
if
(
isNaN
(
floatN
))
{
return
;
if
(
isNaN
(
floatN
))
{
return
;
}
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
return
floatN
;
}
...
...
@@ -96,7 +105,6 @@ export default class GameView extends engine.Container {
}
stop
()
{
// this.countTime = 0
this
.
_timeCounter
=
0
;
clearInterval
(
this
.
_timer
);
...
...
@@ -119,7 +127,7 @@ export default class GameView extends engine.Container {
centerX
:
number
;
centerY
:
number
;
pictures
;
pictures
:
engine
.
Sprite
[]
;
// 点击图片时的一维数组索引
index
;
...
...
@@ -128,7 +136,7 @@ export default class GameView extends engine.Container {
indexJ
:
number
;
rightList
:
engine
.
Sprite
[];
private
picturesWrapper
:
engine
.
Sprite
;
private
guideHole
:
engine
.
Sprite
;
...
...
@@ -141,6 +149,8 @@ export default class GameView extends engine.Container {
MAX_COL
=
props
.
MAX_COL
;
MAX_ROW
=
props
.
MAX_ROW
;
GAME_TIME
=
props
.
GAME_TIME
;
// OFFSET_X = props.OFFSET_X;
// OFFSET_Y = props.OFFSET_Y;
W
=
props
.
W
;
H
=
props
.
H
;
GAP
=
props
.
GAP
;
...
...
@@ -155,6 +165,9 @@ export default class GameView extends engine.Container {
this
.
picturesWrapper
=
parent
;
this
.
addChild
(
parent
);
// this.picturesWrapper.x = OFFSET_X;
// this.picturesWrapper.y = OFFSET_Y;
// 添加按钮
// const btn = new engine.Rect();
// btn.width = 200;
...
...
@@ -223,19 +236,19 @@ export default class GameView extends engine.Container {
this
.
onMove
,
this
);
// 拖动的图片的中心位置在图片之外,回到原来的位置
if
(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
if
(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
))
;
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
))
;
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
// 点击图片的位置
...
...
@@ -267,7 +280,7 @@ export default class GameView extends engine.Container {
this
.
pictures
[
dragPicIndex
]
=
dropPic
;
// 图片中心还是在原来的位置
if
(
dragPicIndex
===
dropPicIndex
)
{
if
(
dragPicIndex
===
dropPicIndex
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
...
...
@@ -284,7 +297,7 @@ export default class GameView extends engine.Container {
this
.
onSuccess
();
}
}
else
{
}
else
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
...
...
@@ -298,14 +311,16 @@ export default class GameView extends engine.Container {
private
onSuccess
()
{
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
this
.
_timeCounter
});
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{});
}
onMove
(
e
:
engine
.
MouseEvent
)
{
// 当前图片的位置
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
;
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)
// 当前图片的中心位置
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
...
...
@@ -313,13 +328,13 @@ export default class GameView extends engine.Container {
}
onClk
(
e
){
// 重置时间
this
.
_timeCounter
=
0
;
//重置图片顺序
this
.
start
();
}
//
onClk(e){
//
// 重置时间
//
this._timeCounter = 0;
//
//重置图片顺序
//
}
}
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