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
634f2330
Commit
634f2330
authored
Jun 05, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拼图1.0版本
parent
2984fe79
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
29 deletions
+17
-29
app.js
src/custom/pictures/debug/app.js
+7
-7
main.js
src/custom/pictures/debug/main.js
+1
-3
main.js.map
src/custom/pictures/debug/main.js.map
+1
-1
GameView.ts
src/custom/pictures/src/game/GameView.ts
+8
-18
No files found.
src/custom/pictures/debug/app.js
View file @
634f2330
...
...
@@ -56,14 +56,14 @@ function launchWithCustomModule(customModule) {
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
).
y
=
(
d
.
stage
.
height
-
props
.
H
)
/
2
;
},
1000
);
//
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"
//
});
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"
});
// }, 5
*1000);
},
30
*
1000
);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
// console.log(e.type, e.data);
...
...
src/custom/pictures/debug/main.js
View file @
634f2330
...
...
@@ -146,6 +146,7 @@
second
:
this
.
getSecond
(),
});
if
(
this
.
getSecond
()
==
0
)
{
GAME_TIME
=
props
.
GAME_TIME
;
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
reason
:
1
...
...
@@ -164,7 +165,6 @@
return
GAME_TIME
;
};
GameView
.
prototype
.
stop
=
function
()
{
GAME_TIME
=
props
.
GAME_TIME
;
clearInterval
(
this
.
_timer
);
var
len
=
this
.
pictures
.
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
...
...
@@ -258,11 +258,9 @@
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
-
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
console
.
log
(
this
.
centerX
,
this
.
centerY
,
"center"
);
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
...
...
src/custom/pictures/debug/main.js.map
View file @
634f2330
This diff is collapsed.
Click to expand it.
src/custom/pictures/src/game/GameView.ts
View file @
634f2330
...
...
@@ -19,11 +19,13 @@ let GAME_TIME;
let
w
;
// 每张图片高
let
h
;
export
default
class
GameView
extends
engine
.
Container
{
private
_timer
;
private
_timeCounter
=
0
;
start
()
{
if
(
!
this
.
guideHole
)
{
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
...
...
@@ -94,6 +96,7 @@ export default class GameView extends engine.Container {
});
if
(
this
.
getSecond
()
==
0
)
{
GAME_TIME
=
props
.
GAME_TIME
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
reason
:
1
...
...
@@ -121,7 +124,7 @@ export default class GameView extends engine.Container {
}
stop
()
{
GAME_TIME
=
props
.
GAME_TIME
//
GAME_TIME = props.GAME_TIME
clearInterval
(
this
.
_timer
);
let
len
=
this
.
pictures
.
length
;
for
(
let
i
=
0
;
i
<
len
;
i
++
){
...
...
@@ -216,22 +219,12 @@ export default class GameView extends engine.Container {
this
.
distanceY
=
this
.
dragPic
.
y
;
// 最开始点击的图片的索引值
// this.indexI = this.distanceX / (w + GAP);
// this.indexJ = this.distanceY / (h + GAP);
// this.index = (this.indexI - 1) * MAX_COL + this.indexJ;
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 = e.clientX + w / 2;
// this.centerY = e.clientY + h / 2;
// this.centerX = Math.floor(e.clientX / w) * w + w / 2;
// this.centerY = Math.floor(e.clientY / h) * h + h / 2;
...
...
@@ -275,14 +268,13 @@ export default class GameView extends engine.Container {
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
// 点击图片的位置
...
...
@@ -343,19 +335,17 @@ export default class GameView extends engine.Container {
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
GAME_TIME
});
this
.
stop
();
}
onMove
(
e
:
engine
.
MouseEvent
)
{
// 当前图片的位置
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
-
(
750
-
props
.
W
)
/
2
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
-
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
// console.log('fuck on this.stage.height', this.stage.height)
// console.log(this.dragPic.x, this.dragPic.y)
// 当前图片的中心位置
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
console
.
log
(
this
.
centerX
,
this
.
centerY
,
"center"
)
}
// onClk(e){
...
...
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