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
0c261be1
Commit
0c261be1
authored
Jun 03, 2020
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a65da7ca
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
17 deletions
+16
-17
pictures.json
dist/customs/pictures.json
+4
-4
app.js
src/custom/pictures/debug/app.js
+1
-1
main.js
src/custom/pictures/debug/main.js
+1
-1
main.js.map
src/custom/pictures/debug/main.js.map
+1
-1
meta.json
src/custom/pictures/meta.json
+3
-3
GameView.ts
src/custom/pictures/src/game/GameView.ts
+6
-7
No files found.
dist/customs/pictures.json
View file @
0c261be1
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
"default"
:
2
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
"default"
:
2
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -30,7 +30,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
2
0
"default"
:
5
0
}
},
"assets"
:
[
...
...
@@ -75,5 +75,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])return[picMap[r],posMap[r]];for(var c=props.W,h=props.H,p=props.GAP,u=[],d=[],t=function(s){for(var t=function(e){var i=engine.Sprite.fromImage(r);u.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(c/o+p),i.y=s*(h/a+p),d.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})},e=0;e<o;e++)t(e)},e=0;e<a;e++)t(e);return picMap[r]=u.concat([]),posMap[r]=d.concat([]),[u,d]};function getTexture(t){return engine.Texture.from(getAssetByUUID(t).uuid)}function getTextureByName(t){return getTexture(engine.getAssetByName(t).uuid)}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.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){
if(this.pictures)for(var t=0,e=this.pictures;t<e.length;t++){var i=e[t];i&&i.parent&&i.parent.removeChild(i)}console.log(
\"
on start
\"
),engine.globalEvent.dispatchEvent(
\"
pictures-time-update
\"
,{second:this.getSecond()});var s=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),this.pictures=s[0],this.rightList=this.pictures.concat([]);var n=s[1];getRandomArray(this.pictures);var r,o=0;for(r=this.pictures.length;o<r;o++){this.dragPic=this.pictures[o],this.pictures[o].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var a=n[o],c=a[0],h=a[1];this.dragPic.x=c,this.dragPic.y=h}},t.prototype.onTimer=function(){this._timeCounter+=.01,this._timeCounter=this.afterPointTwo(this._timeCounter),console.log(this._timeCounter),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-this._timeCounter},t.prototype.stop=function(){this._timeCounter=0,clearInterval(this._timer)},t.prototype.createRects=function(){},t.prototype.setup=function(){this.guideHole=new engine.Image(getTextureByName(
\"
遮罩
\"
)),this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1,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){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/w)*w+w/2,this.centerY=Math.floor(t.clientY/h)*h+w/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){this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),(this.centerY<0||this.centerX<0)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY),this.picturesWrapper.addChild(this.guideHole);var e=Math.floor(this.centerX/(w+GAP)),i=Math.floor(this.centerY/(h+GAP));if(e<MAX_COL&&i<MAX_ROW){var s=getIndexFromRC(i,e,MAX_COL),n=this.pictures[s],r=n.x,o=n.y;n.x=this.distanceX,n.y=this.distanceY,this.dragPic.x=r,this.dragPic.y=o;var a=this.pictures.indexOf(n),c=this.pictures.indexOf(this.dragPic);this.pictures[a]=this.dragPic,this.pictures[c]=n,c===a&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var p=!0,u=0;u<this.rightList.length;u++)if(this.rightList[u]!=this.pictures[u]){p=!1;break}p&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY;this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.onSuccess=function(){console.log(
\"
拼图成功!
\"
),this.stop(),engine.globalEvent.dispatchEvent(
\"
pictures-game-success
\"
,{time:this._timeCounter})},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX,this.dragPic.y=t.stageY-this.localPicY,console.log(this.dragPic.x,this.dragPic.y)
,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"
:
"
\"
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])return[picMap[r],posMap[r]];for(var c=props.W,h=props.H,p=props.GAP,u=[],d=[],t=function(s){for(var t=function(e){var i=engine.Sprite.fromImage(r);u.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(c/o+p),i.y=s*(h/a+p),d.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})},e=0;e<o;e++)t(e)},e=0;e<a;e++)t(e);return picMap[r]=u.concat([]),posMap[r]=d.concat([]),[u,d]};function getTexture(t){return engine.Texture.from(getAssetByUUID(t).uuid)}function getTextureByName(t){return getTexture(engine.getAssetByName(t).uuid)}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.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){
var t=this;if(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),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);var o,a=0;for(o=this.pictures.length;a<o;a++){this.dragPic=this.pictures[a],this.pictures[a].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var c=r[a],h=c[0],p=c[1];this.dragPic.x=h,this.dragPic.y=p}this._timer=setInterval(function(){t.onTimer()},10)},t.prototype.onTimer=function(){this._timeCounter+=.01,this._timeCounter=this.afterPointTwo(this._timeCounter),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-this._timeCounter},t.prototype.stop=function(){this._timeCounter=0,clearInterval(this._timer)},t.prototype.createRects=function(){},t.prototype.setup=function(){this.guideHole=new engine.Image(getTextureByName(
\"
遮罩
\"
)),this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1,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){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/w)*w+w/2,this.centerY=Math.floor(t.clientY/h)*h+w/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){this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),(this.centerY<0||this.centerX<0)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY),this.picturesWrapper.addChild(this.guideHole);var e=Math.floor(this.centerX/(w+GAP)),i=Math.floor(this.centerY/(h+GAP));if(e<MAX_COL&&i<MAX_ROW){var s=getIndexFromRC(i,e,MAX_COL),n=this.pictures[s],r=n.x,o=n.y;n.x=this.distanceX,n.y=this.distanceY,this.dragPic.x=r,this.dragPic.y=o;var a=this.pictures.indexOf(n),c=this.pictures.indexOf(this.dragPic);this.pictures[a]=this.dragPic,this.pictures[c]=n,c===a&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var p=!0,u=0;u<this.rightList.length;u++)if(this.rightList[u]!=this.pictures[u]){p=!1;break}p&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY;this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.onSuccess=function(){console.log(
\"
拼图成功!
\"
),engine.globalEvent.dispatchEvent(
\"
pictures-game-success
\"
,{time:this._timeCounter}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX,this.dragPic.y=t.stageY-this.localPicY
,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
"
}
src/custom/pictures/debug/app.js
View file @
0c261be1
...
...
@@ -53,7 +53,7 @@ function launchWithCustomModule(customModule) {
},
500
);
});
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 @
0c261be1
"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
])
return
[
picMap
[
r
],
posMap
[
r
]];
for
(
var
c
=
props
.
W
,
h
=
props
.
H
,
p
=
props
.
GAP
,
u
=
[],
d
=
[],
t
=
function
(
s
){
for
(
var
t
=
function
(
e
){
var
i
=
engine
.
Sprite
.
fromImage
(
r
);
u
.
push
(
i
),
i
.
scaleX
=
1
/
o
,
i
.
scaleY
=
1
/
a
,
n
.
addChild
(
i
),
i
.
x
=
e
*
(
c
/
o
+
p
),
i
.
y
=
s
*
(
h
/
a
+
p
),
d
.
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
})},
e
=
0
;
e
<
o
;
e
++
)
t
(
e
)},
e
=
0
;
e
<
a
;
e
++
)
t
(
e
);
return
picMap
[
r
]
=
u
.
concat
([]),
posMap
[
r
]
=
d
.
concat
([]),[
u
,
d
]};
function
getTexture
(
t
){
return
engine
.
Texture
.
from
(
getAssetByUUID
(
t
).
uuid
)}
function
getTextureByName
(
t
){
return
getTexture
(
engine
.
getAssetByName
(
t
).
uuid
)}
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
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
t
.
setup
,
t
),
t
}
return
tslib
.
__extends
(
t
,
e
),
t
.
prototype
.
start
=
function
(){
if
(
this
.
pictures
)
for
(
var
t
=
0
,
e
=
this
.
pictures
;
t
<
e
.
length
;
t
++
){
var
i
=
e
[
t
];
i
&&
i
.
parent
&&
i
.
parent
.
removeChild
(
i
)}
console
.
log
(
"on start"
),
engine
.
globalEvent
.
dispatchEvent
(
"pictures-time-update"
,{
second
:
this
.
getSecond
()});
var
s
=
qietu
(
this
.
picturesWrapper
,
props
.
picUrl
,
MAX_COL
,
MAX_ROW
);
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
),
this
.
pictures
=
s
[
0
],
this
.
rightList
=
this
.
pictures
.
concat
([]);
var
n
=
s
[
1
];
getRandomArray
(
this
.
pictures
);
var
r
,
o
=
0
;
for
(
r
=
this
.
pictures
.
length
;
o
<
r
;
o
++
){
this
.
dragPic
=
this
.
pictures
[
o
],
this
.
pictures
[
o
].
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown
,
this
);
var
a
=
n
[
o
],
c
=
a
[
0
],
h
=
a
[
1
];
this
.
dragPic
.
x
=
c
,
this
.
dragPic
.
y
=
h
}},
t
.
prototype
.
onTimer
=
function
(){
this
.
_timeCounter
+=
.
01
,
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
),
console
.
log
(
this
.
_timeCounter
),
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
-
this
.
_timeCounter
},
t
.
prototype
.
stop
=
function
(){
this
.
_timeCounter
=
0
,
clearInterval
(
this
.
_timer
)},
t
.
prototype
.
createRects
=
function
(){},
t
.
prototype
.
setup
=
function
(){
this
.
guideHole
=
new
engine
.
Image
(
getTextureByName
(
"遮罩"
)),
this
.
guideHole
.
mouseChildren
=
this
.
guideHole
.
mouseEnabled
=!
1
,
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
){
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
/
w
)
*
w
+
w
/
2
,
this
.
centerY
=
Math
.
floor
(
t
.
clientY
/
h
)
*
h
+
w
/
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
){
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
),(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
&&
(
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
),
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
var
e
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
)),
i
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
if
(
e
<
MAX_COL
&&
i
<
MAX_ROW
){
var
s
=
getIndexFromRC
(
i
,
e
,
MAX_COL
),
n
=
this
.
pictures
[
s
],
r
=
n
.
x
,
o
=
n
.
y
;
n
.
x
=
this
.
distanceX
,
n
.
y
=
this
.
distanceY
,
this
.
dragPic
.
x
=
r
,
this
.
dragPic
.
y
=
o
;
var
a
=
this
.
pictures
.
indexOf
(
n
),
c
=
this
.
pictures
.
indexOf
(
this
.
dragPic
);
this
.
pictures
[
a
]
=
this
.
dragPic
,
this
.
pictures
[
c
]
=
n
,
c
===
a
&&
(
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
);
for
(
var
p
=!
0
,
u
=
0
;
u
<
this
.
rightList
.
length
;
u
++
)
if
(
this
.
rightList
[
u
]
!=
this
.
pictures
[
u
]){
p
=!
1
;
break
}
p
&&
this
.
onSuccess
()}
else
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
;
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
)},
t
.
prototype
.
onSuccess
=
function
(){
console
.
log
(
"拼图成功!"
),
this
.
stop
(),
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-success"
,{
time
:
this
.
_timeCounter
})},
t
.
prototype
.
onMove
=
function
(
t
){
this
.
dragPic
.
x
=
t
.
stageX
-
this
.
localPicX
,
this
.
dragPic
.
y
=
t
.
stageY
-
this
.
localPicY
,
console
.
log
(
this
.
dragPic
.
x
,
this
.
dragPic
.
y
)
,
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
;
"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
])
return
[
picMap
[
r
],
posMap
[
r
]];
for
(
var
c
=
props
.
W
,
h
=
props
.
H
,
p
=
props
.
GAP
,
u
=
[],
d
=
[],
t
=
function
(
s
){
for
(
var
t
=
function
(
e
){
var
i
=
engine
.
Sprite
.
fromImage
(
r
);
u
.
push
(
i
),
i
.
scaleX
=
1
/
o
,
i
.
scaleY
=
1
/
a
,
n
.
addChild
(
i
),
i
.
x
=
e
*
(
c
/
o
+
p
),
i
.
y
=
s
*
(
h
/
a
+
p
),
d
.
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
})},
e
=
0
;
e
<
o
;
e
++
)
t
(
e
)},
e
=
0
;
e
<
a
;
e
++
)
t
(
e
);
return
picMap
[
r
]
=
u
.
concat
([]),
posMap
[
r
]
=
d
.
concat
([]),[
u
,
d
]};
function
getTexture
(
t
){
return
engine
.
Texture
.
from
(
getAssetByUUID
(
t
).
uuid
)}
function
getTextureByName
(
t
){
return
getTexture
(
engine
.
getAssetByName
(
t
).
uuid
)}
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
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
t
.
setup
,
t
),
t
}
return
tslib
.
__extends
(
t
,
e
),
t
.
prototype
.
start
=
function
(){
var
t
=
this
;
if
(
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
),
this
.
pictures
=
n
[
0
],
this
.
rightList
=
this
.
pictures
.
concat
([]);
var
r
=
n
[
1
];
getRandomArray
(
this
.
pictures
);
var
o
,
a
=
0
;
for
(
o
=
this
.
pictures
.
length
;
a
<
o
;
a
++
){
this
.
dragPic
=
this
.
pictures
[
a
],
this
.
pictures
[
a
].
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown
,
this
);
var
c
=
r
[
a
],
h
=
c
[
0
],
p
=
c
[
1
];
this
.
dragPic
.
x
=
h
,
this
.
dragPic
.
y
=
p
}
this
.
_timer
=
setInterval
(
function
(){
t
.
onTimer
()},
10
)},
t
.
prototype
.
onTimer
=
function
(){
this
.
_timeCounter
+=
.
01
,
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
),
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
-
this
.
_timeCounter
},
t
.
prototype
.
stop
=
function
(){
this
.
_timeCounter
=
0
,
clearInterval
(
this
.
_timer
)},
t
.
prototype
.
createRects
=
function
(){},
t
.
prototype
.
setup
=
function
(){
this
.
guideHole
=
new
engine
.
Image
(
getTextureByName
(
"遮罩"
)),
this
.
guideHole
.
mouseChildren
=
this
.
guideHole
.
mouseEnabled
=!
1
,
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
){
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
/
w
)
*
w
+
w
/
2
,
this
.
centerY
=
Math
.
floor
(
t
.
clientY
/
h
)
*
h
+
w
/
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
){
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
),(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
&&
(
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
),
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
var
e
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
)),
i
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
if
(
e
<
MAX_COL
&&
i
<
MAX_ROW
){
var
s
=
getIndexFromRC
(
i
,
e
,
MAX_COL
),
n
=
this
.
pictures
[
s
],
r
=
n
.
x
,
o
=
n
.
y
;
n
.
x
=
this
.
distanceX
,
n
.
y
=
this
.
distanceY
,
this
.
dragPic
.
x
=
r
,
this
.
dragPic
.
y
=
o
;
var
a
=
this
.
pictures
.
indexOf
(
n
),
c
=
this
.
pictures
.
indexOf
(
this
.
dragPic
);
this
.
pictures
[
a
]
=
this
.
dragPic
,
this
.
pictures
[
c
]
=
n
,
c
===
a
&&
(
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
);
for
(
var
p
=!
0
,
u
=
0
;
u
<
this
.
rightList
.
length
;
u
++
)
if
(
this
.
rightList
[
u
]
!=
this
.
pictures
[
u
]){
p
=!
1
;
break
}
p
&&
this
.
onSuccess
()}
else
this
.
dragPic
.
x
=
this
.
distanceX
,
this
.
dragPic
.
y
=
this
.
distanceY
;
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
)},
t
.
prototype
.
onSuccess
=
function
(){
console
.
log
(
"拼图成功!"
),
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-success"
,{
time
:
this
.
_timeCounter
}),
this
.
stop
()},
t
.
prototype
.
onMove
=
function
(
t
){
this
.
dragPic
.
x
=
t
.
stageX
-
this
.
localPicX
,
this
.
dragPic
.
y
=
t
.
stageY
-
this
.
localPicY
,
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
;
src/custom/pictures/debug/main.js.map
View file @
0c261be1
{"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":["/**\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","import { props } from \"../props\";\nconst urls = [];\nconst picMap = {};\nconst posMap = {};\nexport default (parent, url, MAX_COL, MAX_ROW) => {\n if (picMap[url]) {\n return [picMap[url], posMap[url]]\n }\n\n const W = props.W;\n const H = props.H;\n const GAP = props.GAP;\n\n const spr = [];\n const pos = []\n\n for (let row = 0; row < MAX_ROW; row++) {\n for (let col = 0; col < MAX_COL; col++) {\n\n const child = engine.Sprite.fromImage(url);\n spr.push(child);\n\n child.scaleX = 1 / MAX_COL;\n child.scaleY = 1 / MAX_ROW;\n parent.addChild(child);\n child.x = col * (W / MAX_COL + GAP);\n child.y = row * (H / MAX_ROW + GAP);\n pos.push([child.x, child.y]);\n // child.texture.addEventListener('update', () => {\n child.addEventListener(engine.Event.COMPLETE, () => {\n const uvs = new Float32Array([\n col / MAX_COL,\n row / MAX_ROW,\n (col + 1) / MAX_COL,\n row / MAX_ROW,\n (col + 1) / MAX_COL,\n (row + 1) / MAX_ROW,\n col / MAX_COL,\n (row + 1) / MAX_ROW,\n ]);\n\n child.uvs = uvs;\n // spr.push(child);\n });\n }\n }\n picMap[url] = spr.concat([]);\n posMap[url] = pos.concat([]);;\n // console.log(spr);\n return [spr, pos];\n};\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 createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport qietu from \"./qietu\";\nimport { getIndexFromRC, getRandomArray, getTextureByName } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\n\nlet MAX_COL;\nlet MAX_ROW;\nlet W;\nlet H;\nlet GAP;\nlet GAME_TIME;\n// 每张图片宽\nlet w;\n// 每张图片高\nlet h;\nexport default class GameView extends engine.Container {\n private _timer;\n private _timeCounter = 0;\n\n start() {\n if (this.pictures) {\n for (const pic of this.pictures) {\n if (pic && pic.parent)\n pic.parent.removeChild(pic);\n }\n }\n\n console.log('on start')\n engine.globalEvent.dispatchEvent('pictures-time-update', {\n second: this.getSecond(),\n });\n\n // 图片一维数组\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\n this.picturesWrapper.addChild(this.guideHole);\n this.pictures = result[0];\n this.rightList = this.pictures.concat([]);\n const posList = result[1];\n getRandomArray(this.pictures);\n\n let i = 0;\n let len;\n len = this.pictures.length;\n\n\n for (; i < len; i++) {\n this.dragPic = this.pictures[i];\n this.pictures[i].addEventListener(\n engine.MouseEvent.MOUSE_DOWN,\n this.onDown,\n this\n );\n const [x, y] = posList[i];\n this.dragPic.x = x;\n this.dragPic.y = y;\n\n }\n\n // this._timer = setInterval(() => {\n // this.onTimer();\n // }, 10)\n }\n\n\n onTimer() {\n // this._timeCounter++;\n this._timeCounter += 0.01;\n this._timeCounter = this.afterPointTwo(this._timeCounter);\n // this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;\n console.log(this._timeCounter)\n\n engine.globalEvent.dispatchEvent('pictures-time-update', {\n second: this.getSecond(),\n });\n\n if (this.getSecond() == 0) {\n this.stop();\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\n reason: 1\n });\n }\n }\n\n afterPointTwo(n) {\n var floatN = parseFloat(n);\n if (isNaN(floatN)) {\n return;\n }\n floatN = Math.round(floatN * 100) / 100;\n return floatN;\n }\n\n getSecond() {\n return GAME_TIME - this._timeCounter;\n // return GAME_TIME - this.countTime;\n }\n\n stop() {\n // this.countTime = 0\n\n this._timeCounter = 0;\n clearInterval(this._timer);\n }\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n //当前图片对象\n dragPic;\n // 鼠标在当前图片上的位置\n localPicX;\n localPicY;\n // 拖动的图片最开始的位置(左上角为准)\n distanceX;\n distanceY;\n // 图片中心的位置\n centerX: number;\n centerY: number;\n\n pictures: engine.Sprite[];\n\n // 点击图片时的一维数组索引\n index;\n // 计算目标图片行和列的位置\n indexI: number;\n indexJ: number;\n rightList: engine.Sprite[];\n\n\n\n private picturesWrapper: engine.Sprite;\n private guideHole: engine.Sprite;\n\n createRects() { }\n setup() {\n this.guideHole = new engine.Image(getTextureByName('遮罩'));\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\n\n MAX_COL = props.MAX_COL;\n MAX_ROW = props.MAX_ROW;\n GAME_TIME = props.GAME_TIME;\n W = props.W;\n H = props.H;\n GAP = props.GAP;\n // 每张图片宽\n w = W / MAX_COL;\n // 每张图片高\n h = H / MAX_ROW;\n\n console.log('onSteup', props);\n\n const parent = new engine.Sprite();\n this.picturesWrapper = parent;\n this.addChild(parent);\n\n // 添加按钮\n // const btn = new engine.Rect();\n // btn.width = 200;\n // btn.height = 100;\n // // btn.stage.top = 1000;\n // // btn.stage.left = 350;\n // btn.fillColor = 'cyan';\n // this.addChild(btn)\n\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\n\n }\n\n onDown(e: engine.MouseEvent) {\n // console.log(e);\n\n // 创建一个图片对象接收当前位置信息\n this.dragPic = e.target;\n this.picturesWrapper.addChild(this.dragPic);\n\n // 鼠标的偏移量\n this.localPicX = e.localX / MAX_COL;\n this.localPicY = e.localY / MAX_ROW;\n\n // 最开始图片的位置\n this.distanceX = this.dragPic.x;\n this.distanceY = this.dragPic.y;\n\n // 最开始点击的图片的索引值\n // this.indexI = this.distanceX / (w + GAP);\n // this.indexJ = this.distanceY / (h + GAP);\n // this.index = (this.indexI - 1) * MAX_COL + this.indexJ;\n\n\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\n this.indexI = Math.floor(this.distanceY / (h + GAP));\n this.index = (this.indexI) * MAX_COL + this.indexJ;\n\n\n\n\n // 图片的中心位置\n // this.centerX = e.clientX + w / 2;\n // this.centerY = e.clientY + h / 2;\n\n this.centerX = Math.floor(e.clientX / w) * w + w / 2;\n this.centerY = Math.floor(e.clientY / h) * h + w / 2\n\n\n this.stage.addEventListener(\n engine.MouseEvent.MOUSE_MOVE,\n this.onMove,\n this\n );\n this.stage.addEventListener(\n engine.MouseEvent.MOUSE_UP,\n this.stageOnUp,\n this\n );\n\n }\n\n stageOnUp(e) {\n this.stage.removeEventListener(\n engine.MouseEvent.MOUSE_MOVE,\n this.onMove,\n this\n );\n\n // 拖动的图片的中心位置在图片之外,回到原来的位置\n if (this.centerY < 0 || this.centerX < 0) {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n this.picturesWrapper.addChild(this.guideHole);\n\n // 判断图片是否进入另一张图片的范围内\n // 要交换的图片第几行第几列\n let curJ = Math.floor(this.centerX / (w + GAP));\n let curI = Math.floor(this.centerY / (h + GAP));\n\n\n // 点击图片的位置\n\n if (curJ < (MAX_COL) && curI < (MAX_ROW)) {\n\n // 获取交互图片的索引值\n let index = getIndexFromRC(curI, curJ, MAX_COL);\n // console.log(index);\n\n //要交换的图片\n let dropPic = this.pictures[index];\n\n let dropPicX = dropPic.x;\n let dropPicy = dropPic.y;\n\n dropPic.x = this.distanceX;\n dropPic.y = this.distanceY;\n\n this.dragPic.x = dropPicX;\n this.dragPic.y = dropPicy;\n\n // 交换之后索引也需要交换\n\n const dropPicIndex = this.pictures.indexOf(dropPic);\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\n\n this.pictures[dropPicIndex] = this.dragPic;\n this.pictures[dragPicIndex] = dropPic;\n\n // 图片中心还是在原来的位置\n if (dragPicIndex === dropPicIndex) {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n let result = true;\n for (let j = 0; j < this.rightList.length; j++) {\n if (this.rightList[j] != this.pictures[j]) {\n result = false;\n break;\n }\n }\n\n if (result) {\n this.onSuccess();\n\n }\n } else {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n this.stage.removeEventListener(\n engine.MouseEvent.MOUSE_UP,\n this.stageOnUp,\n this\n );\n }\n\n private onSuccess() {\n console.log('拼图成功!');\n this.stop();\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: this._timeCounter });\n }\n\n onMove(e: engine.MouseEvent) {\n // 当前图片的位置\n this.dragPic.x = e.stageX - this.localPicX;\n this.dragPic.y = e.stageY - this.localPicY;\n console.log(this.dragPic.x, this.dragPic.y)\n\n // 当前图片的中心位置\n this.centerX = this.dragPic.x + w / 2;\n this.centerY = this.dragPic.y + h / 2;\n\n }\n\n // onClk(e){\n // // 重置时间\n // this._timeCounter = 0;\n // //重置图片顺序\n\n\n // }\n\n\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\tthis._gameView.stop();\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":";;;;;;CAIO,IAA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I,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":["/**\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","import { props } from \"../props\";\nconst urls = [];\nconst picMap = {};\nconst posMap = {};\nexport default (parent, url, MAX_COL, MAX_ROW) => {\n if (picMap[url]) {\n return [picMap[url], posMap[url]]\n }\n\n const W = props.W;\n const H = props.H;\n const GAP = props.GAP;\n\n const spr = [];\n const pos = []\n\n for (let row = 0; row < MAX_ROW; row++) {\n for (let col = 0; col < MAX_COL; col++) {\n\n const child = engine.Sprite.fromImage(url);\n spr.push(child);\n\n child.scaleX = 1 / MAX_COL;\n child.scaleY = 1 / MAX_ROW;\n parent.addChild(child);\n child.x = col * (W / MAX_COL + GAP);\n child.y = row * (H / MAX_ROW + GAP);\n pos.push([child.x, child.y]);\n // child.texture.addEventListener('update', () => {\n child.addEventListener(engine.Event.COMPLETE, () => {\n const uvs = new Float32Array([\n col / MAX_COL,\n row / MAX_ROW,\n (col + 1) / MAX_COL,\n row / MAX_ROW,\n (col + 1) / MAX_COL,\n (row + 1) / MAX_ROW,\n col / MAX_COL,\n (row + 1) / MAX_ROW,\n ]);\n\n child.uvs = uvs;\n // spr.push(child);\n });\n }\n }\n picMap[url] = spr.concat([]);\n posMap[url] = pos.concat([]);;\n // console.log(spr);\n return [spr, pos];\n};\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 createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}\n\nexport function getIndexFromRC(row,col,maxCol){\n\tlet index;\n\tindex = row * maxCol + col ;\n\treturn index\n}\n\n\n\n\nexport function getRandomArray(array){\n\tarray.sort(function() {\n\t\treturn .5 - Math.random();\n\t});\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport qietu from \"./qietu\";\nimport { getIndexFromRC, getRandomArray, getTextureByName } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\n\nlet MAX_COL;\nlet MAX_ROW;\nlet W;\nlet H;\nlet GAP;\nlet GAME_TIME;\n// 每张图片宽\nlet w;\n// 每张图片高\nlet h;\nexport default class GameView extends engine.Container {\n private _timer;\n private _timeCounter = 0;\n\n start() {\n if (this.pictures) {\n for (const pic of this.pictures) {\n if (pic && pic.parent)\n pic.parent.removeChild(pic);\n }\n }\n\n console.log('on start')\n engine.globalEvent.dispatchEvent('pictures-time-update', {\n second: this.getSecond(),\n });\n\n // 图片一维数组\n const result = qietu(this.picturesWrapper, props.picUrl, MAX_COL, MAX_ROW);\n this.picturesWrapper.addChild(this.guideHole);\n this.pictures = result[0];\n this.rightList = this.pictures.concat([]);\n const posList = result[1];\n getRandomArray(this.pictures);\n\n let i = 0;\n let len;\n len = this.pictures.length;\n\n\n for (; i < len; i++) {\n this.dragPic = this.pictures[i];\n this.pictures[i].addEventListener(\n engine.MouseEvent.MOUSE_DOWN,\n this.onDown,\n this\n );\n const [x, y] = posList[i];\n this.dragPic.x = x;\n this.dragPic.y = y;\n\n }\n\n this._timer = setInterval(() => {\n this.onTimer();\n }, 10)\n }\n\n\n onTimer() {\n // this._timeCounter++;\n this._timeCounter += 0.01;\n this._timeCounter = this.afterPointTwo(this._timeCounter);\n // this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;\n // console.log(this._timeCounter)\n\n engine.globalEvent.dispatchEvent('pictures-time-update', {\n second: this.getSecond(),\n });\n\n if (this.getSecond() == 0) {\n this.stop();\n engine.globalEvent.dispatchEvent('pictures-game-fail', {\n reason: 1\n });\n }\n }\n\n afterPointTwo(n) {\n var floatN = parseFloat(n);\n if (isNaN(floatN)) {\n return;\n }\n floatN = Math.round(floatN * 100) / 100;\n return floatN;\n }\n\n getSecond() {\n return GAME_TIME - this._timeCounter;\n // return GAME_TIME - this.countTime;\n }\n\n stop() {\n\n this._timeCounter = 0;\n clearInterval(this._timer);\n }\n\n constructor() {\n super();\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n }\n\n //当前图片对象\n dragPic;\n // 鼠标在当前图片上的位置\n localPicX;\n localPicY;\n // 拖动的图片最开始的位置(左上角为准)\n distanceX;\n distanceY;\n // 图片中心的位置\n centerX: number;\n centerY: number;\n\n pictures: engine.Sprite[];\n\n // 点击图片时的一维数组索引\n index;\n // 计算目标图片行和列的位置\n indexI: number;\n indexJ: number;\n rightList: engine.Sprite[];\n\n\n\n private picturesWrapper: engine.Sprite;\n private guideHole: engine.Sprite;\n\n createRects() { }\n setup() {\n this.guideHole = new engine.Image(getTextureByName('遮罩'));\n this.guideHole.mouseChildren = this.guideHole.mouseEnabled = false;\n\n MAX_COL = props.MAX_COL;\n MAX_ROW = props.MAX_ROW;\n GAME_TIME = props.GAME_TIME;\n W = props.W;\n H = props.H;\n GAP = props.GAP;\n // 每张图片宽\n w = W / MAX_COL;\n // 每张图片高\n h = H / MAX_ROW;\n\n console.log('onSteup', props);\n\n const parent = new engine.Sprite();\n this.picturesWrapper = parent;\n this.addChild(parent);\n\n // 添加按钮\n // const btn = new engine.Rect();\n // btn.width = 200;\n // btn.height = 100;\n // // btn.stage.top = 1000;\n // // btn.stage.left = 350;\n // btn.fillColor = 'cyan';\n // this.addChild(btn)\n\n // btn.addEventListener(engine.MouseEvent.CLICK,this.onClk,this)\n\n }\n\n onDown(e: engine.MouseEvent) {\n // console.log(e);\n\n // 创建一个图片对象接收当前位置信息\n this.dragPic = e.target;\n this.picturesWrapper.addChild(this.dragPic);\n\n // 鼠标的偏移量\n this.localPicX = e.localX / MAX_COL;\n this.localPicY = e.localY / MAX_ROW;\n\n // 最开始图片的位置\n this.distanceX = this.dragPic.x;\n this.distanceY = this.dragPic.y;\n\n // 最开始点击的图片的索引值\n // this.indexI = this.distanceX / (w + GAP);\n // this.indexJ = this.distanceY / (h + GAP);\n // this.index = (this.indexI - 1) * MAX_COL + this.indexJ;\n\n\n this.indexJ = Math.floor(this.distanceX / (w + GAP));\n this.indexI = Math.floor(this.distanceY / (h + GAP));\n this.index = (this.indexI) * MAX_COL + this.indexJ;\n\n\n\n\n // 图片的中心位置\n // this.centerX = e.clientX + w / 2;\n // this.centerY = e.clientY + h / 2;\n\n this.centerX = Math.floor(e.clientX / w) * w + w / 2;\n this.centerY = Math.floor(e.clientY / h) * h + w / 2\n\n\n this.stage.addEventListener(\n engine.MouseEvent.MOUSE_MOVE,\n this.onMove,\n this\n );\n this.stage.addEventListener(\n engine.MouseEvent.MOUSE_UP,\n this.stageOnUp,\n this\n );\n\n }\n\n stageOnUp(e) {\n this.stage.removeEventListener(\n engine.MouseEvent.MOUSE_MOVE,\n this.onMove,\n this\n );\n\n // 拖动的图片的中心位置在图片之外,回到原来的位置\n if (this.centerY < 0 || this.centerX < 0) {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n this.picturesWrapper.addChild(this.guideHole);\n\n // 判断图片是否进入另一张图片的范围内\n // 要交换的图片第几行第几列\n let curJ = Math.floor(this.centerX / (w + GAP));\n let curI = Math.floor(this.centerY / (h + GAP));\n\n\n // 点击图片的位置\n\n if (curJ < (MAX_COL) && curI < (MAX_ROW)) {\n\n // 获取交互图片的索引值\n let index = getIndexFromRC(curI, curJ, MAX_COL);\n // console.log(index);\n\n //要交换的图片\n let dropPic = this.pictures[index];\n\n let dropPicX = dropPic.x;\n let dropPicy = dropPic.y;\n\n dropPic.x = this.distanceX;\n dropPic.y = this.distanceY;\n\n this.dragPic.x = dropPicX;\n this.dragPic.y = dropPicy;\n\n // 交换之后索引也需要交换\n\n const dropPicIndex = this.pictures.indexOf(dropPic);\n const dragPicIndex = this.pictures.indexOf(this.dragPic);\n\n this.pictures[dropPicIndex] = this.dragPic;\n this.pictures[dragPicIndex] = dropPic;\n\n // 图片中心还是在原来的位置\n if (dragPicIndex === dropPicIndex) {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n let result = true;\n for (let j = 0; j < this.rightList.length; j++) {\n if (this.rightList[j] != this.pictures[j]) {\n result = false;\n break;\n }\n }\n\n if (result) {\n this.onSuccess();\n\n }\n } else {\n this.dragPic.x = this.distanceX\n this.dragPic.y = this.distanceY\n }\n\n this.stage.removeEventListener(\n engine.MouseEvent.MOUSE_UP,\n this.stageOnUp,\n this\n );\n }\n\n private onSuccess() {\n console.log('拼图成功!');\n engine.globalEvent.dispatchEvent('pictures-game-success', { time: this._timeCounter });\n this.stop();\n }\n\n onMove(e: engine.MouseEvent) {\n // 当前图片的位置\n this.dragPic.x = e.stageX - this.localPicX;\n this.dragPic.y = e.stageY - this.localPicY;\n // console.log(this.dragPic.x, this.dragPic.y)\n\n // 当前图片的中心位置\n this.centerX = this.dragPic.x + w / 2;\n this.centerY = this.dragPic.y + h / 2;\n\n }\n\n // onClk(e){\n // // 重置时间\n // this._timeCounter = 0;\n // //重置图片顺序\n\n\n // }\n\n\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\tthis._gameView.stop();\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":";;;;;;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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ACtB;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
src/custom/pictures/meta.json
View file @
0c261be1
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
"default"
:
2
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
"default"
:
2
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -30,7 +30,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
2
0
"default"
:
5
0
}
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
0c261be1
...
...
@@ -60,9 +60,9 @@ export default class GameView extends engine.Container {
}
//
this._timer = setInterval(() => {
//
this.onTimer();
//
}, 10)
this
.
_timer
=
setInterval
(()
=>
{
this
.
onTimer
();
},
10
)
}
...
...
@@ -71,7 +71,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
(),
...
...
@@ -100,7 +100,6 @@ export default class GameView extends engine.Container {
}
stop
()
{
// this.countTime = 0
this
.
_timeCounter
=
0
;
clearInterval
(
this
.
_timer
);
...
...
@@ -302,15 +301,15 @@ export default class GameView extends engine.Container {
private
onSuccess
()
{
console
.
log
(
'拼图成功!'
);
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
this
.
_timeCounter
});
this
.
stop
();
}
onMove
(
e
:
engine
.
MouseEvent
)
{
// 当前图片的位置
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
;
console
.
log
(
this
.
dragPic
.
x
,
this
.
dragPic
.
y
)
//
console.log(this.dragPic.x, this.dragPic.y)
// 当前图片的中心位置
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
...
...
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