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
b5cf2632
Commit
b5cf2632
authored
Jun 08, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拼图长按bug
parent
634f2330
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
60 deletions
+75
-60
app.js
src/custom/pictures/debug/app.js
+7
-7
main.js
src/custom/pictures/debug/main.js
+58
-51
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
+8
-0
No files found.
src/custom/pictures/debug/app.js
View file @
b5cf2632
...
...
@@ -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"
//
});
},
30
*
1000
);
//
}, 30*1000);
});
engine
.
globalEvent
.
addEventListener
(
'pictures-time-update'
,
(
e
)
=>
{
// console.log(e.type, e.data);
...
...
src/custom/pictures/debug/main.js
View file @
b5cf2632
...
...
@@ -100,7 +100,7 @@
var
_this
=
this
;
if
(
!
this
.
guideHole
)
{
this
.
guideHole
=
new
engine
.
Image
();
this
.
guideHole
.
source
=
'asset://'
+
props
.
blockUrl
;
this
.
guideHole
.
source
=
"asset://"
+
props
.
blockUrl
;
this
.
guideHole
.
mouseChildren
=
this
.
guideHole
.
mouseEnabled
=
false
;
}
if
(
this
.
pictures
)
{
...
...
@@ -110,8 +110,8 @@
pic
.
parent
.
removeChild
(
pic
);
}
}
console
.
log
(
'on start'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
console
.
log
(
"on start"
);
engine
.
globalEvent
.
dispatchEvent
(
"pictures-time-update"
,
{
second
:
this
.
getSecond
(),
});
var
result
=
qietu
(
this
.
picturesWrapper
,
props
.
picUrl
,
MAX_COL
,
MAX_ROW
);
...
...
@@ -140,16 +140,17 @@
GAME_TIME
=
this
.
afterPointTwo
(
GAME_TIME
);
GAME_TIME
=
GAME_TIME
.
toFixed
(
2
);
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
(),
});
if
(
this
.
getSecond
()
==
0
)
{
GAME_TIME
=
props
.
GAME_TIME
;
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-fail'
,
{
reason
:
1
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-fail"
,
{
reason
:
1
,
});
}
};
...
...
@@ -166,6 +167,7 @@
};
GameView
.
prototype
.
stop
=
function
()
{
clearInterval
(
this
.
_timer
);
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
var
len
=
this
.
pictures
.
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
this
.
pictures
[
i
].
removeAllEventListener
();
...
...
@@ -181,7 +183,7 @@
GAP
=
props
.
GAP
;
w
=
W
/
MAX_COL
;
h
=
H
/
MAX_ROW
;
console
.
log
(
'onSteup'
,
props
);
console
.
log
(
"onSteup"
,
props
);
var
parent
=
new
engine
.
Sprite
();
this
.
picturesWrapper
=
parent
;
this
.
addChild
(
parent
);
...
...
@@ -195,67 +197,72 @@
this
.
localPicY
=
e
.
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
.
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
((
e
.
clientX
-
stageLeft
)
/
w
)
*
w
+
w
/
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_UP
,
this
.
stageOnUp
,
this
);
};
GameView
.
prototype
.
stageOnUp
=
function
(
e
)
{
var
stageLeft
=
(
750
-
props
.
W
)
/
2
;
var
stageTop
=
(
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
);
if
(
this
.
centerY
<
stageTop
||
this
.
centerX
<
stageLeft
)
{
this
.
dragPic
.
x
=
this
.
distanceX
;
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
)
{
GameView
.
prototype
.
stageOnUp
=
function
()
{
if
(
GAME_TIME
>
0
)
{
var
stageLeft
=
(
750
-
props
.
W
)
/
2
;
var
stageTop
=
(
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
);
if
(
this
.
centerY
<
stageTop
||
this
.
centerX
<
stageLeft
)
{
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
;
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
.
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
)
{
this
.
onSuccess
();
else
{
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
()
{
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
GAME_TIME
});
console
.
log
(
"拼图成功!"
);
engine
.
globalEvent
.
dispatchEvent
(
"pictures-game-success"
,
{
time
:
GAME_TIME
,
});
this
.
stop
();
};
GameView
.
prototype
.
onMove
=
function
(
e
)
{
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
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
};
...
...
src/custom/pictures/debug/main.js.map
View file @
b5cf2632
This diff is collapsed.
Click to expand it.
src/custom/pictures/meta.json
View file @
b5cf2632
...
...
@@ -40,7 +40,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
5
0
"default"
:
5
}
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
b5cf2632
...
...
@@ -124,12 +124,20 @@ export default class GameView extends engine.Container {
}
stop
()
{
// GAME_TIME = props.GAME_TIME
clearInterval
(
this
.
_timer
);
let
len
=
this
.
pictures
.
length
;
for
(
let
i
=
0
;
i
<
len
;
i
++
){
this
.
pictures
[
i
].
removeAllEventListener
();
}
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
}
constructor
()
{
...
...
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