Commit 8acdd228 authored by Lwd's avatar Lwd

aaaa

parent e9e05281
<div class="p-image-children-editor"> <div class="p-image-children-editor">
<h5 style="margin-left: 2.5%;"> preview: </h5> <h5 style="margin-left: 2.5%;"> preview: </h5>
<div class="preview-box" #wrap> <div class="preview-box" #wrap>
<canvas id="canvas" #canvas></canvas> <canvas id="canvas" #canvas></canvas>
</div> </div>
<div nz-row nzType="flex" nzAlign="middle"> <div nz-row nzType="flex" nzAlign="middle">
<div nz-col nzSpan="5" nzOffset="1"> <div nz-col nzSpan="5" nzOffset="1">
<h5> add background: </h5> <h5> add background: </h5>
<div class="bg-box"> <div class="bg-box">
<app-upload-image-with-preview <app-upload-image-with-preview [picUrl]="bgItem?.url"
[picUrl]="bgItem?.url" (imageUploaded)="onBackgroundUploadSuccess($event)">
(imageUploaded)="onBackgroundUploadSuccess($event)"> </app-upload-image-with-preview>
</app-upload-image-with-preview> </div>
</div> </div>
</div>
<div nz-col nzSpan="5" nzOffset="1" class="img-box" <div nz-col nzSpan="5" nzOffset="1" class="img-box" *ngFor="let it of hotZoneArr; let i = index">
*ngFor="let it of hotZoneArr; let i = index">
<div <div
style="margin: auto; padding: 5px; margin-top: 30px; width:90%; border: 2px dashed #ddd; border-radius: 10px"> style="margin: auto; padding: 5px; margin-top: 30px; width:90%; border: 2px dashed #ddd; border-radius: 10px">
<span style="margin-left: 40%;"> item-{{i + 1}} <span style="margin-left: 40%;"> item-{{i + 1}}
</span> </span>
<button style="float: right;" nz-button nzType="danger" nzSize="small" (click)="deleteBtnClick(i)"> <button style="float: right;" nz-button nzType="danger" nzSize="small" (click)="deleteBtnClick(i)">
X X
</button> </button>
<nz-divider style="margin-top: 10px;"></nz-divider> <nz-divider style="margin-top: 10px;"></nz-divider>
<div style="margin-top: -20px; margin-bottom: 5px"> <div style="margin-top: -20px; margin-bottom: 5px">
<nz-radio-group [ngModel]="it.itemType" (ngModelChange)="radioChange($event, it)"> <nz-radio-group [ngModel]="it.itemType" (ngModelChange)="radioChange($event, it)">
<label *ngIf="isHasRect" nz-radio nzValue="rect">矩形</label> <label *ngIf="isHasRect" nz-radio nzValue="rect">矩形</label>
<label *ngIf="isHasPic" nz-radio nzValue="pic">图片</label> <label *ngIf="isHasPic" nz-radio nzValue="pic">图片</label>
<label *ngIf="isHasText" nz-radio nzValue="text">文本</label> <label *ngIf="isHasText" nz-radio nzValue="text">文本</label>
</nz-radio-group> </nz-radio-group>
</div> </div>
<div *ngIf="it.itemType == 'pic'"> <div *ngIf="it.itemType == 'pic'">
<app-upload-image-with-preview <app-upload-image-with-preview [picUrl]="it?.pic_url"
[picUrl]="it?.pic_url" (imageUploaded)="onItemImgUploadSuccess($event, it)">
(imageUploaded)="onItemImgUploadSuccess($event, it)"> </app-upload-image-with-preview>
</app-upload-image-with-preview> </div>
</div>
<div *ngIf="it.itemType == 'text'"> <div *ngIf="it.itemType == 'text'">
<input type="text" nz-input [(ngModel)]="it.text" (blur)="saveText(it)"> <input type="text" nz-input [(ngModel)]="it.text" (blur)="saveText(it)">
</div> </div>
<div style="width: 100%; margin-top: 5px;"> <div style="width: 100%; margin-top: 5px;">
<app-audio-recorder <app-audio-recorder [audioUrl]="it.audio_url"
[audioUrl]="it.audio_url" (audioUploaded)="onItemAudioUploadSuccess($event, it)"></app-audio-recorder>
(audioUploaded)="onItemAudioUploadSuccess($event, it)" </div>
></app-audio-recorder>
</div>
</div> </div>
</div> </div>
<div nz-col nzSpan="5" nzOffset="1"> <div nz-col nzSpan="5" nzOffset="1">
<div class="bg-box"> <div class="bg-box">
<button nz-button nzType="dashed" (click)="addBtnClick()" <button nz-button nzType="dashed" (click)="addBtnClick()" class="add-btn">
class="add-btn"> <i nz-icon nzType="plus-circle" nzTheme="outline"></i>
<i nz-icon nzType="plus-circle" nzTheme="outline"></i> <!--Add Image-->
<!--Add Image--> Add hot zone
Add hot zone </button>
</button> </div>
</div>
</div> </div>
</div> </div>
<nz-divider></nz-divider> <nz-divider></nz-divider>
<div class="save-box"> <div class="save-box">
<button class="save-btn" nz-button nzType="primary" [nzSize]="'large'" nzShape="round" <button class="save-btn" nz-button nzType="primary" [nzSize]="'large'" nzShape="round" (click)="saveClick()">
(click)="saveClick()" > <i nz-icon nzType="save"></i>
<i nz-icon nzType="save"></i> Save
Save </button>
</button>
</div> </div>
</div> </div>
<label style="opacity: 0; position: absolute; top: 0px; font-family: 'BRLNSR_1'">1</label> <label style="opacity: 0; position: absolute; top: 0px; font-family: 'BRLNSR_1'">1</label>
\ No newline at end of file
import {ApplicationRef, Component, EventEmitter, Input, OnChanges, OnDestroy, Output} from '@angular/core'; import { ApplicationRef, Component, EventEmitter, Input, OnChanges, OnDestroy, Output } from '@angular/core';
import { NzMessageService, UploadXHRArgs, UploadFile } from 'ng-zorro-antd'; import { NzMessageService, UploadXHRArgs, UploadFile } from 'ng-zorro-antd';
@Component({ @Component({
selector: 'app-upload-dragon-bone', selector: 'app-upload-dragon-bone',
templateUrl: './upload-dragon-bone.component.html', templateUrl: './upload-dragon-bone.component.html',
styleUrls: ['./upload-dragon-bone.component.scss'] styleUrls: ['./upload-dragon-bone.component.scss']
}) })
export class UploadDragonBoneComponent implements OnDestroy, OnChanges { export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
uploading = false; uploading = false;
progress = 0; progress = 0;
@Input() @Input()
btnName = '配置龙骨动画'; btnName = '配置龙骨动画';
@Input() @Input()
animaNames = []; animaNames = [];
@Input() @Input()
skeJsonData = {}; skeJsonData = {};
@Input() @Input()
texJsonData = {}; texJsonData = {};
@Input() @Input()
texPngData = {}; texPngData = {};
@Output() @Output()
save = new EventEmitter(); save = new EventEmitter();
@Output() @Output()
refreshEmitter = new EventEmitter(); refreshEmitter = new EventEmitter();
// @Input() // @Input()
// picUrl; // picUrl;
// @Input() // @Input()
// canDelete = false; // canDelete = false;
// @Output() // @Output()
// imageUploaded = new EventEmitter(); // imageUploaded = new EventEmitter();
// @Output() // @Output()
// imageUploadFailure = new EventEmitter(); // imageUploadFailure = new EventEmitter();
// @Output() // @Output()
// delete = new EventEmitter(); // delete = new EventEmitter();
// @Input() // @Input()
// picItem = null; // picItem = null;
// @Input() // @Input()
// iconSize = 2; // iconSize = 2;
// @Input() // @Input()
// TIP = 'Click here to upload image'; // TIP = 'Click here to upload image';
// @Input() // @Input()
// disableUpload = false; // disableUpload = false;
uploadUrl; uploadUrl;
uploadData; uploadData;
animaPanelVisible = false; animaPanelVisible = false;
isSkeJsonLoading = false; isSkeJsonLoading = false;
isTexJsonLoading = false; isTexJsonLoading = false;
isTexPngLoading = false; isTexPngLoading = false;
constructor(private appRef: ApplicationRef, private nzMessageService: NzMessageService) { constructor(private appRef: ApplicationRef, private nzMessageService: NzMessageService) {
this.uploadUrl = (<any> window).courseware.uploadUrl(); this.uploadUrl = (<any>window).courseware.uploadUrl();
this.uploadData = (<any> window).courseware.uploadData(); this.uploadData = (<any>window).courseware.uploadData();
window['air'].getUploadCallback = (url, data) => { window['air'].getUploadCallback = (url, data) => {
this.uploadUrl = url; this.uploadUrl = url;
this.uploadData = data; this.uploadData = data;
}; };
} }
ngOnChanges() { ngOnChanges() {
} }
setAnimaBtnClick() { setAnimaBtnClick() {
this.animaPanelVisible = true; this.animaPanelVisible = true;
this.refresh(); this.refresh();
} }
animaPanelCancel() { animaPanelCancel() {
this.animaPanelVisible = false; this.animaPanelVisible = false;
this.refresh(); this.refresh();
} }
animaPanelOk() { animaPanelOk() {
this.sendItemDragonBoneData(); this.sendItemDragonBoneData();
this.animaPanelVisible = false; this.animaPanelVisible = false;
this.refresh(); this.refresh();
} }
sendItemDragonBoneData() { sendItemDragonBoneData() {
const data = {}; const data = {};
data['skeJsonData'] = this.skeJsonData; data['skeJsonData'] = this.skeJsonData;
data['texJsonData'] = this.texJsonData; data['texJsonData'] = this.texJsonData;
data['texPngData'] = this.texPngData; data['texPngData'] = this.texPngData;
this.save.emit(data); this.save.emit(data);
} }
skeJsonHandleChange(e) { skeJsonHandleChange(e) {
console.log('e: ', e); console.log('e: ', e);
switch (e.type) { switch (e.type) {
case 'start': case 'start':
this.isSkeJsonLoading = true; this.isSkeJsonLoading = true;
break; break;
case 'success': case 'success':
this.skeJsonData['url'] = e.file.response.url; this.skeJsonData['url'] = e.file.response.url;
this.skeJsonData['name'] = e.file.name; this.skeJsonData['name'] = e.file.name;
this.nzMessageService.success('上传成功'); this.nzMessageService.success('上传成功');
this.isSkeJsonLoading = false; this.isSkeJsonLoading = false;
break; break;
case 'progress': case 'progress':
break; break;
} }
} }
texJsonHandleChange(e) { texJsonHandleChange(e) {
console.log('e: ', e); console.log('e: ', e);
switch (e.type) { switch (e.type) {
case 'start': case 'start':
this.isTexJsonLoading = true; this.isTexJsonLoading = true;
break; break;
case 'success': case 'success':
this.texJsonData['url'] = e.file.response.url; this.texJsonData['url'] = e.file.response.url;
this.texJsonData['name'] = e.file.name; this.texJsonData['name'] = e.file.name;
this.nzMessageService.success('上传成功'); this.nzMessageService.success('上传成功');
this.isTexJsonLoading = false; this.isTexJsonLoading = false;
break; break;
case 'progress': case 'progress':
break; break;
} }
} }
texPngHandleChange(e) { texPngHandleChange(e) {
console.log('e: ', e); console.log('e: ', e);
switch (e.type) { switch (e.type) {
case 'start': case 'start':
this.isTexPngLoading = true; this.isTexPngLoading = true;
break; break;
case 'success': case 'success':
this.texPngData['url'] = e.file.response.url; this.texPngData['url'] = e.file.response.url;
this.texPngData['name'] = e.file.name; this.texPngData['name'] = e.file.name;
this.nzMessageService.success('上传成功'); this.nzMessageService.success('上传成功');
this.isTexPngLoading = false; this.isTexPngLoading = false;
break; break;
case 'progress': case 'progress':
break; break;
} }
} }
/** /**
* 刷新 渲染页面 * 刷新 渲染页面
*/ */
refresh() { refresh() {
// this.refreshEmitter.emit(); // this.refreshEmitter.emit();
setTimeout(() => { setTimeout(() => {
this.appRef.tick(); this.appRef.tick();
}, 1); }, 1);
} }
closePanel() { closePanel() {
console.log(' in closePanel '); console.log(' in closePanel ');
this.refresh(); this.refresh();
} }
ngOnDestroy() { ngOnDestroy() {
} }
} }
...@@ -4,6 +4,13 @@ ...@@ -4,6 +4,13 @@
<input type="text" nz-input [(ngModel)]="item.contentObj.title" (blur)="saveItem()"> <input type="text" nz-input [(ngModel)]="item.contentObj.title" (blur)="saveItem()">
</div> </div>
<div class="section-content;text-align:center">
<div style="display: inline-block; margin-bottom: 10px">
<app-audio-recorder [audioUrl]="item.contentObj.audio_url"
(audioUploaded)="onAudioUploadSuccessByItem($event, item.contentObj)">
</app-audio-recorder>
</div>
</div>
<div *ngFor="let it of pageArr; let i = index" style="padding: 0.5vw; width: 20%;"> <div *ngFor="let it of pageArr; let i = index" style="padding: 0.5vw; width: 20%;">
<div class="border" style="display: flex; align-items: center;"> <div class="border" style="display: flex; align-items: center;">
...@@ -64,12 +71,60 @@ ...@@ -64,12 +71,60 @@
<!--公共部分--> <!--公共部分-->
<div class="item-box" style="width: 35% ;padding-left: 100px"> <div class="item-box" style="width: 35% ;padding-left: 100px">
<div style="width: 100%;"> <div style="width: 100%;">
<app-upload-image-with-preview style="width: 100%" [picUrl]="it['groupPic']" <div style="float: left; text-align: right; margin-right: 10px; margin-left: 10px;">
<span>显示选项</span><span> :</span>
</div>
<div style="float: left;width: 100%;">
<nz-radio-group [(ngModel)]="it['type']" (ngModelChange)="handleQuestionTypeChange($event)">
<label nz-radio [nzValue]="'Image'">背景图片</label>
<label nz-radio [nzValue]="'Spine'">骨骼动画</label>
</nz-radio-group>
</div>
<div style="float: left;width: 100%;">
<div *ngIf="it['type']=='Image'">
<app-upload-image-with-preview style="width: 100%;" [picUrl]="it['groupPic']"
(imageUploaded)="onImageUploadSuccessByItem($event, it, 'image_url')">
</app-upload-image-with-preview>
</div>
<div *ngIf="it['type']=='Spine' ">
<div style="display: flex 1;margin-bottom: 10px;margin-left: 10px;">
<span>上传 ske_json 文件</span><span> : </span>
<nz-upload nzAccept=".json" [nzAction]="uploadUrl" [nzData]="uploadData"
[nzShowUploadList]="false" (nzChange)="handleChange($event, it,'ske_json')">
<button nz-button><i nz-icon nzType="upload"></i>Upload</button>
</nz-upload>
<span style="margin-left: 10px;">{{it["ske_json_name"]}}</span>
</div>
<div style="display: flex 1;margin-bottom: 10px;margin-left: 10px;">
<span>上传 tex_json 文件</span><span> : </span>
<nz-upload nzAccept=".json" [nzAction]="uploadUrl" [nzData]="uploadData"
[nzShowUploadList]="false" (nzChange)="handleChange($event, it,'tex_json')">
<button nz-button><i nz-icon nzType="upload"></i>Upload</button>
</nz-upload>
<span style="margin-left: 10px;">{{ it["tex_json_name"] }}</span>
</div>
<div style="display: flex 1;margin-bottom: 10px;margin-left: 10px;">
<span>上传 tex_png 文件</span><span> : </span>
<nz-upload nzAccept=".png" [nzAction]="uploadUrl" [nzData]="uploadData"
[nzShowUploadList]="false" (nzChange)="handleChange($event, it,'tex_png')">
<button nz-button><i nz-icon nzType="upload"></i>Upload</button>
</nz-upload>
<span style="margin-left: 10px;">{{ it["tex_png_name"] }}</span>
</div>
</div>
</div>
<!-- <app-upload-image-with-preview style="width: 100%" [picUrl]="it['groupPic']"
(imageUploaded)="onImageUploadSuccessByItem($event, it)"> (imageUploaded)="onImageUploadSuccessByItem($event, it)">
</app-upload-image-with-preview> </app-upload-image-with-preview> -->
</div> </div>
<input style=" width: 100%; margin-bottom: 0.5vw" type="text" nz-input placeholder="点击输入文本内容" <input style=" width: 100%; margin-bottom: 0.5vw" type="text" nz-input placeholder="点击输入文本内容"
[(ngModel)]="it.groupLabel" (blur)="saveItem()"> [(ngModel)]="it.groupLabel" (blur)="saveItem()">
<app-audio-recorder style="margin-top: 0.5vw" [audioUrl]="it['group_audio_url']"
(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'group')">
</app-audio-recorder>
</div> </div>
<div class="item-box" style="width:35%; padding-left: 100px"> <div class="item-box" style="width:35%; padding-left: 100px">
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
ApplicationRef, ApplicationRef,
ChangeDetectorRef ChangeDetectorRef
} from '@angular/core'; } from '@angular/core';
import { NzMessageService, UploadXHRArgs, UploadFile } from 'ng-zorro-antd';
...@@ -19,6 +20,9 @@ import { ...@@ -19,6 +20,9 @@ import {
}) })
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
pageArr = [];//页数据 pageArr = [];//页数据
fileList
uploadUrl
uploadData
_item: any; _item: any;
KEY = 'hw_004'; KEY = 'hw_004';
...@@ -43,10 +47,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -43,10 +47,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
update = new EventEmitter(); update = new EventEmitter();
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
constructor(private appRef: ApplicationRef, this.uploadUrl = (<any>window).courseware.uploadUrl();
public changeDetectorRef: ChangeDetectorRef) { this.uploadData = (<any>window).courseware.uploadData();
window['air'].getUploadCallback = (url, data) => {
this.uploadUrl = url;
this.uploadData = data;
};
} }
...@@ -55,6 +62,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -55,6 +62,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = {}; this.item = {};
this.item.contentObj = {}; this.item.contentObj = {};
const getData = (<any>window).courseware.getData; const getData = (<any>window).courseware.getData;
getData((data) => { getData((data) => {
...@@ -99,6 +107,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -99,6 +107,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('item:', this.item); console.log('item:', this.item);
} }
getDefaultPicArr() { getDefaultPicArr() {
const arr = []; const arr = [];
// for (let i = 0; i < 4; i ++) { // for (let i = 0; i < 4; i ++) {
...@@ -170,6 +179,38 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -170,6 +179,38 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.save(); this.save();
} }
uploadSuccess(file, item, key) {
console.log(item);
item[key] = file.response.url;
item[key + '_name'] = file.name;
this.save();
}
handleChange(info: { type: string, file: UploadFile, event: any }, item, key) {
console.log('info:', info);
switch (info.type) {
case 'success':
this.uploadSuccess(info.file, item, key);
break;
}
}
handleQuestionTypeChange(key) {
if (key == 'Spine') {
this.fileList = [
{
uid: '-1',
name: this.item['ske_json'],
status: 'done',
url: this.item['ske_json']
}
]
} else if (key == 'Image') {
}
this.saveItem()
this.changeDetectorRef.detectChanges();
this.changeDetectorRef.markForCheck();
}
//添加页面 //添加页面
addPage() { addPage() {
const data = { const data = {
...@@ -189,6 +230,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -189,6 +230,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
b_audio_url: '', b_audio_url: '',
groupLabel: '', groupLabel: '',
groupPic: '', groupPic: '',
group_audio_url: '',
type: '',
ske_json: '',
tex_json: '',
tex_png: '',
// uploadData: '',
// uploadUrl: '',
}; };
this.pageArr[i].pageInfo.push(data); this.pageArr[i].pageInfo.push(data);
console.log(this.pageArr); console.log(this.pageArr);
...@@ -222,6 +270,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -222,6 +270,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
const getData = (<any>window).courseware.getData; const getData = (<any>window).courseware.getData;
getData((data) => { getData((data) => {
console.log('data:', data); console.log('data:', data);
// console.log('string:', JSON.stringify(data));
}, this.KEY); }, this.KEY);
} }
......
This diff is collapsed.
{
"ver": "1.1.0",
"uuid": "61fcc759-2eb5-4e50-a2f3-0cc3393881d8",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
...@@ -114,6 +114,13 @@ var game = cc.Class({ ...@@ -114,6 +114,13 @@ var game = cc.Class({
} }
this.resultNode.active = false; this.resultNode.active = false;
//重置游戏数据游戏数据
g.data_mgr.resGameData();
g.data_mgr.addPreloadImage();
g.data_mgr.addPreloadAudio();
g.data_mgr.addPreloadAnima();
//初始化界面 //初始化界面
this.UpdataUi(); this.UpdataUi();
...@@ -123,6 +130,8 @@ var game = cc.Class({ ...@@ -123,6 +130,8 @@ var game = cc.Class({
//游戏开始 //游戏开始
g.game.inst.gameStart(); g.game.inst.gameStart();
//清除线 //清除线
this.clearLine(); this.clearLine();
}, },
...@@ -162,6 +171,15 @@ var game = cc.Class({ ...@@ -162,6 +171,15 @@ var game = cc.Class({
}); });
}, },
//播放标题音效
playAudioTitle: function () {
//获得播放路径
var path = g.data_mgr.data.contentObj.audio_url;
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url);
});
},
//添加项 //添加项
addItem: function (listInfo, content, item, i) { addItem: function (listInfo, content, item, i) {
if (listInfo.length <= i) { if (listInfo.length <= i) {
...@@ -190,7 +208,12 @@ var game = cc.Class({ ...@@ -190,7 +208,12 @@ var game = cc.Class({
for (var i = 0; i < conten.childrenCount; i++) { for (var i = 0; i < conten.childrenCount; i++) {
var item = conten.children[i] var item = conten.children[i]
if (item.state == 1 || item.state == 3) { if (item.state == 1 || item.state == 3) {
// if (state == 2) {
var com = item.getComponent("item");
//设置状态为可答题
com.setBtnState(item.state);
continue; continue;
// }
} else { } else {
var com = item.getComponent("item"); var com = item.getComponent("item");
//设置状态为可答题 //设置状态为可答题
...@@ -199,7 +222,7 @@ var game = cc.Class({ ...@@ -199,7 +222,7 @@ var game = cc.Class({
} }
}, },
ShowLine: function (sx, sy, ex, ey) { ShowLine: function (sx, sy, ex, ey, cb) {
var b = 0; var b = 0;
var a = 0; var a = 0;
var k = ex == sx ? 0 : (ey - sy) / (ex - sx); var k = ex == sx ? 0 : (ey - sy) / (ex - sx);
...@@ -220,7 +243,7 @@ var game = cc.Class({ ...@@ -220,7 +243,7 @@ var game = cc.Class({
if (difnode) { if (difnode) {
this.scheduleOnce(function () { this.scheduleOnce(function () {
this.DrawLine(sx, sy, difx, dify); this.DrawLine(sx, sy, difx, dify);
this.ShowLine(difx, dify, ex, ey); this.ShowLine(difx, dify, ex, ey, cb);
}.bind(this), 0.01); }.bind(this), 0.01);
} }
else { else {
...@@ -232,6 +255,7 @@ var game = cc.Class({ ...@@ -232,6 +255,7 @@ var game = cc.Class({
//显示弹窗 //显示弹窗
var Info = g.data_mgr.getResultInfo(g.data_mgr.nowNode.typeId); var Info = g.data_mgr.getResultInfo(g.data_mgr.nowNode.typeId);
g.game.inst.showResult(Info); g.game.inst.showResult(Info);
cb && cb();
} }
}, },
......
...@@ -2,144 +2,147 @@ ...@@ -2,144 +2,147 @@
* item * item
*/ */
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
Picture: { Picture: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "图片" displayName: "图片"
}, },
nodeState: { nodeState: {
default: [], default: [],
type: cc.Node, type: cc.Node,
displayName: "节点状态" displayName: "节点状态"
}, },
spt_error: { spt_error: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "失败" displayName: "失败"
}, },
spt_chick: { spt_chick: {
default: null, default: null,
type: cc.Node, type: cc.Node,
displayName: "小鸡" displayName: "小鸡"
} }
}, },
//更新界面ui //更新界面ui
updateUI: function (Info) { updateUI: function (Info) {
//当前数据 //当前数据
this.itemInfo = Info; this.itemInfo = Info;
//初始化数据 //初始化数据
this.InitData(); this.InitData();
//设置图片 //设置图片
this.setPicture(Info.url); this.setPicture(Info.url);
}, },
//初始化信息 //初始化信息
InitData: function () { InitData: function () {
//设置按钮状态 //设置按钮状态
this.setBtnState(0); this.setBtnState(0);
if (this.itemInfo.positionId == 2) { if (this.itemInfo.positionId == 2) {
this.setBtnState(2); this.setBtnState(2);
} }
}, },
//设置图片 //设置图片
setPicture: function (url) { setPicture: function (url) {
//图片资源 //图片资源
g.res_mgr.getSpriteFrimeByUrl(url, function (list) { g.res_mgr.getSpriteFrimeByUrl(url, function (list) {
this.Picture.getComponent(cc.Sprite).spriteFrame = list; this.Picture.getComponent(cc.Sprite).spriteFrame = list;
this.Picture.active = true; this.Picture.active = true;
}.bind(this)); }.bind(this));
}, },
//设置按钮状态 //设置按钮状态
setBtnOpen: function (b) { setBtnOpen: function (b) {
this.node.getComponent(cc.Button).enabled = b; this.node.getComponent(cc.Button).enabled = b;
}, },
//设置按钮状态0可点击 1已答对 2答错 3连线完成 //设置按钮状态0可点击 1已答对 2答错 3连线完成
setBtnState: function (num) { setBtnState: function (num) {
this.nodeState[num].active = true; //this.nodeState[num].active = true;
switch (~~num) { switch (~~num) {
case 0: case 0:
this.nodeState[0].active = true; this.nodeState[0].active = true;
this.nodeState[1].active = false; this.nodeState[1].active = false;
this.nodeState[2].active = false; this.nodeState[2].active = false;
this.node.state = 0; this.node.state = 0;
this.setBtnOpen(true); this.setBtnOpen(true);
break; break;
case 1: case 1:
this.nodeState[1].active = true; this.nodeState[1].active = true;
this.nodeState[2].active = false; this.nodeState[2].active = false;
this.node.state = 1; this.node.state = 1;
this.setBtnOpen(false); this.setBtnOpen(false);
break; break;
case 2: case 2:
this.nodeState[1].active = false; this.nodeState[1].active = false;
this.nodeState[2].active = true; this.nodeState[2].active = true;
this.node.state = 2; this.node.state = 2;
this.setBtnOpen(false); this.setBtnOpen(false);
break; break;
case 3: case 3:
this.nodeState[0].active = true; this.nodeState[0].active = true;
this.nodeState[1].active = false; this.nodeState[1].active = false;
this.nodeState[2].active = false; this.nodeState[2].active = false;
this.node.state = 3; this.node.state = 3;
this.setBtnOpen(false); this.setBtnOpen(false);
break; break;
} }
}, },
// //
onBtnGet: function () { onBtnGet: function () {
//如果节点的Id等于当前数据的id的话 //如果节点的Id等于当前数据的id的话
if (this.itemInfo.typeId == g.data_mgr.playId && this.itemInfo.positionId == g.data_mgr.playType) { if (this.itemInfo.typeId == g.data_mgr.playId && this.itemInfo.positionId == g.data_mgr.playType) {
//播放答对音效 //播放答对音效
g.speaker.inst.play_good(); g.speaker.inst.play_good();
this.setBtnState(1); this.setBtnState(1);
//如果是上面答对的话 //如果是上面答对的话
if (this.itemInfo.positionId == 1) { if (this.itemInfo.positionId == 1) {
//执行播放下排的音乐 //执行播放下排的音乐
g.data_mgr.playType = 2; g.data_mgr.playType = 2;
g.game.inst.PlayAudio(); g.game.inst.PlayAudio();
//设置状态 //设置状态
g.game.inst.allLightDark(1, 2); g.game.inst.allLightDark(1, 2);
g.game.inst.allLightDark(2, 0); g.game.inst.allLightDark(2, 0);
//把这个答对的节点保存起来 //把这个答对的节点保存起来
g.data_mgr.itemInfo = this.spt_chick; g.data_mgr.itemInfo = this;
} }
//如果答对的是下排的话 //如果答对的是下排的话
if (this.itemInfo.positionId == 2) { if (this.itemInfo.positionId == 2) {
//连线 //连线
var posStart = g.data_mgr.itemInfo.parent.convertToWorldSpaceAR(g.data_mgr.itemInfo.position); var posStart = g.data_mgr.itemInfo.spt_chick.parent.convertToWorldSpaceAR(g.data_mgr.itemInfo.spt_chick.position);
var posEnd = this.spt_chick.parent.convertToWorldSpaceAR(this.spt_chick.position); var posEnd = this.spt_chick.parent.convertToWorldSpaceAR(this.spt_chick.position);
g.data_mgr.nowNode = this.itemInfo; g.data_mgr.nowNode = this.itemInfo;
g.game.inst.ShowLine(posStart.x - 640, posStart.y - 360, posEnd.x - 640, posEnd.y - 360); g.game.inst.ShowLine(posStart.x - 640, posStart.y - 360, posEnd.x - 640, posEnd.y - 360, () => {
// //显示弹窗 g.data_mgr.itemInfo.setBtnState(3);
// var Info = g.data_mgr.getResultInfo(this.itemInfo.typeId); this.setBtnState(3);
// g.game.inst.showResult(Info); });
// //显示弹窗
// var Info = g.data_mgr.getResultInfo(this.itemInfo.typeId);
// g.game.inst.showResult(Info);
//弹窗关闭 //弹窗关闭
// //移除当前播放的音乐 // //移除当前播放的音乐
// const index = this.pageArr.indexOf(data); // const index = this.pageArr.indexOf(data);
// if (index !== -1) { // if (index !== -1) {
// this.pageArr.splice(index, 1); // this.pageArr.splice(index, 1);
// } // }
} }
} }
else { else {
this.spt_error.active = true; this.spt_error.active = true;
//播放失败音效 //播放失败音效
g.speaker.inst.play_error(); g.speaker.inst.play_error();
this.setBtnState(2); this.setBtnState(2);
cc.tween(this.spt_error) cc.tween(this.spt_error)
.to(0.2, { scale: 1.1 }) .to(0.2, { scale: 1.1 })
.to(0.5, { scale: 0 }) .to(0.5, { scale: 0 })
.start() .start()
} }
}, },
}); });
/** /**
* result * result
*/ */
const Color_texts = ['#BE1AC1', '#24C11A', '#1A1DC1', '#9F5307'];
var result = cc.Class({ var result = cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -29,6 +31,16 @@ var result = cc.Class({ ...@@ -29,6 +31,16 @@ var result = cc.Class({
default: null, default: null,
type: cc.Animation, type: cc.Animation,
displayName: "撒花特效" displayName: "撒花特效"
},
Armature: {
default: null,
type: dragonBones.ArmatureDisplay,
displayName: "动画"
},
layoutText: {
default: null,
type: cc.Node,
displayName: "文字布局"
} }
}, },
...@@ -39,13 +51,24 @@ var result = cc.Class({ ...@@ -39,13 +51,24 @@ var result = cc.Class({
//更新界面ui //更新界面ui
updateUI: function (Info) { updateUI: function (Info) {
this.Picture.active = false;
this.Armature.node.active = false;
if (Info) { if (Info) {
//当前数据 //当前数据
this.itemInfo = Info; this.itemInfo = Info;
//设置图片
this.setPicture(Info.groupPic); //显示图片
//设置图片 if (Info.type == "Image") {
this.setTips(Info.groupLabel); //设置图片
this.setPicture(Info.groupPic);
}
//显示骨骼动画
if (Info.type == "Spine") {
g.res_mgr.loadSpine(this.Armature, Info);
}
this.initRichText(Info.groupLabel);
this.wellDone.active = false; this.wellDone.active = false;
this.frame_tips.active = true; this.frame_tips.active = true;
this.eff_sahua.node.active = false; this.eff_sahua.node.active = false;
...@@ -61,9 +84,9 @@ var result = cc.Class({ ...@@ -61,9 +84,9 @@ var result = cc.Class({
} }
}, },
//设置标签 // 初始化文本
setTips: function (num) { initRichText(text) {
this.lb_tips.string = num; this.lb_tips.string = text;
}, },
//设置图片 //设置图片
...@@ -75,6 +98,51 @@ var result = cc.Class({ ...@@ -75,6 +98,51 @@ var result = cc.Class({
}.bind(this)); }.bind(this));
}, },
//播放龙骨动画
playSpine() {
this.Armature.playAnimation(g.data_mgr.dragonName, 1);
},
stopSpine() {
this.Armature.dragonAtlasAsset = null;
this.Armature.dragonAsset = null;
this.Armature.armatureName = '';
this.scheduleOnce(() => {
g.res_mgr.loadSpine(this.Armature, this.Info);
})
},
playAudio() {
cc.assetManager.loadRemote(this.itemInfo.group_audio_url, null, (err, clip) => {
this.audioID = cc.audioEngine.play(clip, false, 1);
this.audioDuration = cc.audioEngine.getDuration(this.audioID);
this.textDuration = this.audioDuration / this.layoutText.childrenCount;
this.textIndex = 0;
this.schedule(this.chengeTextColor, this.textDuration, this.layoutText.childrenCount, 0.01)
});
},
stopAudio() {
cc.audioEngine.stop(this.audioID);
this.unschedule(this.chengeTextColor);
this.isPlaying = false;
this.stopSpine();
},
chengeTextColor() {
if (!this.layoutText.children[this.textIndex] || this.textIndex == this.layoutText.childrenCount) {
this.isPlaying = false;
this.unschedule(this.chengeTextColor);
}
this.layoutText.children[this.textIndex] && (this.layoutText.children[this.textIndex].color = new cc.Color().fromHEX(Color_texts[3]));
this.layoutText.children[this.textIndex - 1] && (this.layoutText.children[this.textIndex - 1].color = new cc.Color().fromHEX(Color_texts[3]));
this.textIndex++;
},
clearTextColor() {
for (let i = 0; i < this.layoutText.children.length; i++) {
this.layoutText.children[i].color = new cc.Color().fromHEX(Color_texts[3]);
}
},
//点击关闭 //点击关闭
onBtnClose: function () { onBtnClose: function () {
this.node.active = false; this.node.active = false;
......
...@@ -53,13 +53,47 @@ g.res_mgr = { ...@@ -53,13 +53,47 @@ g.res_mgr = {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
cb && cb(audioClip); cb && cb(audioClip);
// const audioId = cc.audioEngine.play(audioClip, false, 0.8);
// if (cb) {
// cc.audioEngine.setFinishCallback(audioId, () => {
// cb();
// });
// }
}); });
} }
}, },
//加载龙骨
loadSpine(animationDisplay, Info) {
if (Info.type == 'Image') {
return;
}
cc.assetManager.loadAny([{ url: Info.tex_json, ext: '.txt' }, { url: Info.ske_json, ext: '.txt' }], (error, assets) => {
if (error) {
console.log(error)
}
else {
cc.assetManager.loadRemote(Info.tex_png, (error, texture) => {
if (error) {
console.log(error)
}
else {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas._uuid = Info.tex_json;
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset._uuid = Info.ske_json;
asset.dragonBonesJson = assets[1];
animationDisplay.dragonAtlasAsset = atlas;
animationDisplay.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if (!data) {
return;
}
animationDisplay.armatureName = data.name;
g.data_mgr.dragonName = data.animation[0].name;
animationDisplay.node.active = true;
}
});
}
});
},
} }
\ No newline at end of file
// 声音管理器 // 声音管理器
g.snd_mgr = { g.snd_mgr = {
bgmId: -1, // 背景音乐的音频ID bgmId: -1, // 背景音乐的音频ID
effIds: [], // 音效的音频ID列表(由cc.audioEngine保证音频ID不重复) effIds: [], // 音效的音频ID列表(由cc.audioEngine保证音频ID不重复)
bgmVol: 1, // 背景音乐音量 bgmVol: 1, // 背景音乐音量
neweffId: null, //保存上一个音效ID neweffId: null, //保存上一个音效ID
effVol: 1, // 音效音量 effVol: 1, // 音效音量
pausebgVol: 1, pausebgVol: 1,
pauseeffVol: 1, pauseeffVol: 1,
sndNativeUrls: {}, sndNativeUrls: {},
newsnd: null, newsnd: null,
init: function () { init: function () {
var local_storage = g.local_storage; var local_storage = g.local_storage;
var music_vol = local_storage.getMusicVolume(); var music_vol = local_storage.getMusicVolume();
var effect_vol = local_storage.getEffectsVolume(); var effect_vol = local_storage.getEffectsVolume();
music_vol != undefined && music_vol + "" != "" && this.setMusicVolume(music_vol); music_vol != undefined && music_vol + "" != "" && this.setMusicVolume(music_vol);
effect_vol != undefined && effect_vol + "" != "" && this.setEffectsVolume(effect_vol); effect_vol != undefined && effect_vol + "" != "" && this.setEffectsVolume(effect_vol);
}, },
delAudId: function (id) { delAudId: function (id) {
if (id == this.bgmId) { if (id == this.bgmId) {
this.bgmId = -1; this.bgmId = -1;
return; return;
} }
for (var i = 0; i < this.effIds.length; ++i) { for (var i = 0; i < this.effIds.length; ++i) {
if (this.effIds[i] == id) { if (this.effIds[i] == id) {
this.effIds.splice(i, 1); this.effIds.splice(i, 1);
return; return;
} }
} }
}, },
playMusic: function (snd, _loop, finishCB) { playMusic: function (snd, _loop, finishCB) {
if (!snd) return; if (!snd) return;
this.newsnd = snd; this.newsnd = snd;
var loop = _loop ? false : true; // 除非指定为false,否则默认为true var loop = _loop ? false : true; // 除非指定为false,否则默认为true
// if (g.configs.platform == "vo") { // if (g.configs.platform == "vo") {
// this.bgmId = cc.audioEngine.play(snd, loop); // this.bgmId = cc.audioEngine.play(snd, loop);
// return; // return;
// } // }
this.bgmId = cc.audioEngine.playMusic(snd, loop); this.bgmId = cc.audioEngine.playMusic(snd, loop);
// 播放完成回调 // 播放完成回调
if (finishCB) { if (finishCB) {
cc.audioEngine.setFinishCallback(this.bgmId, function () { cc.audioEngine.setFinishCallback(this.bgmId, function () {
finishCB(); finishCB();
}); });
} }
}, },
playEffect: function (snd, finishCB) { playEffect: function (snd, finishCB) {
if (!snd || this.effVol == 0) return; if (!snd || this.effVol == 0) return;
var id = cc.audioEngine.playEffect(snd, false); // 音效限定不能重复播放 var id = cc.audioEngine.playEffect(snd, false); // 音效限定不能重复播放
this.playaudioEffect(id, finishCB); this.playaudioEffect(id, finishCB);
}, },
//播放音效 //播放音效
playaudioEffect: function (id, finishCB) { playaudioEffect: function (id, finishCB) {
var self = this; var self = this;
this.neweffId = id; this.neweffId = id;
this.effIds.push(id); this.effIds.push(id);
// 播放完记得删ID // 播放完记得删ID
cc.audioEngine.setFinishCallback(id, function () { cc.audioEngine.setFinishCallback(id, function () {
self.delAudId(id); self.delAudId(id);
finishCB && finishCB(); finishCB && finishCB();
}); });
}, },
pauseVolume: function () { pauseVolume: function () {
cc.audioEngine.stopAll(); cc.audioEngine.stopAll();
}, },
resumeVolume: function () { resumeVolume: function () {
if (this.newsnd != null) { if (this.newsnd != null) {
cc.audioEngine.playMusic(this.newsnd) cc.audioEngine.playMusic(this.newsnd)
} }
}, },
setMusicVolume: function (percent) { setMusicVolume: function (percent) {
this.bgmVol = percent; this.bgmVol = percent;
cc.audioEngine.setMusicVolume(~~percent); cc.audioEngine.setMusicVolume(~~percent);
}, },
setEffectsVolume: function (percent) { setEffectsVolume: function (percent) {
this.effVol = percent; this.effVol = percent;
cc.audioEngine.setEffectsVolume(~~percent); cc.audioEngine.setEffectsVolume(~~percent);
cc.audioEngine.setMusicVolume(~~this.bgmVol); cc.audioEngine.setMusicVolume(~~this.bgmVol);
}, },
}; };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment