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
6d7c75d5
Commit
6d7c75d5
authored
Jun 04, 2020
by
汪欢
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://gitlab2.dui88.com/laoqifeng/zeroing-libs
into dev
parents
69017731
a0bb5b71
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
48 deletions
+106
-48
.DS_Store
dist/.DS_Store
+0
-0
pictures.json
dist/customs/pictures.json
+14
-4
app.js
src/custom/pictures/debug/app.js
+13
-2
main.js
src/custom/pictures/debug/main.js
+21
-9
main.js.map
src/custom/pictures/debug/main.js.map
+1
-1
meta.json
src/custom/pictures/meta.json
+13
-3
GameView.ts
src/custom/pictures/src/game/GameView.ts
+44
-29
No files found.
dist/.DS_Store
View file @
6d7c75d5
No preview for this file type
dist/customs/pictures.json
View file @
6d7c75d5
This diff is collapsed.
Click to expand it.
src/custom/pictures/debug/app.js
View file @
6d7c75d5
...
...
@@ -50,10 +50,21 @@ function launchWithCustomModule(customModule) {
picUrl
:
"http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png"
});
},
500
);
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
).
x
=
(
d
.
stage
.
width
-
props
.
W
)
/
2
;
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
).
y
=
(
d
.
stage
.
height
-
props
.
H
)
/
2
;
},
1500
);
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"
});
},
10000
);
});
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 @
6d7c75d5
...
...
@@ -12,6 +12,7 @@
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
picMap
=
{};
var
posMap
=
{};
...
...
@@ -59,6 +60,7 @@
posMap
[
url
]
=
pos
.
concat
([]);
return
[
spr
,
pos
];
});
//# sourceMappingURL=qietu.js.map
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
...
...
@@ -76,6 +78,7 @@
return
.
5
-
Math
.
random
();
});
}
//# sourceMappingURL=utils.js.map
var
MAX_COL
;
var
MAX_ROW
;
...
...
@@ -94,6 +97,14 @@
return
_this
;
}
GameView
.
prototype
.
start
=
function
()
{
var
_this
=
this
;
if
(
this
.
pictures
)
{
for
(
var
_i
=
0
,
_a
=
this
.
pictures
;
_i
<
_a
.
length
;
_i
++
)
{
var
pic
=
_a
[
_i
];
if
(
pic
&&
pic
.
parent
)
pic
.
parent
.
removeChild
(
pic
);
}
}
console
.
log
(
'on start'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
...
...
@@ -111,15 +122,17 @@
for
(;
i
<
len
;
i
++
)
{
this
.
dragPic
=
this
.
pictures
[
i
];
this
.
pictures
[
i
].
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDown
,
this
);
var
_
a
=
posList
[
i
],
x
=
_a
[
0
],
y
=
_a
[
1
];
var
_
b
=
posList
[
i
],
x
=
_b
[
0
],
y
=
_b
[
1
];
this
.
dragPic
.
x
=
x
;
this
.
dragPic
.
y
=
y
;
}
this
.
_timer
=
setInterval
(
function
()
{
_this
.
onTimer
();
},
10
);
};
GameView
.
prototype
.
onTimer
=
function
()
{
this
.
_timeCounter
+=
0.01
;
this
.
_timeCounter
=
this
.
afterPointTwo
(
this
.
_timeCounter
);
console
.
log
(
this
.
_timeCounter
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
});
...
...
@@ -222,19 +235,16 @@
};
GameView
.
prototype
.
onSuccess
=
function
()
{
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
this
.
_timeCounter
});
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{});
};
GameView
.
prototype
.
onMove
=
function
(
e
)
{
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
;
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
);
this
.
centerX
=
this
.
dragPic
.
x
+
w
/
2
;
this
.
centerY
=
this
.
dragPic
.
y
+
h
/
2
;
};
GameView
.
prototype
.
onClk
=
function
(
e
)
{
this
.
_timeCounter
=
0
;
this
.
start
();
};
return
GameView
;
}(
engine
.
Container
));
...
...
@@ -257,6 +267,7 @@
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
...
...
@@ -264,6 +275,7 @@
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
...
...
src/custom/pictures/debug/main.js.map
View file @
6d7c75d5
This diff is collapsed.
Click to expand it.
src/custom/pictures/meta.json
View file @
6d7c75d5
...
...
@@ -5,12 +5,12 @@
"MAX_COL"
:
{
"alias"
:
"图片分成几列"
,
"type"
:
"number"
,
"default"
:
3
"default"
:
2
},
"MAX_ROW"
:
{
"alias"
:
"图片分成几行"
,
"type"
:
"number"
,
"default"
:
4
"default"
:
2
},
"W"
:
{
"alias"
:
"图片的宽度"
,
...
...
@@ -22,6 +22,16 @@
"type"
:
"number"
,
"default"
:
827
},
"OFFSET_X"
:
{
"alias"
:
"OFFSET_X"
,
"type"
:
"number"
,
"default"
:
0
},
"OFFSET_Y"
:
{
"alias"
:
"OFFSET_Y"
,
"type"
:
"number"
,
"default"
:
0
},
"GAP"
:
{
"alias"
:
"图片间隙"
,
"type"
:
"number"
,
...
...
@@ -30,7 +40,7 @@
"GAME_TIME"
:
{
"alias"
:
"游戏时间"
,
"type"
:
"number"
,
"default"
:
2
0
"default"
:
5
0
}
},
...
...
src/custom/pictures/src/game/GameView.ts
View file @
6d7c75d5
...
...
@@ -7,6 +7,8 @@ import qietu from "./qietu";
import
{
getIndexFromRC
,
getRandomArray
,
getTextureByName
}
from
"./utils"
;
import
ObjectPool
=
engine
.
ObjectPool
;
// let OFFSET_X;
// let OFFSET_Y;
let
MAX_COL
;
let
MAX_ROW
;
let
W
;
...
...
@@ -22,6 +24,13 @@ export default class GameView extends engine.Container {
private
_timeCounter
=
0
;
start
()
{
if
(
this
.
pictures
)
{
for
(
const
pic
of
this
.
pictures
)
{
if
(
pic
&&
pic
.
parent
)
pic
.
parent
.
removeChild
(
pic
);
}
}
console
.
log
(
'on start'
)
engine
.
globalEvent
.
dispatchEvent
(
'pictures-time-update'
,
{
second
:
this
.
getSecond
(),
...
...
@@ -56,9 +65,9 @@ export default class GameView extends engine.Container {
}
//
this._timer = setInterval(() => {
//
this.onTimer();
//
}, 10)
this
.
_timer
=
setInterval
(()
=>
{
this
.
onTimer
();
},
10
)
}
...
...
@@ -67,7 +76,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
(),
...
...
@@ -81,12 +90,12 @@ export default class GameView extends engine.Container {
}
}
afterPointTwo
(
n
){
afterPointTwo
(
n
)
{
var
floatN
=
parseFloat
(
n
);
if
(
isNaN
(
floatN
))
{
return
;
if
(
isNaN
(
floatN
))
{
return
;
}
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
floatN
=
Math
.
round
(
floatN
*
100
)
/
100
;
return
floatN
;
}
...
...
@@ -96,7 +105,6 @@ export default class GameView extends engine.Container {
}
stop
()
{
// this.countTime = 0
this
.
_timeCounter
=
0
;
clearInterval
(
this
.
_timer
);
...
...
@@ -119,7 +127,7 @@ export default class GameView extends engine.Container {
centerX
:
number
;
centerY
:
number
;
pictures
;
pictures
:
engine
.
Sprite
[]
;
// 点击图片时的一维数组索引
index
;
...
...
@@ -128,7 +136,7 @@ export default class GameView extends engine.Container {
indexJ
:
number
;
rightList
:
engine
.
Sprite
[];
private
picturesWrapper
:
engine
.
Sprite
;
private
guideHole
:
engine
.
Sprite
;
...
...
@@ -141,6 +149,8 @@ export default class GameView extends engine.Container {
MAX_COL
=
props
.
MAX_COL
;
MAX_ROW
=
props
.
MAX_ROW
;
GAME_TIME
=
props
.
GAME_TIME
;
// OFFSET_X = props.OFFSET_X;
// OFFSET_Y = props.OFFSET_Y;
W
=
props
.
W
;
H
=
props
.
H
;
GAP
=
props
.
GAP
;
...
...
@@ -155,6 +165,9 @@ export default class GameView extends engine.Container {
this
.
picturesWrapper
=
parent
;
this
.
addChild
(
parent
);
// this.picturesWrapper.x = OFFSET_X;
// this.picturesWrapper.y = OFFSET_Y;
// 添加按钮
// const btn = new engine.Rect();
// btn.width = 200;
...
...
@@ -223,19 +236,19 @@ export default class GameView extends engine.Container {
this
.
onMove
,
this
);
// 拖动的图片的中心位置在图片之外,回到原来的位置
if
(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
if
(
this
.
centerY
<
0
||
this
.
centerX
<
0
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
this
.
picturesWrapper
.
addChild
(
this
.
guideHole
);
// 判断图片是否进入另一张图片的范围内
// 要交换的图片第几行第几列
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
))
;
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
))
;
let
curJ
=
Math
.
floor
(
this
.
centerX
/
(
w
+
GAP
));
let
curI
=
Math
.
floor
(
this
.
centerY
/
(
h
+
GAP
));
// 点击图片的位置
...
...
@@ -267,7 +280,7 @@ export default class GameView extends engine.Container {
this
.
pictures
[
dragPicIndex
]
=
dropPic
;
// 图片中心还是在原来的位置
if
(
dragPicIndex
===
dropPicIndex
)
{
if
(
dragPicIndex
===
dropPicIndex
)
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
...
...
@@ -284,7 +297,7 @@ export default class GameView extends engine.Container {
this
.
onSuccess
();
}
}
else
{
}
else
{
this
.
dragPic
.
x
=
this
.
distanceX
this
.
dragPic
.
y
=
this
.
distanceY
}
...
...
@@ -298,14 +311,16 @@ export default class GameView extends engine.Container {
private
onSuccess
()
{
console
.
log
(
'拼图成功!'
);
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{
time
:
this
.
_timeCounter
});
this
.
stop
();
engine
.
globalEvent
.
dispatchEvent
(
'pictures-game-success'
,
{});
}
onMove
(
e
:
engine
.
MouseEvent
)
{
// 当前图片的位置
this
.
dragPic
.
x
=
e
.
stageX
-
this
.
localPicX
;
this
.
dragPic
.
y
=
e
.
stageY
-
this
.
localPicY
;
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
;
...
...
@@ -313,13 +328,13 @@ export default class GameView extends engine.Container {
}
onClk
(
e
){
// 重置时间
this
.
_timeCounter
=
0
;
//重置图片顺序
this
.
start
();
}
//
onClk(e){
//
// 重置时间
//
this._timeCounter = 0;
//
//重置图片顺序
//
}
}
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