Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM2-26
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
YM2-26
Commits
f33b7255
Commit
f33b7255
authored
Jun 22, 2020
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 把let改成const
parent
3e3a9e4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
26 deletions
+23
-26
MyGame.ts
src/app/play/game/MyGame.ts
+23
-26
No files found.
src/app/play/game/MyGame.ts
View file @
f33b7255
...
@@ -46,8 +46,8 @@ export class MyGame extends Game {
...
@@ -46,8 +46,8 @@ export class MyGame extends Game {
}
else
{
}
else
{
this
.
data
=
data
.
data
;
this
.
data
=
data
.
data
;
le
t
imgUrlList
=
[];
cons
t
imgUrlList
=
[];
le
t
audioUrlList
=
[];
cons
t
audioUrlList
=
[];
this
.
data
.
audios
.
forEach
((
cube
)
=>
{
this
.
data
.
audios
.
forEach
((
cube
)
=>
{
audioUrlList
.
push
(
cube
);
audioUrlList
.
push
(
cube
);
});
});
...
@@ -59,12 +59,12 @@ export class MyGame extends Game {
...
@@ -59,12 +59,12 @@ export class MyGame extends Game {
}
}
preLoadData
(
imgUrlList
,
audioUrlList
)
{
preLoadData
(
imgUrlList
,
audioUrlList
)
{
for
(
var
i
=
0
;
i
<
imgUrlList
.
length
;
++
i
)
{
imgUrlList
.
forEach
((
imgUrl
)
=>
{
this
.
_parent
.
addUrlToImages
(
imgUrl
List
[
i
]
);
this
.
_parent
.
addUrlToImages
(
imgUrl
);
}
}
);
for
(
var
i
=
0
;
i
<
audioUrlList
.
length
;
++
i
)
{
audioUrlList
.
forEach
((
audioUrl
)
=>
{
this
.
_parent
.
addUrlToAudioObj
(
audioUrl
List
[
i
]
);
this
.
_parent
.
addUrlToAudioObj
(
audioUrl
);
}
}
);
}
}
initView
()
{
initView
()
{
...
@@ -87,10 +87,7 @@ export class MyGame extends Game {
...
@@ -87,10 +87,7 @@ export class MyGame extends Game {
this
.
getFullScaleXY
();
this
.
getFullScaleXY
();
let
screenSize
=
this
.
getScreenSize
();
const
bgSized
=
new
TouchSprite
();
let
defaultSize
=
this
.
getDefaultScreenSize
();
let
bgSized
=
new
TouchSprite
();
bgSized
.
init
(
this
.
images
.
get
(
'
Img_bg
'
));
bgSized
.
init
(
this
.
images
.
get
(
'
Img_bg
'
));
bgSized
.
anchorX
=
0.5
;
bgSized
.
anchorX
=
0.5
;
bgSized
.
anchorY
=
1
;
bgSized
.
anchorY
=
1
;
...
@@ -99,7 +96,7 @@ export class MyGame extends Game {
...
@@ -99,7 +96,7 @@ export class MyGame extends Game {
this
.
addChild
(
bgSized
);
this
.
addChild
(
bgSized
);
// 背景
// 背景
le
t
bg
=
new
TouchSprite
();
cons
t
bg
=
new
TouchSprite
();
bg
.
init
(
this
.
images
.
get
(
'
Img_bg
'
))
bg
.
init
(
this
.
images
.
get
(
'
Img_bg
'
))
bg
.
setPosition
(
this
.
_parent
.
canvasWidth
/
2
,
this
.
_parent
.
canvasHeight
/
2
);
bg
.
setPosition
(
this
.
_parent
.
canvasWidth
/
2
,
this
.
_parent
.
canvasHeight
/
2
);
bg
.
setScaleXY
(
this
.
_parent
.
mapScale
);
bg
.
setScaleXY
(
this
.
_parent
.
mapScale
);
...
@@ -127,14 +124,14 @@ export class MyGame extends Game {
...
@@ -127,14 +124,14 @@ export class MyGame extends Game {
initTittle
()
{
initTittle
()
{
// 标题字母背景
// 标题字母背景
le
t
tittleWordBg
=
new
TouchSprite
();
cons
t
tittleWordBg
=
new
TouchSprite
();
tittleWordBg
.
init
(
this
.
images
.
get
(
'
Img_tittleBg
'
));
tittleWordBg
.
init
(
this
.
images
.
get
(
'
Img_tittleBg
'
));
tittleWordBg
.
setScaleXY
(
this
.
_parent
.
mapScale
);
tittleWordBg
.
setScaleXY
(
this
.
_parent
.
mapScale
);
tittleWordBg
.
setPosition
(
this
.
getTittleBlockPositionX
(),
31
*
this
.
_parent
.
mapScale
);
tittleWordBg
.
setPosition
(
this
.
getTittleBlockPositionX
(),
31
*
this
.
_parent
.
mapScale
);
this
.
addChild
(
tittleWordBg
);
this
.
addChild
(
tittleWordBg
);
// 标题字母
// 标题字母
le
t
tittleWord
=
new
MyLabel
();
cons
t
tittleWord
=
new
MyLabel
();
tittleWord
.
fontSize
=
48
;
tittleWord
.
fontSize
=
48
;
tittleWord
.
fontName
=
'
BerlinSansFBDemi-Bold
'
;
tittleWord
.
fontName
=
'
BerlinSansFBDemi-Bold
'
;
tittleWord
.
fontColor
=
'
#ab5b22
'
;
tittleWord
.
fontColor
=
'
#ab5b22
'
;
...
@@ -147,7 +144,7 @@ export class MyGame extends Game {
...
@@ -147,7 +144,7 @@ export class MyGame extends Game {
tittleWord
.
refreshSize
();
tittleWord
.
refreshSize
();
// 标题文字
// 标题文字
le
t
questionLabel
=
new
MyLabel
();
cons
t
questionLabel
=
new
MyLabel
();
questionLabel
.
fontSize
=
36
;
questionLabel
.
fontSize
=
36
;
questionLabel
.
fontName
=
'
FuturaBT-Bold
'
;
questionLabel
.
fontName
=
'
FuturaBT-Bold
'
;
questionLabel
.
fontColor
=
'
#000000
'
;
questionLabel
.
fontColor
=
'
#000000
'
;
...
@@ -283,15 +280,15 @@ export class MyGame extends Game {
...
@@ -283,15 +280,15 @@ export class MyGame extends Game {
}
}
onClickWords
(
idx
)
{
onClickWords
(
idx
)
{
le
t
label
=
this
.
bg
.
getChildByName
(
'
label_
'
+
idx
);
cons
t
label
=
this
.
bg
.
getChildByName
(
'
label_
'
+
idx
);
this
.
showWindow
(
this
.
data
.
words
[
idx
],
this
.
data
.
audios
[
idx
],
label
);
this
.
showWindow
(
this
.
data
.
words
[
idx
],
this
.
data
.
audios
[
idx
],
label
);
}
}
hideWindow
()
{
hideWindow
()
{
le
t
mask
=
this
.
bg
.
getChildByName
(
'
mask
'
);
cons
t
mask
=
this
.
bg
.
getChildByName
(
'
mask
'
);
le
t
winBg
=
this
.
bg
.
getChildByName
(
'
winBg
'
);
cons
t
winBg
=
this
.
bg
.
getChildByName
(
'
winBg
'
);
le
t
btnClose
=
this
.
bg
.
getChildByName
(
'
btnClose
'
);
cons
t
btnClose
=
this
.
bg
.
getChildByName
(
'
btnClose
'
);
le
t
wordLabel
=
winBg
.
getChildByName
(
'
wordLabel
'
);
cons
t
wordLabel
=
winBg
.
getChildByName
(
'
wordLabel
'
);
tweenChange
(
mask
,
{
alpha
:
0
},
0.5
);
tweenChange
(
mask
,
{
alpha
:
0
},
0.5
);
tweenChange
(
winBg
,
{
alpha
:
0
},
0.5
);
tweenChange
(
winBg
,
{
alpha
:
0
},
0.5
);
...
@@ -300,10 +297,10 @@ export class MyGame extends Game {
...
@@ -300,10 +297,10 @@ export class MyGame extends Game {
}
}
async
showWindow
(
word
,
audio
,
pos
=
{
x
:
0
,
y
:
0
})
{
async
showWindow
(
word
,
audio
,
pos
=
{
x
:
0
,
y
:
0
})
{
le
t
mask
=
this
.
bg
.
getChildByName
(
'
mask
'
);
cons
t
mask
=
this
.
bg
.
getChildByName
(
'
mask
'
);
le
t
winBg
=
this
.
bg
.
getChildByName
(
'
winBg
'
);
cons
t
winBg
=
this
.
bg
.
getChildByName
(
'
winBg
'
);
le
t
btnClose
=
this
.
bg
.
getChildByName
(
'
btnClose
'
);
cons
t
btnClose
=
this
.
bg
.
getChildByName
(
'
btnClose
'
);
le
t
wordLabel
=
winBg
.
getChildByName
(
'
wordLabel
'
);
cons
t
wordLabel
=
winBg
.
getChildByName
(
'
wordLabel
'
);
wordLabel
.
text
=
word
;
wordLabel
.
text
=
word
;
wordLabel
.
refreshSize
();
wordLabel
.
refreshSize
();
...
@@ -325,7 +322,7 @@ export class MyGame extends Game {
...
@@ -325,7 +322,7 @@ export class MyGame extends Game {
}
}
onClickWinWords
()
{
onClickWinWords
()
{
le
t
wordLabel
=
this
.
bg
.
seekChildByName
(
'
wordLabel
'
);
cons
t
wordLabel
=
this
.
bg
.
seekChildByName
(
'
wordLabel
'
);
this
.
_parent
.
playAudio
(
wordLabel
.
get
(
'
audio
'
));
this
.
_parent
.
playAudio
(
wordLabel
.
get
(
'
audio
'
));
}
}
...
...
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