Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaole
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
wildfirecode13
xiaoxiaole
Commits
82fce8f0
Commit
82fce8f0
authored
Nov 04, 2019
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
67a0af56
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
229 additions
and
81 deletions
+229
-81
index.html
egret/index.html
+1
-1
hbGameNumFont.png
egret/resource/assets/hbGame/hbGameNumFont.png
+0
-0
hbGameScoreFont.fnt
egret/resource/assets/hbGame/hbGameScoreFont.fnt
+5
-5
hbGameScoreFont.png
egret/resource/assets/hbGame/hbGameScoreFont.png
+0
-0
default.res.json
egret/resource/default.res.json
+11
-11
HbGameSkin.exml
egret/resource/skins/HbGameSkin.exml
+2
-2
MapScene.ts
egret/src/mapScene/MapScene.ts
+1
-1
HbGame.ts
egret/src/panels/HongbaoRain/HbGame.ts
+47
-18
Pooling.ts
egret/src/panels/HongbaoRain/Pooling.ts
+44
-0
RainData.ts
egret/src/panels/HongbaoRain/RainData.ts
+45
-25
RainMgr.ts
egret/src/panels/HongbaoRain/RainMgr.ts
+53
-8
RainObj.ts
egret/src/panels/HongbaoRain/RainObj.ts
+20
-10
No files found.
egret/index.html
View file @
82fce8f0
...
...
@@ -41,7 +41,7 @@
<body>
<div
style=
"margin: auto;width: 100%;height: 100%;"
class=
"egret-player"
data-entry-class=
"Main"
data-orientation=
"auto"
data-scale-mode=
"showAll"
data-frame-rate=
"60"
data-content-width=
"750"
data-content-height=
"1624"
data-multi-fingered=
"2"
data-show-fps=
"
fals
e"
data-show-log=
"true"
data-content-height=
"1624"
data-multi-fingered=
"2"
data-show-fps=
"
tru
e"
data-show-log=
"true"
data-show-fps-style=
"x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"
>
</div>
...
...
egret/resource/assets/hbGame/hbGameNumFont.png
deleted
100644 → 0
View file @
67a0af56
12.6 KB
egret/resource/assets/hbGame/hbGame
Num
Font.fnt
→
egret/resource/assets/hbGame/hbGame
Score
Font.fnt
View file @
82fce8f0
{"file":"hbGame
Num
Font.png","frames":{
{"file":"hbGame
Score
Font.png","frames":{
"0":{"x":0,"y":0,"w":35,"h":45,"offX":0,"offY":0,"sourceW":35,"sourceH":45},
"1":{"x":70,"y":138,"w":23,"h":43,"offX":0,"offY":0,"sourceW":23,"sourceH":43},
"2
":{"x":0
,"y":93,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"3":{"x":
35,"y":93
,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"2
":{"x":35
,"y":93,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"3":{"x":
0,"y":47
,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"4":{"x":37,"y":0,"w":35,"h":44,"offX":0,"offY":0,"sourceW":35,"sourceH":44},
"5":{"x":
0
,"y":47,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"6":{"x":
72,"y":47
,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"5":{"x":
72
,"y":47,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"6":{"x":
0,"y":93
,"w":33,"h":44,"offX":0,"offY":0,"sourceW":33,"sourceH":44},
"7":{"x":70,"y":93,"w":33,"h":43,"offX":0,"offY":0,"sourceW":33,"sourceH":43},
"8":{"x":74,"y":0,"w":33,"h":45,"offX":0,"offY":0,"sourceW":33,"sourceH":45},
"9":{"x":37,"y":46,"w":33,"h":45,"offX":0,"offY":0,"sourceW":33,"sourceH":45}}}
\ No newline at end of file
egret/resource/assets/hbGame/hbGameScoreFont.png
0 → 100644
View file @
82fce8f0
12.6 KB
egret/resource/default.res.json
View file @
82fce8f0
...
...
@@ -189,7 +189,7 @@
"name"
:
"hbnoprize"
},
{
"keys"
:
"hbGameCutTimeFont_fnt,hbGameCutTimeFont_png,hbGame
NumFont_fnt,hbGameNumFont_png,hbGame_CutTime_bg_png,hbGame_CutTime_progress_png,hbGame_num_bg_png,hbGame_tips_png,hbGame_1_png,hbGame_2_png,hbGame_3_png,hbGame_+1_png,hbGame_bird_touch_png,hbGame_bird_png,hbGame_cattle_png,hbGame_cattle_touch_png,hbGame_hongbao_touch_png,hbGame_+2_png,hbGame_hongbao_png,hbGame_lion_png,hbGame_lion_touch_png,hbGame_pig_touch_png,hbGame_pig_png,hbGame_rabbit_touch_png,hbGame_rabbi
t_png"
,
"keys"
:
"hbGameCutTimeFont_fnt,hbGameCutTimeFont_png,hbGame
_CutTime_bg_png,hbGame_CutTime_progress_png,hbGame_num_bg_png,hbGame_tips_png,hbGame_1_png,hbGame_2_png,hbGame_3_png,hbGame_+1_png,hbGame_bird_touch_png,hbGame_bird_png,hbGame_cattle_png,hbGame_cattle_touch_png,hbGame_hongbao_touch_png,hbGame_+2_png,hbGame_hongbao_png,hbGame_lion_png,hbGame_lion_touch_png,hbGame_pig_touch_png,hbGame_pig_png,hbGame_rabbit_touch_png,hbGame_rabbit_png,hbGameScoreFont_fnt,hbGameScoreFon
t_png"
,
"name"
:
"hbgame"
},
{
...
...
@@ -3008,16 +3008,6 @@
"type"
:
"image"
,
"name"
:
"hbGameCutTimeFont_png"
},
{
"url"
:
"assets/hbGame/hbGameNumFont.fnt"
,
"type"
:
"font"
,
"name"
:
"hbGameNumFont_fnt"
},
{
"url"
:
"assets/hbGame/hbGameNumFont.png"
,
"type"
:
"image"
,
"name"
:
"hbGameNumFont_png"
},
{
"url"
:
"assets/hbGame/hbGame_CutTime_bg.png"
,
"type"
:
"image"
,
...
...
@@ -3242,6 +3232,16 @@
"url"
:
"assets/map/icongray.png"
,
"type"
:
"image"
,
"name"
:
"icongray_png"
},
{
"url"
:
"assets/hbGame/hbGameScoreFont.fnt"
,
"type"
:
"font"
,
"name"
:
"hbGameScoreFont_fnt"
},
{
"url"
:
"assets/hbGame/hbGameScoreFont.png"
,
"type"
:
"image"
,
"name"
:
"hbGameScoreFont_png"
}
]
}
\ No newline at end of file
egret/resource/skins/HbGameSkin.exml
View file @
82fce8f0
...
...
@@ -2,9 +2,9 @@
<e:Skin
class=
"HbGame"
width=
"750"
height=
"1206"
xmlns:e=
"http://ns.egret.com/eui"
xmlns:w=
"http://ns.egret.com/wing"
>
<e:Group
id=
"rainGroup"
left=
"0"
right=
"0"
top=
"0"
height=
"1206"
/>
<e:Group
right=
"40"
top=
"4
5"
>
<e:Group
id=
"scoreGroup"
top=
"45"
horizontalCenter=
"283.
5"
>
<e:Image
y=
"0"
source=
"hbGame_num_bg_png"
horizontalCenter=
"0"
/>
<e:BitmapLabel
id=
"
numLabel"
y=
"33"
font=
"hbGameNumFont_fnt"
text=
"0"
horizontalCenter=
"0
"
/>
<e:BitmapLabel
id=
"
scoreLabel"
y=
"33"
text=
"0"
horizontalCenter=
"0"
font=
"hbGameScoreFont_fnt
"
/>
</e:Group>
<e:Group
y=
"45"
horizontalCenter=
"0"
>
<e:Image
y=
"0"
horizontalCenter=
"0"
source=
"hbGame_CutTime_bg_png"
/>
...
...
egret/src/mapScene/MapScene.ts
View file @
82fce8f0
...
...
@@ -91,7 +91,7 @@ export default class MapScene extends Scene {
this
.
sendInvite
();
//
PanelCtrl.instance.show("HbGame");
PanelCtrl
.
instance
.
show
(
"HbGame"
);
this
.
updateMyInfo
();
this
.
updateAdData
();
...
...
egret/src/panels/HongbaoRain/HbGame.ts
View file @
82fce8f0
import
Panel
from
"../../../libs/new_wx/components/Panel"
;
import
RainMgr
from
"./RainMgr"
;
import
CutTimer
from
"../../CutTimer"
;
import
{
GDispatcher
}
from
"../../../libs/tc/util/GDispatcher"
;
/**
* 红包雨主游戏
*/
export
default
class
HbGame
extends
Panel
{
public
numLabel
:
eui
.
BitmapLabel
;
public
rainGroup
:
eui
.
Group
;
public
scoreGroup
:
eui
.
Group
;
public
scoreLabel
:
eui
.
BitmapLabel
;
public
cutTimeLabel
:
eui
.
BitmapLabel
;
public
readyGroup
:
eui
.
Group
;
public
readyTips
:
eui
.
Image
;
public
readyCutTime
:
eui
.
Image
;
public
rainGroup
:
eui
.
Group
;
private
rainMgr
:
RainMgr
=
null
;
private
cutTime
:
CutTimer
=
null
;
private
cutTime
:
egret
.
Timer
=
null
;
private
time
:
number
=
0
;
private
score
=
0
;
constructor
(
data
)
{
super
();
...
...
@@ -22,11 +27,48 @@ export default class HbGame extends Panel {
}
onLoad
()
{
this
.
readyGroup
.
visible
=
false
;
setTimeout
(()
=>
this
.
readyTipsEffect
(),
500
);
this
.
initUI
();
}
initUI
()
{
this
.
rainGroup
.
height
=
this
.
width
/
window
.
innerWidth
*
window
.
innerHeight
;
this
.
time
=
60
;
this
.
cutTimeLabel
.
text
=
`
${
this
.
time
}
`
}
// 加分
private
addScore
(
score
:
number
)
{
egret
.
Tween
.
get
(
this
.
scoreGroup
).
to
({
scaleX
:
1.3
,
scaleY
:
1.3
},
100
).
call
(()
=>
{
this
.
score
+=
score
;
this
.
scoreLabel
.
text
=
`
${
this
.
score
}
`
;
egret
.
Tween
.
get
(
this
.
scoreGroup
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
);
});
}
private
gameOver
()
{
this
.
cutTime
.
stop
();
this
.
cutTime
.
removeEventListener
(
egret
.
TimerEvent
.
TIMER
,
this
.
timeCallFun
,
this
);
GDispatcher
.
dispatchEvent
(
'hbRainGameOver'
);
}
private
startGame
()
{
this
.
rainMgr
=
new
RainMgr
({
parent
:
this
,
rainGroup
:
this
.
rainGroup
,
});
this
.
cutTime
=
new
egret
.
Timer
(
1000
,
0
);
this
.
cutTime
.
addEventListener
(
egret
.
TimerEvent
.
TIMER
,
this
.
timeCallFun
,
this
);
this
.
cutTime
.
start
();
}
private
timeCallFun
(){
this
.
cutTimeLabel
.
text
=
`
${
--
this
.
time
}
`
;
if
(
this
.
time
<=
0
){
this
.
gameOver
();
}
}
private
readyTimeEffect
()
{
...
...
@@ -57,36 +99,23 @@ export default class HbGame extends Panel {
});
}
private
startGame
()
{
this
.
rainMgr
=
new
RainMgr
({
parent
:
this
,
rainGroup
:
this
.
rainGroup
,
});
this
.
cutTime
=
new
CutTimer
(
this
.
cutTimeLabel
,
'ss'
,
()
=>
this
.
gameOver
());
this
.
cutTime
.
start
(
59
*
1000
);
}
private
gameOver
()
{
}
private
readyTipsEffect
()
{
this
.
readyTips
.
alpha
=
0
;
egret
.
Tween
.
get
(
this
.
readyTips
).
to
({
alpha
:
1
},
300
).
call
(()
=>
this
.
readyTimeEffect
());
}
protected
onSkinComplete
()
{
this
.
readyGroup
.
visible
=
false
;
setTimeout
(()
=>
this
.
readyTipsEffect
(),
1000
);
this
.
onLoad
();
}
initEvents
()
{
super
.
initEvents
();
GDispatcher
.
addEvent
(
'hbGameAddScore'
,
this
.
addScore
,
this
);
}
removeEvents
()
{
super
.
removeEvents
();
GDispatcher
.
removeEvent
(
'hbGameAddScore'
,
this
.
addScore
,
this
);
}
protected
get
closeBtns
():
eui
.
Button
[]
{
...
...
egret/src/panels/HongbaoRain/Pooling.ts
0 → 100644
View file @
82fce8f0
/**
* 简单对象池
*/
export
default
class
Polling
{
private
pool
:
any
[]
=
[];
constructor
()
{
}
/**
* 存入对象
* @param obj - 要存入的对象
*/
public
push
(
obj
:
any
)
{
this
.
pool
.
push
(
obj
);
}
/**
* 返回对象池中的随机对象
* @returns 返回获得的对象 null 对象用完了
*/
public
get
()
{
if
(
this
.
pool
.
length
<=
0
)
{
// 如果对象池用完了就返回 null
return
null
;
}
// 返回随机对象
let
index
=
~~
(
Math
.
random
()
*
this
.
pool
.
length
);
let
obj
=
this
.
pool
[
index
];
this
.
pool
.
splice
(
index
,
1
);
return
obj
}
/**
* 清空对象池
*/
public
clear
()
{
for
(
let
i
=
0
;
i
<
this
.
pool
.
length
;
i
++
)
{
delete
this
.
pool
[
i
];
}
this
.
pool
=
[];
}
}
\ No newline at end of file
egret/src/panels/HongbaoRain/RainData.ts
View file @
82fce8f0
let
RainData
=
{
key
:[
key
:
[
'bird'
,
'cattle'
,
'lion'
,
...
...
@@ -7,6 +7,25 @@ let RainData = {
'rabbit'
,
'hongbao'
],
data
:
{
bird
:
{
score
:
2
,
},
cattle
:
{
score
:
2
,
},
lion
:
{
score
:
2
,
},
pig
:
{
score
:
2
,
},
rabbit
:
{
score
:
2
,
},
hongbao
:
{
score
:
1
,
},
// bird:{
// default:"hbGame_bird_png",
// touch:"hbGame_bird_touch_png",
...
...
@@ -31,6 +50,7 @@ let RainData = {
// default:"hbGame_hongbao_png",
// touch:"hbGame_hongbao_touch_png",
// },
}
};
export
default
RainData
;
\ No newline at end of file
egret/src/panels/HongbaoRain/RainMgr.ts
View file @
82fce8f0
import
RainObj
from
"./RainObj"
;
import
RainData
from
"./RainData"
;
import
{
GDispatcher
}
from
"../../../libs/tc/util/GDispatcher"
;
import
Pooling
from
"./Pooling"
;
import
Utils
from
"../../Utils"
;
export
default
class
RainMgr
{
private
rainPool
:
Pooling
=
null
;
private
data
;
private
parent
;
private
rainGroup
;
private
readonly
rainGroup
;
private
timer
:
egret
.
Timer
=
null
;
constructor
(
data
){
constructor
(
data
)
{
this
.
data
=
data
;
this
.
parent
=
this
.
data
.
parent
;
this
.
rainGroup
=
this
.
data
.
rainGroup
;
...
...
@@ -14,13 +21,51 @@ export default class RainMgr {
this
.
start
();
}
private
start
(){
let
s
=
new
RainObj
({
key
:
RainData
.
key
[
~~
(
Math
.
random
()
*
RainData
.
key
.
length
)],
scale
:
1
,
private
gameOver
()
{
this
.
timer
.
stop
();
// 停止计时器
// 隐藏全部掉落物品
for
(
let
v
of
this
.
rainGroup
.
$children
)
{
v
.
visible
=
false
;
}
}
private
start
()
{
this
.
addPool
();
GDispatcher
.
addEvent
(
'hbRainGameOver'
,
this
.
gameOver
,
this
);
this
.
timer
=
new
egret
.
Timer
(
1500
,
0
);
this
.
timer
.
addEventListener
(
egret
.
TimerEvent
.
TIMER
,
this
.
addRain
,
this
);
this
.
timer
.
start
();
}
private
addRain
()
{
let
num
=
Utils
.
RandomInt
(
3
,
5
);
for
(
let
i
=
0
;
i
<
Utils
.
RandomInt
(
3
,
5
);
i
++
)
{
let
newRainObj
=
this
.
rainPool
.
get
();
if
(
!
newRainObj
)
{
newRainObj
=
new
RainObj
({
key
:
RainData
[
~~
(
Math
.
random
()
*
RainData
.
key
.
length
)],
rainGroup
:
this
.
rainGroup
,
pool
:
this
.
rainPool
,
});
}
newRainObj
.
addStage
((
this
.
rainGroup
.
width
-
200
)
/
num
*
i
+
100
,
Utils
.
RandomInt
(
7
,
10
)
/
10
);
}
}
private
addPool
()
{
this
.
rainPool
=
new
Pooling
();
for
(
let
v
of
RainData
.
key
)
{
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
let
newObj
=
new
RainObj
({
key
:
v
,
rainGroup
:
this
.
rainGroup
,
pool
:
this
.
rainPool
,
});
this
.
rainPool
.
push
(
newObj
);
}
}
}
}
\ No newline at end of file
egret/src/panels/HongbaoRain/RainObj.ts
View file @
82fce8f0
import
{
GDispatcher
}
from
"../../../libs/tc/util/GDispatcher"
;
import
RainData
from
"./RainData"
;
export
default
class
RainObj
{
private
data
=
null
;
private
module
:
eui
.
Image
=
null
;
...
...
@@ -6,35 +9,42 @@ export default class RainObj {
constructor
(
data
)
{
this
.
data
=
data
;
console
.
log
(
this
.
data
);
this
.
module
=
new
eui
.
Image
(
`hbGame_
${
this
.
data
.
key
}
_png`
);
this
.
module
.
scaleX
=
this
.
module
.
scaleY
=
this
.
data
.
scale
;
this
.
module
.
anchorOffsetX
=
75
;
this
.
module
.
anchorOffsetY
=
70
;
this
.
rainGroup
=
this
.
data
.
rainGroup
;
this
.
module
.
x
=
100
;
this
.
module
.
y
=
-
100
;
this
.
rainGroup
.
addChild
(
this
.
module
);
}
public
addStage
(
x
,
scale
)
{
this
.
module
.
x
=
x
;
this
.
module
.
y
=
-
200
;
this
.
module
.
scaleX
=
this
.
module
.
scaleY
=
scale
;
this
.
module
.
visible
=
true
;
this
.
rainGroup
.
addChild
(
this
.
module
);
this
.
start
();
}
private
start
()
{
this
.
module
.
touchEnabled
=
true
;
this
.
module
.
source
=
`hbGame_
${
this
.
data
.
key
}
_png`
;
this
.
module
.
addEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
touchTap
,
this
);
egret
.
Tween
.
get
(
this
.
module
,
{
loop
:
true
}).
to
({
rotation
:
~~
(
Math
.
random
()
*
2
)
?
360
:
-
360
},
18000
);
egret
.
Tween
.
get
(
this
.
module
).
to
({
y
:
this
.
rainGroup
.
height
},
10
000
).
call
(()
=>
this
.
destroy
());
egret
.
Tween
.
get
(
this
.
module
).
to
({
y
:
this
.
rainGroup
.
height
+
200
},
5
000
).
call
(()
=>
this
.
destroy
());
}
private
touchTap
()
{
GDispatcher
.
dispatchEvent
(
'hbGameAddScore'
,
RainData
.
data
[
this
.
data
.
key
].
score
);
this
.
module
.
source
=
`hbGame_
${
this
.
data
.
key
}
_touch_png`
;
this
.
destroy
();
}
private
destroy
()
{
egret
.
Tween
.
removeTweens
(
this
.
module
);
this
.
module
.
removeEventListener
(
egret
.
TouchEvent
.
TOUCH_TAP
,
this
.
touchTap
,
this
);
this
.
module
.
source
=
`hbGame_
${
this
.
data
.
key
}
_touch_png`
;
setTimeout
(()
=>
{
this
.
module
.
touchEnabled
=
false
;
setTimeout
(()
=>
{
this
.
rainGroup
.
removeChild
(
this
.
module
);
this
.
data
.
pool
.
push
(
this
);
},
1000
);
}
}
\ No newline at end of file
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