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
6d9121cd
Commit
6d9121cd
authored
Jun 03, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拼图0.2
parent
53727adb
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
11 deletions
+56
-11
main.js
src/custom/pictures/debug/main.js
+20
-3
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
+32
-4
No files found.
src/custom/pictures/debug/main.js
View file @
6d9121cd
...
...
@@ -79,7 +79,6 @@
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_timeCounter
=
0
;
_this
.
countTime
=
10
;
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
return
_this
;
}
...
...
@@ -106,10 +105,12 @@
}
this
.
_timer
=
setInterval
(
function
()
{
_this
.
onTimer
();
},
10
00
);
},
10
);
};
GameView
.
prototype
.
onTimer
=
function
()
{
this
.
_timeCounter
++
;
this
.
_timeCounter
+=
0.01
;
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
);
console
.
log
(
this
.
_timeCounter
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
});
...
...
@@ -120,6 +121,14 @@
});
}
};
GameView
.
prototype
.
afterPointTwo
=
function
(
n
)
{
var
floatN
=
parseFloat
(
n
);
if
(
isNaN
(
floatN
))
{
return
;
}
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
return
floatN
;
};
GameView
.
prototype
.
getSecond
=
function
()
{
return
GAME_TIME
-
this
.
_timeCounter
;
};
...
...
@@ -174,6 +183,10 @@
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
])
{
...
...
@@ -185,6 +198,10 @@
this
.
onSuccess
();
}
}
else
{
this
.
dragPic
.
x
=
this
.
distanceX
;
this
.
dragPic
.
y
=
this
.
distanceY
;
}
this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
stageOnUp
,
this
);
};
GameView
.
prototype
.
onSuccess
=
function
()
{
...
...
src/custom/pictures/debug/main.js.map
View file @
6d9121cd
This diff is collapsed.
Click to expand it.
src/custom/pictures/meta.json
View file @
6d9121cd
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
2
"default"
:
3
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
2
"default"
:
3
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -30,7 +30,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
1
0
"default"
:
2
0
}
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
6d9121cd
...
...
@@ -21,6 +21,9 @@ export default class GameView extends engine.Container {
private
_timer
;
private
_timeCounter
=
0
;
// 倒计时时间
// private countTime = 20;
start
()
{
console
.
log
(
'on start'
)
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
...
...
@@ -53,12 +56,17 @@ export default class GameView extends engine.Container {
this
.
_timer
=
setInterval
(()
=>
{
this
.
onTimer
();
},
10
00
)
},
10
)
}
onTimer
()
{
this
.
_timeCounter
++
;
// this._timeCounter++;
this
.
_timeCounter
+=
0.01
;
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
);
// this._timeCounter = Math.floor((this._timeCounter + 0.1) * 10) / 10;
console
.
log
(
this
.
_timeCounter
)
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
});
...
...
@@ -71,11 +79,23 @@ export default class GameView extends engine.Container {
}
}
afterPointTwo
(
n
){
var
floatN
=
parseFloat
(
n
);
if
(
isNaN
(
floatN
)){
return
;
}
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
return
floatN
;
}
getSecond
()
{
return
GAME_TIME
-
this
.
_timeCounter
;
// return GAME_TIME - this.countTime;
}
stop
()
{
// this.countTime = 0
this
.
_timeCounter
=
0
;
clearInterval
(
this
.
_timer
);
}
...
...
@@ -105,8 +125,7 @@ export default class GameView extends engine.Container {
indexJ
:
number
;
rightList
:
engine
.
Sprite
[];
// 倒计时时间
countTime
=
10
;
private
picturesWrapper
:
engine
.
Sprite
;
...
...
@@ -208,6 +227,12 @@ export default class GameView extends engine.Container {
this
.
pictures
[
dropPicIndex
]
=
this
.
dragPic
;
this
.
pictures
[
dragPicIndex
]
=
dropPic
;
// 图片还是在原来的位置
if
(
dragPicIndex
===
dropPicIndex
){
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
let
result
=
true
;
for
(
let
j
=
0
;
j
<
this
.
rightList
.
length
;
j
++
)
{
if
(
this
.
rightList
[
j
]
!=
this
.
pictures
[
j
])
{
...
...
@@ -220,6 +245,9 @@ export default class GameView extends engine.Container {
this
.
onSuccess
();
}
}
else
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
this
.
stage
.
removeEventListener
(
...
...
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