Commit b5b2d7e0 authored by asdf's avatar asdf

add option audio

parent 5f3f4903
......@@ -19,7 +19,7 @@
<div style="margin-top: 20px; float: left; border-width: 1px; border-style: dotted;
padding: 20px; margin-right: 20px; width: 230px;">
<span style="height: 30px; font-size: 18px;">题干音频:</span>
<app-audio-recorder [audioUrl]="option.optionAudio" (audioUploaded)="onOptionUploadSuccess($event, i, j)">
<app-audio-recorder [audioUrl]="option.questionAudio" (audioUploaded)="onQuestionUploadSuccess($event, i, j)">
</app-audio-recorder>
<br>
<span style="height: 30px; font-size: 18px;">题干文本:</span>
......@@ -48,6 +48,10 @@
<div *ngFor="let option of question.optionList; let j = index">
<div style="margin-top: 20px; float: left; border-width: 1px; border-style: dotted;
padding: 20px; margin-right: 20px; width: 230px;">
<span style="height: 30px; font-size: 18px;">题干音频:</span>
<app-audio-recorder [audioUrl]="option.optionAudio" (audioUploaded)="onOptionUploadSuccess($event, i, j)">
</app-audio-recorder>
<br>
<span style="height: 30px; font-size: 18px;">选项骨骼动画:</span>
<app-upload-dragon-bone [btnName]="[['配置骨骼动画']]" [animaNames]="[[['normal']]]"
[skeJsonData]=option.optionDragonBone.skeJsonData2 [texJsonData]=option.optionDragonBone.texJsonData2
......
......@@ -23,7 +23,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"questionAudio": "",
"questionText": "",
"optionList": [{
"text":"",
"text": "",
"optionDragonBone": {
"skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
......@@ -32,9 +32,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"texJsonData2": { "url": "" },
"texPngData2": { "url": "" }
},
"questionAudio": "",
"optionAudio": ""
}, {
"text":"",
"text": "",
"optionDragonBone": {
"skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
......@@ -43,9 +44,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"texJsonData2": { "url": "" },
"texPngData2": { "url": "" }
},
"questionAudio": "",
"optionAudio": ""
}, {
"text":"",
"text": "",
"optionDragonBone": {
"skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
......@@ -54,6 +56,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"texJsonData2": { "url": "" },
"texPngData2": { "url": "" }
},
"questionAudio": "",
"optionAudio": ""
}]
});
......@@ -67,8 +70,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
addOption(questionIdx) {
this.item.questionList[questionIdx].optionList.push({
"text":"",
"optionDragonBone": {
"text": "",
"optionDragonBone": {
"skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
"texPngData": { "url": "" },
......@@ -76,6 +79,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
"texJsonData2": { "url": "" },
"texPngData2": { "url": "" }
},
"questionAudio": "",
"optionAudio": ""
});
this.save();
......@@ -116,6 +120,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
onQuestionUploadSuccess(e, questionIdx, optionIdx) {
this.item.questionList[questionIdx].optionList[optionIdx].questionAudio = e.url;
this.save();
}
onOptionUploadSuccess(e, questionIdx, optionIdx) {
this.item.questionList[questionIdx].optionList[optionIdx].optionAudio = e.url;
this.save();
......
......@@ -25,16 +25,19 @@
},
{
"__id__": 8
},
{
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 11
"__id__": 18
}
],
"_prefab": {
"__id__": 12
"__id__": 19
},
"_opacity": 255,
"_color": {
......@@ -408,6 +411,288 @@
"fileId": "3d73OiHzxCPoDl3F8SILEe",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "New Button",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 12
}
],
"_active": true,
"_components": [
{
"__id__": 15
}
],
"_prefab": {
"__id__": 17
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 56,
"height": 56
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
73.548,
-101.302,
0,
0,
0,
0,
1,
1,
1,
0
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "btn_laba",
"_objFlags": 0,
"_parent": {
"__id__": 11
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 52,
"height": 56
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "b8916cdd-f8f9-40ae-8d54-783bd1725f4a"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b125237b-1bc1-4ec8-9b7b-60c16e96c5ae"
},
"fileId": "77z8KiqOxIZLIp/aotSOWi",
"sync": false
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [
{
"__id__": 16
}
],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 230,
"g": 230,
"b": 230,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 120,
"g": 120,
"b": 120,
"a": 200
},
"_N$normalSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"_N$pressedSprite": {
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
},
"pressedSprite": {
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
},
"_N$hoverSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"hoverSprite": {
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
},
"_N$disabledSprite": {
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
},
"_N$target": {
"__id__": 11
},
"_id": ""
},
{
"__type__": "cc.ClickEvent",
"target": {
"__id__": 1
},
"component": "",
"_componentId": "c7c4a6NgRBL1LYik/VyDNVL",
"handler": "onBtnClickAudio",
"customEventData": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "b125237b-1bc1-4ec8-9b7b-60c16e96c5ae"
},
"fileId": "c73uuBzS9BT5YEviGtEkCk",
"sync": false
},
{
"__type__": "c7c4a6NgRBL1LYik/VyDNVL",
"_name": "",
......@@ -427,6 +712,9 @@
"sprBg": {
"__id__": 3
},
"sprAudio": {
"__id__": 13
},
"nodLight": {
"__id__": 8
},
......@@ -439,6 +727,14 @@
"audWrong": {
"__uuid__": "169e45bc-9858-4f55-8020-667f6e4563c6"
},
"spfAudio": [
{
"__uuid__": "91142e92-4b78-4f47-a50f-c6af85b22675"
},
{
"__uuid__": "b8916cdd-f8f9-40ae-8d54-783bd1725f4a"
}
],
"_id": ""
},
{
......
......@@ -4,10 +4,12 @@ cc.Class({
properties: {
spfBase: [cc.SpriteFrame],
sprBg: cc.Sprite,
sprAudio: cc.Sprite,
nodLight: cc.Node,
dragonBone: dragonBones.ArmatureDisplay,
audRight: cc.AudioClip,
audWrong: cc.AudioClip,
spfAudio: [cc.SpriteFrame],
},
// onLoad () {},
......@@ -121,5 +123,41 @@ cc.Class({
GameData.audioCount--;
})
},
changeAudioSpfCb() {
this.sprAudio.spriteFrame = this.sprAudio.spriteFrame == this.spfAudio[0] ? this.spfAudio[1] : this.spfAudio[0];
},
onBtnClickAudio() {
if(GameData.audioCount > 0){
return;
}
this.dragonBone.playAnimation(this.animationName, 0);
this.sprAudio.spriteFrame = this.spfAudio[0];
this.schedule(this.changeAudioSpfCb, 0.2)
this.playAudioOption(() => {
this.unschedule(this.changeAudioSpfCb)
this.sprAudio.spriteFrame = this.spfAudio[1];
GameData.isAudio = false;
});
},
playAudioOption(cb) {
GameData.audioCount++;
let url = this.data.optionAudio;
// url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
let id = cc.audioEngine.play(clip, false, 1);
cc.audioEngine.setFinishCallback(id, () => {
if (!cc.isValid(this)) {
return;
}
GameData.audioCount--;
cb && cb();
})
});
},
// update (dt) {},
});
......@@ -37,9 +37,9 @@ cc.Class({
var imageUrl = this.data.optionDragonBone.texPngData.url;
var skeUrl = this.data.optionDragonBone.skeJsonData.url;
var atlasUrl = this.data.optionDragonBone.texJsonData.url;
// imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
// skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
// atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
imageUrl = 'http://127.0.0.1/NewProject_2_tex.png';
skeUrl = 'http://127.0.0.1/NewProject_2_ske.json';
atlasUrl = 'http://127.0.0.1/NewProject_2_tex.json';
// imageUrl = 'http://127.0.0.1/walkingfish_tex.png';
// skeUrl = 'http://127.0.0.1/walkingfish_ske.json';
......@@ -160,7 +160,7 @@ cc.Class({
playAudioOption(showNext) {
GameData.audioCount++;
let url = this.data.optionAudio;
let url = this.data.questionAudio;
// url = 'http://127.0.0.1/iamflying.mp3';
cc.assetManager.loadRemote(url, null, (err, clip) => {
if (err) {
......
{
"ver": "2.3.5",
"uuid": "d1614876-ddf1-4d62-b334-8f6cb91b01e4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 56,
"platformSettings": {},
"subMetas": {
"btn_laba": {
"ver": "1.0.4",
"uuid": "b8916cdd-f8f9-40ae-8d54-783bd1725f4a",
"rawTextureUuid": "d1614876-ddf1-4d62-b334-8f6cb91b01e4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 52,
"height": 56,
"rawWidth": 52,
"rawHeight": 56,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "86a60707-62d7-40da-9980-86e81171840c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 56,
"platformSettings": {},
"subMetas": {
"btn_laba2": {
"ver": "1.0.4",
"uuid": "91142e92-4b78-4f47-a50f-c6af85b22675",
"rawTextureUuid": "86a60707-62d7-40da-9980-86e81171840c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 52,
"height": 56,
"rawWidth": 52,
"rawHeight": 56,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment