Commit d39ff12f authored by jeff's avatar jeff

提交

parent d63fd780
<div class="position-relative"> <div class="position-relative">
<button nz-button (click)="setAnimaBtnClick()" style=" border-radius: 0.5rem; border: 1px solid #ddd;" > <button nz-button (click)="setAnimaBtnClick()" style=" border-radius: 0.5rem; border: 1px solid #ddd;">
<i nz-icon nzType="tool" nzTheme="outline"></i> <i nz-icon nzType="tool" nzTheme="outline"></i>
{{btnName}} {{btnName}}
</button> </button>
<!--配置龙骨面板--> <!--配置龙骨面板-->
<nz-modal [(nzVisible)]="panelVisible" (nzAfterClose)="closePanel()" [nzTitle]="btnName" (nzOnCancel)="panelCancel()" (nzOnOk)="panelOk()" nzOkText="保存"> <nz-modal [(nzVisible)]="panelVisible" (nzAfterClose)="closePanel()" [nzTitle]="btnName" (nzOnCancel)="panelCancel()"
(nzOnOk)="panelOk()" nzOkText="保存">
<div> <div>
<h4>基础内容:</h4> <h4>基础内容:</h4>
...@@ -20,8 +21,7 @@ ...@@ -20,8 +21,7 @@
</nz-radio-group> --> </nz-radio-group> -->
<div *ngIf="item.type == 'pic'"> <div *ngIf="item.type == 'pic'">
<app-upload-image-with-preview <app-upload-image-with-preview [picUrl]="item?.pic_url"
[picUrl]="item?.pic_url"
(imageUploaded)="onItemImgUploadSuccess($event, item)"> (imageUploaded)="onItemImgUploadSuccess($event, item)">
</app-upload-image-with-preview> </app-upload-image-with-preview>
</div> </div>
...@@ -31,12 +31,8 @@ ...@@ -31,12 +31,8 @@
</div> </div>
<div *ngIf="item.type == 'anima'" style="margin-left: 100px;"> <div *ngIf="item.type == 'anima'" style="margin-left: 100px;">
<app-upload-dragon-bone <app-upload-dragon-bone [skeJsonData]=item.skeJsonData [texJsonData]=item.texJsonData
[skeJsonData]=item.skeJsonData [texPngData]=item.texPngData (save)="saveAnima($event)">
[texJsonData]=item.texJsonData
[texPngData]=item.texPngData
(save)="saveAnima($event)"
>
</app-upload-dragon-bone> </app-upload-dragon-bone>
</div> </div>
</div> </div>
...@@ -47,7 +43,7 @@ ...@@ -47,7 +43,7 @@
<h4>状态设置:</h4> <h4>状态设置:</h4>
<div style="display: flex; justify-content: space-around;"> <div style="display: flex; justify-content: space-around;">
<div style="width: 30%; display: flex; align-items: center; flex-direction: column;"> <!-- <div style="width: 30%; display: flex; align-items: center; flex-direction: column;">
<h5> 开始状态 </h5> <h5> 开始状态 </h5>
<div *ngFor="let op of item.changeOption; let i = index" style="margin-bottom: 5px; "> <div *ngFor="let op of item.changeOption; let i = index" style="margin-bottom: 5px; ">
<div style="display: flex; align-items: center; justify-content: center;"> <div style="display: flex; align-items: center; justify-content: center;">
...@@ -72,17 +68,25 @@ ...@@ -72,17 +68,25 @@
<span>{{op[0]}}: </span> <input [disabled]="op[2] == null" type="text" nz-input [(ngModel)]="op[2]" (blur)="saveText(op)" style="margin-left: 5px;"> <span>{{op[0]}}: </span> <input [disabled]="op[2] == null" type="text" nz-input [(ngModel)]="op[2]" (blur)="saveText(op)" style="margin-left: 5px;">
</div> </div>
</div> </div>
</div> -->
<div style="width: 30%; display: flex; align-items: center; flex-direction: column;">
<div *ngFor="let op of item.changeOption; let i = index" style="margin-bottom: 5px; ">
<div style="display: flex; align-items: center; justify-content: center;">
<span style="white-space: nowrap">{{op[0]}}: </span> <input type="text" nz-input [(ngModel)]="op[1]"
(blur)="saveText(op)" style="margin-left: 5px;">
</div>
</div>
</div> </div>
</div> </div>
<div style="display: flex; align-items: center; justify-content: center; margin-top: 10px;"> <div style="display: flex; align-items: center; justify-content: center; margin-top: 10px;">
<button style="margin-left: 20px; margin-top: -5px" nz-button (click)="copyChangeData()"> 复制数据 </button> <button style="margin-left: 20px; margin-top: -5px" nz-button (click)="copyChangeData()"> 复制数据 </button>
<div style="margin-left: 20px; margin-top: -5px" > <div style="margin-left: 20px; margin-top: -5px">
<span>粘贴数据: </span> <span>粘贴数据: </span>
<input style="width: 100px;" type="text" nz-input [(ngModel)]="pasteData" > <input style="width: 100px;" type="text" nz-input [(ngModel)]="pasteData">
<button style="margin-left: 5px;" nz-button [disabled]="pasteData==''" nzType="primary" (click)="importData()">导入</button> <button style="margin-left: 5px;" nz-button [disabled]="pasteData==''" nzType="primary"
(click)="importData()">导入</button>
</div> </div>
</div> </div>
...@@ -92,17 +96,14 @@ ...@@ -92,17 +96,14 @@
<h4> 音频设置 </h4> <h4> 音频设置 </h4>
<app-audio-recorder <app-audio-recorder style="margin: auto" [audioUrl]="item?.audio_url"
style="margin: auto" (audioUploaded)="onItemAudioUploadSuccess($event, item)"></app-audio-recorder>
[audioUrl]="item?.audio_url"
(audioUploaded)="onItemAudioUploadSuccess($event, item)"
></app-audio-recorder>
</div> </div>
<!-- <!--
<div class="anima-upload-btn"> <div class="anima-upload-btn">
<span style="margin-right: 10px">上传 ske_json 文件: </span> <span style="margin-right: 10px">上传 ske_json 文件: </span>
<nz-upload [nzShowUploadList]="false" <nz-upload [nzShowUploadList]="false"
...@@ -149,5 +150,3 @@ ...@@ -149,5 +150,3 @@
</nz-modal> </nz-modal>
</div> </div>
\ No newline at end of file
...@@ -70,18 +70,18 @@ export class CustomActionComponent implements OnDestroy, OnChanges { ...@@ -70,18 +70,18 @@ export class CustomActionComponent implements OnDestroy, OnChanges {
if (!this.item) { if (!this.item) {
this.item = { this.item = {
type: this.type, type: this.type,
skeJsonData: {}, // skeJsonData: {},
texJsonData: {}, // texJsonData: {},
texPngData: {}, // texPngData: {},
changeStart: [ // changeStart: [
], // ],
changeEnd: [ // changeEnd: [
], // ],
changeTime: 0.3 // changeTime: 0.3
}; };
if (this.option) { if (this.option) {
......
...@@ -7,20 +7,27 @@ ...@@ -7,20 +7,27 @@
</div> </div>
<div nz-row nzType="flex" nzAlign="middle"> <div nz-row nzType="flex" nzAlign="middle">
<div nz-col nzSpan="5" nzOffset="1"> <div nz-col nzSpan="5" nzOffset="1" style="display:flex; flex-wrap:wrap;flex-direction: row;width: 100%;">
<h5> 添加背景: </h5> <!-- <h5> 添加背景: </h5>
<div class="bg-box"> <div class="bg-box">
<app-upload-image-with-preview [picUrl]="bgItem?.url" (imageUploaded)="onBackgroundUploadSuccess($event)"> <app-upload-image-with-preview [picUrl]="bgItem?.url" (imageUploaded)="onBackgroundUploadSuccess($event)">
</app-upload-image-with-preview> </app-upload-image-with-preview>
</div> </div>
</div> -->
<div>
<h5>题干音频</h5>
<div style="display: flex;align-items: center; margin-top: 5px">
<app-audio-recorder style="margin: auto" [audioUrl]="bgAudioUrl"
(audioUploaded)="onBgAudioUploadSuucess($event)"></app-audio-recorder>
</div> </div>
</div>
<div nz-col nzSpan="5" nzOffset="1" class="img-box" *ngFor="let it of hotZoneArr; let i = index"> <div nz-col nzSpan="5" nzOffset="1" class="img-box" style="width: auto;"
*ngFor="let it of hotZoneArr; let i = index">
<div <div
style="margin: auto; padding: 5px;min-width: 220px; margin-top: 30px; width:90%; border: 2px dashed #ddd; border-radius: 10px"> style="width: auto; margin: auto; padding: 5px;min-width: 220px; margin-top: 30px; width:90%; border: 2px dashed #ddd; border-radius: 10px">
<span style="margin-left: 40%;"> 区域{{i + 1}} <span style="margin-left: 40%;"> 区域{{i + 1}}
</span> </span>
<button style="float: right;" nz-button nzType="danger" nzSize="small" (click)="deleteBtnClick(i)"> <button style="float: right;" nz-button nzType="danger" nzSize="small" (click)="deleteBtnClick(i)">
...@@ -56,18 +63,10 @@ ...@@ -56,18 +63,10 @@
<div *ngIf="customTypeGroupArr && customTypeGroupArr[it.gIdx]"> <div *ngIf="customTypeGroupArr && customTypeGroupArr[it.gIdx]">
<div *ngIf="customTypeGroupArr[it.gIdx].pic"> <div *ngIf="customTypeGroupArr[it.gIdx].pic">
<app-upload-image-with-preview [picUrl]="it?.pic_url" (imageUploaded)="onItemImgUploadSuccess($event, it)"> <app-upload-image-with-preview [picUrl]="it?.pic_url"
(imageUploaded)="onItemImgUploadSuccess($event, it)">
</app-upload-image-with-preview> </app-upload-image-with-preview>
</div> </div>
<div
style="margin-top: 5px; margin-bottom: 5px; display: inline-flex;justify-content: space-between;justify-items: center;">
<div>
手提示 <nz-switch [ngModel]="it.useHand" (ngModelChange)="onChangeSwitch(it,'useHand')" nzCheckedChildren="开" nzUnCheckedChildren="关"></nz-switch>
</div>
<div *ngIf="it.gIdx==0" style="margin-left: 10px;">
显示边框 <nz-switch [ngModel]='it.useBorder' (ngModelChange)="onChangeSwitch(it,'useBorder')" nzCheckedChildren="开" nzUnCheckedChildren="关"></nz-switch>
</div>
</div>
<div *ngIf="customTypeGroupArr[it.gIdx].text" style="margin-top: 5px"> <div *ngIf="customTypeGroupArr[it.gIdx].text" style="margin-top: 5px">
<input type="text" nz-input [(ngModel)]="it.text" (blur)="saveText(it)"> <input type="text" nz-input [(ngModel)]="it.text" (blur)="saveText(it)">
...@@ -141,9 +140,9 @@ ...@@ -141,9 +140,9 @@
</div> </div>
<div nz-col nzSpan="5" nzOffset="1"> <div nz-col nzSpan="5" nzOffset="1" style="width: 230px;height: auto;align-self: center;">
<div class="bg-box"> <div class="bg-box" style="width: auto;height: auto;">
<button nz-button nzType="dashed" (click)="addBtnClick()" class="add-btn"> <button nz-button nzType="dashed" (click)="addBtnClick()" class="add-btn">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i> <i nz-icon nzType="plus-circle" nzTheme="outline"></i>
<!--Add Image--> <!--Add Image-->
...@@ -189,13 +188,13 @@ ...@@ -189,13 +188,13 @@
</div> </div>
</div> </div>
<label style="opacity: 0; position: absolute; top: 0px; font-family: 'BRLNSR_1'">1</label> <label style="opacity: 0; position: absolute; top: 0px; font-family: 'BRLNSR_1'">1</label>
<!--龙骨面板--> <!--龙骨面板-->
<nz-modal [(nzVisible)]="animaPanelVisible" nzTitle="配置资源文件" (nzAfterClose)="closeAfterPanel()" <nz-modal [(nzVisible)]="animaPanelVisible" nzTitle="配置资源文件" (nzAfterClose)="closeAfterPanel()"
(nzOnCancel)="animaPanelCancel()" (nzOnOk)="animaPanelOk()" nzOkText="保存"> (nzOnCancel)="animaPanelCancel()" (nzOnOk)="animaPanelOk()" nzOkText="保存">
<div class="anima-upload-btn"> <div class="anima-upload-btn">
...@@ -233,4 +232,4 @@ ...@@ -233,4 +232,4 @@
提示:需包含以下动画: {{customTypeGroupArr[curDragonBoneGIdx].animaNames.toString()}} 提示:需包含以下动画: {{customTypeGroupArr[curDragonBoneGIdx].animaNames.toString()}}
</div> </div>
</nz-modal> </nz-modal>
\ No newline at end of file \ No newline at end of file
...@@ -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();
...@@ -169,6 +169,14 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -169,6 +169,14 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
} }
// 背景音频
@Input()
bgAudioUrl: string = ''
onBgAudioUploadSuucess(e) {
console.log(e)
this.bgAudioUrl = e.url
}
onBackgroundUploadSuccess(e) { onBackgroundUploadSuccess(e) {
console.log('e: ', e); console.log('e: ', e);
...@@ -196,7 +204,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -196,7 +204,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
} }
if (!this.bgItem.url) { if (!this.bgItem.url) {
this.bgItem.url = 'http://teach.cdn.ireadabc.com/8ebb1858564340ea0936b83e3280ad7d.jpg'; this.bgItem.url = 'http://staging-teach.cdn.ireadabc.com/b90a006ba41723ec11970051e92f43e0.png';
} }
const bg = this.bg; const bg = this.bg;
...@@ -309,8 +317,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -309,8 +317,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
item['id'] = new Date().getTime().toString(); item['id'] = new Date().getTime().toString();
item['data'] = saveData; item['data'] = saveData;
item['useHand'] = true
item['useBorder'] = true
console.log('item.x: ', item.x); console.log('item.x: ', item.x);
if (saveData) { if (saveData) {
...@@ -592,7 +598,7 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -592,7 +598,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) this.showArrowTop(item, true)
} }
showItemRect(item, isShowArrowTop = true) { showItemRect(item, isShowArrowTop = true) {
...@@ -1167,7 +1173,8 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1167,7 +1173,8 @@ 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) {
...@@ -1359,8 +1366,8 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1359,8 +1366,8 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
} }
copyHotZoneData() { copyHotZoneData() {
const { hotZoneItemArr } = this.getSendData();
const { bgItem, hotZoneItemArr } = this.getSendData(); // const { bgItem, hotZoneItemArr } = this.getSendData();
// const hotZoneItemArrNew = []; // const hotZoneItemArrNew = [];
// const tmpArr = JSON.parse(JSON.stringify(hotZoneItemArr)); // const tmpArr = JSON.parse(JSON.stringify(hotZoneItemArr));
...@@ -1371,7 +1378,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges { ...@@ -1371,7 +1378,6 @@ export class CustomHotZoneComponent1 implements OnInit, OnDestroy, OnChanges {
// }) // })
const jsonData = { const jsonData = {
bgItem,
hotZoneItemArr, hotZoneItemArr,
isHasRect: this.isHasRect, isHasRect: this.isHasRect,
isHasPic: this.isHasPic, isHasPic: this.isHasPic,
......
...@@ -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 [bgItem]="data.bgItem" [hotZoneItemArr]="data.hotZoneItemArr" <app-custom-hot-zone-mini [bgAudioUrl]="data.bgAudioUrl" [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>
......
...@@ -10,20 +10,30 @@ import { JsonPipe } from '@angular/common'; ...@@ -10,20 +10,30 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "et_13"; saveKey = "PU21";
// 储存对象 // 储存对象
item; item;
customTypeGroupArr = [ customTypeGroupArr = [
{ {
name: '发音图片', name: '句子音频',
pic: true, action: {
audio: true, type: 'text',
option: [
['color', '#000000'],
['size', '100']
]
}
}, },
{ {
name: '发音区块', name: '发音区域',
rect: true, action: {
audio: true, type: 'text',
option: [
['color', '#000000'],
['size', '100']
]
}
}, },
] ]
...@@ -80,9 +90,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -80,9 +90,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/** 保存按钮 */ /** 保存按钮 */
saveHotZone(group, e) { saveHotZone(group, e) {
console.log('e: ', e); console.log('e: ', e);
const { bgItem, hotZoneItemArr } = e; const { hotZoneItemArr ,bgAudioUrl} = e;
group.bgItem = bgItem; group.bgAudioUrl = bgAudioUrl;
group.hotZoneItemArr = hotZoneItemArr; group.hotZoneItemArr = hotZoneItemArr;
this.save(); this.save();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"compressing": "^1.5.0" "compressing": "^1.5.0",
"ngx-color-picker": "^11.0.0"
} }
} }
...@@ -22,24 +22,14 @@ cc.Class({ ...@@ -22,24 +22,14 @@ cc.Class({
this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this) this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this)
}, },
initWithData(data, scale) { initWithData(data) {
console.log(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) / 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
this.node.width = rect.width / scale this.node.width = rect.width
this.node.height = rect.height / scale this.node.height = rect.height
console.log(this.node) this.label = data.text
this.sprite.node.active = false
if (data.useHand) {
this.handAnim.node.active = true
this.handAnim.play()
}
let comps = this.getComponentsInChildren(cc.Widget)
for (let one of comps) {
one.updateAlignment()
}
this.audioId = null this.audioId = null
}, },
...@@ -52,19 +42,6 @@ cc.Class({ ...@@ -52,19 +42,6 @@ cc.Class({
this.tipsAnim.node.active = true this.tipsAnim.node.active = true
this.tipsAnim.play() this.tipsAnim.play()
} }
if (this.data.pic_url) {
tools.getSpriteFrimeByUrl(this.data.pic_url, (sp) => {
this.sprite.spriteFrame = sp
this.sprite.node.width = this.node.width
this.sprite.node.height = this.node.height
this.sprite.node.active = true
})
}
if (this.data.useBorder) {
this.quan.active = true
}
this.handAnim.stop()
this.handAnim.node.active = false
cc.audioEngine.play(this.tipClip) cc.audioEngine.play(this.tipClip)
} }
}, },
...@@ -83,14 +60,6 @@ cc.Class({ ...@@ -83,14 +60,6 @@ cc.Class({
if (this.audioId != null) { if (this.audioId != null) {
cc.audioEngine.stop(this.audioId) cc.audioEngine.stop(this.audioId)
this.audioId = null this.audioId = null
this.quan.active = false
this.tipsAnim.stop()
this.tipsAnim.node.active = false
this.sprite.node.active = false
if (this.data.useHand) {
this.handAnim.node.active = true
this.handAnim.play()
}
cc.systemEvent.off('stopMusic', this.stopAudio, this) cc.systemEvent.off('stopMusic', this.stopAudio, this)
} }
}, },
......
...@@ -4,7 +4,8 @@ cc.Class({ ...@@ -4,7 +4,8 @@ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
hitPre: cc.Prefab hitPre: cc.Prefab,
wordsPre: cc.Prefab
}, },
onLoad() { onLoad() {
...@@ -15,44 +16,57 @@ cc.Class({ ...@@ -15,44 +16,57 @@ cc.Class({
initWithData(data) { initWithData(data) {
this.clearItems() this.clearItems()
tools.getSpriteFrimeByUrl(data.bgItem.url, (sp) => { // tools.getSpriteFrimeByUrl(data.bgItem.url, (sp) => {
let rect = sp.getRect() // let rect = sp.getRect()
let scale = rect.width / rect.height // let scale = rect.width / rect.height
let originRect = cc.size(1280, 720) // let originRect = cc.size(1280, 720)
let originScale = originRect.width / originRect.height // let originScale = originRect.width / originRect.height
if (scale < originScale) { // if (scale < originScale) {
scale = rect.height / originRect.height // scale = rect.height / originRect.height
let width = rect.width / scale // let width = rect.width / scale
this.node.width = width // this.node.width = width
this.node.height = originRect.height // this.node.height = originRect.height
} else if (scale > originScale) { // } else if (scale > originScale) {
scale = rect.width / originRect.width // scale = rect.width / originRect.width
this.node.height = rect.height / scale // this.node.height = rect.height / scale
this.node.width = originRect.width // this.node.width = originRect.width
// } else {
// scale = rect.width / originRect.width
// this.node.width = originRect.width
// this.node.height = originRect.height
// }
// this._sprite.spriteFrame = sp
// this._sprite.node.width = this.node.width
// this._sprite.node.height = this.node.height
// this._items.width = this.node.width
// this._items.height = this.node.height
// this._items.x = -this.node.width / 2
// this._items.y = this.node.height / 2
// scale = data.bgItem.rect.width / this.node.width
// //初始化点击区域
// let node, comp
// for (let data of data.hotZoneItemArr) {
// node = cc.instantiate(this.hitPre)
// this._items.addChild(node)
// comp = node.getComponent('hitItem')
// comp.initWithData(data, scale)
// this._hitItem.push(node)
// }
// })
let node
for (let one of data.hotZoneItemArr) {
if (one.gIdx == '0') { // 发音句子
node = cc.instantiate(this.wordsPre)
comp = node.getComponent('wordsItem')
} else { } else {
scale = rect.width / originRect.width
this.node.width = originRect.width
this.node.height = originRect.height
}
this._sprite.spriteFrame = sp
this._sprite.node.width = this.node.width
this._sprite.node.height = this.node.height
this._items.width = this.node.width
this._items.height = this.node.height
this._items.x = -this.node.width / 2
this._items.y = this.node.height / 2
scale = data.bgItem.rect.width / this.node.width
//初始化点击区域
let node, comp
for (let data of data.hotZoneItemArr) {
node = cc.instantiate(this.hitPre) node = cc.instantiate(this.hitPre)
this._items.addChild(node)
comp = node.getComponent('hitItem') comp = node.getComponent('hitItem')
comp.initWithData(data, scale) }
this._items.addChild(node)
comp.initWithData(one)
this._hitItem.push(node) this._hitItem.push(node)
} }
})
}, },
/** 清除item */ /** 清除item */
......
This diff is collapsed.
...@@ -100,7 +100,7 @@ cc.Class({ ...@@ -100,7 +100,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '[{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/1a7513da33595f343fa73efa3be153d6.png","rect":{"x":231,"y":0,"width":287,"height":287}},"hotZoneItemArr":[{"id":"1620741734006","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/e74a1c89473132b6ce53633fc53a6aee.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3","itemType":"pic","fontScale":0.58515625,"imgScale":0.12725,"mapScale":0.58515625,"gIdx":"1","rect":{"x":113.87,"y":112.33,"width":64.9,"height":86.02}}]},{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/1a7513da33595f343fa73efa3be153d6.png","rect":{"x":231,"y":0,"width":287,"height":287}},"hotZoneItemArr":[{"id":"1620741734006","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/e74a1c89473132b6ce53633fc53a6aee.jpg","audio_url":"http://staging-teach.cdn.ireadabc.com/c8a7dd49a778b0b6dd509aac0ef437ff.mp3","itemType":"pic","fontScale":0.58515625,"imgScale":0.12725,"mapScale":0.58515625,"gIdx":"1","rect":{"x":113.87,"y":112.33,"width":64.9,"height":86.02}}]}]' 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 data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -112,9 +112,8 @@ cc.Class({ ...@@ -112,9 +112,8 @@ cc.Class({
addPreload() { addPreload() {
for (let item of this.data) { for (let item of this.data) {
this._imageResList.push({ url: item.bgItem.url }) item.bgAudioUrl && this._audioResList.push({ url: item.bgAudioUrl })
for (let item of item.hotZoneItemArr) { for (let item of item.hotZoneItemArr) {
item.pic_url && this._imageResList.push({ url: item.pic_url })
item.audio_url && this._audioResList.push({ url: item.audio_url }) item.audio_url && this._audioResList.push({ url: item.audio_url })
} }
} }
......
...@@ -17,18 +17,22 @@ cc.Class({ ...@@ -17,18 +17,22 @@ cc.Class({
}, },
initWithData(data, scale) { initWithData(data) {
this.data = data this.data = data
let rect = this.data.rect let rect = this.data.rect
this.node.x = (rect.x + rect.width / 2) / scale console.log(rect)
this.node.y = (-rect.y - rect.height / 2) / scale this.node.x = rect.x + rect.width / 2
this.node.width = rect.width / scale this.node.y = -rect.y - rect.height / 2
this.node.height = rect.height / scale this.node.width = rect.width
let comps = this.getComponentsInChildren(cc.Widget) this.node.height = rect.height
for (let one of comps) { this.node.scale = data.fontScale ? data.fontScale : 1
one.updateAlignment() this.label.string = data.text ? data.text : ''
}
this.audioId = null this.audioId = null
if (data.audio_url) {
this.playAnim.node.active = true
} else {
this.playAnim.node.active = false
}
}, },
onTouchStart() { onTouchStart() {
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
"rawHeight": 30, "rawHeight": 30,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 35,
"borderRight": 0, "borderRight": 35,
"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