Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
db-game-template
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
崔立强
db-game-template
Commits
a050fd80
Commit
a050fd80
authored
Oct 12, 2019
by
huangwenjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bg修复
parent
e803cb72
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
317 additions
and
216 deletions
+317
-216
PlaySkin.exml
egret/resource/skins/PlaySkin.exml
+2
-2
LoopComponent.ts
egret/src/playScene/LoopComponent.ts
+77
-0
PlayScene.ts
egret/src/playScene/PlayScene.ts
+165
-152
ExStartScene.ts
egret/src/startScene/ExStartScene.ts
+71
-60
getCredits.json
mock/json/getCredits.json
+2
-2
No files found.
egret/resource/skins/PlaySkin.exml
View file @
a050fd80
<?xml version="1.0" encoding="utf-8"?>
<e:Skin
class=
"PlaySkin"
width=
"750"
height=
"1206"
xmlns:e=
"http://ns.egret.com/eui"
xmlns:w=
"http://ns.egret.com/wing"
>
<e:Image
id=
"bg1"
source=
"playBg_jpg"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
x=
"0"
bottom=
"0"
/>
<e:Image
id=
"bg2"
source=
"playBg_jpg"
anchorOffsetX=
"0"
anchorOffsetY=
"0"
x=
"2248"
bottom=
"0"
/>
<e:Image
id=
"mainFish"
source=
"fishCLv1_png"
anchorOffsetX=
"31"
anchorOffsetY=
"18"
horizontalCenter=
"-60"
y=
"97"
width=
"60"
height=
"40"
/>
<e:Image
id=
"gameTips"
source=
"guideTips_png"
bottom=
"290"
anchorOffsetX=
"386"
anchorOffsetY=
"204"
horizontalCenter=
"0"
visible=
"false"
/>
<e:Component
id=
"levelUpPanel"
width=
"750"
height=
"1624"
skinName=
"LevelUpSkin"
left=
"0"
top=
"0"
visible=
"false"
/>
...
...
egret/src/playScene/LoopComponent.ts
0 → 100644
View file @
a050fd80
/**
* Created by rockyl on 2018/8/16.
*
* 滚动式背景图
*/
export
class
LoopComponent
extends
egret
.
DisplayObjectContainer
{
parts
:
any
[];
onceInfo
:
any
=
{
width
:
0
,
height
:
0
,
count
:
0
};
loopInfo
:
any
=
{
width
:
0
,
height
:
0
,
count
:
0
};
constructor
()
{
super
();
this
.
parts
=
[];
}
private
setup
(
parts
,
info
)
{
parts
.
forEach
((
item
,
index
)
=>
{
let
part
;
if
(
typeof
item
==
'string'
)
{
part
=
new
egret
.
Bitmap
(
RES
.
getRes
(
item
));
}
else
if
(
item
instanceof
egret
.
Texture
)
{
part
=
new
egret
.
Bitmap
(
item
);
}
else
{
part
=
item
;
}
this
.
addChild
(
part
);
this
.
parts
.
push
(
part
);
if
(
index
==
0
)
{
info
.
width
=
part
.
width
;
info
.
height
=
part
.
height
;
}
});
info
.
count
=
parts
.
length
;
this
.
setViewport
(
0
,
0
)
}
setupOnce
(
resArr
)
{
this
.
setup
(
resArr
,
this
.
onceInfo
);
}
setupLoop
(
resArr
)
{
this
.
setup
(
resArr
,
this
.
loopInfo
);
}
setViewport
(
x
,
y
=
0
)
{
const
sizeField
=
y
==
0
?
'width'
:
'height'
;
const
posField
=
y
==
0
?
'x'
:
'y'
;
const
pos
=
y
==
0
?
x
:
y
;
let
index
;
const
onceSize
=
this
.
onceInfo
[
sizeField
];
const
onceCount
=
this
.
onceInfo
.
count
;
const
loopCount
=
this
.
loopInfo
.
count
;
const
loopSize
=
this
.
loopInfo
[
sizeField
];
index
=
onceSize
==
0
?
-
1
:
Math
.
floor
(
pos
/
onceSize
);
if
(
index
<
0
||
index
>=
onceCount
)
{
const
loopIndex
=
Math
.
floor
((
pos
-
onceCount
*
onceSize
)
/
this
.
loopInfo
[
sizeField
]);
index
=
onceCount
+
loopIndex
;
}
let
formerIndex
=
index
<
onceCount
?
index
:
(
index
)
%
loopCount
+
onceCount
;
let
latterIndex
=
index
<
onceCount
?
index
+
1
:
(
index
-
onceCount
+
1
)
%
loopCount
+
onceCount
;
let
former
=
this
.
parts
[
formerIndex
];
let
latter
=
this
.
parts
[
latterIndex
];
if
(
!
former
||
!
latter
)
{
console
.
log
(
formerIndex
,
latterIndex
);
}
former
[
posField
]
=
-
(
pos
-
loopSize
*
(
index
<
onceCount
?
index
:
index
-
onceCount
)
-
(
index
<
onceCount
?
0
:
onceCount
*
onceSize
));
latter
[
posField
]
=
former
.
x
+
(
index
<
onceCount
?
onceSize
:
loopSize
);
}
}
\ No newline at end of file
egret/src/playScene/PlayScene.ts
View file @
a050fd80
This diff is collapsed.
Click to expand it.
egret/src/startScene/ExStartScene.ts
View file @
a050fd80
import
{
GetCreditsData
}
from
'./../../libs/tw/data/common/getCredits/GetCreditsData'
;
import
{
NetManager
}
from
'./../../libs/tw/manager/NetManager'
;
import
{
GCache
}
from
'./../../libs/tc/util/GCache'
;
import
{
GetInfoData
}
from
'./../../libs/tw/data/game/getInfo/GetInfoData'
;
import
{
DataManager
}
from
'./../../libs/tw/manager/DataManager'
;
...
...
@@ -5,37 +7,37 @@ import StartScene from './StartScene';
import
GameConst
from
'../GameConst'
;
import
fishesConfig
from
'../playScene/fishesConfig'
;
export
default
class
ExStartScene
extends
StartScene
{
constructor
(){
constructor
()
{
super
()
}
public
bg
:
eui
.
Image
;
public
title
:
eui
.
Image
;
public
ruleBtn
:
eui
.
Button
;
public
recordBtn
:
eui
.
Button
;
public
startBtn
:
eui
.
Button
;
public
optionBtn
:
eui
.
Button
;
public
myCreditsTxt
:
eui
.
Label
;
public
mainFish
:
eui
.
Image
;
public
warningTips
:
eui
.
Label
;
public
bubblePool
:
any
[]
=
[];
// 泡泡池
public
bubbleMoveCount
:
number
=
0
;
// 泡泡移动计数
public
gameCount
:
number
=
0
;
// 游戏计数
public
maxLevel
:
number
=
1
;
public
bg
:
eui
.
Image
;
public
title
:
eui
.
Image
;
public
ruleBtn
:
eui
.
Button
;
public
recordBtn
:
eui
.
Button
;
public
startBtn
:
eui
.
Button
;
public
optionBtn
:
eui
.
Button
;
public
myCreditsTxt
:
eui
.
Label
;
public
mainFish
:
eui
.
Image
;
public
warningTips
:
eui
.
Label
;
public
bubblePool
:
any
[]
=
[];
// 泡泡池
public
bubbleMoveCount
:
number
=
0
;
// 泡泡移动计数
public
gameCount
:
number
=
0
;
// 游戏计数
public
maxLevel
:
number
=
1
;
/**
* 初始化UI
*/
protected
initUI
(){
protected
initUI
()
{
super
.
initUI
();
this
.
updateCostTxt
();
this
.
updateMyCredits
();
// 免责声明
if
(
this
.
isIOS
())
{
if
(
this
.
isIOS
())
{
this
.
warningTips
.
visible
=
true
;
}
else
{
}
else
{
this
.
warningTips
.
visible
=
false
;
}
...
...
@@ -46,23 +48,23 @@ export default class ExStartScene extends StartScene {
this
.
title
.
y
=
-
300
;
this
.
title
.
rotation
=
60
;
let
titleTW
=
egret
.
Tween
.
get
(
this
.
title
);
titleTW
.
to
({
y
:
180
,
rotation
:
-
5
},
300
).
to
({
y
:
224.5
,
rotation
:
0
},
200
).
call
(()
=>
{
titleTW
.
to
({
y
:
180
,
rotation
:
-
5
},
300
).
to
({
y
:
224.5
,
rotation
:
0
},
200
).
call
(()
=>
{
let
startBtnTW0
=
egret
.
Tween
.
get
(
this
.
startBtn
[
'btn'
]);
startBtnTW0
.
to
({
alpha
:
1
},
300
).
call
(()
=>
{
startBtnTW0
.
to
({
alpha
:
1
},
300
).
call
(()
=>
{
this
.
startBtn
[
'btn'
].
touchEnable
=
true
;
let
startBtnTW
=
egret
.
Tween
.
get
(
this
.
startBtn
[
'btn'
],
{
loop
:
true
});
startBtnTW
.
to
({
scaleX
:
1.2
,
scaleY
:
1.2
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
).
to
({
scaleX
:
1.2
,
scaleY
:
1.2
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
).
wait
(
200
);
let
startBtnTW
=
egret
.
Tween
.
get
(
this
.
startBtn
[
'btn'
],
{
loop
:
true
});
startBtnTW
.
to
({
scaleX
:
1.2
,
scaleY
:
1.2
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
).
to
({
scaleX
:
1.2
,
scaleY
:
1.2
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
200
).
wait
(
200
);
})
});
setTimeout
(()
=>
{
let
fishTW
=
egret
.
Tween
.
get
(
this
.
mainFish
,
{
loop
:
true
});
fishTW
.
to
({
y
:
fishTemp
-
100
},
1500
).
to
({
y
:
fishTemp
+
100
},
3000
).
to
({
y
:
fishTemp
},
1500
);
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
let
fishTW
=
egret
.
Tween
.
get
(
this
.
mainFish
,
{
loop
:
true
});
fishTW
.
to
({
y
:
fishTemp
-
100
},
1500
).
to
({
y
:
fishTemp
+
100
},
3000
).
to
({
y
:
fishTemp
},
1500
);
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
let
bubble
=
new
eui
.
Image
;
bubble
.
source
=
'bubble_png'
;
bubble
.
x
=
Math
.
max
(
Math
.
random
()
*
1
,
0.5
)
*
750
/
6
+
750
/
6
*
(
i
-
1
);
bubble
[
'dir'
]
=
[
-
1
,
1
][
Math
.
round
(
Math
.
random
()
*
(
2
-
1
))];
bubble
.
x
=
Math
.
max
(
Math
.
random
()
*
1
,
0.5
)
*
750
/
6
+
750
/
6
*
(
i
-
1
);
bubble
[
'dir'
]
=
[
-
1
,
1
][
Math
.
round
(
Math
.
random
()
*
(
2
-
1
))];
bubble
.
y
=
GameConst
.
stage
.
stageHeight
;
bubble
.
scaleX
=
0
;
bubble
.
scaleY
=
0
;
...
...
@@ -70,63 +72,63 @@ export default class ExStartScene extends StartScene {
this
.
addChild
(
this
.
mainFish
);
this
.
bubblePool
.
push
(
bubble
);
setTimeout
(()
=>
{
let
bubbleTW
=
egret
.
Tween
.
get
(
bubble
,
{
loop
:
true
,
onChange
:
this
.
updatebubble
.
bind
(
this
)
});
let
nScaleX
=
Math
.
max
(
Math
.
random
()
*
1.6
,
0.8
);
setTimeout
(()
=>
{
let
bubbleTW
=
egret
.
Tween
.
get
(
bubble
,
{
loop
:
true
,
onChange
:
this
.
updatebubble
.
bind
(
this
)
});
let
nScaleX
=
Math
.
max
(
Math
.
random
()
*
1.6
,
0.8
);
let
nY
=
GameConst
.
stage
.
stageHeight
-
300
;
bubbleTW
.
to
({
scaleX
:
nScaleX
,
scaleY
:
nScaleX
,
y
:
nY
},
1000
).
to
({
y
:
300
},
2500
);
bubbleTW
.
to
({
scaleX
:
nScaleX
,
scaleY
:
nScaleX
,
y
:
nY
},
1000
).
to
({
y
:
300
},
2500
);
},
Math
.
random
()
*
3000
)
}
this
.
addChild
(
this
.
startBtn
)
},
200
);
this
.
addEventListener
(
egret
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
onEnterFrame
(
e
){
onEnterFrame
(
e
)
{
this
.
gameCount
++
;
if
(
this
.
maxLevel
)
{
if
(
Math
.
floor
(
this
.
gameCount
/
15
)
%
2
==
0
)
{
this
.
mainFish
.
source
=
`fishCLv
${
this
.
maxLevel
}
_png`
;
if
(
this
.
maxLevel
)
{
if
(
Math
.
floor
(
this
.
gameCount
/
15
)
%
2
==
0
)
{
this
.
mainFish
.
source
=
`fishCLv
${
this
.
maxLevel
}
_png`
;
this
.
mainFish
.
width
=
fishesConfig
.
config
[
`lv
${
this
.
maxLevel
}
`
].
uW
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv
${
this
.
maxLevel
}
`
].
uH
;
}
else
{
}
else
{
this
.
mainFish
.
source
=
`fishOLv
${
this
.
maxLevel
}
_png`
;
this
.
mainFish
.
width
=
fishesConfig
.
config
[
`lv
${
this
.
maxLevel
}
`
].
uW
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv
${
this
.
maxLevel
}
`
].
uH
;
}
}
else
{
if
(
Math
.
floor
(
this
.
gameCount
/
15
)
%
2
==
0
)
{
this
.
mainFish
.
source
=
`fishCLv1_png`
;
}
else
{
if
(
Math
.
floor
(
this
.
gameCount
/
15
)
%
2
==
0
)
{
this
.
mainFish
.
source
=
`fishCLv1_png`
;
this
.
mainFish
.
width
=
fishesConfig
.
config
[
`lv1`
].
uW
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv1`
].
uH
;
}
else
{
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv1`
].
uH
;
}
else
{
this
.
mainFish
.
source
=
`fishOLv1_png`
;
this
.
mainFish
.
width
=
fishesConfig
.
config
[
`lv1`
].
uW
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv1`
].
uH
;
this
.
mainFish
.
height
=
fishesConfig
.
config
[
`lv1`
].
uH
;
}
}
this
.
mainFish
.
anchorOffsetX
=
this
.
mainFish
.
width
/
2
;
this
.
mainFish
.
anchorOffsetY
=
this
.
mainFish
.
height
/
2
;
this
.
mainFish
.
anchorOffsetX
=
this
.
mainFish
.
width
/
2
;
this
.
mainFish
.
anchorOffsetY
=
this
.
mainFish
.
height
/
2
;
}
updatebubble
(
e
){
updatebubble
(
e
)
{
this
.
bubbleMoveCount
++
;
for
(
let
i
=
0
;
i
<
this
.
bubblePool
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
bubblePool
.
length
;
i
++
)
{
let
speed
=
0.3
;
let
bubble
=
this
.
bubblePool
[
i
];
setTimeout
(()
=>
{
bubble
.
x
+=
Math
.
cos
(
this
.
bubbleMoveCount
/
400
)
*
bubble
.
dir
*
speed
;
},
(
i
+
1
)
*
200
);
bubble
.
x
+=
Math
.
cos
(
this
.
bubbleMoveCount
/
400
)
*
bubble
.
dir
*
speed
;
},
(
i
+
1
)
*
200
);
}
}
updateCostTxt
(){
updateCostTxt
()
{
// 更新开始按钮的字
let
txt
:
string
;
let
txt
:
string
;
if
(
DataManager
.
ins
.
getInfoData
.
status
.
code
!=
0
)
{
txt
=
DataManager
.
ins
.
getInfoData
.
status
.
btnText
;
}
else
{
...
...
@@ -135,13 +137,22 @@ export default class ExStartScene extends StartScene {
this
.
startBtn
[
'gameInfoTxt'
].
text
=
txt
;
}
updateMyCredits
(){
this
.
myCreditsTxt
.
text
=
`我的积分:
${
DataManager
.
ins
.
getInfoData
.
credits
}
`
;
updateMyCredits
()
{
if
(
DataManager
.
ins
.
getCreditsData
&&
DataManager
.
ins
.
getCreditsData
.
unitName
)
{
this
.
myCreditsTxt
.
text
=
`我的
${
DataManager
.
ins
.
getCreditsData
.
unitName
}
:
${
DataManager
.
ins
.
getInfoData
.
credits
}
`
;
}
else
{
NetManager
.
ins
.
getCredits
(()
=>
{
// console.log(data)
this
.
myCreditsTxt
.
text
=
`我的
${
DataManager
.
ins
.
getCreditsData
.
unitName
}
:
${
DataManager
.
ins
.
getInfoData
.
credits
}
`
;
})
}
// this.myCreditsTxt.text = `我的积分:${DataManager.ins.getInfoData.credits}`;
}
isIOS
(){
isIOS
()
{
const
u
=
navigator
.
userAgent
;
let
isiOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
let
isiOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
return
isiOS
;
}
}
\ No newline at end of file
mock/json/getCredits.json
View file @
a050fd80
...
...
@@ -4,7 +4,7 @@
"desc"
:
"成功"
,
"data"
:
{
"unitName"
:
"金币"
,
"credits"
:
"100"
,
"consumerCredits"
:
100
"credits"
:
"100"
,
"consumerCredits"
:
100
}
}
\ 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