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
21a3813f
Commit
21a3813f
authored
Aug 17, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://gitlab2.dui88.com/laoqifeng/zeroing-libs
into dev
parents
2a1e1b52
33823dbd
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
843 additions
and
2 deletions
+843
-2
p2demo.json
dist/customs/p2demo.json
+17
-0
pictures.json
dist/customs/pictures.json
+5
-2
app.js
src/custom/p2demo/debug/app.js
+81
-0
index.html
src/custom/p2demo/debug/index.html
+52
-0
load-assets.js
src/custom/p2demo/debug/load-assets.js
+52
-0
main.js
src/custom/p2demo/debug/main.js
+175
-0
main.js.map
src/custom/p2demo/debug/main.js.map
+1
-0
props.js
src/custom/p2demo/debug/props.js
+7
-0
meta.json
src/custom/p2demo/meta.json
+99
-0
GameView.ts
src/custom/p2demo/src/game/GameView.ts
+160
-0
GameWrapper.ts
src/custom/p2demo/src/game/GameWrapper.ts
+39
-0
object-pool-init.ts
src/custom/p2demo/src/game/object-pool-init.ts
+14
-0
qietu.ts
src/custom/p2demo/src/game/qietu.ts
+55
-0
utils.ts
src/custom/p2demo/src/game/utils.ts
+35
-0
index.ts
src/custom/p2demo/src/index.ts
+15
-0
props.ts
src/custom/p2demo/src/props.ts
+15
-0
app.js
src/custom/pictures/debug/app.js
+6
-0
main.js
src/custom/pictures/debug/main.js
+3
-0
main.js.map
src/custom/pictures/debug/main.js.map
+4
-0
GameView.ts
src/custom/pictures/src/game/GameView.ts
+8
-0
No files found.
dist/customs/p2demo.json
View file @
21a3813f
...
...
@@ -45,10 +45,23 @@
},
"assets"
:
[
{
<<<<<<<
HEAD
"name"
:
"遮罩"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png"
,
"uuid"
:
"888"
,
"ext"
:
".png"
=======
"name"
:
"block"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/f91184b338ef9540b167eebe7d58e71402e8d9d9.png"
,
"uuid"
:
"888"
,
"ext"
:
".png"
},
{
"name"
:
"ball"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png"
,
"uuid"
:
"999"
,
"ext"
:
".png"
>>>>>>>
33823
dbdb
9
c
3
b
079
aa
71
a
545
ab
5472146
df
6429
b
}
],
"events"
:
{
...
...
@@ -89,5 +102,9 @@
}
},
"id"
:
"p2demo"
,
<<<<<<<
HEAD
"code"
:
"(function (global, factory) {
\n
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n
(global = global || self, global.p2demo = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n
var GameView = (function (_super) {
\r\n
tslib.__extends(GameView, _super);
\r\n
function GameView() {
\r\n
var _this = _super.call(this) || this;
\r\n
_this.factor = 10;
\r\n
_this.isDebug = 1;
\r\n
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\r\n
return _this;
\r\n
}
\r\n
GameView.prototype.createBall = function (r) {
\r\n
var shape = new engine.Shape();
\r\n
shape.beginFill(0xfff000);
\r\n
shape.drawCircle(0, 0, r);
\r\n
shape.endFill();
\r\n
return shape;
\r\n
};
\r\n
GameView.prototype.start = function () {
\r\n
console.log('start');
\r\n
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
\r\n
};
\r\n
GameView.prototype.createBox = function (width, height) {
\r\n
var shape = new engine.Shape();
\r\n
shape.beginFill(0xfff000);
\r\n
shape.drawRect(-width / 2, -height / 2, width, height);
\r\n
shape.endFill();
\r\n
return shape;
\r\n
};
\r\n
GameView.prototype.onClick = function (e) {
\r\n
var _a = this, world = _a.world, factor = _a.factor;
\r\n
var positionX = (e.stageX / factor);
\r\n
var positionY = ((engine.gameStage.stage.height - e.stageY) / factor);
\r\n
var display;
\r\n
if (Math.random() > .5) {
\r\n
var boxShape = new p2.Box({ width: 200 / factor, height: 100 / factor });
\r\n
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });
\r\n
boxBody.addShape(boxShape);
\r\n
world.addBody(boxBody);
\r\n
if (this.isDebug) {
\r\n
display = this.createBox(boxShape.width * factor, boxShape.height * factor);
\r\n
}
\r\n
}
\r\n
else {
\r\n
var boxShape = new p2.Circle({ radius: 200 / 2 / factor });
\r\n
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY] });
\r\n
boxBody.addShape(boxShape);
\r\n
world.addBody(boxBody);
\r\n
if (this.isDebug) {
\r\n
display = this.createBall(boxShape.radius * factor);
\r\n
}
\r\n
}
\r\n
boxBody.displays = [display];
\r\n
this.addChild(display);
\r\n
};
\r\n
GameView.prototype.setup = function () {
\r\n
console.log('setup');
\r\n
var world = new p2.World({});
\r\n
world.sleepMode = p2.World.BODY_SLEEPING;
\r\n
var planeShape = new p2.Plane();
\r\n
var planeBody = new p2.Body();
\r\n
planeBody.addShape(planeShape);
\r\n
planeBody.displays = [];
\r\n
world.addBody(planeBody);
\r\n
this.world = world;
\r\n
this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\r\n
};
\r\n
GameView.prototype.onEnterFrame = function () {
\r\n
var _a = this, world = _a.world, factor = _a.factor;
\r\n
world.step(60 / 1000);
\r\n
var stageHeight = engine.gameStage.stage.height;
\r\n
var l = world.bodies.length;
\r\n
for (var i = 0; i < l; i++) {
\r\n
var boxBody = world.bodies[i];
\r\n
var box = boxBody.displays[0];
\r\n
if (box) {
\r\n
box.x = boxBody.position[0] * factor;
\r\n
box.y = stageHeight - boxBody.position[1] * factor;
\r\n
box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;
\r\n
if (boxBody.sleepState == p2.Body.SLEEPING) {
\r\n
box.alpha = 0.5;
\r\n
}
\r\n
else {
\r\n
box.alpha = 1;
\r\n
}
\r\n
}
\r\n
}
\r\n
};
\r\n
return GameView;
\r\n
}(engine.Container));
\n\n
var props = {};
\r\n
function prepareProps() {
\r\n
var metaProps = getProps();
\r\n
engine.injectProp(props, metaProps);
\r\n
}
\r\n
function injectProps(p) {
\r\n
engine.injectProp(props, p);
\r\n
}
\n\n
var GameWrapper = (function (_super) {
\r\n
tslib.__extends(GameWrapper, _super);
\r\n
function GameWrapper() {
\r\n
var _this = _super.call(this) || this;
\r\n
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
\r\n
engine.globalEvent.addEventListener('pictures-stop', _this.stop, _this);
\r\n
var gameView = _this._gameView = new GameView();
\r\n
_this.addChild(gameView);
\r\n
return _this;
\r\n
}
\r\n
GameWrapper.prototype.start = function (event) {
\r\n
injectProps(event.data);
\r\n
this._gameView.start();
\r\n
};
\r\n
GameWrapper.prototype.stop = function (event) {
\r\n
};
\r\n
return GameWrapper;
\r\n
}(engine.Container));
\n\n
function index (props) {
\r\n
prepareProps();
\r\n
injectProps(props);
\r\n
var instance = new GameWrapper();
\r\n
return instance;
\r\n
}
\n\n
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.p2demo = 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
var OptionState;
\n\t
(function (OptionState) {
\n\t
OptionState[OptionState[
\"
CHOICE_RIGHT
\"
] = 0] =
\"
CHOICE_RIGHT
\"
;
\n\t
OptionState[OptionState[
\"
CHOICE_WRONG
\"
] = 1] =
\"
CHOICE_WRONG
\"
;
\n\t
OptionState[OptionState[
\"
CHOICE_SELECT
\"
] = 2] =
\"
CHOICE_SELECT
\"
;
\n\t
})(OptionState || (OptionState = {}));
\n\t
var GameState;
\n\t
(function (GameState) {
\n\t
GameState[GameState[
\"
STATE_START
\"
] = 0] =
\"
STATE_START
\"
;
\n\t
GameState[GameState[
\"
STATE_END
\"
] = 1] =
\"
STATE_END
\"
;
\n\t
})(GameState || (GameState = {}));
\n\t
//# sourceMappingURL=utils.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.factor = 10;
\n\t
_this.isDebug = 0;
\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\n\t
return _this;
\n\t
}
\n\t
GameView.prototype.createBall = function (r) {
\n\t
var shape = new engine.Shape();
\n\t
shape.beginFill(0xfff000);
\n\t
shape.drawCircle(0, 0, r);
\n\t
shape.endFill();
\n\t
return shape;
\n\t
};
\n\t
GameView.prototype.start = function () {
\n\t
console.log('start');
\n\t
this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);
\n\t
};
\n\t
GameView.prototype.createBitmapByName = function (name) {
\n\t
var imgContainer = new engine.Sprite();
\n\t
var img = new engine.Sprite(getTextureByName(name));
\n\t
img.anchorX = img.width / 2;
\n\t
img.anchorY = img.height / 2;
\n\t
img.x = -img.width / 2;
\n\t
img.y = -img.height / 2;
\n\t
imgContainer.addChild(img);
\n\t
return imgContainer;
\n\t
};
\n\t
GameView.prototype.createBox = function (width, height) {
\n\t
var shape = new engine.Shape();
\n\t
shape.beginFill(0xfff000);
\n\t
shape.drawRect(-width / 2, -height / 2, width, height);
\n\t
shape.endFill();
\n\t
return shape;
\n\t
};
\n\t
GameView.prototype.onClick = function (e) {
\n\t
var _a = this, world = _a.world, factor = _a.factor;
\n\t
var positionX = (e.stageX / factor);
\n\t
var positionY = ((engine.gameStage.stage.height - e.stageY) / factor);
\n\t
var display;
\n\t
if (Math.random() > .5) {
\n\t
var boxShape = new p2.Box({ width: 306 / factor, height: 172 / factor });
\n\t
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });
\n\t
boxBody.addShape(boxShape);
\n\t
world.addBody(boxBody);
\n\t
if (this.isDebug) {
\n\t
display = this.createBox(boxShape.width * factor, boxShape.height * factor);
\n\t
}
\n\t
else {
\n\t
display = this.createBitmapByName(
\"
block
\"
);
\n\t
}
\n\t
}
\n\t
else {
\n\t
var boxShape = new p2.Circle({ radius: 120 / 2 / factor });
\n\t
var boxBody = new p2.Body({ mass: 1, position: [positionX, positionY] });
\n\t
boxBody.addShape(boxShape);
\n\t
world.addBody(boxBody);
\n\t
if (this.isDebug) {
\n\t
display = this.createBall(boxShape.radius * factor);
\n\t
}
\n\t
else {
\n\t
display = this.createBitmapByName(
\"
ball
\"
);
\n\t
}
\n\t
}
\n\t
boxBody.displays = [display];
\n\t
this.addChild(display);
\n\t
};
\n\t
GameView.prototype.setup = function () {
\n\t
console.log('setup');
\n\t
var world = new p2.World({
\n\t
gravity: [0, -10],
\n\t
});
\n\t
world.sleepMode = p2.World.BODY_SLEEPING;
\n\t
var planeShape = new p2.Plane();
\n\t
var planeBody = new p2.Body();
\n\t
planeBody.addShape(planeShape);
\n\t
planeBody.displays = [];
\n\t
world.addBody(planeBody);
\n\t
this.world = world;
\n\t
this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
GameView.prototype.onEnterFrame = function () {
\n\t
var _a = this, world = _a.world, factor = _a.factor;
\n\t
world.step(60 / 1000);
\n\t
var stageHeight = engine.gameStage.stage.height;
\n\t
var l = world.bodies.length;
\n\t
for (var i = 0; i < l; i++) {
\n\t
var boxBody = world.bodies[i];
\n\t
var box = boxBody.displays[0];
\n\t
if (box) {
\n\t
box.x = boxBody.position[0] * factor;
\n\t
box.y = stageHeight - boxBody.position[1] * factor;
\n\t
box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;
\n\t
if (boxBody.sleepState == p2.Body.SLEEPING) {
\n\t
box.alpha = 0.5;
\n\t
}
\n\t
else {
\n\t
box.alpha = 1;
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
return GameView;
\n\t
}(engine.Container));
\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 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('pictures-start', _this.start, _this);
\n\t
engine.globalEvent.addEventListener('pictures-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
};
\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
"
>>>>>>>
33823
dbdb
9
c
3
b
079
aa
71
a
545
ab
5472146
df
6429
b
}
dist/customs/pictures.json
View file @
21a3813f
...
...
@@ -57,7 +57,10 @@
"alias"
:
"开始"
,
"data"
:
{
"picUrl"
:
"图片路径"
,
"blockUrl"
:
"blockUrl"
"blockUrl"
:
"blockUrl"
,
"row"
:
"行"
,
"column"
:
"列"
,
"gameTime"
:
"游戏时间"
}
},
"pictures-stop"
:
{
...
...
@@ -86,5 +89,5 @@
}
},
"id"
:
"pictures"
,
"code"
:
"
\"
use strict
\"
;var tslib=require(
\"
tslib
\"
),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],g=[],s=0;s<a;s++)!function(s){for(var t=0;t<o;t++)!function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),g.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})}(t)}(s);return picMap[r]=d.concat([]),posMap[r]=g.concat([]),[d,g]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source=
\"
asset://
\"
+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log(
\"
on start
\"
),engine.globalEvent.dispatchEvent(
\"
pictures-time-update
\"
,{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);for(var o=0,a=this.pictures.length;o<a;o++){this.dragPic=this.pictures[o],this.pictures[o].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[o],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10),this.date=(new Date).getTime()},t.prototype.onTimer=function(){var t=(new Date).getTime(),e=(t-this.date)/1e3;this.date=t,console.log(e,
\"
gap
\"
),(GAME_TIME-=e)<0&&(GAME_TIME=0),(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME=
\"
0
\"
+GAME_TIME),console.log(GAME_TIME),engine.globalEvent.dispatchEvent(
\"
pictures-time-update
\"
,{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(
\"
pictures-game-fail
\"
,{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer);for(var t=this.pictures.length,e=0;e<t;e++)this.pictures[e].removeAllEventListener();this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log(
\"
onSteup
\"
,props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor((t.clientX-e)/w)*w+w/2,this.centerY=Math.floor((t.clientY-i)/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){var e=(750-props.W)/2,i=(this.stage.height-props.H)/2;this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<i||this.centerX<e)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);var s=Math.floor(this.centerX/(w+GAP)),n=Math.floor(this.centerY/(h+GAP));if(this.picturesWrapper.addChild(this.guideHole),0<=s&&s<MAX_COL&&0<=n&&n<MAX_ROW){var r=getIndexFromRC(n,s,MAX_COL),o=this.pictures[r],a=o.x+e,p=o.y+i;o.x=this.distanceX,o.y=this.distanceY,this.dragPic.x=a-e,this.dragPic.y=p-i;var c=this.pictures.indexOf(o),d=this.pictures.indexOf(this.dragPic);this.pictures[c]=this.dragPic,this.pictures[d]=o,d===c&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var g=!0,u=0;u<this.rightList.length;u++)if(this.rightList[u]!=this.pictures[u]){g=!1;break}g&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log(
\"
拼图成功!
\"
),engine.globalEvent.dispatchEvent(
\"
pictures-game-success
\"
,{time:GAME_TIME}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener(
\"
pictures-start
\"
,t.start,t),engine.globalEvent.addEventListener(
\"
pictures-stop
\"
,t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index
;
\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
}
\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
var pics = picMap[url];
\r\n\t
for (var _i = 0, pics_1 = pics; _i < pics_1.length; _i++) {
\r\n\t
var pic = pics_1[_i];
\r\n\t
parent.addChild(pic);
\r\n\t
}
\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 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.listenStageOn = 1;
\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
MAX_COL = props.column || props.MAX_COL;
\r\n\t
MAX_ROW = props.row || props.MAX_ROW;
\r\n\t
GAME_TIME = props.gameTime || props.GAME_TIME;
\r\n\t
console.log('start', props.column, props.row, props.gameTime);
\r\n\t
if (!this.guideHole) {
\r\n\t
this.guideHole = new engine.Image();
\r\n\t
this.guideHole.source = 'asset://' + props.blockUrl;
\r\n\t
this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;
\r\n\t
}
\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.wrapper)
\r\n\t
pic.wrapper.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
this.date = new Date().getTime();
\r\n\t
};
\r\n\t
GameView.prototype.onTimer = function () {
\r\n\t
var date = new Date().getTime();
\r\n\t
var gap = ((date - this.date) / 1000);
\r\n\t
this.date = date;
\r\n\t
console.log(gap,
\"
gap
\"
);
\r\n\t
GAME_TIME -= gap;
\r\n\t
if (GAME_TIME < 0) {
\r\n\t
GAME_TIME = 0;
\r\n\t
}
\r\n\t
GAME_TIME = this.afterPointTwo(GAME_TIME);
\r\n\t
GAME_TIME = GAME_TIME.toFixed(2);
\r\n\t
if (GAME_TIME < 10) {
\r\n\t
GAME_TIME = '0' + GAME_TIME;
\r\n\t
}
\r\n\t
console.log(GAME_TIME);
\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;
\r\n\t
};
\r\n\t
GameView.prototype.stop = function () {
\r\n\t
GAME_TIME = props.GAME_TIME;
\r\n\t
clearInterval(this._timer);
\r\n\t
var len = this.pictures.length;
\r\n\t
for (var i = 0; i < len; i++) {
\r\n\t
this.pictures[i].removeAllEventListener();
\r\n\t
}
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
};
\r\n\t
GameView.prototype.createRects = function () { };
\r\n\t
GameView.prototype.setup = function () {
\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
var stageLeft = (750 - props.W) / 2;
\r\n\t
var stageTop = (this.stage.height - props.H) / 2;
\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 - stageLeft) / w) * w + w / 2;
\r\n\t
this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 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
var stageLeft = (750 - props.W) / 2;
\r\n\t
var stageTop = (this.stage.height - props.H) / 2;
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMove, this);
\r\n\t
this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP, this.stageOnUp, this);
\r\n\t
if (this.centerY < stageTop || this.centerX < stageLeft) {
\r\n\t
this.dragPic.x = this.distanceX;
\r\n\t
this.dragPic.y = this.distanceY;
\r\n\t
}
\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
this.picturesWrapper.addChild(this.guideHole);
\r\n\t
if (0 <= curJ && curJ < (MAX_COL) && 0 <= curI && 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 + stageLeft;
\r\n\t
var dropPicy = dropPic.y + stageTop;
\r\n\t
dropPic.x = this.distanceX;
\r\n\t
dropPic.y = this.distanceY;
\r\n\t
this.dragPic.x = dropPicX - stageLeft;
\r\n\t
this.dragPic.y = dropPicy - stageTop;
\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
};
\r\n\t
GameView.prototype.onSuccess = function () {
\r\n\t
console.log('拼图成功!');
\r\n\t
engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });
\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
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));
\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
"
}
src/custom/p2demo/debug/app.js
0 → 100644
View file @
21a3813f
/**
* Created by renjianfeng on 2020-03-13.
*/
const
customId
=
'p2demo'
;
(
async
function
()
{
let
customModule
=
await
fetch
(
`../meta.json`
);
customModule
=
await
customModule
.
json
();
console
.
log
(
customModule
);
await
loadAssets
(
customModule
.
assets
);
launchWithCustomModule
(
customModule
);
})();
function
launchWithCustomModule
(
customModule
)
{
//engine.registerCustomCodeModule(customModule);
engine
.
registerCustomModule
(
customId
,
window
[
customId
]);
const
{
props
:
propsOption
,
assets
}
=
customModule
;
let
props
=
engine
.
computeProps
(
customModuleProps
,
propsOption
);
const
customModuleIns
=
{
id
:
customId
,
props
,
assets
,
};
engine
.
registerCustomModules
([
customModuleIns
]);
engine
.
launchWithConfig
({
options
:
{
entrySceneView
:
'entry'
,
},
assets
:
[],
views
:
[{
name
:
'entry'
,
type
:
'node'
,
properties
:
{
x
:
0
,
y
:
0
,
}
}],
customs
:
[],
},
null
,
function
()
{
setTimeout
(()
=>
{
engine
.
addCustomModule
(
customId
,
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
));
},
100
);
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'pictures-start'
,
{
});
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
},
100
);
// 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"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
// console.log(e.type, e.data);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-game-fail'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-game-success'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
});
}
function
getAssetByUUID
(
uuid
)
{
return
engine
.
resolveCustomAsset
(
customId
,
uuid
);
}
function
getProps
()
{
return
engine
.
getProps
(
customId
);
}
src/custom/p2demo/debug/index.html
0 → 100644
View file @
21a3813f
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
美食从天而降
</title>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
/>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
/>
<meta
name=
"full-screen"
content=
"true"
/>
<meta
name=
"screen-orientation"
content=
"portrait"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"360-fullscreen"
content=
"true"
/>
<style>
html
,
body
{
padding
:
0
;
margin
:
0
;
border
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
absolute
;
background-color
:
gray
;
}
.game-container
{
width
:
100%
;
height
:
100%
;
line-height
:
0
;
font-size
:
0
;
}
</style>
</head>
<body>
<div
id=
"game-container"
class=
"game-container"
></div>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/engine.1de84ff79dba19e949088de63aa75af51a515e5c.js"
></script>
<script
crossorigin=
"anonymous"
src=
"//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"
></script>
<script
src=
"//yun.duiba.com.cn/js-libs/p2.js/0.7.1/p2.min.js"
></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script
src=
"app.js"
></script>
<script
src=
"props.js"
></script>
<script
src=
"load-assets.js"
></script>
<script
src=
"main.js"
></script>
<script>
</script>
</body>
\ No newline at end of file
src/custom/p2demo/debug/load-assets.js
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-01-21.
*/
const
assets
=
[
{
"name"
:
"玩家icon"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png"
,
"uuid"
:
"888"
,
"ext"
:
".png"
},
{
"name"
:
"雨滴"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png"
,
"uuid"
:
"264a6192-d7bf-45e8-8f15-6ba2c439a532"
,
"ext"
:
".png"
},
{
"name"
:
"炸弹"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png"
,
"uuid"
:
"eb88b42d-e151-4c1b-94b9-7c16f7bfac29"
,
"ext"
:
".png"
},
{
"name"
:
"石块"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png"
,
"uuid"
:
"ab1bdabc-21ba-46bf-9299-6c638f766c88"
,
"ext"
:
".png"
},
{
"name"
:
"水花"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga"
,
"uuid"
:
"b521bf94-20e1-44dd-8eca-d24996cbaeae"
,
"ext"
:
".svga"
},
{
"name"
:
"炸弹"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga"
,
"uuid"
:
"322edf39-805b-4e84-9d07-5573dfeebc0e"
,
"ext"
:
".svga"
},
{
"name"
:
"玩家"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga"
,
"uuid"
:
"71d8dcbc-3931-471a-b585-b3ae01b25aa6"
,
"ext"
:
".svga"
}
];
function
loadAssets
(
customModuleAssets
,
onProgress
,
onComplete
){
return
engine
.
loadAssets
(
assets
.
concat
(...
customModuleAssets
),
onProgress
,
onComplete
);
}
src/custom/p2demo/debug/main.js
0 → 100644
View file @
21a3813f
(
function
(
global
,
factory
)
{
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
(
require
(
'tslib'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'tslib'
],
factory
)
:
(
global
=
global
||
self
,
global
.
p2demo
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
var
OptionState
;
(
function
(
OptionState
)
{
OptionState
[
OptionState
[
"CHOICE_RIGHT"
]
=
0
]
=
"CHOICE_RIGHT"
;
OptionState
[
OptionState
[
"CHOICE_WRONG"
]
=
1
]
=
"CHOICE_WRONG"
;
OptionState
[
OptionState
[
"CHOICE_SELECT"
]
=
2
]
=
"CHOICE_SELECT"
;
})(
OptionState
||
(
OptionState
=
{}));
var
GameState
;
(
function
(
GameState
)
{
GameState
[
GameState
[
"STATE_START"
]
=
0
]
=
"STATE_START"
;
GameState
[
GameState
[
"STATE_END"
]
=
1
]
=
"STATE_END"
;
})(
GameState
||
(
GameState
=
{}));
//# sourceMappingURL=utils.js.map
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
factor
=
10
;
_this
.
isDebug
=
0
;
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
return
_this
;
}
GameView
.
prototype
.
createBall
=
function
(
r
)
{
var
shape
=
new
engine
.
Shape
();
shape
.
beginFill
(
0xfff000
);
shape
.
drawCircle
(
0
,
0
,
r
);
shape
.
endFill
();
return
shape
;
};
GameView
.
prototype
.
start
=
function
()
{
console
.
log
(
'start'
);
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
onClick
,
this
);
};
GameView
.
prototype
.
createBitmapByName
=
function
(
name
)
{
var
imgContainer
=
new
engine
.
Sprite
();
var
img
=
new
engine
.
Sprite
(
getTextureByName
(
name
));
img
.
anchorX
=
img
.
width
/
2
;
img
.
anchorY
=
img
.
height
/
2
;
img
.
x
=
-
img
.
width
/
2
;
img
.
y
=
-
img
.
height
/
2
;
imgContainer
.
addChild
(
img
);
return
imgContainer
;
};
GameView
.
prototype
.
createBox
=
function
(
width
,
height
)
{
var
shape
=
new
engine
.
Shape
();
shape
.
beginFill
(
0xfff000
);
shape
.
drawRect
(
-
width
/
2
,
-
height
/
2
,
width
,
height
);
shape
.
endFill
();
return
shape
;
};
GameView
.
prototype
.
onClick
=
function
(
e
)
{
var
_a
=
this
,
world
=
_a
.
world
,
factor
=
_a
.
factor
;
var
positionX
=
(
e
.
stageX
/
factor
);
var
positionY
=
((
engine
.
gameStage
.
stage
.
height
-
e
.
stageY
)
/
factor
);
var
display
;
if
(
Math
.
random
()
>
.
5
)
{
var
boxShape
=
new
p2
.
Box
({
width
:
306
/
factor
,
height
:
172
/
factor
});
var
boxBody
=
new
p2
.
Body
({
mass
:
1
,
position
:
[
positionX
,
positionY
],
angularVelocity
:
1
});
boxBody
.
addShape
(
boxShape
);
world
.
addBody
(
boxBody
);
if
(
this
.
isDebug
)
{
display
=
this
.
createBox
(
boxShape
.
width
*
factor
,
boxShape
.
height
*
factor
);
}
else
{
display
=
this
.
createBitmapByName
(
"block"
);
}
}
else
{
var
boxShape
=
new
p2
.
Circle
({
radius
:
120
/
2
/
factor
});
var
boxBody
=
new
p2
.
Body
({
mass
:
1
,
position
:
[
positionX
,
positionY
]
});
boxBody
.
addShape
(
boxShape
);
world
.
addBody
(
boxBody
);
if
(
this
.
isDebug
)
{
display
=
this
.
createBall
(
boxShape
.
radius
*
factor
);
}
else
{
display
=
this
.
createBitmapByName
(
"ball"
);
}
}
boxBody
.
displays
=
[
display
];
this
.
addChild
(
display
);
};
GameView
.
prototype
.
setup
=
function
()
{
console
.
log
(
'setup'
);
var
world
=
new
p2
.
World
({
gravity
:
[
0
,
-
10
],
});
world
.
sleepMode
=
p2
.
World
.
BODY_SLEEPING
;
var
planeShape
=
new
p2
.
Plane
();
var
planeBody
=
new
p2
.
Body
();
planeBody
.
addShape
(
planeShape
);
planeBody
.
displays
=
[];
world
.
addBody
(
planeBody
);
this
.
world
=
world
;
this
.
stage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
};
GameView
.
prototype
.
onEnterFrame
=
function
()
{
var
_a
=
this
,
world
=
_a
.
world
,
factor
=
_a
.
factor
;
world
.
step
(
60
/
1000
);
var
stageHeight
=
engine
.
gameStage
.
stage
.
height
;
var
l
=
world
.
bodies
.
length
;
for
(
var
i
=
0
;
i
<
l
;
i
++
)
{
var
boxBody
=
world
.
bodies
[
i
];
var
box
=
boxBody
.
displays
[
0
];
if
(
box
)
{
box
.
x
=
boxBody
.
position
[
0
]
*
factor
;
box
.
y
=
stageHeight
-
boxBody
.
position
[
1
]
*
factor
;
box
.
rotation
=
360
-
(
boxBody
.
angle
+
boxBody
.
shapes
[
0
].
angle
)
*
180
/
Math
.
PI
;
if
(
boxBody
.
sleepState
==
p2
.
Body
.
SLEEPING
)
{
box
.
alpha
=
0.5
;
}
else
{
box
.
alpha
=
1
;
}
}
}
};
return
GameView
;
}(
engine
.
Container
));
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
function
GameWrapper
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
'pictures-start'
,
_this
.
start
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'pictures-stop'
,
_this
.
stop
,
_this
);
var
gameView
=
_this
.
_gameView
=
new
GameView
();
_this
.
addChild
(
gameView
);
return
_this
;
}
GameWrapper
.
prototype
.
start
=
function
(
event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
start
();
};
GameWrapper
.
prototype
.
stop
=
function
(
event
)
{
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/p2demo/debug/main.js.map
0 → 100644
View file @
21a3813f
{"version":3,"file":"index.js","sources":["src/custom/answer-game/src/game/utils.ts","src/custom/p2demo/src/game/GameView.ts","src/custom/p2demo/src/props.ts","src/custom/p2demo/src/game/GameWrapper.ts","src/custom/p2demo/src/index.ts"],"sourcesContent":["\n/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function getStage(){\n\treturn engine.gameStage.stage;\n}\n\n\nexport enum OptionState{\n\tCHOICE_RIGHT,//选对\n\tCHOICE_WRONG,//选错\n\tCHOICE_SELECT,//选中\n}\n\nexport enum GameState{\n\tSTATE_START,//开始 选择中\n\tSTATE_END,//倒计时结束\n}","import { Tool } from \"../../../seabed-game/src/game/Tools\";\nimport { getTextureByName } from \"../../../answer-game/src/game/utils\";\n\nexport default class GameView extends engine.Container {\n world: p2.World;\n factor: number = 10;\n isDebug = 0;\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n private createBall(r: number) {\n var shape = new engine.Shape();\n shape.beginFill(0xfff000);\n shape.drawCircle(0, 0, r);\n shape.endFill();\n return shape;\n }\n\n start() {\n console.log('start');\n this.stage.addEventListener(engine.MouseEvent.CLICK, this.onClick, this);\n }\n\n createBitmapByName(name) {\n const imgContainer = new engine.Sprite();\n const img = new engine.Sprite(getTextureByName(name));\n img.anchorX = img.width / 2;\n img.anchorY = img.height / 2;\n img.x = -img.width / 2;\n img.y = -img.height / 2;\n imgContainer.addChild(img);\n return imgContainer\n }\n\n private createBox(width: number, height: number): engine.Shape {\n var shape = new engine.Shape();\n shape.beginFill(0xfff000);\n shape.drawRect(-width / 2, -height / 2, width, height);\n shape.endFill();\n return shape;\n }\n\n onClick(e: engine.MouseEvent) {\n\n // const ball = this.createBitmapByName('ball');\n // this.addChild(ball);\n // engine.Tween.get(ball, { loop: true }).to({ rotation: 360 }, 1000);\n // return;\n\n // const box = this.createBitmapByName('block');\n // this.addChild(box);\n // engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000);\n // return;\n\n // const box = this.createBox(750, 100)\n // this.addChild(box);\n // box.x = 750/2;\n // box.y = 1624/2;\n // engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000)\n // return;\n\n // const ball = this.createBall(750/2);\n // this.addChild(ball);\n // ball.x = e.stageX;\n // ball.y = e.stageY;\n // return;\n const { world, factor } = this;\n var positionX: number = (e.stageX / factor);\n var positionY: number = ((engine.gameStage.stage.height - e.stageY) / factor);\n var display: engine.DisplayObject;\n\n if (Math.random() > .5) {\n //添加方形刚体\n var boxShape: p2.Shape = new p2.Box({ width: 306 / factor, height: 172 / factor });\n var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY], angularVelocity: 1 });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n if (this.isDebug) {\n display = this.createBox((<p2.Box>boxShape).width * factor, (<p2.Box>boxShape).height * factor);\n } else {\n display = this.createBitmapByName(\"block\");\n }\n }\n else {\n //添加圆形刚体\n var boxShape: p2.Shape = new p2.Circle({ radius: 120 / 2 / factor });\n var boxBody: p2.Body = new p2.Body({ mass: 1, position: [positionX, positionY] });\n boxBody.addShape(boxShape);\n world.addBody(boxBody);\n\n if (this.isDebug) {\n display = this.createBall((<p2.Circle>boxShape).radius * factor);\n } else {\n display = this.createBitmapByName(\"ball\");\n }\n\n // display.width = (<p2.Circle>boxShape).radius * 2 * factor;\n // display.height = (<p2.Circle>boxShape).radius * 2 * factor;\n\n }\n\n // display.anchorX = display.width / 2;\n // display.anchorY = display.height / 2;\n\n boxBody.displays = [display];\n\n this.addChild(display);\n\n }\n\n setup() {\n console.log('setup');\n\n //创建world\n var world: p2.World = new p2.World({\n gravity: [0, -10],\n });\n\n world.sleepMode = p2.World.BODY_SLEEPING;\n\n //创建plane\n var planeShape: p2.Plane = new p2.Plane();\n var planeBody: p2.Body = new p2.Body();\n planeBody.addShape(planeShape);\n planeBody.displays = [];\n world.addBody(planeBody);\n this.world = world;\n\n this.stage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this)\n }\n\n onEnterFrame() {\n const { world, factor } = this;\n world.step(60 / 1000);\n const stageHeight = engine.gameStage.stage.height;\n var l = world.bodies.length;\n\n for (var i: number = 0; i < l; i++) {\n var boxBody: p2.Body = world.bodies[i];\n var box = boxBody.displays[0];\n if (box) {\n box.x = boxBody.position[0] * factor;\n box.y = stageHeight - boxBody.position[1] * factor;\n\n box.rotation = 360 - (boxBody.angle + boxBody.shapes[0].angle) * 180 / Math.PI;\n if (boxBody.sleepState == p2.Body.SLEEPING) {\n box.alpha = 0.5;\n }\n else {\n box.alpha = 1;\n }\n }\n }\n\n }\n\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport { injectProps } from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\t// private _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('pictures-stop', this.stop, this);\n\n\t\t//创建实例\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\n\t\t// this._status = 1;\n\n\t\tthis._gameView.start();\n\t}\n\tstop(event: engine.Event) {\n\t\t\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\t\n\treturn instance;\n}\n"],"names":["__extends"],"mappings":";;;;;;UA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E,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;MAEvB;KACF,kBAAC;CAAD,CAAC,CA9BgC,MAAM,CAAC,SAAS,GA8BhD;;;iBC/BwB,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
src/custom/p2demo/debug/props.js
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-01-21.
*/
let
customModuleProps
=
{
};
src/custom/p2demo/meta.json
0 → 100644
View file @
21a3813f
{
"name"
:
"拼图"
,
"desc"
:
"拼图模块1.0"
,
"props"
:
{
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
},
"W"
:
{
"alias"
:
"图片的宽度"
,
"type"
:
"number"
,
"default"
:
618
},
"H"
:
{
"alias"
:
"图片的高度"
,
"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"
,
"default"
:
0
},
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
10
}
},
"assets"
:
[
{
"name"
:
"block"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/f91184b338ef9540b167eebe7d58e71402e8d9d9.png"
,
"uuid"
:
"888"
,
"ext"
:
".png"
},
{
"name"
:
"ball"
,
"url"
:
"//yun.duiba.com.cn/aurora/assets/3dc11f2d91659b7e7e1d06a9853cbc9f818e1ea2.png"
,
"uuid"
:
"999"
,
"ext"
:
".png"
}
],
"events"
:
{
"in"
:
{
"pictures-start"
:
{
"alias"
:
"开始"
,
"data"
:
{
"picUrl"
:
"图片路径"
,
"blockUrl"
:
"blockUrl"
,
"row"
:
"行"
,
"column"
:
"列"
,
"gameTime"
:
"游戏时间"
}
},
"pictures-stop"
:
{
"alias"
:
"停止"
}
},
"out"
:
{
"pictures-time-update"
:
{
"alias"
:
"倒计时更新"
,
"data"
:
{
"time"
:
"剩余时间"
}
},
"pictures-game-fail"
:
{
"alias"
:
"游戏结束"
,
"data"
:
{
"reason"
:
"结束原因(1:时间到了)"
}
},
"pictures-game-success"
:
{
"alias"
:
"游戏成功"
,
"data"
:
{
"time"
:
"游戏消耗时间"
}
}
}
}
}
\ No newline at end of file
src/custom/p2demo/src/game/GameView.ts
0 → 100644
View file @
21a3813f
import
{
Tool
}
from
"../../../seabed-game/src/game/Tools"
;
import
{
getTextureByName
}
from
"../../../answer-game/src/game/utils"
;
export
default
class
GameView
extends
engine
.
Container
{
world
:
p2
.
World
;
factor
:
number
=
10
;
isDebug
=
0
;
constructor
()
{
super
();
this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
this
.
setup
,
this
);
}
private
createBall
(
r
:
number
)
{
var
shape
=
new
engine
.
Shape
();
shape
.
beginFill
(
0xfff000
);
shape
.
drawCircle
(
0
,
0
,
r
);
shape
.
endFill
();
return
shape
;
}
start
()
{
console
.
log
(
'start'
);
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
CLICK
,
this
.
onClick
,
this
);
}
createBitmapByName
(
name
)
{
const
imgContainer
=
new
engine
.
Sprite
();
const
img
=
new
engine
.
Sprite
(
getTextureByName
(
name
));
img
.
anchorX
=
img
.
width
/
2
;
img
.
anchorY
=
img
.
height
/
2
;
img
.
x
=
-
img
.
width
/
2
;
img
.
y
=
-
img
.
height
/
2
;
imgContainer
.
addChild
(
img
);
return
imgContainer
}
private
createBox
(
width
:
number
,
height
:
number
):
engine
.
Shape
{
var
shape
=
new
engine
.
Shape
();
shape
.
beginFill
(
0xfff000
);
shape
.
drawRect
(
-
width
/
2
,
-
height
/
2
,
width
,
height
);
shape
.
endFill
();
return
shape
;
}
onClick
(
e
:
engine
.
MouseEvent
)
{
// const ball = this.createBitmapByName('ball');
// this.addChild(ball);
// engine.Tween.get(ball, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBitmapByName('block');
// this.addChild(box);
// engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000);
// return;
// const box = this.createBox(750, 100)
// this.addChild(box);
// box.x = 750/2;
// box.y = 1624/2;
// engine.Tween.get(box, { loop: true }).to({ rotation: 360 }, 1000)
// return;
// const ball = this.createBall(750/2);
// this.addChild(ball);
// ball.x = e.stageX;
// ball.y = e.stageY;
// return;
const
{
world
,
factor
}
=
this
;
var
positionX
:
number
=
(
e
.
stageX
/
factor
);
var
positionY
:
number
=
((
engine
.
gameStage
.
stage
.
height
-
e
.
stageY
)
/
factor
);
var
display
:
engine
.
DisplayObject
;
if
(
Math
.
random
()
>
.
5
)
{
//添加方形刚体
var
boxShape
:
p2
.
Shape
=
new
p2
.
Box
({
width
:
306
/
factor
,
height
:
172
/
factor
});
var
boxBody
:
p2
.
Body
=
new
p2
.
Body
({
mass
:
1
,
position
:
[
positionX
,
positionY
],
angularVelocity
:
1
});
boxBody
.
addShape
(
boxShape
);
world
.
addBody
(
boxBody
);
if
(
this
.
isDebug
)
{
display
=
this
.
createBox
((
<
p2
.
Box
>
boxShape
).
width
*
factor
,
(
<
p2
.
Box
>
boxShape
).
height
*
factor
);
}
else
{
display
=
this
.
createBitmapByName
(
"block"
);
}
}
else
{
//添加圆形刚体
var
boxShape
:
p2
.
Shape
=
new
p2
.
Circle
({
radius
:
120
/
2
/
factor
});
var
boxBody
:
p2
.
Body
=
new
p2
.
Body
({
mass
:
1
,
position
:
[
positionX
,
positionY
]
});
boxBody
.
addShape
(
boxShape
);
world
.
addBody
(
boxBody
);
if
(
this
.
isDebug
)
{
display
=
this
.
createBall
((
<
p2
.
Circle
>
boxShape
).
radius
*
factor
);
}
else
{
display
=
this
.
createBitmapByName
(
"ball"
);
}
// display.width = (<p2.Circle>boxShape).radius * 2 * factor;
// display.height = (<p2.Circle>boxShape).radius * 2 * factor;
}
// display.anchorX = display.width / 2;
// display.anchorY = display.height / 2;
boxBody
.
displays
=
[
display
];
this
.
addChild
(
display
);
}
setup
()
{
console
.
log
(
'setup'
);
//创建world
var
world
:
p2
.
World
=
new
p2
.
World
({
gravity
:
[
0
,
-
10
],
});
world
.
sleepMode
=
p2
.
World
.
BODY_SLEEPING
;
//创建plane
var
planeShape
:
p2
.
Plane
=
new
p2
.
Plane
();
var
planeBody
:
p2
.
Body
=
new
p2
.
Body
();
planeBody
.
addShape
(
planeShape
);
planeBody
.
displays
=
[];
world
.
addBody
(
planeBody
);
this
.
world
=
world
;
this
.
stage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
}
onEnterFrame
()
{
const
{
world
,
factor
}
=
this
;
world
.
step
(
60
/
1000
);
const
stageHeight
=
engine
.
gameStage
.
stage
.
height
;
var
l
=
world
.
bodies
.
length
;
for
(
var
i
:
number
=
0
;
i
<
l
;
i
++
)
{
var
boxBody
:
p2
.
Body
=
world
.
bodies
[
i
];
var
box
=
boxBody
.
displays
[
0
];
if
(
box
)
{
box
.
x
=
boxBody
.
position
[
0
]
*
factor
;
box
.
y
=
stageHeight
-
boxBody
.
position
[
1
]
*
factor
;
box
.
rotation
=
360
-
(
boxBody
.
angle
+
boxBody
.
shapes
[
0
].
angle
)
*
180
/
Math
.
PI
;
if
(
boxBody
.
sleepState
==
p2
.
Body
.
SLEEPING
)
{
box
.
alpha
=
0.5
;
}
else
{
box
.
alpha
=
1
;
}
}
}
}
}
src/custom/p2demo/src/game/GameWrapper.ts
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-01-09.
*/
import
GameView
from
"./GameView"
;
import
{
injectProps
}
from
"../props"
;
export
class
GameWrapper
extends
engine
.
Container
{
// private _status;
private
_gameView
:
GameView
;
constructor
()
{
super
();
engine
.
globalEvent
.
addEventListener
(
'pictures-start'
,
this
.
start
,
this
);
engine
.
globalEvent
.
addEventListener
(
'pictures-stop'
,
this
.
stop
,
this
);
//创建实例
let
gameView
=
this
.
_gameView
=
new
GameView
();
this
.
addChild
(
gameView
);
}
start
(
event
:
engine
.
Event
)
{
injectProps
(
event
.
data
);
// this._status = 1;
this
.
_gameView
.
start
();
}
stop
(
event
:
engine
.
Event
)
{
}
}
src/custom/p2demo/src/game/object-pool-init.ts
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-02-03.
*/
import
{
Goods
}
from
"./Goods"
;
import
ObjectPool
=
engine
.
ObjectPool
;
export
const
PoolName
:
string
=
'goods'
;
ObjectPool
.
registerPool
(
PoolName
,
function
()
{
return
new
Goods
();
},
function
(
item
:
Goods
,
data
)
{
item
.
reset
();
});
src/custom/p2demo/src/game/qietu.ts
0 → 100644
View file @
21a3813f
import
{
props
}
from
"../props"
;
const
urls
=
[];
const
picMap
=
{};
const
posMap
=
{};
export
default
(
parent
,
url
,
MAX_COL
,
MAX_ROW
)
=>
{
if
(
picMap
[
url
])
{
const
pics
:
any
[]
=
picMap
[
url
];
for
(
const
pic
of
pics
)
{
parent
.
addChild
(
pic
);
}
return
[
picMap
[
url
],
posMap
[
url
]]
}
const
W
=
props
.
W
;
const
H
=
props
.
H
;
const
GAP
=
props
.
GAP
;
const
spr
=
[];
const
pos
=
[]
for
(
let
row
=
0
;
row
<
MAX_ROW
;
row
++
)
{
for
(
let
col
=
0
;
col
<
MAX_COL
;
col
++
)
{
const
child
=
engine
.
Sprite
.
fromImage
(
url
);
spr
.
push
(
child
);
child
.
scaleX
=
1
/
MAX_COL
;
child
.
scaleY
=
1
/
MAX_ROW
;
parent
.
addChild
(
child
);
child
.
x
=
col
*
(
W
/
MAX_COL
+
GAP
);
child
.
y
=
row
*
(
H
/
MAX_ROW
+
GAP
);
pos
.
push
([
child
.
x
,
child
.
y
]);
// child.texture.addEventListener('update', () => {
child
.
addEventListener
(
engine
.
Event
.
COMPLETE
,
()
=>
{
const
uvs
=
new
Float32Array
([
col
/
MAX_COL
,
row
/
MAX_ROW
,
(
col
+
1
)
/
MAX_COL
,
row
/
MAX_ROW
,
(
col
+
1
)
/
MAX_COL
,
(
row
+
1
)
/
MAX_ROW
,
col
/
MAX_COL
,
(
row
+
1
)
/
MAX_ROW
,
]);
child
.
uvs
=
uvs
;
// spr.push(child);
});
}
}
picMap
[
url
]
=
spr
.
concat
([]);
posMap
[
url
]
=
pos
.
concat
([]);;
// console.log(spr);
return
[
spr
,
pos
];
};
src/custom/p2demo/src/game/utils.ts
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-01-21.
*/
export
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
export
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
export
function
playSound
(
name
)
{
engine
.
playSound
(
engine
.
getAssetByName
(
name
).
uuid
,
{
keep
:
true
});
}
export
function
createSvga
(
name
,
anchorName
?)
{
let
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
return
inst
;
}
export
function
getIndexFromRC
(
row
,
col
,
maxCol
){
let
index
;
index
=
row
*
maxCol
+
col
;
return
index
}
export
function
getRandomArray
(
array
){
array
.
sort
(
function
()
{
return
.
5
-
Math
.
random
();
});
}
\ No newline at end of file
src/custom/p2demo/src/index.ts
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2019-11-20.
*/
import
{
GameWrapper
}
from
"./game/GameWrapper"
;
import
{
injectProps
,
prepareProps
}
from
"./props"
;
export
default
function
(
props
)
{
prepareProps
();
injectProps
(
props
);
let
instance
=
new
GameWrapper
();
return
instance
;
}
src/custom/p2demo/src/props.ts
0 → 100644
View file @
21a3813f
/**
* Created by rockyl on 2020-01-21.
*/
export
let
props
:
any
=
{};
export
function
prepareProps
()
{
let
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
export
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
src/custom/pictures/debug/app.js
View file @
21a3813f
...
...
@@ -52,9 +52,15 @@ function launchWithCustomModule(customModule) {
engine
.
globalEvent
.
dispatchEvent
(
'pictures-start'
,
{
picUrl
:
"http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
,
blockUrl
:
"888"
,
<<<<<<<
HEAD
row
:
3
,
column
:
3
,
gameTime
:
50
=======
column
:
"2"
,
row
:
"2"
,
gameTime
:
"50"
>>>>>>>
33823
dbdb9c3b079aa71a545ab5472146df6429b
});
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
...
...
src/custom/pictures/debug/main.js
View file @
21a3813f
...
...
@@ -187,7 +187,10 @@
MAX_COL
=
props
.
MAX_COL
;
MAX_ROW
=
props
.
MAX_ROW
;
GAME_TIME
=
props
.
GAME_TIME
;
<<<<<<<
HEAD
console
.
log
(
GAME_TIME
,
'setuptime'
);
=======
>>>>>>>
33823
dbdb9c3b079aa71a545ab5472146df6429b
W
=
props
.
W
;
H
=
props
.
H
;
GAP
=
props
.
GAP
;
...
...
src/custom/pictures/debug/main.js.map
View file @
21a3813f
<<<<<<< HEAD
{"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 const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\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, getTexture } 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\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n private date\r\n\r\n start() {\r\n MAX_COL = props.column || props.MAX_COL;\r\n MAX_ROW = props.row || props.MAX_ROW;\r\n GAME_TIME = props.gameTime || props.GAME_TIME;\r\n console.log('start',props.column,props.row,props.gameTime)\r\n \r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = 'asset://' + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.wrapper)\r\n pic.wrapper.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 this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2)\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n console.log(GAME_TIME,\"gametime1\");\r\n\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\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\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\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\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 private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\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 console.log(GAME_TIME,'setuptime')\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 let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\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\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 // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\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 listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\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 if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\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 this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && 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 + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\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\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n\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\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 // 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;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IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
=======
{"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 const pics:any[] = picMap[url];\r\n for (const pic of pics) {\r\n parent.addChild(pic);\r\n }\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, getTexture } 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\n\r\nexport default class GameView extends engine.Container {\r\n private _timer;\r\n private _timeCounter = 0;\r\n\r\n private date\r\n\r\n start() {\r\n //优先获取start事件接收到的参数\r\n MAX_COL = props.column || props.MAX_COL;\r\n MAX_ROW = props.row || props.MAX_ROW;\r\n GAME_TIME = props.gameTime || props.GAME_TIME;\r\n console.log('start',props.column,props.row,props.gameTime)\r\n\r\n if (!this.guideHole) {\r\n this.guideHole = new engine.Image();\r\n this.guideHole.source = 'asset://' + props.blockUrl;\r\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\r\n }\r\n\r\n if (this.pictures) {\r\n for (const pic of this.pictures) {\r\n if (pic && pic.wrapper)\r\n pic.wrapper.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 this.date = new Date().getTime();\r\n\r\n }\r\n\r\n onTimer() {\r\n\r\n let date = new Date().getTime();\r\n\r\n let gap = ((date - this.date) / 1000);\r\n this.date = date;\r\n console.log(gap,\"gap\");\r\n\r\n // 以GAME_TIME为标准\r\n GAME_TIME -= gap;\r\n if(GAME_TIME < 0){\r\n GAME_TIME = 0;\r\n }\r\n GAME_TIME = this.afterPointTwo(GAME_TIME);\r\n GAME_TIME = GAME_TIME.toFixed(2)\r\n if (GAME_TIME < 10) {\r\n GAME_TIME = '0' + GAME_TIME\r\n }\r\n console.log(GAME_TIME);\r\n\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\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\r\n getSecond() {\r\n return GAME_TIME\r\n }\r\n\r\n stop() {\r\n \r\n GAME_TIME = props.GAME_TIME\r\n clearInterval(this._timer);\r\n let len = this.pictures.length;\r\n for(let i=0;i<len;i++){\r\n this.pictures[i].removeAllEventListener();\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\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 private picturesWrapper: engine.Sprite;\r\n private guideHole: engine.Image;\r\n\r\n createRects() { }\r\n setup() {\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 let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n // 创建一个图片对象接收当前位置信息\r\n this.dragPic = e.target;\r\n this.picturesWrapper.addChild(this.dragPic);\r\n\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\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 // this.centerX = Math.floor(e.clientX / w) * w + w / 2;\r\n // this.centerY = Math.floor(e.clientY / h) * h + h / 2;\r\n\r\n this.centerX = Math.floor((e.clientX - stageLeft) / w) * w + w / 2;\r\n this.centerY = Math.floor((e.clientY - stageTop) / h) * h + h / 2;\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 listenStageOn = 1;\r\n\r\n stageOnUp(e) {\r\n\r\n let stageLeft = (750 - props.W) / 2\r\n let stageTop = (this.stage.height - props.H) / 2;\r\n\r\n this.stage.removeEventListener(\r\n engine.MouseEvent.MOUSE_MOVE,\r\n this.onMove,\r\n this\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 if (this.centerY < stageTop || this.centerX < stageLeft) {\r\n this.dragPic.x = this.distanceX ;\r\n this.dragPic.y = this.distanceY ;\r\n }\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 this.picturesWrapper.addChild(this.guideHole);\r\n\r\n\r\n // 点击图片的位置\r\n\r\n if ( 0 <= curJ && curJ < (MAX_COL) && 0 <= curI && 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 + stageLeft;\r\n let dropPicy = dropPic.y + stageTop;\r\n\r\n dropPic.x = this.distanceX;\r\n dropPic.y = this.distanceY;\r\n\r\n this.dragPic.x = dropPicX - stageLeft;\r\n this.dragPic.y = dropPicy - stageTop;\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\r\n }\r\n\r\n private onSuccess() {\r\n console.log('拼图成功!');\r\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: GAME_TIME });\r\n this.stop();\r\n\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\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 // 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);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,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
>>>>>>> 33823dbdb9c3b079aa71a545ab5472146df6429b
src/custom/pictures/src/game/GameView.ts
View file @
21a3813f
...
...
@@ -28,18 +28,26 @@ export default class GameView extends engine.Container {
start
()
{
<<<<<<<
HEAD
<<<<<<<
HEAD
=======
//优先获取start事件接收到的参数
>>>>>>>
2533
efe07c13d1586974175c8874bc3dad71643a
=======
//优先获取start事件接收到的参数
>>>>>>>
33823
dbdb9c3b079aa71a545ab5472146df6429b
MAX_COL
=
props
.
column
||
props
.
MAX_COL
;
MAX_ROW
=
props
.
row
||
props
.
MAX_ROW
;
GAME_TIME
=
props
.
gameTime
||
props
.
GAME_TIME
;
console
.
log
(
'start'
,
props
.
column
,
props
.
row
,
props
.
gameTime
)
<<<<<<<
HEAD
<<<<<<<
HEAD
=======
>>>>>>>
2533
efe07c13d1586974175c8874bc3dad71643a
=======
>>>>>>>
33823
dbdb9c3b079aa71a545ab5472146df6429b
if
(
!
this
.
guideHole
)
{
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
...
...
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