Commit d25c8f86 authored by limingzhe's avatar limingzhe

refactor: 数据重构

parent 144337b0
......@@ -152,8 +152,8 @@
<label style="margin-left: 40px" nz-checkbox [(ngModel)]="bgItem.isShowDebugLine">显示辅助框</label>
<button style="margin-left: 20px; margin-top: -5px" nz-button (click)="copyHotZoneData()"> 复制数据 </button>
<div style="margin-left: 20px; margin-top: -5px" >
<button style="margin-left: 20px; margin-top: -5px" nz-button (click)="copyHotZoneData()"> 复制基础数据 </button>
<div style="margin-left: 10px; margin-top: -5px" >
<span>粘贴数据: </span>
<input style="width: 100px;" type="text" nz-input [(ngModel)]="pasteData" >
......
......@@ -14,9 +14,9 @@ import {Subject} from 'rxjs';
import {debounceTime} from 'rxjs/operators';
import {EditorItem, HotZoneImg, HotZoneItem, HotZoneLabel, Label, MySprite, removeItemFromArr} from './Unit';
import TWEEN from '@tweenjs/tween.js';
import {getMinScale} from "../../play/Unit";
import {tar} from "compressing";
import {NzMessageService} from "ng-zorro-antd";
import {getMinScale} from '../../play/Unit';
import {tar} from 'compressing';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
......@@ -47,11 +47,12 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
@Input()
customTypeGroupArr; // [{name:string, rect:boolean, pic:boolean, text:boolean, audio:boolean, anima:boolean}, ...]
@Input()
hotZoneFontObj = {
size: 50,
name: 'BRLNSR_1',
color: '#8f3758'
}
hotZoneFontObj;
// hotZoneFontObj = {
// size: 50,
// name: 'BRLNSR_1',
// color: '#8f3758'
// }
@Input()
defaultItemType = 'text';
@Input()
......@@ -109,10 +110,9 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
isTexPngLoading = false;
constructor(private nzMessageService: NzMessageService) {
this.uploadUrl = (<any>window).courseware.uploadUrl();
this.uploadData = (<any>window).courseware.uploadData();
this.uploadUrl = (<any> window).courseware.uploadUrl();
this.uploadData = (<any> window).courseware.uploadData();
window['air'].getUploadCallback = (url, data) => {
this.uploadUrl = url;
......@@ -141,7 +141,6 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
ngOnInit() {
this.initListener();
// this.init();
......@@ -434,19 +433,27 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
refreshCustomItem(item) {
this.hideHotZoneItem(item);
const group = this.customTypeGroupArr[item.gIdx];
if (!group) {
return;
}
if (group.text) {
item.textLabel.visible = true;
item.itemType = 'text';
}
if (group.pic) {
item.pic.visible = true;
item.itemType = 'pic';
}
if (group.rect) {
item.visible = true;
item.itemType = 'rect';
}
if (group.pic && !group.anima) {
item.pic.visible = true;
item.itemType = 'pic';
}
}
hideHotZoneItem(item) {
......@@ -781,7 +788,7 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
// }
this.updateArr(this.hotZoneArr);
this.updatePos()
this.updatePos();
TWEEN.update();
......@@ -1073,7 +1080,85 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
}
}
copyHotZoneData() {
const {bgItem, hotZoneItemArr} = this.getSendData();
// const hotZoneItemArrNew = [];
// const tmpArr = JSON.parse(JSON.stringify(hotZoneItemArr));
// tmpArr.forEach((item) => {
// if (item.gIdx === '0') {
// hotZoneItemArr.push(item);
// }
// })
const jsonData = {
bgItem,
hotZoneItemArr,
isHasRect: this.isHasRect,
isHasPic: this.isHasPic,
isHasText: this.isHasText,
isHasAudio: this.isHasAudio,
isHasAnima: this.isHasAnima,
hotZoneFontObj: this.hotZoneFontObj,
defaultItemType: this.defaultItemType,
hotZoneImgSize: this.hotZoneImgSize,
};
const oInput = document.createElement('input');
oInput.value = JSON.stringify(jsonData);
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand('Copy'); // 执行浏览器复制命令
document.body.removeChild(oInput);
this.nzMessageService.success('复制成功');
// alert('复制成功');
}
importData() {
if (!this.pasteData) {
return;
}
try {
const data = JSON.parse(this.pasteData);
console.log('data:', data);
const {
bgItem,
hotZoneItemArr,
isHasRect,
isHasPic,
isHasText,
isHasAudio,
isHasAnima,
hotZoneFontObj,
defaultItemType,
hotZoneImgSize,
} = data;
this.hotZoneItemArr = hotZoneItemArr;
this.isHasRect = isHasRect;
this.isHasPic = isHasPic;
this.isHasText = isHasText;
this.isHasAudio = isHasAudio;
this.isHasAnima = isHasAnima;
this.hotZoneFontObj = hotZoneFontObj;
this.defaultItemType = defaultItemType;
this.hotZoneImgSize = hotZoneImgSize;
this.bgItem = bgItem;
this.pasteData = '';
} catch (e) {
console.log('err: ', e);
this.nzMessageService.error('导入失败');
}
}
private updatePos() {
this.hotZoneArr.forEach((item) => {
......@@ -1172,78 +1257,4 @@ export class CustomHotZoneComponent implements OnInit, OnDestroy, OnChanges {
});
}
copyHotZoneData() {
const {bgItem, hotZoneItemArr} = this.getSendData();
const jsonData = {
bgItem,
hotZoneItemArr,
isHasRect: this.isHasRect,
isHasPic: this.isHasPic,
isHasText: this.isHasText,
isHasAudio: this.isHasAudio,
isHasAnima: this.isHasAnima,
hotZoneFontObj: this.hotZoneFontObj,
defaultItemType: this.defaultItemType,
hotZoneImgSize: this.hotZoneImgSize,
};
const oInput = document.createElement('input');
oInput.value = JSON.stringify(jsonData);
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
document.body.removeChild(oInput);
this.nzMessageService.success('复制成功');
// alert('复制成功');
}
importData() {
if (!this.pasteData) {
return;
}
try {
const data = JSON.parse(this.pasteData);
console.log('data:', data);
const {
bgItem,
hotZoneItemArr,
isHasRect,
isHasPic,
isHasText,
isHasAudio,
isHasAnima,
hotZoneFontObj,
defaultItemType,
hotZoneImgSize,
} = data;
this.hotZoneItemArr = hotZoneItemArr;
this.isHasRect = isHasRect;
this.isHasPic = isHasPic;
this.isHasText = isHasText;
this.isHasAudio = isHasAudio;
this.isHasAnima = isHasAnima;
this.hotZoneFontObj = hotZoneFontObj;
this.defaultItemType = defaultItemType;
this.hotZoneImgSize = hotZoneImgSize;
this.bgItem = bgItem;
this.pasteData = '';
} catch (e) {
console.log('err: ', e);
this.nzMessageService.error('导入失败');
}
}
}
......@@ -24,11 +24,18 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
customTypeGroupArr = [
{
name: '底部资源',
name: '基础资源',
rect: true,
anima: true,
pic: true,
text: true,
audio: true
audio: true,
},
// {
// name: '动画',
// rect: true,
// anima: true
// }
]
constructor(private appRef: ApplicationRef,private changeDetectorRef: ChangeDetectorRef, private message: NzMessageService) {
......
......@@ -2,24 +2,15 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1066b0c4-930a-4bd6-9ddd-3f8f036e226e" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../form/src/app/common/custom-hot-zone/custom-hot-zone.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../form/src/app/common/custom-hot-zone/custom-hot-zone.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../form/src/app/common/custom-hot-zone/custom-hot-zone.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../form/src/app/common/custom-hot-zone/custom-hot-zone.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../form/src/app/form/form.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../form/src/app/form/form.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/mz_003/scene/scene.fire" beforeDir="false" afterPath="$PROJECT_DIR$/assets/mz_003/scene/scene.fire" afterDir="false" />
<change beforePath="$PROJECT_DIR$/assets/mz_003/script/scene.js" beforeDir="false" afterPath="$PROJECT_DIR$/assets/mz_003/script/scene.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/web-desktop/assets/main/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/build/web-desktop/assets/main/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/web-desktop/assets/main/import/0c/0cd3ee167.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/build/web-desktop/assets/main/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/build/web-desktop/assets/main/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js" beforeDir="false" afterPath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js.map" afterDir="false" />
<change beforePath="$PROJECT_DIR$/library/imports/c3/c3f18614-c716-4f1f-899f-09f073ac6c43.json" beforeDir="false" afterPath="$PROJECT_DIR$/library/imports/c3/c3f18614-c716-4f1f-899f-09f073ac6c43.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/library/imports/33/335fe6b8-2b52-45a9-a9c9-cb3b54014251.js.map" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/library/uuid-to-mtime.json" beforeDir="false" afterPath="$PROJECT_DIR$/library/uuid-to-mtime.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/local/layout.editor.json" beforeDir="false" afterPath="$PROJECT_DIR$/local/layout.editor.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/local/node-tree-state.json" beforeDir="false" afterPath="$PROJECT_DIR$/local/node-tree-state.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package/Archive.zip" beforeDir="false" afterPath="$PROJECT_DIR$/package/Archive.zip" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package/play/assets/main/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/package/play/assets/main/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package/play/assets/main/import/0c/0cd3ee167.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/package/play/assets/main/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/package/play/assets/main/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings/project.json" beforeDir="false" afterPath="$PROJECT_DIR$/settings/project.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/temp/BackupAssets/assets/mz_003/scene/scene.fire" beforeDir="false" afterPath="$PROJECT_DIR$/temp/BackupAssets/assets/mz_003/scene/scene.fire" afterDir="false" />
<change beforePath="$PROJECT_DIR$/temp/quick-scripts/dst/__file_stats__.json" beforeDir="false" afterPath="$PROJECT_DIR$/temp/quick-scripts/dst/__file_stats__.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/temp/quick-scripts/dst/__qc_bundle__.js" beforeDir="false" afterPath="$PROJECT_DIR$/temp/quick-scripts/dst/__qc_bundle__.js" afterDir="false" />
......@@ -43,8 +34,8 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/assets/mz_003/script/scene.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="200">
<caret line="852" column="36" selection-start-line="852" selection-start-column="36" selection-end-line="852" selection-end-column="36" />
<state relative-caret-position="426">
<caret line="669" column="13" lean-forward="true" selection-start-line="669" selection-start-column="13" selection-end-line="669" selection-end-column="13" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
......@@ -55,7 +46,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/assets/mz_003/script/util.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1110">
<state relative-caret-position="711">
<caret line="74" column="94" selection-start-line="74" selection-start-column="2" selection-end-line="74" selection-end-column="94" />
</state>
</provider>
......@@ -64,8 +55,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/creator.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1568">
<caret line="13608" column="4" selection-start-line="13608" selection-start-column="4" selection-end-line="13608" selection-end-column="4" />
<state relative-caret-position="516">
<caret line="13570" column="7" selection-start-line="13570" selection-start-column="4" selection-end-line="13570" selection-end-column="7" />
</state>
</provider>
</entry>
......@@ -73,20 +64,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/assets/mz_003/prefab/bgBottom.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4230">
<caret line="282" column="37" selection-start-line="282" selection-start-column="37" selection-end-line="282" selection-end-column="37" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../cocos_mz_001/play/assets/mz_001/script/scene.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="668">
<caret line="460" column="2" selection-start-line="460" selection-start-column="2" selection-end-line="482" selection-end-column="3" />
<state relative-caret-position="237">
<caret line="181" column="28" selection-start-line="181" selection-start-column="21" selection-end-line="181" selection-end-column="28" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
......@@ -98,12 +77,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>_curShowItem =</find>
<find>Event</find>
<find>_dragLayer</find>
<find>_itemLayer</find>
<find>initview</find>
<find>initHotZone</find>
<find>clicked</find>
<find>newNode.width</find>
<find>circle</find>
......@@ -128,6 +101,12 @@
<find>isDrag</find>
<find>itemAppear</find>
<find>_wrongAudioSource</find>
<find>initbg</find>
<find>preload</find>
<find>bgbottom</find>
<find>this.hotzoneitem</find>
<find>setitem</find>
<find>showAnima</find>
</findStrings>
<replaceStrings>
<replace>dragging</replace>
......@@ -146,11 +125,11 @@
</list>
</option>
</component>
<component name="ProjectFrameBounds" fullScreen="true">
<option name="x" value="535" />
<option name="y" value="122" />
<option name="width" value="1103" />
<option name="height" value="704" />
<component name="ProjectFrameBounds" extendedState="6" fullScreen="true">
<option name="x" value="38" />
<option name="y" value="34" />
<option name="width" value="1630" />
<option name="height" value="896" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
......@@ -199,6 +178,7 @@
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="Errors" />
......@@ -228,18 +208,28 @@
<updated>1597213672621</updated>
<workItem from="1597213674034" duration="10942000" />
<workItem from="1597284452866" duration="1542000" />
<workItem from="1597368337011" duration="2818000" />
<workItem from="1597368337011" duration="2889000" />
<workItem from="1597397994102" duration="311000" />
<workItem from="1597802695491" duration="1548000" />
</task>
<task id="LOCAL-00001" summary="fix: 点击播放音频 返回音效">
<created>1597387006533</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1597387006533</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="15302000" />
<option name="totallyTimeSpent" value="17232000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1680" height="1050" extended-state="0" />
<frame x="0" y="0" width="1680" height="1050" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24954791" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24171187" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -252,7 +242,7 @@
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info anchor="bottom" id="Docker" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="TypeScript" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" weight="0.23979592" />
<window_info active="true" anchor="bottom" id="Terminal" order="10" visible="true" weight="0.19591837" />
<window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
......@@ -262,6 +252,10 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="fix: 点击播放音频 返回音效" />
<option name="LAST_COMMIT_MESSAGE" value="fix: 点击播放音频 返回音效" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../../cc_mz_002/play/assets/mz_002/script/scene.js">
<provider selected="true" editor-type-id="text-editor">
......@@ -273,44 +267,44 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/assets/mz_003/script/util.js">
<entry file="file://$PROJECT_DIR$/../../cocos_mz_001/play/assets/mz_001/script/scene.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1110">
<caret line="74" column="94" selection-start-line="74" selection-start-column="2" selection-end-line="74" selection-end-column="94" />
<state relative-caret-position="237">
<caret line="472" column="30" selection-start-line="472" selection-start-column="18" selection-end-line="472" selection-end-column="30" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/assets/mz_003/prefab/bgBottom.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4230">
<caret line="282" column="37" selection-start-line="282" selection-start-column="37" selection-end-line="282" selection-end-column="37" />
<state relative-caret-position="237">
<caret line="181" column="28" selection-start-line="181" selection-start-column="21" selection-end-line="181" selection-end-column="28" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../cocos_mz_001/play/assets/mz_001/script/scene.js">
<entry file="file://$PROJECT_DIR$/creator.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="668">
<caret line="460" column="2" selection-start-line="460" selection-start-column="2" selection-end-line="482" selection-end-column="3" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
<state relative-caret-position="516">
<caret line="13570" column="7" selection-start-line="13570" selection-start-column="4" selection-end-line="13570" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/creator.d.ts">
<entry file="file://$PROJECT_DIR$/assets/mz_003/script/util.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1568">
<caret line="13608" column="4" selection-start-line="13608" selection-start-column="4" selection-end-line="13608" selection-end-column="4" />
<state relative-caret-position="711">
<caret line="74" column="94" selection-start-line="74" selection-start-column="2" selection-end-line="74" selection-end-column="94" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/assets/mz_003/script/scene.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="200">
<caret line="852" column="36" selection-start-line="852" selection-start-column="36" selection-end-line="852" selection-end-column="36" />
<state relative-caret-position="426">
<caret line="669" column="13" lean-forward="true" selection-start-line="669" selection-start-column="13" selection-end-line="669" selection-end-column="13" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
......
......@@ -88,7 +88,7 @@ cc.Class({
getDefaultData() {
const dataJson = '{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":188.28,"y":0,"width":780.44,"height":439}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":0.375,"mapScale":0.90390625,"gIdx":"0","rect":{"x":4.13,"y":208.1,"width":75,"height":75}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":5.119657856821507,"mapScale":0.90390625,"gIdx":"0","rect":{"x":419.85,"y":124,"width":255.98,"height":255.98}}]}'
const dataJson = ' {"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":205.28,"y":0,"width":844.44,"height":475}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":0.375,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/351545fd8fcc6d721cfc63afd243207d.json","name":"Ubbie_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/f4a5db504729d53c9e1f5b055312b6ef.json","name":"Ubbie_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2e56dbe3134380952a725eacceb86359.png","name":"Ubbie_tex.png"},"gIdx":"0","rect":{"x":13.36,"y":225.06,"width":65.36,"height":65.36}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":5.119657856821507,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ab66b9d704187f60fd8a61c981435b8e.json","name":"finish2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/a4b74d67df855493b394c7df9625ba24.json","name":"finish2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/e485027385bab93761a5d1749166ba83.png","name":"finish2_tex.png"},"gIdx":"0","rect":{"x":636.11,"y":220,"width":123.31,"height":123.31}}]}'
const data1 = JSON.parse(dataJson);
return data1;
......@@ -166,6 +166,14 @@ cc.Class({
if (this.data.bgItem) {
this._imageResList.push({url: this.data.bgItem.url});
}
if (!this.data.hotZoneItemArr) {
return;
}
this.data.hotZoneItemArr.forEach((item) => {
if (item.gIdx == '0' && item.pic_url) {
this._imageResList.push({url: item.pic_url});
}
})
},
......@@ -183,13 +191,13 @@ cc.Class({
if (!this.data.hotZoneItemArr) {
return;
}
// this.data.hotZoneItemArr.forEach((item) => {
// if (item.gIdx == '0') {
// this._animaResList.push({url: item.skeJsonData.url});
// this._animaResList.push({url: item.texJsonData.url});
// this._animaResList.push({url: item.texPngData.url});
// }
// })
this.data.hotZoneItemArr.forEach((item) => {
if (item.gIdx == '0' && item.skeJsonData) {
this._animaResList.push({url: item.skeJsonData.url});
this._animaResList.push({url: item.texJsonData.url});
this._animaResList.push({url: item.texPngData.url});
}
})
},
......@@ -382,8 +390,8 @@ cc.Class({
const bgBottom = cc.find('Canvas/bgBottom');
const script = bgBottom.getComponent('bgBottom');
const picArr = this.getBottomPicArr();
script.setItemData(picArr);
// const picArr = this.getBottomPicArr();
script.setItemData(this.data.hotZoneItemArr);
},
getBottomPicArr() {
......@@ -561,11 +569,6 @@ cc.Class({
const circleSmallNode = cc.find('Canvas/res/circle_bg_small')
spr.spriteFrame = circleSmallNode.getComponent(cc.Sprite).spriteFrame;
// const ctx = rectNode.addComponent(cc.Graphics);
// // 红色矩形
// ctx.lineWidth = 4;
// ctx.strokeColor = cc.Color.BLACK;
// ctx.fillColor = cc.Color.WHITE.setA(100);
const scale = rate / this.hotZoneBg.scaleY;
......@@ -573,30 +576,103 @@ cc.Class({
rectNode.height = circleSmallNode.height;
rectNode.x = -this.hotZoneBg.width / 2 + (data.rect.x + data.rect.width / 2) * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height / 2 * scale - data.rect.y * scale;
// rectNode.width = data.rect.width * scale;
// rectNode.height = data.rect.height * scale;
// rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
// rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0.5;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
data.audioClip = audioClip;
});
}
// if (this.data.bgItem.isShowDebugLine) {
// ctx.rect(0, 0, rectNode.width, rectNode.height);
// }
// ctx.stroke();
// ctx.fill();
this.hotzoneCircleArr.push(rectNode);
if (!data.skeJsonData) {
return;
}
const animaNode = new cc.Node();
animaNode.name = 'anima_' + data.index;
this.hotZoneBg.addChild(animaNode);
data.animaNode = animaNode;
animaNode.active = false;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
data.audioClip = audioClip;
animaNode.audioClip = audioClip;
});
}
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
const image = data.texPngData.url//"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url//"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, (error, texture) => {
cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => {
cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => {
const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = texture;
this.hotzoneCircleArr.push(rectNode);
const asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = dragonBonesJson;
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
let json = JSON.parse(asset.dragonBonesJson);
let armatures = json["armature"];
console.log('armatures: ', armatures);
let armatureNames = [];
for (let i = 0; i < armatures.length; i++) {
armatureNames.push(armatures[i].name);
}
// console.log('armatureNames: ', armatureNames);
if (armatureNames.length > 0) {
let defaultArmatureName = armatureNames[0];
dragonDisplay.armatureName = defaultArmatureName;
// let animationNames = dragonDisplay.getAnimationNames(defaultArmatureName);
let defaultArmature = armatures[0];
let animations = defaultArmature.animation;
let animationNames = [];
for (let i = 0; i < animations.length; i++) {
animationNames.push(animations[i].name);
}
// rectNode.addComponent(cc.Button);
animaNode.showAnima = () => {
animaNode.active = true;
// rectNode.on('click', () => {
if (rectNode.isClicked) {
// return;
}
rectNode.isClicked = true;
console.log('clicked');
if (animaNode.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(animaNode.audioClip, false, 0.8);
}
if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1);
}
}
}
});
});
});
},
......@@ -831,13 +907,17 @@ cc.Class({
this._curShowItem.active = false;
cc.tween(this._curShowItem.data.pic)
.to(3, {opacity: 255}, {easing: 'cubicOut'})
.start();
// cc.tween(this._curShowItem.data.pic)
// .to(3, {opacity: 255}, {easing: 'cubicOut'})
// .start();
// if (circle.data.audioClip) {
// cc.audioEngine.stopAll();
// cc.audioEngine.play(circle.data.audioClip, false, 0.8);
// }
if (circle.data.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(circle.data.audioClip, false, 0.8);
if (circle.data.animaNode) {
circle.data.animaNode.showAnima();
}
},
......
......@@ -85,7 +85,7 @@ cc.Class({
func(this.getDefaultData());
},
getDefaultData: function getDefaultData() {
var dataJson = '{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":188.28,"y":0,"width":780.44,"height":439}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":0.375,"mapScale":0.90390625,"gIdx":"0","rect":{"x":4.13,"y":208.1,"width":75,"height":75}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":5.119657856821507,"mapScale":0.90390625,"gIdx":"0","rect":{"x":419.85,"y":124,"width":255.98,"height":255.98}}]}';
var dataJson = ' {"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":205.28,"y":0,"width":844.44,"height":475}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":0.375,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/351545fd8fcc6d721cfc63afd243207d.json","name":"Ubbie_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/f4a5db504729d53c9e1f5b055312b6ef.json","name":"Ubbie_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2e56dbe3134380952a725eacceb86359.png","name":"Ubbie_tex.png"},"gIdx":"0","rect":{"x":13.36,"y":225.06,"width":65.36,"height":65.36}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":5.119657856821507,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ab66b9d704187f60fd8a61c981435b8e.json","name":"finish2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/a4b74d67df855493b394c7df9625ba24.json","name":"finish2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/e485027385bab93761a5d1749166ba83.png","name":"finish2_tex.png"},"gIdx":"0","rect":{"x":636.11,"y":220,"width":123.31,"height":123.31}}]}';
var data1 = JSON.parse(dataJson);
return data1;
var data = {
......@@ -153,36 +153,61 @@ cc.Class({
});
},
addPreloadImage: function addPreloadImage() {
var _this3 = this;
if (this.data.bgItem) {
this._imageResList.push({
url: this.data.bgItem.url
});
}
if (!this.data.hotZoneItemArr) {
return;
}
this.data.hotZoneItemArr.forEach(function (item) {
if (item.gIdx == '0' && item.pic_url) {
_this3._imageResList.push({
url: item.pic_url
});
}
});
},
addPreloadAudio: function addPreloadAudio() {
var _this3 = this;
var _this4 = this;
if (!this.data.hotZoneItemArr) {
return;
}
this.data.hotZoneItemArr.forEach(function (item) {
_this3._audioResList.push({
_this4._audioResList.push({
url: item.audio_url
});
});
},
addPreloadAnima: function addPreloadAnima() {
var _this5 = this;
if (!this.data.hotZoneItemArr) {
return;
} // this.data.hotZoneItemArr.forEach((item) => {
// if (item.gIdx == '0') {
// this._animaResList.push({url: item.skeJsonData.url});
// this._animaResList.push({url: item.texJsonData.url});
// this._animaResList.push({url: item.texPngData.url});
// }
// })
}
this.data.hotZoneItemArr.forEach(function (item) {
if (item.gIdx == '0' && item.skeJsonData) {
_this5._animaResList.push({
url: item.skeJsonData.url
});
_this5._animaResList.push({
url: item.texJsonData.url
});
_this5._animaResList.push({
url: item.texPngData.url
});
}
});
},
loadEnd: function loadEnd() {
this.initView();
......@@ -194,27 +219,27 @@ cc.Class({
this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource);
},
initListener: function initListener() {
var _this4 = this;
var _this6 = this;
var bgBottom = cc.find('Canvas/bgBottom'); // bgBottom.on('item_click', (item) => {
// this.bottomItemClick(item);
// })
bgBottom.on('item_touch_start', function (item) {
_this4.touchStartItem(item);
_this6.touchStartItem(item);
});
var canvas = cc.find('Canvas'); // canvas.on('click', () => {
// this.canvasClick();
// })
canvas.on(cc.Node.EventType.TOUCH_MOVE, function (e) {
_this4.canvasTouchMove(e);
_this6.canvasTouchMove(e);
});
canvas.on(cc.Node.EventType.TOUCH_CANCEL, function (e) {
_this4.canvasTouchEnd(e);
_this6.canvasTouchEnd(e);
});
canvas.on(cc.Node.EventType.TOUCH_END, function (e) {
_this4.canvasTouchEnd(e);
_this6.canvasTouchEnd(e);
});
},
initView: function initView() {
......@@ -245,7 +270,7 @@ cc.Class({
hotZoneBg: null,
hotzoneCircleArr: null,
initHotZoneBg: function initHotZoneBg() {
var _this5 = this;
var _this7 = this;
this.hotZoneBg = new cc.Node();
this.hotZoneBg.name = 'hotZoneBg';
......@@ -260,45 +285,45 @@ cc.Class({
cc.loader.load({
url: this.data.bgItem.url
}, function (err, img) {
_this5.addMask(_this5.hotZoneBg);
_this7.addMask(_this7.hotZoneBg);
_this5.hotZoneBg.width = img.width;
_this5.hotZoneBg.height = img.height;
_this7.hotZoneBg.width = img.width;
_this7.hotZoneBg.height = img.height;
var box = _this5.hotZoneBg.getBoundingBox();
var box = _this7.hotZoneBg.getBoundingBox();
var tmpS = 640 / 720;
var subNum = 720 - 640;
var frameSize = cc.view.getFrameSize();
var winSize = cc.winSize;
console.log('this.hotZoneBg.box: ', _this5.hotZoneBg.getBoundingBox());
console.log('this.hotZoneBg.box: ', _this7.hotZoneBg.getBoundingBox());
console.log('let visiSize=cc.director.getVisibleSize();: ', cc.view.getVisibleSize());
console.log('lframeSize: ', frameSize);
var sx = frameSize.width / _this5._designSize.width;
var sy = frameSize.height / _this5._designSize.height;
var sx = frameSize.width / _this7._designSize.width;
var sy = frameSize.height / _this7._designSize.height;
var mapS = Math.min(sx, sy); // const sy = canvas.height * tmpS / box.height;
var bgBottom = cc.find('Canvas/bgBottom');
bgBottom.scale = mapS * _this5._cocosScale; // subNum = bgBottom.height;
bgBottom.scale = mapS * _this7._cocosScale; // subNum = bgBottom.height;
sx = frameSize.width * _this5._cocosScale / img.width;
sy = (frameSize.height * _this5._cocosScale - subNum * mapS * _this5._cocosScale) / img.height;
sx = frameSize.width * _this7._cocosScale / img.width;
sy = (frameSize.height * _this7._cocosScale - subNum * mapS * _this7._cocosScale) / img.height;
var sprNode = new cc.Node();
var sf = new cc.SpriteFrame(img); // const spr = this.hotZoneBg.addComponent(cc.Sprite);
var spr = sprNode.addComponent(cc.Sprite);
spr.spriteFrame = sf;
sprNode.width = _this5.hotZoneBg.width;
sprNode.height = _this5.hotZoneBg.height;
sprNode.parent = _this5.hotZoneBg;
_this5.hotZoneBg.scale = Math.min(sx, sy); // this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
sprNode.width = _this7.hotZoneBg.width;
sprNode.height = _this7.hotZoneBg.height;
sprNode.parent = _this7.hotZoneBg;
_this7.hotZoneBg.scale = Math.min(sx, sy); // this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
_this5.hotZoneBg.y = frameSize.height / 2 * _this5._cocosScale - _this5.hotZoneBg.height / 2 * _this5.hotZoneBg.scaleY; // this.hotZoneBg.opacity = 20;
_this7.hotZoneBg.y = frameSize.height / 2 * _this7._cocosScale - _this7.hotZoneBg.height / 2 * _this7.hotZoneBg.scaleY; // this.hotZoneBg.opacity = 20;
var bgWhite = cc.find('Canvas/bgWhite');
bgWhite.y = _this5.hotZoneBg.y;
bgWhite.scaleX = _this5.hotZoneBg.width * _this5.hotZoneBg.scaleX / bgWhite.width;
bgWhite.scaleY = _this5.hotZoneBg.height * _this5.hotZoneBg.scaleY / bgWhite.height;
bgWhite.y = _this7.hotZoneBg.y;
bgWhite.scaleX = _this7.hotZoneBg.width * _this7.hotZoneBg.scaleX / bgWhite.width;
bgWhite.scaleY = _this7.hotZoneBg.height * _this7.hotZoneBg.scaleY / bgWhite.height;
var canvas = cc.find('Canvas');
var shadowNode = new cc.Node();
shadowNode.y = bgWhite.y;
......@@ -308,23 +333,23 @@ cc.Class({
var ctx = shadowNode.addComponent(cc.Graphics);
ctx.fillColor = cc.Color.BLACK.setA(30); // ctx.fillRect(5, 5, this.hotZoneBg.width*this.hotZoneBg.scaleX, this.hotZoneBg.height * this.hotZoneBg.scaleY);
ctx.fillRect(-bgWhite.width / 2 + 8 / bgWhite.scaleX * _this5.hotZoneBg.scale, -bgWhite.height / 2 - 8 / bgWhite.scaleX * _this5.hotZoneBg.scale, bgWhite.width, bgWhite.height);
ctx.fillRect(-bgWhite.width / 2 + 8 / bgWhite.scaleX * _this7.hotZoneBg.scale, -bgWhite.height / 2 - 8 / bgWhite.scaleX * _this7.hotZoneBg.scale, bgWhite.width, bgWhite.height);
ctx.fill();
shadowNode.zIndex = 1;
bgWhite.zIndex = 2;
bgBottom.y = -frameSize.height / 2 * _this5._cocosScale - 15 * bgBottom.scaleY;
bgBottom.y = -frameSize.height / 2 * _this7._cocosScale - 15 * bgBottom.scaleY;
_this5.data.hotZoneItemArr.forEach(function (item) {
_this7.data.hotZoneItemArr.forEach(function (item) {
// if (item.gIdx == '0') {
// this.setOneAnima(item);
// } else {
_this5.setOneCirclePoint(item); // }
_this7.setOneCirclePoint(item); // }
_this5.setOnePic(item);
_this7.setOnePic(item);
});
_this5.initBottomPart();
_this7.initBottomPart();
});
},
addMask: function addMask(node) {
......@@ -333,9 +358,9 @@ cc.Class({
},
initBottomPart: function initBottomPart() {
var bgBottom = cc.find('Canvas/bgBottom');
var script = bgBottom.getComponent('bgBottom');
var picArr = this.getBottomPicArr();
script.setItemData(picArr);
var script = bgBottom.getComponent('bgBottom'); // const picArr = this.getBottomPicArr();
script.setItemData(this.data.hotZoneItemArr);
},
getBottomPicArr: function getBottomPicArr() {
var arr = []; // for (let i = 0; i < this.hotzoneCircleArr.length; i++) {
......@@ -455,7 +480,7 @@ cc.Class({
});
},
setOnePic: function setOnePic(data) {
var _this6 = this;
var _this8 = this;
var rate = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width;
var picNode = new cc.Node();
......@@ -466,11 +491,11 @@ cc.Class({
}, function (err, img) {
var spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img);
var scale = rate / _this6.hotZoneBg.scaleY;
var scale = rate / _this8.hotZoneBg.scaleY;
picNode.width = data.rect.width * scale;
picNode.height = data.rect.height * scale;
picNode.x = -_this6.hotZoneBg.width / 2 + data.rect.x * scale;
picNode.y = _this6.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.x = -_this8.hotZoneBg.width / 2 + data.rect.x * scale;
picNode.y = _this8.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.anchorX = picNode.anchorY = 0;
picNode.opacity = 0;
data.pic = picNode;
......@@ -484,26 +509,13 @@ cc.Class({
this.hotZoneBg.addChild(rectNode);
var spr = rectNode.addComponent(cc.Sprite);
var circleSmallNode = cc.find('Canvas/res/circle_bg_small');
spr.spriteFrame = circleSmallNode.getComponent(cc.Sprite).spriteFrame; // const ctx = rectNode.addComponent(cc.Graphics);
// // 红色矩形
// ctx.lineWidth = 4;
// ctx.strokeColor = cc.Color.BLACK;
// ctx.fillColor = cc.Color.WHITE.setA(100);
spr.spriteFrame = circleSmallNode.getComponent(cc.Sprite).spriteFrame;
var scale = rate / this.hotZoneBg.scaleY;
rectNode.width = circleSmallNode.width;
rectNode.height = circleSmallNode.height;
rectNode.x = -this.hotZoneBg.width / 2 + (data.rect.x + data.rect.width / 2) * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height / 2 * scale - data.rect.y * scale; // rectNode.width = data.rect.width * scale;
// rectNode.height = data.rect.height * scale;
// rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
// rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0.5; // if (this.data.bgItem.isShowDebugLine) {
// ctx.rect(0, 0, rectNode.width, rectNode.height);
// }
// ctx.stroke();
// ctx.fill();
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height / 2 * scale - data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0.5;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, function (err, audioClip) {
......@@ -512,10 +524,95 @@ cc.Class({
}
this.hotzoneCircleArr.push(rectNode);
if (!data.skeJsonData) {
return;
}
var animaNode = new cc.Node();
animaNode.name = 'anima_' + data.index;
this.hotZoneBg.addChild(animaNode);
data.animaNode = animaNode;
animaNode.active = false;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, function (err, audioClip) {
animaNode.audioClip = audioClip;
});
}
var dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
var image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
var ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
var atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, function (error, texture) {
cc.loader.load({
url: atlas,
type: 'txt'
}, function (error, atlasJson) {
cc.loader.load({
url: ske,
type: 'txt'
}, function (error, dragonBonesJson) {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = dragonBonesJson;
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
var json = JSON.parse(asset.dragonBonesJson);
var armatures = json["armature"];
console.log('armatures: ', armatures);
var armatureNames = [];
for (var i = 0; i < armatures.length; i++) {
armatureNames.push(armatures[i].name);
} // console.log('armatureNames: ', armatureNames);
if (armatureNames.length > 0) {
var defaultArmatureName = armatureNames[0];
dragonDisplay.armatureName = defaultArmatureName; // let animationNames = dragonDisplay.getAnimationNames(defaultArmatureName);
var defaultArmature = armatures[0];
var animations = defaultArmature.animation;
var animationNames = [];
for (var _i2 = 0; _i2 < animations.length; _i2++) {
animationNames.push(animations[_i2].name);
} // rectNode.addComponent(cc.Button);
animaNode.showAnima = function () {
animaNode.active = true; // rectNode.on('click', () => {
if (rectNode.isClicked) {// return;
}
rectNode.isClicked = true;
console.log('clicked');
if (animaNode.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(animaNode.audioClip, false, 0.8);
}
if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1);
}
};
}
});
});
});
},
_curShowItem: null,
bottomItemClick: function bottomItemClick(item) {
var _this7 = this;
var _this9 = this;
return;
......@@ -543,13 +640,13 @@ cc.Class({
newNode.addComponent(cc.Button);
newNode.on('click', function () {
if (newNode.isSmall) {
if (_this7._curShowItem) {
if (_this9._curShowItem) {
return;
}
_this7._curShowItem = newNode;
_this9._curShowItem = newNode;
_this7._toCenterShow(newNode);
_this9._toCenterShow(newNode);
} else {
console.log('newNode', newNode);
......@@ -694,16 +791,16 @@ cc.Class({
},
itemAppear: function itemAppear(circle) {
circle.active = false;
this._curShowItem.active = false;
cc.tween(this._curShowItem.data.pic).to(3, {
opacity: 255
}, {
easing: 'cubicOut'
}).start();
this._curShowItem.active = false; // cc.tween(this._curShowItem.data.pic)
// .to(3, {opacity: 255}, {easing: 'cubicOut'})
// .start();
// if (circle.data.audioClip) {
// cc.audioEngine.stopAll();
// cc.audioEngine.play(circle.data.audioClip, false, 0.8);
// }
if (circle.data.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(circle.data.audioClip, false, 0.8);
if (circle.data.animaNode) {
circle.data.animaNode.showAnima();
}
},
itemBack: function itemBack() {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -500,8 +500,8 @@
"relativePath": "model/primitives.fbx"
},
"b3e401a5-91fc-4a28-87e3-0b4063ba359c": {
"asset": 1596533409542,
"meta": 1596591444218,
"asset": 1597369245920,
"meta": 1597398041690,
"relativePath": "mz_003"
},
"4622f21b-4a93-4460-bbc0-350907c5dded": {
......@@ -515,13 +515,13 @@
"relativePath": "mz_003/scene"
},
"c3f18614-c716-4f1f-899f-09f073ac6c43": {
"asset": 1597370954795,
"meta": 1597370954802,
"asset": 1597804594032,
"meta": 1597804594038,
"relativePath": "mz_003/scene/scene.fire"
},
"b5c6439b-d99b-428f-9454-22f767de4a02": {
"asset": 1597368895290,
"meta": 1597368919166,
"asset": 1597370866565,
"meta": 1597398041693,
"relativePath": "mz_003/script"
},
"3531d7ec-7dc9-49bd-be94-92677dc9b7c0": {
......@@ -600,8 +600,8 @@
"relativePath": "mz_003/prefab/bgBottom.js"
},
"4fd428f3-cf22-467b-8ae4-09dfc1fa94c2": {
"asset": 1597369244594,
"meta": 1597369244595,
"asset": 1597369249348,
"meta": 1597398041692,
"relativePath": "mz_003/audio"
},
"d36dd89b-a002-4dc6-8383-ea534341830e": {
......@@ -610,8 +610,8 @@
"relativePath": "mz_003/audio/wrong.mp3"
},
"335fe6b8-2b52-45a9-a9c9-cb3b54014251": {
"asset": 1597370866564,
"meta": 1597370869301,
"asset": 1597804590766,
"meta": 1597804593676,
"relativePath": "mz_003/script/scene.js"
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
"url": "app://editor/index.html",
"windowType": "dockable",
"x": 0,
"y": 24,
"y": 23,
"width": 1680,
"height": 942,
"layout": {
......@@ -18,7 +18,7 @@
"children": [
"hierarchy"
],
"height": 296.6875,
"height": 297,
"type": "panel",
"width": 306
},
......@@ -28,7 +28,7 @@
"assets",
"cloud-function"
],
"height": 561.3125,
"height": 561,
"type": "panel",
"width": 306
}
......@@ -46,7 +46,7 @@
"children": [
"scene"
],
"height": 589.375,
"height": 588.984375,
"type": "panel",
"width": 701.984375
},
......@@ -55,12 +55,12 @@
"children": [
"node-library"
],
"height": 589.375,
"height": 588.984375,
"type": "panel",
"width": 264
}
],
"height": 589.375,
"height": 588.984375,
"type": "dock-h",
"width": 969
},
......@@ -71,7 +71,7 @@
"timeline",
"game-window"
],
"height": 268.625,
"height": 269,
"type": "panel",
"width": 969
}
......@@ -105,8 +105,7 @@
"inspector",
"cocos-services"
]
},
"window-1597372045932": {}
}
},
"panels": {
"sprite-editor": {
......
......@@ -2208,7 +2208,7 @@
"_clip": {
"__uuid__": "d36dd89b-a002-4dc6-8383-ea534341830e"
},
"_volume": 0.6,
"_volume": 0.4,
"_mute": false,
"_loop": false,
"playOnLoad": false,
......
{"version":"1.0.8","stats":{"/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/__qc_index__.js":"2020-08-14T01:35:19.685Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/prefab/bgBottom.js":"2020-08-14T01:35:19.667Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/util.js":"2020-08-14T01:35:19.665Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/scene.js":"2020-08-14T01:35:19.664Z"}}
{"version":"1.0.8","stats":{"/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/__qc_index__.js":"2020-08-19T01:42:12.970Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/scene.js":"2020-08-19T01:42:12.949Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/prefab/bgBottom.js":"2020-08-19T01:42:12.953Z","/Users/lmz/Documents/workspace/git_project/cocos/cc_mz_003/play/temp/quick-scripts/src/assets/mz_003/script/util.js":"2020-08-19T01:42:12.951Z"}}
This source diff could not be displayed because it is too large. You can view the blob instead.
(function () {
var scripts = [{"deps":{"./assets/mz_003/script/util":2,"./assets/mz_003/prefab/bgBottom":1,"./assets/mz_003/script/scene":3},"path":"preview-scripts/__qc_index__.js"},{"deps":{"../script/util":2},"path":"preview-scripts/assets/mz_003/prefab/bgBottom.js"},{"deps":{},"path":"preview-scripts/assets/mz_003/script/util.js"},{"deps":{"./util":2},"path":"preview-scripts/assets/mz_003/script/scene.js"}];
var scripts = [{"deps":{"./assets/mz_003/script/scene":1,"./assets/mz_003/prefab/bgBottom":2,"./assets/mz_003/script/util":3},"path":"preview-scripts/__qc_index__.js"},{"deps":{"./util":3},"path":"preview-scripts/assets/mz_003/script/scene.js"},{"deps":{"../script/util":3},"path":"preview-scripts/assets/mz_003/prefab/bgBottom.js"},{"deps":{},"path":"preview-scripts/assets/mz_003/script/util.js"}];
var entries = ["preview-scripts/__qc_index__.js"];
var bundleScript = 'preview-scripts/__qc_bundle__.js';
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -85,7 +85,7 @@ cc.Class({
func(this.getDefaultData());
},
getDefaultData: function getDefaultData() {
var dataJson = '{"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":188.28,"y":0,"width":780.44,"height":439}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":0.375,"mapScale":0.90390625,"gIdx":"0","rect":{"x":4.13,"y":208.1,"width":75,"height":75}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"pic","fontScale":0.90390625,"imgScale":5.119657856821507,"mapScale":0.90390625,"gIdx":"0","rect":{"x":419.85,"y":124,"width":255.98,"height":255.98}}]}';
var dataJson = ' {"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/3dd0eab42b3c17d7c28d3792f8a985b9.png","rect":{"x":205.28,"y":0,"width":844.44,"height":475}},"hotZoneItemArr":[{"id":"1597212942004","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/8734cd9faae8092a38fff9398330222d.png","text":"aaa","audio_url":"http://staging-teach.cdn.ireadabc.com/f51e3fedc88aa69a99f6ef579f7de047.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":0.375,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/351545fd8fcc6d721cfc63afd243207d.json","name":"Ubbie_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/f4a5db504729d53c9e1f5b055312b6ef.json","name":"Ubbie_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2e56dbe3134380952a725eacceb86359.png","name":"Ubbie_tex.png"},"gIdx":"0","rect":{"x":13.36,"y":225.06,"width":65.36,"height":65.36}},{"id":"1597213039921","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/18f2a029e02d679da8d42746daea228f.png","text":"bbb","audio_url":"http://staging-teach.cdn.ireadabc.com/fbe2f23b9eb191a9330f99800e0d54d5.mp3","itemType":"rect","fontScale":0.98046875,"imgScale":5.119657856821507,"mapScale":0.98046875,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ab66b9d704187f60fd8a61c981435b8e.json","name":"finish2_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/a4b74d67df855493b394c7df9625ba24.json","name":"finish2_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/e485027385bab93761a5d1749166ba83.png","name":"finish2_tex.png"},"gIdx":"0","rect":{"x":636.11,"y":220,"width":123.31,"height":123.31}}]}';
var data1 = JSON.parse(dataJson);
return data1;
var data = {
......@@ -153,36 +153,61 @@ cc.Class({
});
},
addPreloadImage: function addPreloadImage() {
var _this3 = this;
if (this.data.bgItem) {
this._imageResList.push({
url: this.data.bgItem.url
});
}
if (!this.data.hotZoneItemArr) {
return;
}
this.data.hotZoneItemArr.forEach(function (item) {
if (item.gIdx == '0' && item.pic_url) {
_this3._imageResList.push({
url: item.pic_url
});
}
});
},
addPreloadAudio: function addPreloadAudio() {
var _this3 = this;
var _this4 = this;
if (!this.data.hotZoneItemArr) {
return;
}
this.data.hotZoneItemArr.forEach(function (item) {
_this3._audioResList.push({
_this4._audioResList.push({
url: item.audio_url
});
});
},
addPreloadAnima: function addPreloadAnima() {
var _this5 = this;
if (!this.data.hotZoneItemArr) {
return;
} // this.data.hotZoneItemArr.forEach((item) => {
// if (item.gIdx == '0') {
// this._animaResList.push({url: item.skeJsonData.url});
// this._animaResList.push({url: item.texJsonData.url});
// this._animaResList.push({url: item.texPngData.url});
// }
// })
}
this.data.hotZoneItemArr.forEach(function (item) {
if (item.gIdx == '0' && item.skeJsonData) {
_this5._animaResList.push({
url: item.skeJsonData.url
});
_this5._animaResList.push({
url: item.texJsonData.url
});
_this5._animaResList.push({
url: item.texPngData.url
});
}
});
},
loadEnd: function loadEnd() {
this.initView();
......@@ -194,27 +219,27 @@ cc.Class({
this._wrongAudioSource = cc.find('Canvas/res/wrong_audio').getComponent(cc.AudioSource);
},
initListener: function initListener() {
var _this4 = this;
var _this6 = this;
var bgBottom = cc.find('Canvas/bgBottom'); // bgBottom.on('item_click', (item) => {
// this.bottomItemClick(item);
// })
bgBottom.on('item_touch_start', function (item) {
_this4.touchStartItem(item);
_this6.touchStartItem(item);
});
var canvas = cc.find('Canvas'); // canvas.on('click', () => {
// this.canvasClick();
// })
canvas.on(cc.Node.EventType.TOUCH_MOVE, function (e) {
_this4.canvasTouchMove(e);
_this6.canvasTouchMove(e);
});
canvas.on(cc.Node.EventType.TOUCH_CANCEL, function (e) {
_this4.canvasTouchEnd(e);
_this6.canvasTouchEnd(e);
});
canvas.on(cc.Node.EventType.TOUCH_END, function (e) {
_this4.canvasTouchEnd(e);
_this6.canvasTouchEnd(e);
});
},
initView: function initView() {
......@@ -245,7 +270,7 @@ cc.Class({
hotZoneBg: null,
hotzoneCircleArr: null,
initHotZoneBg: function initHotZoneBg() {
var _this5 = this;
var _this7 = this;
this.hotZoneBg = new cc.Node();
this.hotZoneBg.name = 'hotZoneBg';
......@@ -260,45 +285,45 @@ cc.Class({
cc.loader.load({
url: this.data.bgItem.url
}, function (err, img) {
_this5.addMask(_this5.hotZoneBg);
_this7.addMask(_this7.hotZoneBg);
_this5.hotZoneBg.width = img.width;
_this5.hotZoneBg.height = img.height;
_this7.hotZoneBg.width = img.width;
_this7.hotZoneBg.height = img.height;
var box = _this5.hotZoneBg.getBoundingBox();
var box = _this7.hotZoneBg.getBoundingBox();
var tmpS = 640 / 720;
var subNum = 720 - 640;
var frameSize = cc.view.getFrameSize();
var winSize = cc.winSize;
console.log('this.hotZoneBg.box: ', _this5.hotZoneBg.getBoundingBox());
console.log('this.hotZoneBg.box: ', _this7.hotZoneBg.getBoundingBox());
console.log('let visiSize=cc.director.getVisibleSize();: ', cc.view.getVisibleSize());
console.log('lframeSize: ', frameSize);
var sx = frameSize.width / _this5._designSize.width;
var sy = frameSize.height / _this5._designSize.height;
var sx = frameSize.width / _this7._designSize.width;
var sy = frameSize.height / _this7._designSize.height;
var mapS = Math.min(sx, sy); // const sy = canvas.height * tmpS / box.height;
var bgBottom = cc.find('Canvas/bgBottom');
bgBottom.scale = mapS * _this5._cocosScale; // subNum = bgBottom.height;
bgBottom.scale = mapS * _this7._cocosScale; // subNum = bgBottom.height;
sx = frameSize.width * _this5._cocosScale / img.width;
sy = (frameSize.height * _this5._cocosScale - subNum * mapS * _this5._cocosScale) / img.height;
sx = frameSize.width * _this7._cocosScale / img.width;
sy = (frameSize.height * _this7._cocosScale - subNum * mapS * _this7._cocosScale) / img.height;
var sprNode = new cc.Node();
var sf = new cc.SpriteFrame(img); // const spr = this.hotZoneBg.addComponent(cc.Sprite);
var spr = sprNode.addComponent(cc.Sprite);
spr.spriteFrame = sf;
sprNode.width = _this5.hotZoneBg.width;
sprNode.height = _this5.hotZoneBg.height;
sprNode.parent = _this5.hotZoneBg;
_this5.hotZoneBg.scale = Math.min(sx, sy); // this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
sprNode.width = _this7.hotZoneBg.width;
sprNode.height = _this7.hotZoneBg.height;
sprNode.parent = _this7.hotZoneBg;
_this7.hotZoneBg.scale = Math.min(sx, sy); // this.hotZoneBg.y = -frameSize.height / 2 * this._cocosScale + this.hotZoneBg.height / 2 * this.hotZoneBg.scaleY + (subNum * mapS * this._cocosScale);
_this5.hotZoneBg.y = frameSize.height / 2 * _this5._cocosScale - _this5.hotZoneBg.height / 2 * _this5.hotZoneBg.scaleY; // this.hotZoneBg.opacity = 20;
_this7.hotZoneBg.y = frameSize.height / 2 * _this7._cocosScale - _this7.hotZoneBg.height / 2 * _this7.hotZoneBg.scaleY; // this.hotZoneBg.opacity = 20;
var bgWhite = cc.find('Canvas/bgWhite');
bgWhite.y = _this5.hotZoneBg.y;
bgWhite.scaleX = _this5.hotZoneBg.width * _this5.hotZoneBg.scaleX / bgWhite.width;
bgWhite.scaleY = _this5.hotZoneBg.height * _this5.hotZoneBg.scaleY / bgWhite.height;
bgWhite.y = _this7.hotZoneBg.y;
bgWhite.scaleX = _this7.hotZoneBg.width * _this7.hotZoneBg.scaleX / bgWhite.width;
bgWhite.scaleY = _this7.hotZoneBg.height * _this7.hotZoneBg.scaleY / bgWhite.height;
var canvas = cc.find('Canvas');
var shadowNode = new cc.Node();
shadowNode.y = bgWhite.y;
......@@ -308,23 +333,23 @@ cc.Class({
var ctx = shadowNode.addComponent(cc.Graphics);
ctx.fillColor = cc.Color.BLACK.setA(30); // ctx.fillRect(5, 5, this.hotZoneBg.width*this.hotZoneBg.scaleX, this.hotZoneBg.height * this.hotZoneBg.scaleY);
ctx.fillRect(-bgWhite.width / 2 + 8 / bgWhite.scaleX * _this5.hotZoneBg.scale, -bgWhite.height / 2 - 8 / bgWhite.scaleX * _this5.hotZoneBg.scale, bgWhite.width, bgWhite.height);
ctx.fillRect(-bgWhite.width / 2 + 8 / bgWhite.scaleX * _this7.hotZoneBg.scale, -bgWhite.height / 2 - 8 / bgWhite.scaleX * _this7.hotZoneBg.scale, bgWhite.width, bgWhite.height);
ctx.fill();
shadowNode.zIndex = 1;
bgWhite.zIndex = 2;
bgBottom.y = -frameSize.height / 2 * _this5._cocosScale - 15 * bgBottom.scaleY;
bgBottom.y = -frameSize.height / 2 * _this7._cocosScale - 15 * bgBottom.scaleY;
_this5.data.hotZoneItemArr.forEach(function (item) {
_this7.data.hotZoneItemArr.forEach(function (item) {
// if (item.gIdx == '0') {
// this.setOneAnima(item);
// } else {
_this5.setOneCirclePoint(item); // }
_this7.setOneCirclePoint(item); // }
_this5.setOnePic(item);
_this7.setOnePic(item);
});
_this5.initBottomPart();
_this7.initBottomPart();
});
},
addMask: function addMask(node) {
......@@ -333,9 +358,9 @@ cc.Class({
},
initBottomPart: function initBottomPart() {
var bgBottom = cc.find('Canvas/bgBottom');
var script = bgBottom.getComponent('bgBottom');
var picArr = this.getBottomPicArr();
script.setItemData(picArr);
var script = bgBottom.getComponent('bgBottom'); // const picArr = this.getBottomPicArr();
script.setItemData(this.data.hotZoneItemArr);
},
getBottomPicArr: function getBottomPicArr() {
var arr = []; // for (let i = 0; i < this.hotzoneCircleArr.length; i++) {
......@@ -455,7 +480,7 @@ cc.Class({
});
},
setOnePic: function setOnePic(data) {
var _this6 = this;
var _this8 = this;
var rate = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width;
var picNode = new cc.Node();
......@@ -466,11 +491,11 @@ cc.Class({
}, function (err, img) {
var spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img);
var scale = rate / _this6.hotZoneBg.scaleY;
var scale = rate / _this8.hotZoneBg.scaleY;
picNode.width = data.rect.width * scale;
picNode.height = data.rect.height * scale;
picNode.x = -_this6.hotZoneBg.width / 2 + data.rect.x * scale;
picNode.y = _this6.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.x = -_this8.hotZoneBg.width / 2 + data.rect.x * scale;
picNode.y = _this8.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.anchorX = picNode.anchorY = 0;
picNode.opacity = 0;
data.pic = picNode;
......@@ -484,26 +509,13 @@ cc.Class({
this.hotZoneBg.addChild(rectNode);
var spr = rectNode.addComponent(cc.Sprite);
var circleSmallNode = cc.find('Canvas/res/circle_bg_small');
spr.spriteFrame = circleSmallNode.getComponent(cc.Sprite).spriteFrame; // const ctx = rectNode.addComponent(cc.Graphics);
// // 红色矩形
// ctx.lineWidth = 4;
// ctx.strokeColor = cc.Color.BLACK;
// ctx.fillColor = cc.Color.WHITE.setA(100);
spr.spriteFrame = circleSmallNode.getComponent(cc.Sprite).spriteFrame;
var scale = rate / this.hotZoneBg.scaleY;
rectNode.width = circleSmallNode.width;
rectNode.height = circleSmallNode.height;
rectNode.x = -this.hotZoneBg.width / 2 + (data.rect.x + data.rect.width / 2) * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height / 2 * scale - data.rect.y * scale; // rectNode.width = data.rect.width * scale;
// rectNode.height = data.rect.height * scale;
// rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
// rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0.5; // if (this.data.bgItem.isShowDebugLine) {
// ctx.rect(0, 0, rectNode.width, rectNode.height);
// }
// ctx.stroke();
// ctx.fill();
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height / 2 * scale - data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0.5;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, function (err, audioClip) {
......@@ -512,10 +524,95 @@ cc.Class({
}
this.hotzoneCircleArr.push(rectNode);
if (!data.skeJsonData) {
return;
}
var animaNode = new cc.Node();
animaNode.name = 'anima_' + data.index;
this.hotZoneBg.addChild(animaNode);
data.animaNode = animaNode;
animaNode.active = false;
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, function (err, audioClip) {
animaNode.audioClip = audioClip;
});
}
var dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
var image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
var ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
var atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, function (error, texture) {
cc.loader.load({
url: atlas,
type: 'txt'
}, function (error, atlasJson) {
cc.loader.load({
url: ske,
type: 'txt'
}, function (error, dragonBonesJson) {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset.dragonBonesJson = dragonBonesJson;
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
var json = JSON.parse(asset.dragonBonesJson);
var armatures = json["armature"];
console.log('armatures: ', armatures);
var armatureNames = [];
for (var i = 0; i < armatures.length; i++) {
armatureNames.push(armatures[i].name);
} // console.log('armatureNames: ', armatureNames);
if (armatureNames.length > 0) {
var defaultArmatureName = armatureNames[0];
dragonDisplay.armatureName = defaultArmatureName; // let animationNames = dragonDisplay.getAnimationNames(defaultArmatureName);
var defaultArmature = armatures[0];
var animations = defaultArmature.animation;
var animationNames = [];
for (var _i2 = 0; _i2 < animations.length; _i2++) {
animationNames.push(animations[_i2].name);
} // rectNode.addComponent(cc.Button);
animaNode.showAnima = function () {
animaNode.active = true; // rectNode.on('click', () => {
if (rectNode.isClicked) {// return;
}
rectNode.isClicked = true;
console.log('clicked');
if (animaNode.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(animaNode.audioClip, false, 0.8);
}
if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1);
}
};
}
});
});
});
},
_curShowItem: null,
bottomItemClick: function bottomItemClick(item) {
var _this7 = this;
var _this9 = this;
return;
......@@ -543,13 +640,13 @@ cc.Class({
newNode.addComponent(cc.Button);
newNode.on('click', function () {
if (newNode.isSmall) {
if (_this7._curShowItem) {
if (_this9._curShowItem) {
return;
}
_this7._curShowItem = newNode;
_this9._curShowItem = newNode;
_this7._toCenterShow(newNode);
_this9._toCenterShow(newNode);
} else {
console.log('newNode', newNode);
......@@ -694,16 +791,16 @@ cc.Class({
},
itemAppear: function itemAppear(circle) {
circle.active = false;
this._curShowItem.active = false;
cc.tween(this._curShowItem.data.pic).to(3, {
opacity: 255
}, {
easing: 'cubicOut'
}).start();
this._curShowItem.active = false; // cc.tween(this._curShowItem.data.pic)
// .to(3, {opacity: 255}, {easing: 'cubicOut'})
// .start();
// if (circle.data.audioClip) {
// cc.audioEngine.stopAll();
// cc.audioEngine.play(circle.data.audioClip, false, 0.8);
// }
if (circle.data.audioClip) {
cc.audioEngine.stopAll();
cc.audioEngine.play(circle.data.audioClip, false, 0.8);
if (circle.data.animaNode) {
circle.data.animaNode.showAnima();
}
},
itemBack: function itemBack() {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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