Commit 83de2984 authored by jeff's avatar jeff

更新

parent d39ff12f
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
"cli": {
"analytics": "06333645-37f7-4fd6-9eb2-94a40b76c96a"
}
} }
\ No newline at end of file
...@@ -91,13 +91,14 @@ ...@@ -91,13 +91,14 @@
</div> </div>
</div> </div>
<div *ngIf='audio'>
<nz-divider style="margin-top: 10px;"></nz-divider> <nz-divider style="margin-top: 10px;"></nz-divider>
<h4> 音频设置 </h4> <h4> 音频设置 </h4>
<app-audio-recorder style="margin: auto" [audioUrl]="item?.audio_url" <app-audio-recorder style="margin: auto" [audioUrl]="item?.audio_url"
(audioUploaded)="onItemAudioUploadSuccess($event, item)"></app-audio-recorder> (audioUploaded)="onItemAudioUploadSuccess($event, item)"></app-audio-recorder>
</div>
</div> </div>
......
...@@ -22,6 +22,8 @@ export class CustomActionComponent implements OnDestroy, OnChanges { ...@@ -22,6 +22,8 @@ export class CustomActionComponent implements OnDestroy, OnChanges {
@Input() @Input()
type = 'text' type = 'text'
@Input()
audio =true
@Output() @Output()
save = new EventEmitter(); save = new EventEmitter();
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<div> <div>
<h5>题干音频</h5> <h5>题干音频</h5>
<div style="display: flex;align-items: center; margin-top: 5px"> <div style="display: flex;align-items: center; margin-top: 5px">
<app-audio-recorder style="margin: auto" [audioUrl]="bgAudioUrl" <app-audio-recorder style="margin: auto" [audioUrl]="bgItem?.bgAudioUrl"
(audioUploaded)="onBgAudioUploadSuucess($event)"></app-audio-recorder> (audioUploaded)="onBgAudioUploadSuucess($event)"></app-audio-recorder>
</div> </div>
</div> </div>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<div *ngIf="customTypeGroupArr[it.gIdx]?.action" style="display: flex;align-items: center; margin-top: 5px"> <div *ngIf="customTypeGroupArr[it.gIdx]?.action" style="display: flex;align-items: center; margin-top: 5px">
<app-custom-action style="margin: auto" [item]="it ? it['actionData_' + it.gIdx] : {}" <app-custom-action style="margin: auto" [item]="it ? it['actionData_' + it.gIdx] : {}"
[type]="customTypeGroupArr[it.gIdx].action.type" [option]="customTypeGroupArr[it.gIdx].action.option" [type]="customTypeGroupArr[it.gIdx].action.type" [option]="customTypeGroupArr[it.gIdx].action.option"
(save)="onSaveCustomAction($event, it)"> (save)="onSaveCustomAction($event, it)" [audio] ='customTypeGroupArr[it.gIdx].action.audio'>
></app-custom-action> ></app-custom-action>
</div> </div>
......
@font-face {
font-family: 'font';
src: url('BRLNSDB.TTF');
}
.p-image-children-editor { .p-image-children-editor {
width: 100%; width: 100%;
......
...@@ -153,7 +153,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -153,7 +153,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
this.initListener(); this.initListener();
this.init(); // this.init();
this.update(); this.update();
this.refresh(); this.refresh();
...@@ -233,20 +233,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -233,20 +233,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
} }
addBtnClick() {
// this.imgArr.push({});
// this.hotZoneArr.push({});
const item = this.getHotZoneItem();
this.hotZoneArr.push(item);
this.refreshItem(item);
this.refreshHotZoneId();
console.log(item)
}
deleteBtnClick(index) { deleteBtnClick(index) {
const item = this.hotZoneArr.splice(index, 1)[0]; const item = this.hotZoneArr.splice(index, 1)[0];
...@@ -364,7 +350,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -364,7 +350,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
if (saveData) { if (saveData) {
let picUrl = saveData.pic_url; let picUrl = saveData.pic_url;
const actionData = saveData['actionData_' + item.gIdx]; const actionData = saveData['actionData_'];
if (actionData && actionData.type == 'pic') { if (actionData && actionData.type == 'pic') {
picUrl = actionData.pic_url; picUrl = actionData.pic_url;
} }
...@@ -428,7 +414,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -428,7 +414,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
textLabel.text = saveData.text textLabel.text = saveData.text
} }
this.setActionFont(textLabel, saveData['actionData_' + item.gIdx]); this.setActionFont(textLabel, saveData['actionData_']);
textLabel.refreshSize(); textLabel.refreshSize();
} }
...@@ -515,37 +501,26 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -515,37 +501,26 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
this.refresh(); this.refresh();
} }
deleteItem(e, i) { addBtnClick() {
// this.imgArr.splice(i , 1); // this.imgArr.push({});
// this.refreshImageId(); // this.hotZoneArr.push({});
this.hotZoneArr.splice(i, 1);
this.refreshHotZoneId();
this.refresh();
}
const item = this.getHotZoneItem();
this.hotZoneArr.push(item);
this.refreshCustomItem(item)
// radioChange(e, item) { this.refreshHotZoneId();
// item.itemType = e;
// this.refreshItem(item); }
// this.refresh();
// // console.log(' in radioChange e: ', e);
// }
customRadioChange(e, item) { deleteItem(e, i) {
// this.imgArr.splice(i , 1);
// this.refreshImageId();
console.log('in customRadioChange', e); this.hotZoneArr.splice(i, 1);
item.gIdx = -1; this.refreshHotZoneId();
setTimeout(() => {
item.gIdx = e;
this.refreshCustomItem(item);
this.refresh(); this.refresh();
}, 1);
// const curGroup = this.customTypeGroupArr[e];
} }
refreshCustomItem(item) { refreshCustomItem(item) {
...@@ -585,6 +560,30 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -585,6 +560,30 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
} }
// radioChange(e, item) {
// item.itemType = e;
// this.refreshItem(item);
// this.refresh();
// // console.log(' in radioChange e: ', e);
// }
customRadioChange(e, item) {
console.log('in customRadioChange', e);
item.gIdx = -1;
setTimeout(() => {
item.gIdx = e;
this.refreshCustomItem(item);
this.refresh();
}, 1);
// const curGroup = this.customTypeGroupArr[e];
}
setItemIsAnimaStyle(item, isAnimal) { setItemIsAnimaStyle(item, isAnimal) {
} }
...@@ -598,7 +597,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -598,7 +597,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
showItemLabel(item) { showItemLabel(item) {
item.textLabel.visible = true; item.textLabel.visible = true;
item.itemType = 'text'; item.itemType = 'text';
this.showArrowTop(item, true) this.showArrowTop(item)
} }
showItemRect(item, isShowArrowTop = true) { showItemRect(item, isShowArrowTop = true) {
...@@ -1140,7 +1139,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1140,7 +1139,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
useBorder: hotZoneArr[i].useBorder useBorder: hotZoneArr[i].useBorder
}; };
hotZoneItem['actionData_' + hotZoneItem.gIdx] = hotZoneArr[i]['actionData_' + hotZoneArr[i].gIdx] hotZoneItem['actionData_' ] = hotZoneArr[i]['actionData_']
if (this.hotZoneFontObj) { if (this.hotZoneFontObj) {
...@@ -1173,8 +1172,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1173,8 +1172,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
console.log('hotZoneItemArr: ', hotZoneItemArr); console.log('hotZoneItemArr: ', hotZoneItemArr);
// return { bgItem, hotZoneItemArr }; return { bgItem, hotZoneItemArr };
return { hotZoneItemArr, bgAudioUrl: this.bgAudioUrl };
} }
saveText(item) { saveText(item) {
...@@ -1186,7 +1184,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1186,7 +1184,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
onSaveCustomAction(e, item) { onSaveCustomAction(e, item) {
const data = e; const data = e;
item['actionData_' + item.gIdx] = data; item['actionData_'] = data;
if (data.type == 'pic') { if (data.type == 'pic') {
let picUrl = data.pic_url; let picUrl = data.pic_url;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
--> -->
<div *ngFor='let data of item ;index as i'> <div *ngFor='let data of item ;index as i'>
<span> 卡片{{i+1}}</span> <span> 卡片{{i+1}}</span>
<app-custom-hot-zone-mini [bgAudioUrl]="data.bgAudioUrl" [hotZoneItemArr]="data.hotZoneItemArr" <app-custom-hot-zone-mini [bgItem]="data.bgItem" [hotZoneItemArr]="data.hotZoneItemArr"
[customTypeGroupArr]="customTypeGroupArr" (save)="saveHotZone(data, $event)" (del)="delHotZone(i)"> [customTypeGroupArr]="customTypeGroupArr" (save)="saveHotZone(data, $event)" (del)="delHotZone(i)">
</app-custom-hot-zone-mini> </app-custom-hot-zone-mini>
</div> </div>
......
...@@ -19,23 +19,28 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -19,23 +19,28 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
name: '句子音频', name: '句子音频',
action: { action: {
type: 'text', type: 'text',
audio:true,
option: [ option: [
['color', '#000000'], ['fontColor', '#000000'],
['size', '100'] ['fontSize', '100']
] ]
} }
}, },
{ {
name: '发音区域', name: '点击区域',
action: { action: {
type: 'text', type: 'text',
aduio:false,
option: [ option: [
['color', '#000000'], ['fontColor', '#000000'],
['size', '100'] ['fontSize', '100']
] ]
}
}, },
},
{
name: '图片',
pic: true
}
] ]
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
...@@ -90,9 +95,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -90,9 +95,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/** 保存按钮 */ /** 保存按钮 */
saveHotZone(group, e) { saveHotZone(group, e) {
console.log('e: ', e); console.log('e: ', e);
const { hotZoneItemArr ,bgAudioUrl} = e; const { hotZoneItemArr, bgItem } = e;
group.bgAudioUrl = bgAudioUrl; group.bgItem = bgItem;
group.hotZoneItemArr = hotZoneItemArr; group.hotZoneItemArr = hotZoneItemArr;
this.save(); this.save();
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 6 "__id__": 5
} }
], ],
"_prefab": { "_prefab": {
"__id__": 7 "__id__": 6
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -89,13 +89,10 @@ ...@@ -89,13 +89,10 @@
"_components": [ "_components": [
{ {
"__id__": 3 "__id__": 3
},
{
"__id__": 4
} }
], ],
"_prefab": { "_prefab": {
"__id__": 5 "__id__": 4
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -179,33 +176,6 @@ ...@@ -179,33 +176,6 @@
"_N$cacheMode": 0, "_N$cacheMode": 0,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
...@@ -228,6 +198,9 @@ ...@@ -228,6 +198,9 @@
"label": { "label": {
"__id__": 3 "__id__": 3
}, },
"tipClip": {
"__uuid__": "e0bcf4cc-35a7-4d61-b202-8dd49299c2c0"
},
"_id": "" "_id": ""
}, },
{ {
......
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "node",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
}
],
"_prefab": {
"__id__": 4
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 40,
"height": 36
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 1
},
"_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__": 1
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "577b3ZhuUNJtLzUNX3CEf1G",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "85e73971-9396-4c2a-9fac-2b187fd99c48"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "85e73971-9396-4c2a-9fac-2b187fd99c48",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -21,17 +21,17 @@ ...@@ -21,17 +21,17 @@
"__id__": 2 "__id__": 2
}, },
{ {
"__id__": 6 "__id__": 5
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 12 "__id__": 11
} }
], ],
"_prefab": { "_prefab": {
"__id__": 13 "__id__": 12
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 64.47, "width": 64.51,
"height": 55 "height": 55
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -92,13 +92,10 @@ ...@@ -92,13 +92,10 @@
"_components": [ "_components": [
{ {
"__id__": 3 "__id__": 3
},
{
"__id__": 4
} }
], ],
"_prefab": { "_prefab": {
"__id__": 5 "__id__": 4
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -182,33 +179,6 @@ ...@@ -182,33 +179,6 @@
"_N$cacheMode": 0, "_N$cacheMode": 0,
"_id": "" "_id": ""
}, },
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 18,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
...@@ -231,17 +201,17 @@ ...@@ -231,17 +201,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 7 "__id__": 6
}, },
{ {
"__id__": 8 "__id__": 7
}, },
{ {
"__id__": 9 "__id__": 8
} }
], ],
"_prefab": { "_prefab": {
"__id__": 11 "__id__": 10
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -265,8 +235,8 @@ ...@@ -265,8 +235,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
71.659, 78.809,
-3.917, -3.5,
0, 0,
0, 0,
0, 0,
...@@ -295,7 +265,7 @@ ...@@ -295,7 +265,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 6 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -327,7 +297,7 @@ ...@@ -327,7 +297,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 6 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"_defaultClip": { "_defaultClip": {
...@@ -349,7 +319,7 @@ ...@@ -349,7 +319,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 6 "__id__": 5
}, },
"_enabled": true, "_enabled": true,
"_normalMaterial": null, "_normalMaterial": null,
...@@ -358,7 +328,7 @@ ...@@ -358,7 +328,7 @@
"zoomScale": 1.1, "zoomScale": 1.1,
"clickEvents": [ "clickEvents": [
{ {
"__id__": 10 "__id__": 9
} }
], ],
"_N$interactable": true, "_N$interactable": true,
...@@ -449,7 +419,7 @@ ...@@ -449,7 +419,7 @@
"__id__": 3 "__id__": 3
}, },
"playAnim": { "playAnim": {
"__id__": 8 "__id__": 7
}, },
"_id": "" "_id": ""
}, },
......
...@@ -5,64 +5,47 @@ cc.Class({ ...@@ -5,64 +5,47 @@ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
label: cc.Label label: cc.Label,
tipClip: cc.AudioClip
}, },
data: null, data: null,
onLoad() { onLoad() {
}, },
onEnable() { onEnable() {
this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this) this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
cc.systemEvent.on('changeAnswerState', this.onChangeState, this)
}, },
onDisable() { onDisable() {
this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this) this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
cc.systemEvent.off('changeAnswerState', this.onChangeState, this)
}, },
initWithData(data) { initWithData(data, scale) {
this.data = data this.data = data
let rect = this.data.rect let rect = this.data.rect
this.node.x = rect.x + rect.width / 2 this.node.x = rect.x * scale
this.node.y = -rect.y - rect.height / 2 this.node.y = -rect.y * scale
this.node.width = rect.width this.node.width = rect.width
this.node.height = rect.height this.node.height = rect.height
this.label = data.text this.node.scale = data.fontScale ? data.fontScale * scale : scale
this.audioId = null let action = data['actionData_']
this.label.string = action.text ? action.text : ''
this.label.node.active = false
let option = action.changeOption
this.label.node.color = option[0][1] ? cc.color(option[0][1]) : cc.color(0, 0, 0)
}, },
onTouchStart() { onTouchStart() {
if (this.audioId) return this.label.node.active = true
if (this.data) {
let url = this.data.audio_url
if (url && url != '') {
this.playAudio(url)
this.tipsAnim.node.active = true
this.tipsAnim.play()
}
cc.audioEngine.play(this.tipClip) cc.audioEngine.play(this.tipClip)
}
}, },
/** 播放音乐 */ /** 改变答案显示状态 */
playAudio(url) { onChangeState(show) {
cc.assetManager.loadRemote(url, (err, audioClip) => { this.label.node.active = show
if (err) return
cc.systemEvent.once('stopMusic', this.stopAudio, this)
this.audioId = cc.audioEngine.play(audioClip, false, 0.8);
cc.audioEngine.setFinishCallback(this.audioId, this.stopAudio.bind(this));
});
},
stopAudio() {
if (this.audioId != null) {
cc.audioEngine.stop(this.audioId)
this.audioId = null
cc.systemEvent.off('stopMusic', this.stopAudio, this)
} }
},
/** 音频id */
audioId: null,
}); });
const tools = require("../script/tools");
cc.Class({
extends: cc.Component,
properties: {
},
initWithData(data,scale) {
let sprite = this.getComponent(cc.Sprite)
tools.getSpriteFrimeByUrl(data.pic_url,(sp)=>{
sprite.spriteFrame = sp
let rect = data.rect
this.node.setPosition(rect.x*scale,-rect.y*scale)
this.node.width = rect.width*scale
this.node.height = rect.height*scale
})
}
});
{
"ver": "1.0.8",
"uuid": "577b3661-b943-49b4-bcd4-357dc211fd46",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -5,7 +5,8 @@ cc.Class({ ...@@ -5,7 +5,8 @@ cc.Class({
properties: { properties: {
hitPre: cc.Prefab, hitPre: cc.Prefab,
wordsPre: cc.Prefab wordsPre: cc.Prefab,
picPre: cc.Prefab
}, },
onLoad() { onLoad() {
...@@ -54,17 +55,22 @@ cc.Class({ ...@@ -54,17 +55,22 @@ cc.Class({
// this._hitItem.push(node) // this._hitItem.push(node)
// } // }
// }) // })
let rect = data.bgItem.rect
let scale = 1280/rect.width
let node let node
for (let one of data.hotZoneItemArr) { for (let one of data.hotZoneItemArr) {
if (one.gIdx == '0') { // 发音句子 if (one.gIdx == '0') { // 发音句子
node = cc.instantiate(this.wordsPre) node = cc.instantiate(this.wordsPre)
comp = node.getComponent('wordsItem') comp = node.getComponent('wordsItem')
} else { } else if (one.gIdx == '1') {
node = cc.instantiate(this.hitPre) node = cc.instantiate(this.hitPre)
comp = node.getComponent('hitItem') comp = node.getComponent('hitItem')
} else {
node = cc.instantiate(this.picPre)
comp = node.getComponent('picItem')
} }
this._items.addChild(node) this._items.addChild(node)
comp.initWithData(one) comp.initWithData(one, scale)
this._hitItem.push(node) this._hitItem.push(node)
} }
}, },
......
This diff is collapsed.
...@@ -20,6 +20,7 @@ cc.Class({ ...@@ -20,6 +20,7 @@ cc.Class({
type: cc.Node, type: cc.Node,
default: null default: null
}, },
bgAudioNode: cc.Node,
btnClip: cc.AudioClip btnClip: cc.AudioClip
}, },
...@@ -87,11 +88,11 @@ cc.Class({ ...@@ -87,11 +88,11 @@ cc.Class({
}, },
onEnable() { onEnable() {
cc.systemEvent.on('playAudio', this.onPlayAudio, this)
}, },
onDisable() { onDisable() {
cc.systemEvent.off('playAudio', this.onPlayAudio, this)
}, },
...@@ -100,7 +101,7 @@ cc.Class({ ...@@ -100,7 +101,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '[{"hotZoneItemArr":[{"id":"1620866294132","index":0,"itemType":"text","fontScale":0.29296875,"imgScale":1,"mapScale":0.29296875,"gIdx":"0","rect":{"width":58.1,"height":11.72,"x":300.54,"y":305.15}},{"id":"1620866973543","index":1,"itemType":"text","fontScale":0.29296875,"imgScale":1,"mapScale":0.29296875,"gIdx":"1","rect":{"width":46.84,"height":11.72,"x":387.59,"y":236.14}}],"bgAudioUrl":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3"}]' const dataJson = ' [{"hotZoneItemArr":[{"id":"1620886548676","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/aa0d852ef05d9d8de158f10b4a727376.jpg","itemType":"text","fontScale":0.7859375,"imgScale":0.5236111111111111,"mapScale":0.7859375,"gIdx":"0","actionData_":{"type":"text","changeOption":[["fontColor","#000000"],["fontSize","100"]],"text":"I WANT Fly","audio_url":"http://staging-teach.cdn.ireadabc.com/bd0502e664d0d279ccbec4e22b60f051.mp3"},"rect":{"width":438.31,"height":78.59,"x":115.96,"y":149.2}}],"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/b90a006ba41723ec11970051e92f43e0.png","rect":{"x":167.89,"y":0,"width":670.22,"height":377}}}]'
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -270,8 +271,17 @@ cc.Class({ ...@@ -270,8 +271,17 @@ cc.Class({
console.log('数据错误') console.log('数据错误')
return return
} }
picNode.getComponent('picNode').initWithData(data) if (data.bgAudioUrl && data.bgAudioUrl != '') {
this.bgAudioNode.active = true
} else {
this.bgAudioNode.active = false
} }
picNode.getComponent('picNode').initWithData(data)
},
/** 点击切换答案显示 */
onCheckall() {
}
// ------------------------------------------ // ------------------------------------------
}); });
...@@ -10,6 +10,8 @@ cc.Class({ ...@@ -10,6 +10,8 @@ cc.Class({
data: null, data: null,
audio_url: null,
onEnable() { onEnable() {
}, },
...@@ -17,18 +19,25 @@ cc.Class({ ...@@ -17,18 +19,25 @@ cc.Class({
}, },
initWithData(data) { initWithData(data, scale) {
this.data = data this.data = data
let rect = this.data.rect let rect = this.data.rect
console.log(rect) this.node.x = (rect.x + rect.width / 2) * scale
this.node.x = rect.x + rect.width / 2 this.node.y = (-rect.y - rect.height / 2) * scale
this.node.y = -rect.y - rect.height / 2 let action = data['actionData_']
this.node.width = rect.width let node = this.label.node
this.node.height = rect.height let option = action.changeOption
this.node.scale = data.fontScale ? data.fontScale : 1 node.color = option[0][1] ? cc.color(option[0][1]) : cc.color(0, 0, 0)
this.label.string = data.text ? data.text : '' node.scale = data.fontScale ? data.fontScale*scale : scale
this.label.string = action.text ? action.text : ''
this.node.width = node.width * node.scale
this.node.height = node.height * node.height
this.audioId = null this.audioId = null
if (data.audio_url) { this.audio_url = action.audio_url
if (this.audio_url) {
let node = this.playAnim.node
node.scale = 1 / this.node.scale
node.setPosition(this.label.node.width + node.width / 2 + 15, -this.node.height / 2)
this.playAnim.node.active = true this.playAnim.node.active = true
} else { } else {
this.playAnim.node.active = false this.playAnim.node.active = false
...@@ -37,11 +46,8 @@ cc.Class({ ...@@ -37,11 +46,8 @@ cc.Class({
onTouchStart() { onTouchStart() {
if (this.audioId) return if (this.audioId) return
if (this.data) { if (this.audio_url && this.audio_url != '') {
let url = this.data.audio_url this.playAudio(this.audio_url)
if (url && url != '') {
this.playAudio(url)
}
this.playAnim.play('play') this.playAnim.play('play')
} }
}, },
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"rawWidth": 55, "rawWidth": 55,
"rawHeight": 59, "rawHeight": 59,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 2,
"borderLeft": 0, "borderLeft": 0,
"borderRight": 0, "borderRight": 0,
"subMetas": {} "subMetas": {}
......
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