Commit 8acdd228 authored by Lwd's avatar Lwd

aaaa

parent e9e05281
......@@ -12,15 +12,13 @@
<h5> add background: </h5>
<div class="bg-box">
<app-upload-image-with-preview
[picUrl]="bgItem?.url"
<app-upload-image-with-preview [picUrl]="bgItem?.url"
(imageUploaded)="onBackgroundUploadSuccess($event)">
</app-upload-image-with-preview>
</div>
</div>
<div nz-col nzSpan="5" nzOffset="1" class="img-box"
*ngFor="let it of hotZoneArr; let i = index">
<div nz-col nzSpan="5" nzOffset="1" class="img-box" *ngFor="let it of hotZoneArr; let i = index">
<div
style="margin: auto; padding: 5px; margin-top: 30px; width:90%; border: 2px dashed #ddd; border-radius: 10px">
......@@ -42,8 +40,7 @@
</div>
<div *ngIf="it.itemType == 'pic'">
<app-upload-image-with-preview
[picUrl]="it?.pic_url"
<app-upload-image-with-preview [picUrl]="it?.pic_url"
(imageUploaded)="onItemImgUploadSuccess($event, it)">
</app-upload-image-with-preview>
</div>
......@@ -53,10 +50,8 @@
</div>
<div style="width: 100%; margin-top: 5px;">
<app-audio-recorder
[audioUrl]="it.audio_url"
(audioUploaded)="onItemAudioUploadSuccess($event, it)"
></app-audio-recorder>
<app-audio-recorder [audioUrl]="it.audio_url"
(audioUploaded)="onItemAudioUploadSuccess($event, it)"></app-audio-recorder>
</div>
</div>
......@@ -67,8 +62,7 @@
<div nz-col nzSpan="5" nzOffset="1">
<div class="bg-box">
<button nz-button nzType="dashed" (click)="addBtnClick()"
class="add-btn">
<button nz-button nzType="dashed" (click)="addBtnClick()" class="add-btn">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
<!--Add Image-->
Add hot zone
......@@ -83,8 +77,7 @@
<div class="save-box">
<button class="save-btn" nz-button nzType="primary" [nzSize]="'large'" nzShape="round"
(click)="saveClick()" >
<button class="save-btn" nz-button nzType="primary" [nzSize]="'large'" nzShape="round" (click)="saveClick()">
<i nz-icon nzType="save"></i>
Save
</button>
......@@ -96,5 +89,3 @@
<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';
......@@ -59,8 +59,8 @@ export class UploadDragonBoneComponent implements OnDestroy, OnChanges {
constructor(private appRef: ApplicationRef, 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;
......
......@@ -4,6 +4,13 @@
<input type="text" nz-input [(ngModel)]="item.contentObj.title" (blur)="saveItem()">
</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 class="border" style="display: flex; align-items: center;">
......@@ -64,12 +71,60 @@
<!--公共部分-->
<div class="item-box" style="width: 35% ;padding-left: 100px">
<div style="width: 100%;">
<app-upload-image-with-preview style="width: 100%" [picUrl]="it['groupPic']"
(imageUploaded)="onImageUploadSuccessByItem($event, it)">
<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)">
</app-upload-image-with-preview> -->
</div>
<input style=" width: 100%; margin-bottom: 0.5vw" type="text" nz-input placeholder="点击输入文本内容"
[(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 class="item-box" style="width:35%; padding-left: 100px">
......
......@@ -9,6 +9,7 @@ import {
ApplicationRef,
ChangeDetectorRef
} from '@angular/core';
import { NzMessageService, UploadXHRArgs, UploadFile } from 'ng-zorro-antd';
......@@ -19,6 +20,9 @@ import {
})
export class FormComponent implements OnInit, OnChanges, OnDestroy {
pageArr = [];//页数据
fileList
uploadUrl
uploadData
_item: any;
KEY = 'hw_004';
......@@ -43,10 +47,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
update = new EventEmitter();
constructor(private appRef: ApplicationRef,
public changeDetectorRef: ChangeDetectorRef) {
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
this.uploadUrl = (<any>window).courseware.uploadUrl();
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 {
this.item = {};
this.item.contentObj = {};
const getData = (<any>window).courseware.getData;
getData((data) => {
......@@ -99,6 +107,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
console.log('item:', this.item);
}
getDefaultPicArr() {
const arr = [];
// for (let i = 0; i < 4; i ++) {
......@@ -170,6 +179,38 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
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() {
const data = {
......@@ -189,6 +230,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
b_audio_url: '',
groupLabel: '',
groupPic: '',
group_audio_url: '',
type: '',
ske_json: '',
tex_json: '',
tex_png: '',
// uploadData: '',
// uploadUrl: '',
};
this.pageArr[i].pageInfo.push(data);
console.log(this.pageArr);
......@@ -222,6 +270,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
const getData = (<any>window).courseware.getData;
getData((data) => {
console.log('data:', data);
// console.log('string:', JSON.stringify(data));
}, 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({
}
this.resultNode.active = false;
//重置游戏数据游戏数据
g.data_mgr.resGameData();
g.data_mgr.addPreloadImage();
g.data_mgr.addPreloadAudio();
g.data_mgr.addPreloadAnima();
//初始化界面
this.UpdataUi();
......@@ -123,6 +130,8 @@ var game = cc.Class({
//游戏开始
g.game.inst.gameStart();
//清除线
this.clearLine();
},
......@@ -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) {
if (listInfo.length <= i) {
......@@ -190,7 +208,12 @@ var game = cc.Class({
for (var i = 0; i < conten.childrenCount; i++) {
var item = conten.children[i]
if (item.state == 1 || item.state == 3) {
// if (state == 2) {
var com = item.getComponent("item");
//设置状态为可答题
com.setBtnState(item.state);
continue;
// }
} else {
var com = item.getComponent("item");
//设置状态为可答题
......@@ -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 a = 0;
var k = ex == sx ? 0 : (ey - sy) / (ex - sx);
......@@ -220,7 +243,7 @@ var game = cc.Class({
if (difnode) {
this.scheduleOnce(function () {
this.DrawLine(sx, sy, difx, dify);
this.ShowLine(difx, dify, ex, ey);
this.ShowLine(difx, dify, ex, ey, cb);
}.bind(this), 0.01);
}
else {
......@@ -232,6 +255,7 @@ var game = cc.Class({
//显示弹窗
var Info = g.data_mgr.getResultInfo(g.data_mgr.nowNode.typeId);
g.game.inst.showResult(Info);
cb && cb();
}
},
......
......@@ -62,7 +62,7 @@ cc.Class({
//设置按钮状态0可点击 1已答对 2答错 3连线完成
setBtnState: function (num) {
this.nodeState[num].active = true;
//this.nodeState[num].active = true;
switch (~~num) {
case 0:
this.nodeState[0].active = true;
......@@ -110,15 +110,18 @@ cc.Class({
g.game.inst.allLightDark(2, 0);
//把这个答对的节点保存起来
g.data_mgr.itemInfo = this.spt_chick;
g.data_mgr.itemInfo = this;
}
//如果答对的是下排的话
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);
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);
this.setBtnState(3);
});
// //显示弹窗
// var Info = g.data_mgr.getResultInfo(this.itemInfo.typeId);
// g.game.inst.showResult(Info);
......
/**
* result
*/
const Color_texts = ['#BE1AC1', '#24C11A', '#1A1DC1', '#9F5307'];
var result = cc.Class({
extends: cc.Component,
......@@ -29,6 +31,16 @@ var result = cc.Class({
default: null,
type: cc.Animation,
displayName: "撒花特效"
},
Armature: {
default: null,
type: dragonBones.ArmatureDisplay,
displayName: "动画"
},
layoutText: {
default: null,
type: cc.Node,
displayName: "文字布局"
}
},
......@@ -39,13 +51,24 @@ var result = cc.Class({
//更新界面ui
updateUI: function (Info) {
this.Picture.active = false;
this.Armature.node.active = false;
if (Info) {
//当前数据
this.itemInfo = Info;
//显示图片
if (Info.type == "Image") {
//设置图片
this.setPicture(Info.groupPic);
//设置图片
this.setTips(Info.groupLabel);
}
//显示骨骼动画
if (Info.type == "Spine") {
g.res_mgr.loadSpine(this.Armature, Info);
}
this.initRichText(Info.groupLabel);
this.wellDone.active = false;
this.frame_tips.active = true;
this.eff_sahua.node.active = false;
......@@ -61,9 +84,9 @@ var result = cc.Class({
}
},
//设置标签
setTips: function (num) {
this.lb_tips.string = num;
// 初始化文本
initRichText(text) {
this.lb_tips.string = text;
},
//设置图片
......@@ -75,6 +98,51 @@ var result = cc.Class({
}.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 () {
this.node.active = false;
......
......@@ -53,13 +53,47 @@ g.res_mgr = {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, 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
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