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
589c0357
Commit
589c0357
authored
Jun 10, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
ca76151e
b5cf2632
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
75 deletions
+78
-75
app.js
src/custom/pictures/debug/app.js
+1
-1
main.js
src/custom/pictures/debug/main.js
+59
-54
main.js.map
src/custom/pictures/debug/main.js.map
+1
-1
meta.json
src/custom/pictures/meta.json
+1
-1
GameView.ts
src/custom/pictures/src/game/GameView.ts
+16
-18
No files found.
src/custom/pictures/debug/app.js
View file @
589c0357
...
@@ -63,7 +63,7 @@ function launchWithCustomModule(customModule) {
...
@@ -63,7 +63,7 @@ function launchWithCustomModule(customModule) {
// blockUrl: "888"
// blockUrl: "888"
// });
// });
// },
5
*1000);
// },
30
*1000);
});
});
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
// console.log(e.type, e.data);
// console.log(e.type, e.data);
...
...
src/custom/pictures/debug/main.js
View file @
589c0357
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
var
_this
=
this
;
var
_this
=
this
;
if
(
!
this
.
guideHole
)
{
if
(
!
this
.
guideHole
)
{
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
this
.
guideHole
.
source
=
"asset://"
+
props
.
blockUrl
;
this
.
guideHole
.
mouseChildren
=
this
.
guideHole
.
mouseEnabled
=
false
;
this
.
guideHole
.
mouseChildren
=
this
.
guideHole
.
mouseEnabled
=
false
;
}
}
if
(
this
.
pictures
)
{
if
(
this
.
pictures
)
{
...
@@ -110,8 +110,8 @@
...
@@ -110,8 +110,8 @@
pic
.
parent
.
removeChild
(
pic
);
pic
.
parent
.
removeChild
(
pic
);
}
}
}
}
console
.
log
(
'on start'
);
console
.
log
(
"on start"
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
engine
.
globalEvent
.
dispatchEvent
(
"pictures-time-update"
,
{
second
:
this
.
getSecond
(),
second
:
this
.
getSecond
(),
});
});
var
result
=
qietu
(
this
.
picturesWrapper
,
props
.
picUrl
,
MAX_COL
,
MAX_ROW
);
var
result
=
qietu
(
this
.
picturesWrapper
,
props
.
picUrl
,
MAX_COL
,
MAX_ROW
);
...
@@ -140,15 +140,17 @@
...
@@ -140,15 +140,17 @@
GAME_TIME
=
this
.
afterPointTwo
(
GAME_TIME
);
GAME_TIME
=
this
.
afterPointTwo
(
GAME_TIME
);
GAME_TIME
=
GAME_TIME
.
toFixed
(
2
);
GAME_TIME
=
GAME_TIME
.
toFixed
(
2
);
if
(
GAME_TIME
<
10
)
{
if
(
GAME_TIME
<
10
)
{
GAME_TIME
=
'0'
+
GAME_TIME
;
GAME_TIME
=
"0"
+
GAME_TIME
;
}
}
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
console
.
log
(
GAME_TIME
);
engine
.
globalEvent
.
dispatchEvent
(
"pictures-time-update"
,
{
second
:
this
.
getSecond
(),
second
:
this
.
getSecond
(),
});
});
if
(
this
.
getSecond
()
==
0
)
{
if
(
this
.
getSecond
()
==
0
)
{
GAME_TIME
=
props
.
GAME_TIME
;
this
.
stop
();
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-fail"
,
{
reason
:
1
reason
:
1
,
});
});
}
}
};
};
...
@@ -164,8 +166,8 @@
...
@@ -164,8 +166,8 @@
return
GAME_TIME
;
return
GAME_TIME
;
};
};
GameView
.
prototype
.
stop
=
function
()
{
GameView
.
prototype
.
stop
=
function
()
{
GAME_TIME
=
props
.
GAME_TIME
;
clearInterval
(
this
.
_timer
);
clearInterval
(
this
.
_timer
);
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
var
len
=
this
.
pictures
.
length
;
var
len
=
this
.
pictures
.
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
this
.
pictures
[
i
].
removeAllEventListener
();
this
.
pictures
[
i
].
removeAllEventListener
();
...
@@ -181,7 +183,7 @@
...
@@ -181,7 +183,7 @@
GAP
=
props
.
GAP
;
GAP
=
props
.
GAP
;
w
=
W
/
MAX_COL
;
w
=
W
/
MAX_COL
;
h
=
H
/
MAX_ROW
;
h
=
H
/
MAX_ROW
;
console
.
log
(
'onSteup'
,
props
);
console
.
log
(
"onSteup"
,
props
);
var
parent
=
new
engine
.
Sprite
();
var
parent
=
new
engine
.
Sprite
();
this
.
picturesWrapper
=
parent
;
this
.
picturesWrapper
=
parent
;
this
.
addChild
(
parent
);
this
.
addChild
(
parent
);
...
@@ -195,74 +197,77 @@
...
@@ -195,74 +197,77 @@
this
.
localPicY
=
e
.
localY
/
MAX_ROW
;
this
.
localPicY
=
e
.
localY
/
MAX_ROW
;
this
.
distanceX
=
this
.
dragPic
.
x
;
this
.
distanceX
=
this
.
dragPic
.
x
;
this
.
distanceY
=
this
.
dragPic
.
y
;
this
.
distanceY
=
this
.
dragPic
.
y
;
this
.
indexJ
=
Math
.
floor
(
(
this
.
distanceX
)
/
(
w
+
GAP
));
this
.
indexJ
=
Math
.
floor
(
this
.
distanceX
/
(
w
+
GAP
));
this
.
indexI
=
Math
.
floor
(
(
this
.
distanceY
)
/
(
h
+
GAP
));
this
.
indexI
=
Math
.
floor
(
this
.
distanceY
/
(
h
+
GAP
));
this
.
index
=
(
this
.
indexI
)
*
MAX_COL
+
this
.
indexJ
;
this
.
index
=
this
.
indexI
*
MAX_COL
+
this
.
indexJ
;
this
.
centerX
=
Math
.
floor
((
e
.
clientX
-
stageLeft
)
/
w
)
*
w
+
w
/
2
;
this
.
centerX
=
Math
.
floor
((
e
.
clientX
-
stageLeft
)
/
w
)
*
w
+
w
/
2
;
this
.
centerY
=
Math
.
floor
((
e
.
clientY
-
stageTop
)
/
h
)
*
h
+
h
/
2
;
this
.
centerY
=
Math
.
floor
((
e
.
clientY
-
stageTop
)
/
h
)
*
h
+
h
/
2
;
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
);
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
);
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
};
};
GameView
.
prototype
.
stageOnUp
=
function
(
e
)
{
GameView
.
prototype
.
stageOnUp
=
function
()
{
var
stageLeft
=
(
750
-
props
.
W
)
/
2
;
if
(
GAME_TIME
>
0
)
{
var
stageTop
=
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
var
stageLeft
=
(
750
-
props
.
W
)
/
2
;
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
);
var
stageTop
=
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMove
,
this
);
if
(
this
.
centerY
<
stageTop
||
this
.
centerX
<
stageLeft
)
{
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
this
.
dragPic
.
x
=
this
.
distanceX
;
if
(
this
.
centerY
<
stageTop
||
this
.
centerX
<
stageLeft
)
{
this
.
dragPic
.
y
=
this
.
distanceY
;
}
var
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
var
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
if
(
0
<=
curJ
&&
curJ
<
(
MAX_COL
)
&&
0
<=
curI
&&
curI
<
(
MAX_ROW
))
{
var
index
=
getIndexFromRC
(
curI
,
curJ
,
MAX_COL
);
var
dropPic
=
this
.
pictures
[
index
];
var
dropPicX
=
dropPic
.
x
+
stageLeft
;
var
dropPicy
=
dropPic
.
y
+
stageTop
;
dropPic
.
x
=
this
.
distanceX
;
dropPic
.
y
=
this
.
distanceY
;
this
.
dragPic
.
x
=
dropPicX
-
stageLeft
;
this
.
dragPic
.
y
=
dropPicy
-
stageTop
;
var
dropPicIndex
=
this
.
pictures
.
indexOf
(
dropPic
);
var
dragPicIndex
=
this
.
pictures
.
indexOf
(
this
.
dragPic
);
this
.
pictures
[
dropPicIndex
]
=
this
.
dragPic
;
this
.
pictures
[
dragPicIndex
]
=
dropPic
;
if
(
dragPicIndex
===
dropPicIndex
)
{
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
}
var
result
=
true
;
var
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
for
(
var
j
=
0
;
j
<
this
.
rightList
.
length
;
j
++
)
{
var
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
if
(
this
.
rightList
[
j
]
!=
this
.
pictures
[
j
])
{
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
result
=
false
;
if
(
0
<=
curJ
&&
curJ
<
MAX_COL
&&
0
<=
curI
&&
curI
<
MAX_ROW
)
{
break
;
var
index
=
getIndexFromRC
(
curI
,
curJ
,
MAX_COL
);
var
dropPic
=
this
.
pictures
[
index
];
var
dropPicX
=
dropPic
.
x
+
stageLeft
;
var
dropPicy
=
dropPic
.
y
+
stageTop
;
dropPic
.
x
=
this
.
distanceX
;
dropPic
.
y
=
this
.
distanceY
;
this
.
dragPic
.
x
=
dropPicX
-
stageLeft
;
this
.
dragPic
.
y
=
dropPicy
-
stageTop
;
var
dropPicIndex
=
this
.
pictures
.
indexOf
(
dropPic
);
var
dragPicIndex
=
this
.
pictures
.
indexOf
(
this
.
dragPic
);
this
.
pictures
[
dropPicIndex
]
=
this
.
dragPic
;
this
.
pictures
[
dragPicIndex
]
=
dropPic
;
if
(
dragPicIndex
===
dropPicIndex
)
{
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
var
result
=
true
;
for
(
var
j
=
0
;
j
<
this
.
rightList
.
length
;
j
++
)
{
if
(
this
.
rightList
[
j
]
!=
this
.
pictures
[
j
])
{
result
=
false
;
break
;
}
}
if
(
result
)
{
this
.
onSuccess
();
}
}
}
}
if
(
result
)
{
else
{
this
.
onSuccess
();
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
}
}
}
else
{
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
};
};
GameView
.
prototype
.
onSuccess
=
function
()
{
GameView
.
prototype
.
onSuccess
=
function
()
{
console
.
log
(
'拼图成功!'
);
console
.
log
(
"拼图成功!"
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
GAME_TIME
});
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-success"
,
{
time
:
GAME_TIME
,
});
this
.
stop
();
this
.
stop
();
};
};
GameView
.
prototype
.
onMove
=
function
(
e
)
{
GameView
.
prototype
.
onMove
=
function
(
e
)
{
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
-
(
750
-
props
.
W
)
/
2
;
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
-
(
750
-
props
.
W
)
/
2
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
-
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
-
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
console
.
log
(
this
.
centerX
,
this
.
centerY
,
"center"
);
};
};
return
GameView
;
return
GameView
;
}(
engine
.
Container
));
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
tslib
.
__extends
(
GameWrapper
,
_super
);
...
...
src/custom/pictures/debug/main.js.map
View file @
589c0357
This diff is collapsed.
Click to expand it.
src/custom/pictures/meta.json
View file @
589c0357
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
"GAME_TIME"
:
{
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"type"
:
"number"
,
"default"
:
5
0
"default"
:
5
}
}
},
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
589c0357
...
@@ -19,11 +19,13 @@ let GAME_TIME;
...
@@ -19,11 +19,13 @@ let GAME_TIME;
let
w
;
let
w
;
// 每张图片高
// 每张图片高
let
h
;
let
h
;
export
default
class
GameView
extends
engine
.
Container
{
export
default
class
GameView
extends
engine
.
Container
{
private
_timer
;
private
_timer
;
private
_timeCounter
=
0
;
private
_timeCounter
=
0
;
start
()
{
start
()
{
if
(
!
this
.
guideHole
)
{
if
(
!
this
.
guideHole
)
{
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
...
@@ -94,6 +96,7 @@ export default class GameView extends engine.Container {
...
@@ -94,6 +96,7 @@ export default class GameView extends engine.Container {
});
});
if
(
this
.
getSecond
()
==
0
)
{
if
(
this
.
getSecond
()
==
0
)
{
GAME_TIME
=
props
.
GAME_TIME
this
.
stop
();
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
reason
:
1
reason
:
1
...
@@ -121,12 +124,20 @@ export default class GameView extends engine.Container {
...
@@ -121,12 +124,20 @@ export default class GameView extends engine.Container {
}
}
stop
()
{
stop
()
{
GAME_TIME
=
props
.
GAME_TIME
// GAME_TIME = props.GAME_TIME
clearInterval
(
this
.
_timer
);
clearInterval
(
this
.
_timer
);
let
len
=
this
.
pictures
.
length
;
let
len
=
this
.
pictures
.
length
;
for
(
let
i
=
0
;
i
<
len
;
i
++
){
for
(
let
i
=
0
;
i
<
len
;
i
++
){
this
.
pictures
[
i
].
removeAllEventListener
();
this
.
pictures
[
i
].
removeAllEventListener
();
}
}
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
}
}
constructor
()
{
constructor
()
{
...
@@ -216,22 +227,12 @@ export default class GameView extends engine.Container {
...
@@ -216,22 +227,12 @@ export default class GameView extends engine.Container {
this
.
distanceY
=
this
.
dragPic
.
y
;
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
.
indexJ
=
Math
.
floor
((
this
.
distanceX
)
/
(
w
+
GAP
));
this
.
indexI
=
Math
.
floor
((
this
.
distanceY
)
/
(
h
+
GAP
));
this
.
indexI
=
Math
.
floor
((
this
.
distanceY
)
/
(
h
+
GAP
));
this
.
index
=
(
this
.
indexI
)
*
MAX_COL
+
this
.
indexJ
;
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.centerX = Math.floor(e.clientX / w) * w + w / 2;
// this.centerY = Math.floor(e.clientY / h) * h + h / 2;
// this.centerY = Math.floor(e.clientY / h) * h + h / 2;
...
@@ -275,15 +276,14 @@ export default class GameView extends engine.Container {
...
@@ -275,15 +276,14 @@ export default class GameView extends engine.Container {
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
}
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
// 点击图片的位置
// 点击图片的位置
...
@@ -343,19 +343,17 @@ export default class GameView extends engine.Container {
...
@@ -343,19 +343,17 @@ export default class GameView extends engine.Container {
console
.
log
(
'拼图成功!'
);
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
GAME_TIME
});
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
GAME_TIME
});
this
.
stop
();
this
.
stop
();
}
}
onMove
(
e
:
engine
.
MouseEvent
)
{
onMove
(
e
:
engine
.
MouseEvent
)
{
// 当前图片的位置
// 当前图片的位置
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
-
(
750
-
props
.
W
)
/
2
;
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
-
(
750
-
props
.
W
)
/
2
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
-
(
this
.
stage
.
height
-
props
.
H
)
/
2
;
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
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
console
.
log
(
this
.
centerX
,
this
.
centerY
,
"center"
)
}
}
// onClk(e){
// 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