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
0e85c3c0
Commit
0e85c3c0
authored
Jun 29, 2020
by
任建锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--
parent
91229572
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
146 additions
and
76 deletions
+146
-76
.DS_Store
.DS_Store
+0
-0
.DS_Store
dist/.DS_Store
+0
-0
food-fell2.json
dist/customs/food-fell2.json
+1
-1
main.js
src/custom/dragon-boat-race/debug/main.js
+11
-4
main.js.map
src/custom/dragon-boat-race/debug/main.js.map
+1
-1
meta.json
src/custom/dragon-boat-race/meta.json
+5
-0
GameView.ts
src/custom/dragon-boat-race/src/game/GameView.ts
+5
-4
main.js
src/custom/food-fell2/debug/main.js
+53
-32
main.js.map
src/custom/food-fell2/debug/main.js.map
+1
-1
meta.json
src/custom/food-fell2/meta.json
+1
-1
GameView.ts
src/custom/food-fell2/src/game/GameView.ts
+67
-31
Goods.ts
src/custom/food-fell2/src/game/Goods.ts
+1
-1
No files found.
.DS_Store
View file @
0e85c3c0
No preview for this file type
dist/.DS_Store
View file @
0e85c3c0
No preview for this file type
dist/customs/food-fell2.json
View file @
0e85c3c0
This diff is collapsed.
Click to expand it.
src/custom/dragon-boat-race/debug/main.js
View file @
0e85c3c0
...
...
@@ -215,7 +215,7 @@
this
.
visible
=
false
;
setTimeout
(
function
()
{
_this
.
visible
=
true
;
_this
.
player
.
x
=
375
-
_this
.
player
.
width
/
2
;
_this
.
player
.
x
=
props
.
playerPositionX
;
_this
.
player
.
y
=
props
.
playerPositionY
;
_this
.
playerSvgaRun
.
x
=
props
.
playerRunPosition3Offset
[
0
];
_this
.
playerSvgaRun
.
y
=
props
.
playerRunPosition3Offset
[
1
];
...
...
@@ -276,11 +276,11 @@
GameView
.
prototype
.
reset
=
function
()
{
this
.
recycleGoods
();
this
.
score
=
0
;
this
.
speed
=
1
;
this
.
bg
.
y
=
-
1624
;
this
.
speed
=
props
.
speed
;
this
.
bg
.
y
=
-
this
.
bg3
.
y
;
this
.
player
.
anchorY
=
this
.
player
.
height
/
2
;
this
.
player
.
anchorX
=
this
.
player
.
width
/
2
;
this
.
player
.
x
=
375
-
this
.
player
.
width
/
2
;
this
.
player
.
x
=
props
.
playerPositionX
;
this
.
player
.
y
=
props
.
playerPositionY
;
this
.
setPlayState
(
this
.
playerSvgaReset
);
};
...
...
@@ -332,6 +332,7 @@
var
_this
=
this
;
this
.
timer
=
setTimeout
(
function
()
{
if
(
_this
.
gameIng
)
{
_this
.
speed
+=
props
.
acceleratedSpeed
;
_this
.
speed
+=
props
.
acceleratedSpeed
;
if
(
_this
.
speed
>
props
.
maxSpeed
)
{
_this
.
speed
=
props
.
maxSpeed
;
...
...
@@ -368,6 +369,9 @@
if
(
goods
[
"npcType"
]
==
"rain0"
)
{
console
.
log
(
"碰到雨滴"
);
_this
.
score
+=
props
.
rainScore
;
if
(
_this
.
score
<
0
)
{
_this
.
score
=
0
;
}
_this
.
setBoomPosition
(
_this
.
waterSvga
);
engine
.
Tween
.
get
(
goods
,
null
,
null
,
true
)
.
to
({
scaleX
:
0
,
scaleY
:
0
},
200
)
...
...
@@ -376,6 +380,9 @@
else
if
(
goods
[
"npcType"
]
==
"rain1"
)
{
console
.
log
(
"碰到雨滴"
);
_this
.
score
+=
props
.
rain2Score
;
if
(
_this
.
score
<
0
)
{
_this
.
score
=
0
;
}
_this
.
setBoomPosition
(
_this
.
water2Svga
);
engine
.
Tween
.
get
(
goods
,
null
,
null
,
true
)
.
to
({
scaleX
:
0
,
scaleY
:
0
},
200
)
...
...
src/custom/dragon-boat-race/debug/main.js.map
View file @
0e85c3c0
This diff is collapsed.
Click to expand it.
src/custom/dragon-boat-race/meta.json
View file @
0e85c3c0
...
...
@@ -7,6 +7,11 @@
"type"
:
"number"
,
"default"
:
900
},
"playerPositionX"
:
{
"alias"
:
"玩家Y轴位置"
,
"type"
:
"number"
,
"default"
:
300
},
"runScore"
:
{
"alias"
:
"每前进1米加分(不能小于1)"
,
"type"
:
"number"
,
...
...
src/custom/dragon-boat-race/src/game/GameView.ts
View file @
0e85c3c0
...
...
@@ -130,7 +130,7 @@ export default class GameView extends engine.Container {
this
.
visible
=
true
;
//this.player.anchorY = this.player.height / 2;
// this.player.anchorX = this.player.width / 2;
this
.
player
.
x
=
375
-
this
.
player
.
width
/
2
;
this
.
player
.
x
=
props
.
playerPositionX
;
this
.
player
.
y
=
props
.
playerPositionY
;
// this.stoneSvga.x = this.player.width / 2 - this.stoneSvga.width/2 + props.boomPosition1Offset[0];
...
...
@@ -228,12 +228,12 @@ export default class GameView extends engine.Container {
reset
()
{
this
.
recycleGoods
()
this
.
score
=
0
;
this
.
speed
=
1
;
this
.
bg
.
y
=-
1624
this
.
speed
=
props
.
speed
;
this
.
bg
.
y
=-
this
.
bg3
.
y
this
.
player
.
anchorY
=
this
.
player
.
height
/
2
;
this
.
player
.
anchorX
=
this
.
player
.
width
/
2
;
this
.
player
.
x
=
375
-
this
.
player
.
width
/
2
;
this
.
player
.
x
=
props
.
playerPositionX
;
this
.
player
.
y
=
props
.
playerPositionY
;
this
.
setPlayState
(
this
.
playerSvgaReset
)
}
...
...
@@ -292,6 +292,7 @@ export default class GameView extends engine.Container {
beginNpc
()
{
this
.
timer
=
setTimeout
(()
=>
{
if
(
this
.
gameIng
)
{
this
.
speed
+=
props
.
acceleratedSpeed
;
this
.
speed
+=
props
.
acceleratedSpeed
;
if
(
this
.
speed
>
props
.
maxSpeed
){
this
.
speed
=
props
.
maxSpeed
...
...
src/custom/food-fell2/debug/main.js
View file @
0e85c3c0
...
...
@@ -67,7 +67,6 @@
var
random
=
Math
.
random
();
if
(
typeof
(
props
.
goodsProbability
)
==
'string'
)
{
props
.
goodsProbability
=
props
.
goodsProbability
.
split
(
','
).
map
(
function
(
i
)
{
return
+
i
;
});
console
.
log
(
props
.
goodsProbability
);
}
if
(
random
<
props
.
goodsProbability
[
0
])
{
var
randomNum
=
Math
.
floor
(
Math
.
random
()
*
3
);
...
...
@@ -117,6 +116,9 @@
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
goodsItems
=
[];
_this
.
viewVisible
=
true
;
_this
.
cacheTime
=
0
;
_this
.
cacheTime2
=
0
;
_this
.
moveCatchX
=
0
;
_this
.
playerCatchX
=
0
;
_this
.
onDownStage
=
function
(
e
)
{
...
...
@@ -191,47 +193,71 @@
this
.
rectBg
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDownStage
,
this
);
this
.
rectBg
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onMoveStage
,
this
);
this
.
rectBg
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_OUT
,
this
.
onOutStage
,
this
);
document
.
addEventListener
(
"visibilitychange"
,
function
()
{
if
(
document
.
visibilityState
==
"visible"
)
{
_this
.
viewVisible
=
true
;
}
if
(
document
.
visibilityState
==
"hidden"
)
{
_this
.
viewVisible
=
false
;
}
});
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
enterFrame
,
this
);
};
GameView
.
prototype
.
enterFrame
=
function
()
{
this
.
updateTime
();
this
.
updateTimeBeginNpc
();
};
GameView
.
prototype
.
reset
=
function
()
{
this
.
score
=
0
;
this
.
score
=
props
.
speed
;
this
.
recycleGoods
();
this
.
player
.
x
=
375
-
this
.
player
.
width
/
2
;
};
GameView
.
prototype
.
start
=
function
()
{
var
_this
=
this
;
this
.
score
=
0
;
this
.
speed
=
1
;
this
.
gameIng
=
true
;
this
.
creatNpc
();
this
.
beginNpc
();
this
.
countdown
=
props
.
countDown
;
this
.
countdownTimer
=
setInterval
(
function
()
{
if
(
_this
.
gameIng
)
{
if
(
_this
.
countdown
>
0
)
{
};
GameView
.
prototype
.
updateTime
=
function
()
{
if
(
Date
.
now
()
-
this
.
cacheTime
>
1000
)
{
this
.
cacheTime
=
Date
.
now
();
}
else
{
return
;
}
if
(
this
.
gameIng
)
{
if
(
this
.
countdown
>
0
)
{
engine
.
globalEvent
.
dispatchEvent
(
'food-fell-time-update'
,
{
time
:
_
this
.
countdown
,
time
:
this
.
countdown
,
});
_
this
.
countdown
-=
1
;
this
.
countdown
-=
1
;
}
else
{
engine
.
globalEvent
.
dispatchEvent
(
'food-fell-game-over'
,
{
score
:
_
this
.
score
,
score
:
this
.
score
,
reason
:
1
});
_
this
.
died
();
this
.
died
();
}
}
},
1000
);
};
GameView
.
prototype
.
beginNpc
=
function
()
{
var
_this
=
this
;
this
.
timer
=
setTimeout
(
function
()
{
if
(
_this
.
gameIng
)
{
_this
.
speed
+=
props
.
acceleratedSpeed
;
_this
.
creatNpc
();
};
GameView
.
prototype
.
updateTimeBeginNpc
=
function
()
{
if
(
Date
.
now
()
-
this
.
cacheTime2
>
(
2000
/
this
.
speed
))
{
this
.
cacheTime2
=
Date
.
now
();
}
else
{
return
;
}
if
(
this
.
gameIng
)
{
this
.
speed
+=
props
.
acceleratedSpeed
;
if
(
this
.
speed
>=
props
.
maxSpeed
)
{
this
.
speed
=
props
.
maxSpeed
;
}
this
.
creatNpc
();
}
_this
.
beginNpc
();
},
2000
/
this
.
speed
);
};
GameView
.
prototype
.
pause
=
function
()
{
this
.
gameIng
=
false
;
...
...
@@ -247,7 +273,6 @@
var
_this
=
this
;
var
goods
=
this
.
_goods
=
ObjectPool$1
.
getObject
(
PoolName
);
this
.
goodsItems
.
push
(
goods
);
console
.
log
(
goods
);
this
.
NpcBg
.
addChild
(
goods
);
goods
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
goods
[
"onGoodsEnter"
]
=
function
()
{
if
(
goods
.
y
>
1624
)
{
...
...
@@ -258,7 +283,6 @@
goods
.
y
+=
(
4
*
_this
.
speed
);
if
(
_this
.
hasHit
(
_this
.
player
,
goods
))
{
if
(
goods
[
"npcType"
].
indexOf
(
"rain"
)
>
-
1
)
{
console
.
log
(
"碰到雨滴"
);
_this
.
score
+=
props
.
rainScore
;
_this
.
waterSvga
.
visible
=
true
;
_this
.
waterSvga
.
play
(
false
,
false
);
...
...
@@ -270,7 +294,6 @@
}
}
else
if
(
goods
[
"npcType"
]
==
"stone"
)
{
console
.
log
(
"碰到石头"
);
_this
.
score
+=
props
.
stoneScore
;
if
(
_this
.
score
<
0
)
{
_this
.
score
=
0
;
...
...
@@ -282,7 +305,6 @@
},
_this
);
}
else
if
(
goods
[
"npcType"
]
==
"boom"
)
{
console
.
log
(
"碰到炸弹"
);
_this
.
boomSvga
.
visible
=
true
;
_this
.
boomSvga
.
play
(
false
,
false
);
_this
.
died
();
...
...
@@ -332,7 +354,6 @@
var
playerH
=
a
.
height
;
var
playerW
=
a
.
width
;
var
playerX
=
a
.
x
;
console
.
log
(
"props"
,
props
.
playerHeight
);
if
(
props
.
playerHeight
)
{
playerH
=
props
.
playerHeight
;
}
...
...
src/custom/food-fell2/debug/main.js.map
View file @
0e85c3c0
This diff is collapsed.
Click to expand it.
src/custom/food-fell2/meta.json
View file @
0e85c3c0
...
...
@@ -20,7 +20,7 @@
"speed"
:
{
"alias"
:
"道具掉落初始速度"
,
"type"
:
"number"
,
"default"
:
1
0
"default"
:
1
},
"maxSpeed"
:
{
"alias"
:
"道具掉落速度上限"
,
...
...
src/custom/food-fell2/src/game/GameView.ts
View file @
0e85c3c0
...
...
@@ -42,6 +42,8 @@ export default class GameView extends engine.Container {
// 当前场景上面的物品
private
goodsItems
=
[]
private
viewVisible
=
true
;
private
_goods
:
Goods
;
...
...
@@ -133,6 +135,22 @@ export default class GameView extends engine.Container {
this
.
rectBg
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_OUT
,
this
.
onOutStage
,
this
);
document
.
addEventListener
(
"visibilitychange"
,()
=>
{
if
(
document
.
visibilityState
==
"visible"
){
this
.
viewVisible
=
true
;
}
if
(
document
.
visibilityState
==
"hidden"
){
this
.
viewVisible
=
false
;
}
})
this
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
enterFrame
,
this
)
}
enterFrame
(){
this
.
updateTime
()
this
.
updateTimeBeginNpc
()
}
...
...
@@ -140,7 +158,7 @@ export default class GameView extends engine.Container {
* 重置场景
*/
reset
()
{
this
.
score
=
0
this
.
score
=
props
.
speed
this
.
recycleGoods
()
this
.
player
.
x
=
375
-
this
.
player
.
width
/
2
;
}
...
...
@@ -152,11 +170,18 @@ export default class GameView extends engine.Container {
this
.
score
=
0
;
this
.
speed
=
1
this
.
gameIng
=
true
;
this
.
creatNpc
()
//
this.creatNpc()
this
.
beginNpc
()
this
.
countdown
=
props
.
countDown
;
}
this
.
countdownTimer
=
setInterval
(()
=>
{
cacheTime
=
0
updateTime
(){
if
(
Date
.
now
()
-
this
.
cacheTime
>
1000
){
this
.
cacheTime
=
Date
.
now
()
}
else
{
return
;
}
if
(
this
.
gameIng
)
{
if
(
this
.
countdown
>
0
)
{
engine
.
globalEvent
.
dispatchEvent
(
'food-fell-time-update'
,
{
...
...
@@ -171,21 +196,33 @@ export default class GameView extends engine.Container {
this
.
died
()
}
}
},
1000
)
}
/**
* npc开始掉落
*/
beginNpc
()
{
this
.
timer
=
setTimeout
(()
=>
{
// this.timer = setTimeout(() => {
// //递归执行
// this.beginNpc()
// }, 2000 / this.speed)
}
cacheTime2
=
0
updateTimeBeginNpc
(){
if
(
Date
.
now
()
-
this
.
cacheTime2
>
(
2000
/
this
.
speed
)){
this
.
cacheTime2
=
Date
.
now
()
}
else
{
return
;
}
if
(
this
.
gameIng
)
{
this
.
speed
+=
props
.
acceleratedSpeed
;
if
(
this
.
speed
>=
props
.
maxSpeed
){
this
.
speed
=
props
.
maxSpeed
}
this
.
creatNpc
()
}
//递归执行
this
.
beginNpc
()
},
2000
/
this
.
speed
)
}
/**
...
...
@@ -216,7 +253,7 @@ export default class GameView extends engine.Container {
private
creatNpc
()
{
let
goods
=
this
.
_goods
=
<
Goods
>
ObjectPool
.
getObject
(
PoolName
);
this
.
goodsItems
.
push
(
goods
)
console
.
log
(
goods
);
//
console.log(goods);
this
.
NpcBg
.
addChild
(
goods
);
goods
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
goods
[
"onGoodsEnter"
]
=
()
=>
{
...
...
@@ -229,7 +266,7 @@ export default class GameView extends engine.Container {
//如果玩家和物品发生碰撞
if
(
this
.
hasHit
(
this
.
player
,
goods
))
{
if
(
goods
[
"npcType"
].
indexOf
(
"rain"
)
>
-
1
)
{
console
.
log
(
"碰到雨滴"
)
//
console.log("碰到雨滴")
this
.
score
+=
props
.
rainScore
;
this
.
waterSvga
.
visible
=
true
;
// this.waterSvga.x= goods.x - this.player.x;
...
...
@@ -243,7 +280,7 @@ export default class GameView extends engine.Container {
}
}
else
if
(
goods
[
"npcType"
]
==
"stone"
)
{
console
.
log
(
"碰到石头"
)
//
console.log("碰到石头")
this
.
score
+=
props
.
stoneScore
if
(
this
.
score
<
0
){
this
.
score
=
0
;
...
...
@@ -254,7 +291,7 @@ export default class GameView extends engine.Container {
this
.
stoneSvga
.
visible
=
false
;
},
this
);
}
else
if
(
goods
[
"npcType"
]
==
"boom"
)
{
console
.
log
(
"碰到炸弹"
)
//
console.log("碰到炸弹")
this
.
boomSvga
.
visible
=
true
;
this
.
boomSvga
.
play
(
false
,
false
)
this
.
died
()
...
...
@@ -281,7 +318,7 @@ export default class GameView extends engine.Container {
* 玩家死亡
*/
private
died
()
{
this
.
pause
()
this
.
pause
()
;
}
/**
...
...
@@ -327,7 +364,6 @@ export default class GameView extends engine.Container {
let
playerH
=
a
.
height
let
playerW
=
a
.
width
let
playerX
=
a
.
x
console
.
log
(
"props"
,
props
.
playerHeight
)
if
(
props
.
playerHeight
){
playerH
=
props
.
playerHeight
}
...
...
src/custom/food-fell2/src/game/Goods.ts
View file @
0e85c3c0
...
...
@@ -62,7 +62,7 @@ export class Goods extends engine.Container {
let
random
=
Math
.
random
()
if
(
typeof
(
props
.
goodsProbability
)
==
'string'
){
props
.
goodsProbability
=
props
.
goodsProbability
.
split
(
','
).
map
((
i
:
string
)
=>
+
i
)
console
.
log
(
props
.
goodsProbability
);
//
console.log(props.goodsProbability);
}
if
(
random
<
props
.
goodsProbability
[
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