Commit 39b31330 authored by xytk's avatar xytk

提交代码

parent 3bdab7f3
...@@ -13,6 +13,37 @@ ...@@ -13,6 +13,37 @@
(audioUploaded)="onAudioUploadSuccess($event, 'bt_audio_url')" (audioUploaded)="onAudioUploadSuccess($event, 'bt_audio_url')"
></app-audio-recorder> ></app-audio-recorder>
</div> </div>
<div *ngFor="let option of item.pic_or_dragonBone; let i = index">
<span style="font-size: 30px;">位置:{{i+1}}</span>
<br>
<input type="radio" id="img{{i}}" name="type{{i}}" (click)="setType('img',i)">
图片
<input id="dragonBone{{i}}" type="radio" name="type{{i}}" (click)="setType('dragonBone',i)">
骨骼动画
<div *ngIf="(option.type == 'dragonBone')" style="margin-top: 5px">
<span style="height: 30px; font-size: 18px;">上传骨骼动画(建议上传尺寸为280x368像素):</span>
<app-upload-dragon-bone [btnName]="[['配置骨骼动画']]" [animaNames]="[[['normal']]]"
[skeJsonData]=option.skeJsonData [texJsonData]=option.texJsonData
[texPngData]=option.texPngData (save)="saveAnima($event, item.pic_or_dragonBone,i)"
(refreshEmitter)="refresh()">
</app-upload-dragon-bone>
<br/>
</div>
<div *ngIf="(option.type == 'img')" style="width: 300px;" align='center'>
<span>图片(建议上传尺寸为280x368像素): </span>
<app-upload-image-with-preview
[picUrl]="option.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url',i)">
</app-upload-image-with-preview>
<br/>
</div>
<span style="height: 30px; font-size: 18px;">上传音频:</span>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess2($event, 'audio_url',i)"
></app-audio-recorder>
</div>
<!--
<div style="margin-top: 5px"> <div style="margin-top: 5px">
<span style="height: 30px; font-size: 18px;">上传骨骼动画(建议上传尺寸为280x368像素):</span> <span style="height: 30px; font-size: 18px;">上传骨骼动画(建议上传尺寸为280x368像素):</span>
<app-upload-dragon-bone [btnName]="[['配置骨骼动画']]" [animaNames]="[[['normal']]]" <app-upload-dragon-bone [btnName]="[['配置骨骼动画']]" [animaNames]="[[['normal']]]"
...@@ -56,7 +87,7 @@ ...@@ -56,7 +87,7 @@
(audioUploaded)="onAudioUploadSuccess($event, 'pic_C_audio_url')" (audioUploaded)="onAudioUploadSuccess($event, 'pic_C_audio_url')"
></app-audio-recorder> ></app-audio-recorder>
</div> </div>
-->
<div style="width: 300px; margin-top: 15px;"> <div style="width: 300px; margin-top: 15px;">
<span>底部文本: </span> <span>底部文本: </span>
<input type="text" nz-input [(ngModel)]="item.bottom_text" (blur)="save()"> <input type="text" nz-input [(ngModel)]="item.bottom_text" (blur)="save()">
......
...@@ -38,16 +38,42 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -38,16 +38,42 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = { this.item = {
bt_text:"", bt_text:"",
bt_audio_url:"", bt_audio_url:"",
dragonBone:{ pic_or_dragonBone:[
{
type:"dragonBone",
audio_url:"",
pic_url:"",
"skeJsonData": { "url": "" }, "skeJsonData": { "url": "" },
"texJsonData": { "url": "" }, "texJsonData": { "url": "" },
"texPngData": { "url": "" }, "texPngData": { "url": "" },
}, },
dragonBone_audio_url:"", {
pic_A_url:"", type:"img",
pic_A_audio_url:"", audio_url:"",
pic_C_url:"", pic_url:"",
pic_C_audio_url:"", "skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
"texPngData": { "url": "" },
},
{
type:"img",
audio_url:"",
pic_url:"",
"skeJsonData": { "url": "" },
"texJsonData": { "url": "" },
"texPngData": { "url": "" },
}
],
// dragonBone:{
// "skeJsonData": { "url": "" },
// "texJsonData": { "url": "" },
// "texPngData": { "url": "" },
// },
// dragonBone_audio_url:"",
// pic_A_url:"",
// pic_A_audio_url:"",
// pic_C_url:"",
// pic_C_audio_url:"",
bottom_text:"", bottom_text:"",
bottom_audio_url:"" bottom_audio_url:""
}; };
...@@ -65,6 +91,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -65,6 +91,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.refresh(); this.refresh();
}, this.saveKey); }, this.saveKey);
} }
ngOnChanges() { ngOnChanges() {
...@@ -74,23 +101,45 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -74,23 +101,45 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
init() { init() {
setTimeout(()=>{
for (let i = 0; i < this.item.pic_or_dragonBone.length; i++) {
const type = this.item.pic_or_dragonBone[i].type;
if(type=="img"){
//@ts-ignore
document.getElementById('dragonBone'+i).checked =false;
var r = document.getElementById('img'+i)
//@ts-ignore
r.checked = true;
}else{
//@ts-ignore
document.getElementById('dragonBone'+i).checked =true;
var r = document.getElementById('img'+i)
//@ts-ignore
r.checked = false;
}
}
},500);
} }
setType(val,i){
this.item.pic_or_dragonBone[i].type = val;
this.save();
}
saveAnima(event, group) { saveAnima(event, group,i) {
group.skeJsonData = event.skeJsonData; group[i].skeJsonData = event.skeJsonData;
group.texJsonData = event.texJsonData; group[i].texJsonData = event.texJsonData;
group.texPngData = event.texPngData; group[i].texPngData = event.texPngData;
this.save(); this.save();
} }
/** /**
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key,i) {
this.item[key] = e.url; this.item.pic_or_dragonBone[i][key] = e.url;
this.save(); this.save();
} }
...@@ -102,7 +151,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -102,7 +151,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item[key] = e.url; this.item[key] = e.url;
this.save(); this.save();
} }
/**
* 储存音频数据2
* @param e
*/
onAudioUploadSuccess2(e, key,i) {
this.item.pic_or_dragonBone[i][key] = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) { onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url; this.item.wordList[idx].audio = e.url;
this.save(); this.save();
......
...@@ -81,28 +81,28 @@ ...@@ -81,28 +81,28 @@
"__id__": 16 "__id__": 16
}, },
{ {
"__id__": 32 "__id__": 30
}, },
{ {
"__id__": 42 "__id__": 40
}, },
{ {
"__id__": 44 "__id__": 42
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 54 "__id__": 52
}, },
{ {
"__id__": 55 "__id__": 53
}, },
{ {
"__id__": 57 "__id__": 55
}, },
{ {
"__id__": 56 "__id__": 54
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
"array": [ "array": [
0, 0,
0, 0,
586.5427680068793, 587.2719034940045,
0, 0,
0, 0,
0, 0,
...@@ -710,16 +710,16 @@ ...@@ -710,16 +710,16 @@
"__id__": 23 "__id__": 23
}, },
{ {
"__id__": 27 "__id__": 26
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 30 "__id__": 28
}, },
{ {
"__id__": 31 "__id__": 29
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1058,9 +1058,6 @@ ...@@ -1058,9 +1058,6 @@
}, },
{ {
"__id__": 25 "__id__": 25
},
{
"__id__": 26
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1111,36 +1108,6 @@ ...@@ -1111,36 +1108,6 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "7aZr/4CVNGTatn+RFZh7kf" "_id": "7aZr/4CVNGTatn+RFZh7kf"
}, },
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "c3a+SuRTtCfZEdA/lKdzfR"
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
...@@ -1195,10 +1162,7 @@ ...@@ -1195,10 +1162,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 28 "__id__": 27
},
{
"__id__": 29
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1249,42 +1213,12 @@ ...@@ -1249,42 +1213,12 @@
"groupIndex": 0, "groupIndex": 0,
"_id": "eaPfUaETlHwZ/5GqT5VgvK" "_id": "eaPfUaETlHwZ/5GqT5VgvK"
}, },
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 27
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "3c3MU8idVAibDF4ufQHJCy"
},
{ {
"__type__": "cc.AudioSource", "__type__": "cc.AudioSource",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 27 "__id__": 26
}, },
"_enabled": true, "_enabled": true,
"_clip": null, "_clip": null,
...@@ -1307,10 +1241,10 @@ ...@@ -1307,10 +1241,10 @@
"__id__": 22 "__id__": 22
}, },
"picAAudioSource": { "picAAudioSource": {
"__id__": 26 "__id__": 25
}, },
"picCAudioSource": { "picCAudioSource": {
"__id__": 29 "__id__": 27
}, },
"_id": "a2RsgrevxLALki66+UKTAy" "_id": "a2RsgrevxLALki66+UKTAy"
}, },
...@@ -1350,19 +1284,19 @@ ...@@ -1350,19 +1284,19 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 33 "__id__": 31
}, },
{ {
"__id__": 37 "__id__": 35
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 40 "__id__": 38
}, },
{ {
"__id__": 41 "__id__": 39
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1418,19 +1352,19 @@ ...@@ -1418,19 +1352,19 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 32 "__id__": 30
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 34 "__id__": 32
}, },
{ {
"__id__": 35 "__id__": 33
}, },
{ {
"__id__": 36 "__id__": 34
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1486,7 +1420,7 @@ ...@@ -1486,7 +1420,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 33 "__id__": 31
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1522,7 +1456,7 @@ ...@@ -1522,7 +1456,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 33 "__id__": 31
}, },
"_enabled": true, "_enabled": true,
"_color": { "_color": {
...@@ -1540,7 +1474,7 @@ ...@@ -1540,7 +1474,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 33 "__id__": 31
}, },
"_enabled": true, "_enabled": true,
"_clip": null, "_clip": null,
...@@ -1556,16 +1490,16 @@ ...@@ -1556,16 +1490,16 @@
"_name": "doc", "_name": "doc",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 32 "__id__": 30
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 38 "__id__": 36
}, },
{ {
"__id__": 39 "__id__": 37
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1621,7 +1555,7 @@ ...@@ -1621,7 +1555,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 37 "__id__": 35
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1653,7 +1587,7 @@ ...@@ -1653,7 +1587,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 37 "__id__": 35
}, },
"_enabled": true, "_enabled": true,
"_defaultClip": { "_defaultClip": {
...@@ -1672,14 +1606,14 @@ ...@@ -1672,14 +1606,14 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 32 "__id__": 30
}, },
"_enabled": true, "_enabled": true,
"doc": { "doc": {
"__id__": 37 "__id__": 35
}, },
"text": { "text": {
"__id__": 33 "__id__": 31
}, },
"_id": "624Q23nvtEgp2teq8h6WHj" "_id": "624Q23nvtEgp2teq8h6WHj"
}, },
...@@ -1688,7 +1622,7 @@ ...@@ -1688,7 +1622,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 32 "__id__": 30
}, },
"_enabled": true, "_enabled": true,
"alignMode": 1, "alignMode": 1,
...@@ -1721,7 +1655,7 @@ ...@@ -1721,7 +1655,7 @@
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 43 "__id__": 41
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1777,7 +1711,7 @@ ...@@ -1777,7 +1711,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 42 "__id__": 40
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1821,13 +1755,13 @@ ...@@ -1821,13 +1755,13 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 45 "__id__": 43
}, },
{ {
"__id__": 48 "__id__": 46
}, },
{ {
"__id__": 51 "__id__": 49
} }
], ],
"_active": false, "_active": false,
...@@ -1885,11 +1819,11 @@ ...@@ -1885,11 +1819,11 @@
"_name": "font", "_name": "font",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 44 "__id__": 42
}, },
"_children": [ "_children": [
{ {
"__id__": 46 "__id__": 44
} }
], ],
"_active": true, "_active": true,
...@@ -1947,13 +1881,13 @@ ...@@ -1947,13 +1881,13 @@
"_name": "BRLNSDB", "_name": "BRLNSDB",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 45 "__id__": 43
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 47 "__id__": 45
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2009,7 +1943,7 @@ ...@@ -2009,7 +1943,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 46 "__id__": 44
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2045,11 +1979,11 @@ ...@@ -2045,11 +1979,11 @@
"_name": "img", "_name": "img",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 44 "__id__": 42
}, },
"_children": [ "_children": [
{ {
"__id__": 49 "__id__": 47
} }
], ],
"_active": true, "_active": true,
...@@ -2107,13 +2041,13 @@ ...@@ -2107,13 +2041,13 @@
"_name": "icon", "_name": "icon",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 48 "__id__": 46
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 50 "__id__": 48
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2169,7 +2103,7 @@ ...@@ -2169,7 +2103,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 49 "__id__": 47
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2201,11 +2135,11 @@ ...@@ -2201,11 +2135,11 @@
"_name": "audio", "_name": "audio",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 44 "__id__": 42
}, },
"_children": [ "_children": [
{ {
"__id__": 52 "__id__": 50
} }
], ],
"_active": true, "_active": true,
...@@ -2263,13 +2197,13 @@ ...@@ -2263,13 +2197,13 @@
"_name": "btn", "_name": "btn",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 51 "__id__": 49
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 53 "__id__": 51
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2325,7 +2259,7 @@ ...@@ -2325,7 +2259,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 52 "__id__": 50
}, },
"_enabled": true, "_enabled": true,
"_clip": { "_clip": {
...@@ -2364,25 +2298,25 @@ ...@@ -2364,25 +2298,25 @@
}, },
"_enabled": true, "_enabled": true,
"loadInAudioSource": { "loadInAudioSource": {
"__id__": 56 "__id__": 54
}, },
"dragonBonesNode": { "dragonBonesNode": {
"__id__": 19 "__id__": 19
}, },
"pic_a_sprite": { "pic_a_sprite": {
"__id__": 24 "__id__": 23
}, },
"pic_c_sprite": { "pic_c_sprite": {
"__id__": 28 "__id__": 26
}, },
"tittleJs": { "tittleJs": {
"__id__": 15 "__id__": 15
}, },
"middleJs": { "middleJs": {
"__id__": 30 "__id__": 28
}, },
"bottomJs": { "bottomJs": {
"__id__": 40 "__id__": 38
}, },
"_id": "e687yyoRBIzZAOVRL8Sseh" "_id": "e687yyoRBIzZAOVRL8Sseh"
}, },
......
...@@ -21,12 +21,24 @@ export default class NewClass extends cc.Component { ...@@ -21,12 +21,24 @@ export default class NewClass extends cc.Component {
this.dragonBoneAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{ this.dragonBoneAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.dragonBoneAudioSource.play(); this.dragonBoneAudioSource.play();
let ad = this.dragonBoneAudioSource.node.getComponent(dragonBones.ArmatureDisplay);
if(ad){
ad.playAnimation("normal", 1);
}
}) })
this.picAAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{ this.picAAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.picAAudioSource.play(); this.picAAudioSource.play();
let ad = this.picAAudioSource.node.getComponent(dragonBones.ArmatureDisplay);
if(ad){
ad.playAnimation("normal", 1);
}
}) })
this.picCAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{ this.picCAudioSource.node.on(cc.Node.EventType.TOUCH_START,()=>{
this.picCAudioSource.play(); this.picCAudioSource.play();
let ad = this.picCAudioSource.node.getComponent(dragonBones.ArmatureDisplay);
if(ad){
ad.playAnimation("normal", 1);
}
}) })
} }
......
...@@ -10,8 +10,8 @@ cc.Class({ ...@@ -10,8 +10,8 @@ cc.Class({
properties: { properties: {
loadInAudioSource:cc.AudioSource, loadInAudioSource:cc.AudioSource,
dragonBonesNode:cc.Node, dragonBonesNode:cc.Node,
pic_a_sprite:cc.Sprite, pic_a_sprite:cc.Node,
pic_c_sprite:cc.Sprite, pic_c_sprite:cc.Node,
tittleJs:Tittle, tittleJs:Tittle,
middleJs:Middle, middleJs:Middle,
bottomJs:Bottom bottomJs:Bottom
...@@ -70,7 +70,7 @@ cc.Class({ ...@@ -70,7 +70,7 @@ cc.Class({
if (window && window.courseware) { if (window && window.courseware) {
getData = window.courseware.getData; getData = window.courseware.getData;
} }
this.dragonBonesNode.on(cc.Node.EventType.TOUCH_START,this.playDragonAnimation,this) // this.dragonBonesNode.on(cc.Node.EventType.TOUCH_START,this.playDragonAnimation,this)
getData((data) => { getData((data) => {
cc.log('data:', data); cc.log('data:', data);
this.data = data || this.getDefaultData(); this.data = data || this.getDefaultData();
...@@ -84,7 +84,6 @@ cc.Class({ ...@@ -84,7 +84,6 @@ cc.Class({
if(ad){ if(ad){
ad.playAnimation("normal", 1); ad.playAnimation("normal", 1);
} }
}, },
getData(cb) { getData(cb) {
...@@ -92,7 +91,7 @@ cc.Class({ ...@@ -92,7 +91,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '{"bt_text":"11111","bt_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone":{"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/14ca834d522122b031a2e18be5129251.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}},"dragonBone_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_url":"http://staging-teach.cdn.ireadabc.com/79f4b6912d1ffad13da6c05dda328237.jpg","pic_C_url":"http://staging-teach.cdn.ireadabc.com/79f4b6912d1ffad13da6c05dda328237.jpg","bottom_text":"底部的文本","bottom_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_A_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_C_audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","dragonBone_animationName":"unit1_boy_jump","dragonBone_armatureName":"Armature"}' const dataJson = '{"bt_text":"111","bt_audio_url":"http://staging-teach.cdn.ireadabc.com/7934cdcec68eabe639020bad5420d7f8.mp3","pic_or_dragonBone":[{"type":"dragonBone","audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_url":"http://staging-teach.cdn.ireadabc.com/db8a7ed8fb354558fad66edfbba43d89.jpg","skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/14ca834d522122b031a2e18be5129251.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}},{"type":"img","audio_url":"http://staging-teach.cdn.ireadabc.com/0f0482ddb8c0d3329165ab0612683148.mp3","pic_url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/14ca834d522122b031a2e18be5129251.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}},{"type":"dragonBone","audio_url":"http://staging-teach.cdn.ireadabc.com/b0c23eb327ec13212d09516a1a8a49ec.mp3","pic_url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/14ca834d522122b031a2e18be5129251.json","name":"sb_boy_ske.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/ecc48e23d55b1af8eb40d997dc573791.json","name":"sb_boy_tex.json"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/2d668f8049bc98c0e026921ef316a0fd.png","name":"sb_boy_tex.png"}}],"bottom_text":"9999999999999","bottom_audio_url":"http://staging-teach.cdn.ireadabc.com/784cd4188bf126d6c3c9395d9a807619.mp3"}'
const data = JSON.parse(dataJson); const data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -108,7 +107,7 @@ cc.Class({ ...@@ -108,7 +107,7 @@ cc.Class({
addPreloadImage() { addPreloadImage() {
this._imageResList.push({ url: this.data.pic_A_url }); this._imageResList.push({ url: this.data.pic_A_url });
this._imageResList.push({ url: this.data.pic_C_url }); this._imageResList.push({ url: this.data.pic_C_url });
this._imageResList.push({ url: this.data.dragonBone.texPngData.url }); // this._imageResList.push({ url: this.data.dragonBone.texPngData.url });
}, },
addPreloadAudio() { addPreloadAudio() {
...@@ -120,9 +119,9 @@ cc.Class({ ...@@ -120,9 +119,9 @@ cc.Class({
}, },
addPreloadAnima() { addPreloadAnima() {
this._animaResList.push({url: this.data.dragonBone.skeJsonData.url}); // this._animaResList.push({url: this.data.dragonBone.skeJsonData.url});
this._animaResList.push({url: this.data.dragonBone.texJsonData.url}); // this._animaResList.push({url: this.data.dragonBone.texJsonData.url});
this._animaResList.push({url: this.data.dragonBone.texPngData.url}); // this._animaResList.push({url: this.data.dragonBone.texPngData.url});
}, },
preload() { preload() {
...@@ -161,13 +160,13 @@ cc.Class({ ...@@ -161,13 +160,13 @@ cc.Class({
this.getAudioByUrl(this.data.bottom_audio_url,(ac)=>{ this.getAudioByUrl(this.data.bottom_audio_url,(ac)=>{
this.bottomJs.setAudioClip(ac); this.bottomJs.setAudioClip(ac);
}); });
this.getAudioByUrl(this.data.dragonBone_audio_url,(ac)=>{ this.getAudioByUrl(this.data.pic_or_dragonBone[0].audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,0); this.middleJs.setAudioClip(ac,0);
}); });
this.getAudioByUrl(this.data.pic_A_audio_url,(ac)=>{ this.getAudioByUrl(this.data.pic_or_dragonBone[1].audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,1); this.middleJs.setAudioClip(ac,1);
}); });
this.getAudioByUrl(this.data.pic_C_audio_url,(ac)=>{ this.getAudioByUrl(this.data.pic_or_dragonBone[2].audio_url,(ac)=>{
this.middleJs.setAudioClip(ac,2); this.middleJs.setAudioClip(ac,2);
}); });
}, },
...@@ -179,15 +178,18 @@ cc.Class({ ...@@ -179,15 +178,18 @@ cc.Class({
this.initTile(); this.initTile();
//this.initBtn(); //this.initBtn();
this.initIcon(); this.initIcon();
this.loadDragonBones(); // this.loadDragonBones();
}, },
loadDragonBones(){ loadDragonBones(node,urlData){
var animNode = this.dragonBonesNode; var animNode = node;
var dragonDisplay = animNode.addComponent(dragonBones.ArmatureDisplay); var dragonDisplay = animNode.addComponent(dragonBones.ArmatureDisplay);
var image = this.data.dragonBone.texPngData.url; var image = urlData.texPngData.url;
var ske = this.data.dragonBone.skeJsonData.url; var ske = urlData.skeJsonData.url;
var atlas = this.data.dragonBone.texJsonData.url; var atlas = urlData.texJsonData.url;
// var image = this.data.dragonBone.texPngData.url;
// var ske = this.data.dragonBone.skeJsonData.url;
// var atlas = this.data.dragonBone.texJsonData.url;
var item = this.data; var item = this.data;
cc.loader.load(image, (error, texture) => { cc.loader.load(image, (error, texture) => {
cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => { cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
...@@ -244,6 +246,28 @@ cc.Class({ ...@@ -244,6 +246,28 @@ cc.Class({
pic1: null, pic1: null,
pic2: null, pic2: null,
initPic() { initPic() {
// debugger
if(this.data.pic_or_dragonBone[0].type == "img"){
this.loadPic(this.dragonBonesNode,this.data.pic_or_dragonBone[0].pic_url);
}else{
this.loadDragonBones(this.dragonBonesNode,this.data.pic_or_dragonBone[0]);
}
if(this.data.pic_or_dragonBone[1].type == "img"){
this.loadPic(this.pic_a_sprite,this.data.pic_or_dragonBone[1].pic_url);
}else{
this.loadDragonBones(this.pic_a_sprite,this.data.pic_or_dragonBone[1]);
}
if(this.data.pic_or_dragonBone[2].type == "img"){
this.loadPic(this.pic_c_sprite,this.data.pic_or_dragonBone[2].pic_url);
}else{
this.loadDragonBones(this.pic_c_sprite,this.data.pic_or_dragonBone[2]);
}
// dragonBonesNode:cc.Node,
// pic_a_sprite:cc.Node,
// pic_c_sprite:cc.Node,
/*
this.getSpriteFrimeByUrl(this.data.pic_A_url,(spriteFrame)=>{ this.getSpriteFrimeByUrl(this.data.pic_A_url,(spriteFrame)=>{
let width = this.pic_a_sprite.node.width; let width = this.pic_a_sprite.node.width;
let height = this.pic_a_sprite.node.height; let height = this.pic_a_sprite.node.height;
...@@ -265,7 +289,22 @@ cc.Class({ ...@@ -265,7 +289,22 @@ cc.Class({
this.pic_c_sprite.node.scale = height/this.pic_c_sprite.node.height; this.pic_c_sprite.node.scale = height/this.pic_c_sprite.node.height;
} }
}); });
*/
},
loadPic(node,pic_url){
this.getSpriteFrimeByUrl(pic_url,(spriteFrame)=>{
let width = node.width;
let height = node.height;
let sprite = node.addComponent(cc.Sprite);
sprite.spriteFrame = spriteFrame;
// cc.log(this.pic_a_sprite.node.scale);
if(node.width/node.height > width/height){
node.scale = width/node.width;
}else{
node.scale = height/node.height;
}
});
}, },
initIcon() {}, initIcon() {},
......
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