Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
YM2-30
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-30
Commits
6526bffd
Commit
6526bffd
authored
Jun 28, 2020
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 点击胡萝卜发音
parent
e9b41469
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
36 deletions
+44
-36
form.component.html
src/app/form/form.component.html
+7
-0
form.component.ts
src/app/form/form.component.ts
+22
-25
MyGame.ts
src/app/play/game/MyGame.ts
+13
-10
resources.js
src/app/play/resources.js
+2
-1
audio_new_page.mp3
src/assets/play/audio_new_page.mp3
+0
-0
audio_right.mp3
src/assets/play/audio_right.mp3
+0
-0
No files found.
src/app/form/form.component.html
View file @
6526bffd
...
@@ -23,7 +23,14 @@
...
@@ -23,7 +23,14 @@
[
picUrl
]="
it
.
carrotImg
"
[
picUrl
]="
it
.
carrotImg
"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
'
carrot
',
i
)"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
'
carrot
',
i
)"
></app-upload-image-with-preview>
></app-upload-image-with-preview>
<br>
<span
style=
"float: left; height: 30px; font-size: 18px;"
>
胡萝卜发音:
</span>
<br><br>
<br><br>
<app-audio-recorder
[
audioUrl
]="
it
.
carrotAudio
"
(
audioUploaded
)="
onCarrotImgUploadSuccess
($
event
,
i
)"
></app-audio-recorder>
<br>
<span
style=
"float: left; height: 30px; font-size: 18px;"
>
坑:
</span>
<span
style=
"float: left; height: 30px; font-size: 18px;"
>
坑:
</span>
<br><br>
<br><br>
<app-upload-image-with-preview
<app-upload-image-with-preview
...
...
src/app/form/form.component.ts
View file @
6526bffd
...
@@ -23,11 +23,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -23,11 +23,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
save
();
this
.
save
();
}
}
addCarrot
()
{
addCarrot
(
saveFlg
=
true
)
{
this
.
item
.
carrots
.
push
({
this
.
item
.
carrots
.
push
({
carrotImg
:
''
,
carrotImg
:
''
,
carrotAudio
:
''
,
holeImg
:
''
,
holeImg
:
''
,
});
});
if
(
saveFlg
)
{
this
.
save
();
}
}
addTarget
()
{
this
.
item
.
targets
.
push
({
targetImg
:
''
,
x
:
0
,
y
:
-
300
});
this
.
save
();
this
.
save
();
}
}
...
@@ -38,25 +50,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -38,25 +50,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
text
:
""
,
text
:
""
,
audio
:
""
audio
:
""
},
},
carrots
:
[{
carrots
:
[],
carrotImg
:
''
,
holeImg
:
''
,
},
{
carrotImg
:
''
,
holeImg
:
''
,
},
{
carrotImg
:
''
,
holeImg
:
''
,
},
{
carrotImg
:
''
,
holeImg
:
''
,
},
{
carrotImg
:
''
,
holeImg
:
''
,
}],
targets
:
[]
targets
:
[]
};
};
for
(
var
i
=
0
;
i
<
5
;
++
i
)
{
this
.
addCarrot
(
false
);
}
// 获取存储的数据
// 获取存储的数据
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
...
@@ -73,14 +74,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -73,14 +74,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
}
addTarget
()
{
this
.
item
.
targets
.
push
({
targetImg
:
''
,
x
:
0
,
y
:
-
300
});
}
deleteTarget
(
idx
)
{
deleteTarget
(
idx
)
{
this
.
item
.
targets
.
splice
(
idx
,
1
);
this
.
item
.
targets
.
splice
(
idx
,
1
);
this
.
save
();
this
.
save
();
...
@@ -117,6 +110,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -117,6 +110,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
item
.
targets
[
idx
].
targetImg
=
e
.
url
;
this
.
item
.
targets
[
idx
].
targetImg
=
e
.
url
;
this
.
save
();
this
.
save
();
}
}
onCarrotImgUploadSuccess
(
e
,
idx
)
{
this
.
item
.
carrots
[
idx
].
carrotAudio
=
e
.
url
;
this
.
save
();
}
/**
/**
* 储存音频数据
* 储存音频数据
...
...
src/app/play/game/MyGame.ts
View file @
6526bffd
...
@@ -49,15 +49,10 @@ export class MyGame extends Game {
...
@@ -49,15 +49,10 @@ export class MyGame extends Game {
let
imgUrlList
=
[];
let
imgUrlList
=
[];
let
audioUrlList
=
[];
let
audioUrlList
=
[];
this
.
data
.
carrots
.
forEach
((
carrot
)
=>
{
imgUrlList
.
push
(...
this
.
data
.
carrots
.
map
(
data
=>
[
data
.
carrotImg
,
data
.
holeImg
]).
flat
(
Infinity
));
imgUrlList
.
push
(
carrot
.
carrotImg
);
imgUrlList
.
push
(...
this
.
data
.
targets
.
map
(
data
=>
data
.
targetImg
));
imgUrlList
.
push
(
carrot
.
holeImg
);
audioUrlList
.
push
(...
this
.
data
.
carrots
.
map
(
data
=>
data
.
carrotAudio
));
});
audioUrlList
.
push
(...
this
.
data
.
targets
.
map
(
data
=>
data
.
targetAudio
));
this
.
data
.
targets
.
forEach
((
target
)
=>
{
imgUrlList
.
push
(
target
.
targetImg
);
});
// audioUrlList.push(this.data.wholeAuido);
// audioUrlList.push(this.data.tittle.audio);
this
.
preLoadData
(
imgUrlList
,
audioUrlList
);
this
.
preLoadData
(
imgUrlList
,
audioUrlList
);
}
}
...
@@ -198,9 +193,17 @@ export class MyGame extends Game {
...
@@ -198,9 +193,17 @@ export class MyGame extends Game {
carrotSp
.
setPositionX
(
this
.
bg
.
width
/
length
*
(
idx
-
(
length
-
1
)
/
2
));
carrotSp
.
setPositionX
(
this
.
bg
.
width
/
length
*
(
idx
-
(
length
-
1
)
/
2
));
carrotSp
.
setPositionY
(
-
550
);
carrotSp
.
setPositionY
(
-
550
);
this
.
bg
.
addChild
(
carrotSp
);
this
.
bg
.
addChild
(
carrotSp
);
carrotSp
.
addTouchBeganListener
(()
=>
{
this
.
onClickCarrot
(
idx
);
});
});
});
}
}
onClickCarrot
(
idx
)
{
this
.
playAudio
(
this
.
data
.
carrots
[
idx
].
carrotAudio
);
}
createHoles
()
{
createHoles
()
{
let
screenSize
=
this
.
getScreenSize
();
let
screenSize
=
this
.
getScreenSize
();
let
defaultSize
=
this
.
getDefaultScreenSize
();
let
defaultSize
=
this
.
getDefaultScreenSize
();
...
@@ -251,7 +254,7 @@ export class MyGame extends Game {
...
@@ -251,7 +254,7 @@ export class MyGame extends Game {
targetSp
.
set
(
'
startPos
'
,
{
x
:
targetSp
.
x
,
y
:
targetSp
.
y
});
targetSp
.
set
(
'
startPos
'
,
{
x
:
targetSp
.
x
,
y
:
targetSp
.
y
});
}
else
{
}
else
{
tweenChange
(
targetSp
,
{
alpha
:
1
},
0.2
);
tweenChange
(
targetSp
,
{
alpha
:
1
},
0.2
);
this
.
playAudio
(
'
click
'
,
true
,
()
=>
{
this
.
playAudio
(
'
audio_right
'
,
true
,
()
=>
{
this
.
playAudio
(
this
.
data
.
targets
[
idx
].
targetAudio
);
this
.
playAudio
(
this
.
data
.
targets
[
idx
].
targetAudio
);
});
});
}
}
...
...
src/app/play/resources.js
View file @
6526bffd
...
@@ -10,7 +10,8 @@ const res = [
...
@@ -10,7 +10,8 @@ const res = [
const
resAudio
=
[
const
resAudio
=
[
// ['click', "assets/play/music/click.mp3"],
[
'
audio_new_page
'
,
"
assets/play/audio_new_page.mp3
"
],
[
'
audio_right
'
,
"
assets/play/audio_right.mp3
"
],
];
];
...
...
src/assets/play/audio_new_page.mp3
0 → 100644
View file @
6526bffd
File added
src/assets/play/audio_right.mp3
0 → 100644
View file @
6526bffd
File added
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