Commit 58c06c41 authored by huoshizhe's avatar huoshizhe

feat: ET17

parent ff9e0d97
No preview for this file type
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
/publish/publish/play /publish/publish/play
/publish/publish/form /publish/publish/form
/publish/publish/android /publish/publish/android
/publish/publish/web_desktop
/publish/publish/ios /publish/publish/ios
/publish/publish/*.zip /publish/publish/*.zip
/node_modules /publish/publish/config.json
\ No newline at end of file /publish/publish/Release*
/node_modules
/play/build_android
/play/build_ios
/play/build_web_desktop
\ No newline at end of file
...@@ -128,5 +128,8 @@ ...@@ -128,5 +128,8 @@
} }
} }
}, },
"defaultProject": "ng-template-generator" "defaultProject": "ng-template-generator",
} "cli": {
"analytics": false
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -55,4 +55,4 @@ ...@@ -55,4 +55,4 @@
"tslint": "~5.18.0", "tslint": "~5.18.0",
"typescript": "~3.7.5" "typescript": "~3.7.5"
} }
} }
\ No newline at end of file
<div class="model-content"> <div class="model-content">
<div class="border" style=" width: 520px; height: 130px;">
<div style="padding: 10px;"> <span style="height: 30px; font-size: 18px; float: left;">标题文字:</span>
<input style="width: 150px; float: left;" type="text" nz-input [(ngModel)]="item.titleTxt" (blur)="save()">
<div style="width: 300px;" align='center'> <br><br>
<span>图1: </span> <span style="height: 30px; font-size: 18px; float: left;">标题音频:</span>
<app-upload-image-with-preview <app-audio-recorder style="float: left;" [audioUrl]="item.titleAudio" (audioUploaded)="onAudioUploadSuccess($event)">
[picUrl]="item.pic_url" </app-audio-recorder>
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')"> </div>
</app-upload-image-with-preview> <div class="border" style=" width: 520px;">
</div> <span style="height: 30px; font-size: 18px;">已选字母:</span>
<div *ngFor="let letter of item.letterList; let i = index">
<div style="width: 300px; margin-top: 5px;" align='center'> <div style="float: left; width: 60px;">
<span>图2: </span> <span style="font-size: 50px;align-content: center;">{{letter}}</span>
<app-upload-image-with-preview <br>
[picUrl]="item.pic_url_2" <button style="color: red;" nz-button nzType="dashed" class="add-btn" (click)="removeLetter(i)">
(imageUploaded)="onImageUploadSuccess($event, 'pic_url_2')"> X
</app-upload-image-with-preview> </button>
</div>
</div> </div>
<div style="float: none;clear: both;">&nbsp;</div>
<div style="width: 300px; margin-top: 15px;"> </div>
<span>文本: </span> <!-- <div class="border" style=" width: 520px;">
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()"> <span style="height: 30px; font-size: 18px;">可选字母(点击下方字母选择):</span>
<br>
<a (click)="addLetter('Q')" style="font-size: 50px; width: 50px;">Q&nbsp;</a>
<a (click)="addLetter('W')" style="font-size: 50px; width: 50px;">W&nbsp;</a>
<a (click)="addLetter('E')" style="font-size: 50px; width: 50px;">E&nbsp;</a>
<a (click)="addLetter('R')" style="font-size: 50px; width: 50px;">R&nbsp;</a>
<a (click)="addLetter('T')" style="font-size: 50px; width: 50px;">T&nbsp;</a>
<a (click)="addLetter('Y')" style="font-size: 50px; width: 50px;">Y&nbsp;</a>
<a (click)="addLetter('U')" style="font-size: 50px; width: 50px;">U&nbsp;</a>
<a (click)="addLetter('I')" style="font-size: 50px; width: 50px;">I&nbsp;</a>
<a (click)="addLetter('O')" style="font-size: 50px; width: 50px;">O&nbsp;</a>
<a (click)="addLetter('P')" style="font-size: 50px; width: 50px;">P&nbsp;</a>
<br>
<a (click)="addLetter('A')" style="font-size: 50px; margin-left: 20px;">A&nbsp;</a>
<a (click)="addLetter('S')" style="font-size: 50px;">S&nbsp;</a>
<a (click)="addLetter('D')" style="font-size: 50px;">D&nbsp;</a>
<a (click)="addLetter('F')" style="font-size: 50px;">F&nbsp;</a>
<a (click)="addLetter('G')" style="font-size: 50px;">G&nbsp;</a>
<a (click)="addLetter('H')" style="font-size: 50px;">H&nbsp;</a>
<a (click)="addLetter('J')" style="font-size: 50px;">J&nbsp;</a>
<a (click)="addLetter('K')" style="font-size: 50px;">K&nbsp;</a>
<a (click)="addLetter('L')" style="font-size: 50px;">L&nbsp;</a>
<br>
<a (click)="addLetter('Z')" style="font-size: 50px; margin-left: 40px;">Z&nbsp;</a>
<a (click)="addLetter('X')" style="font-size: 50px;">X&nbsp;</a>
<a (click)="addLetter('C')" style="font-size: 50px;">C&nbsp;</a>
<a (click)="addLetter('V')" style="font-size: 50px;">V&nbsp;</a>
<a (click)="addLetter('B')" style="font-size: 50px;">B&nbsp;</a>
<a (click)="addLetter('N')" style="font-size: 50px;">N&nbsp;</a>
<a (click)="addLetter('M')" style="font-size: 50px;">M&nbsp;</a>
<br>
</div> -->
<div class="border" style="width: 350px;">
<span style="height: 30px; font-size: 18px;">可选字母(点击下方字母选择):</span>
<br>
<a (click)="addLetter('A')" style="font-size: 50px;">A&nbsp;</a>
<a (click)="addLetter('B')" style="font-size: 50px;">B&nbsp;</a>
<a (click)="addLetter('C')" style="font-size: 50px;">C&nbsp;</a>
<a (click)="addLetter('D')" style="font-size: 50px;">D&nbsp;</a>
<a (click)="addLetter('E')" style="font-size: 50px;">E&nbsp;</a>
<a (click)="addLetter('F')" style="font-size: 50px;">F&nbsp;</a>
<a (click)="addLetter('G')" style="font-size: 50px;">G&nbsp;</a>
<br>
<a (click)="addLetter('H')" style="font-size: 50px;">H&nbsp;</a>
<a (click)="addLetter('I')" style="font-size: 50px;">I&nbsp;</a>
<a (click)="addLetter('J')" style="font-size: 50px;">J&nbsp;</a>
<a (click)="addLetter('K')" style="font-size: 50px;">K&nbsp;</a>
<a (click)="addLetter('L')" style="font-size: 50px;">L&nbsp;</a>
<a (click)="addLetter('M')" style="font-size: 50px;">M&nbsp;</a>
<a (click)="addLetter('N')" style="font-size: 50px;">N&nbsp;</a>
<br>
<a (click)="addLetter('O')" style="font-size: 50px;">O&nbsp;</a>
<a (click)="addLetter('P')" style="font-size: 50px;">P&nbsp;</a>
<a (click)="addLetter('Q')" style="font-size: 50px;">Q&nbsp;</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a (click)="addLetter('R')" style="font-size: 50px;">R&nbsp;</a>
<a (click)="addLetter('S')" style="font-size: 50px;">S&nbsp;</a>
<a (click)="addLetter('T')" style="font-size: 50px;">T&nbsp;</a>
<br>
<a (click)="addLetter('U')" style="font-size: 50px;">U&nbsp;</a>
<a (click)="addLetter('V')" style="font-size: 50px;">V&nbsp;</a>
<a (click)="addLetter('W')" style="font-size: 50px;">W&nbsp;</a>
&nbsp;&nbsp;
<a (click)="addLetter('X')" style="font-size: 50px;">X&nbsp;</a>
<a (click)="addLetter('Y')" style="font-size: 50px;">Y&nbsp;</a>
<a (click)="addLetter('Z')" style="font-size: 50px;">Z&nbsp;</a>
<br>
</div>
<!-- <div class="border" style=" width: 520px; height: 120px;">
<span style="height: 30px; font-size: 18px;">单词音频:</span>
<br>
<app-audio-recorder [audioUrl]=" item.audio" (audioUploaded)="onAudioUploadSuccess($event)">
</app-audio-recorder>
</div>
<div class="border" style="width: 520px;">
<span style="height: 30px; font-size: 18px;">正确字母:</span>
<div>
<div *ngFor="let rightWord of item.rightWordList; let i = index">
<div style="padding: 2px;">
<input style="width: 150px;float: left;" type="text" nz-input [(ngModel)]="rightWord.word" (blur)="save()">
<app-audio-recorder style="float: left;" [audioUrl]="rightWord.audio"
(audioUploaded)="onRightAudioUploadSuccess($event, i)">
</app-audio-recorder>
<button style="float: right; margin-left: 10px; height: 32px; color: red;" nz-button nzType="dashed"
class="add-btn" (click)="removeRightWord(i)">
<i nz-icon nzType="minus-circle" nzTheme="outline"></i>
删除字母
</button>
</div>
<br> <br>
</div>
</div> </div>
<div *ngIf="(item.rightWordList.length +item.wrongWordList.length < 5)">
<div style="margin-top: 5px"> <button style="margin-left: 2px; margin-top: 2px; height: 32px;" nz-button nzType="dashed" class="add-btn"
<span>音频: </span> (click)="addRightWord()">
<app-audio-recorder <i nz-icon nzType="plus-circle" nzTheme="outline"></i>
[audioUrl]="item.audio_url" 添加<span style="color: #44bb44;">正确</span>的字母
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')" </button>
></app-audio-recorder>
</div> </div>
</div> </div>
-->
</div> </div>
\ No newline at end of file
...@@ -18,24 +18,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -18,24 +18,13 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
createShell() {
this.item.wordList.push({
word: '',
audio: '',
backWord: '',
backWordAudio: '',
});
this.save();
}
removeShell(idx) {
this.item.wordList.splice(idx, 1);
this.save();
}
ngOnInit() { ngOnInit() {
this.item = {}; this.item = {
letterList: [],
titleAudio: '',
titleTxt: ''
};
// 获取存储的数据 // 获取存储的数据
(<any>window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
...@@ -52,6 +41,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -52,6 +41,16 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}, this.saveKey); }, this.saveKey);
} }
addLetter(letter) {
this.item.letterList.push(letter);
this.save();
}
removeLetter(idx) {
this.item.letterList.splice(idx, 1);
this.save();
}
ngOnChanges() { ngOnChanges() {
} }
...@@ -77,18 +76,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -77,18 +76,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e) {
this.item[key] = e.url; this.item.titleAudio = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].audio = e.url;
this.save();
}
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
this.save(); this.save();
} }
...@@ -97,7 +86,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -97,7 +86,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/ */
save() { save() {
(<any>window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh(); this.refresh();
console.log('this.item = ' + JSON.stringify(this.item)); console.log('this.item = ' + JSON.stringify(this.item));
} }
......
{ {"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2", \ No newline at end of file
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b", "uuid": "9d027405-7058-4f74-be5b-0326be5edad4",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.130612,
"subMetas": {} "subMetas": {}
......
{
"ver": "2.0.1",
"uuid": "e736fa7c-759d-453d-874f-f63005132da5",
"downloadMode": 0,
"duration": 0.229333,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "fe4bf0f9-3e28-47c6-87c6-633340cee6bf",
"downloadMode": 0,
"duration": 1.854694,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5eaa6a2a-5291-4b07-ac9e-7156f3252b00",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "1fefcb3d-2443-443a-b58f-1301f013965c",
"downloadMode": 0,
"duration": 0.375833,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "1219a144-5601-4623-b5dd-2f1d9a56a32f",
"downloadMode": 0,
"duration": 0.532333,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "888ad5a3-8ec9-486f-aa05-234bb7124592",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "946b0364-a100-471c-a736-35be588ccded",
"downloadMode": 0,
"duration": 0.323667,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "96cb4901-0e14-4261-af21-846e7532ce1f",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "0d853882-7ed4-44c5-bddc-a86a90096c43",
"downloadMode": 0,
"duration": 0.688833,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "20c0ca53-a3c8-4ee8-959f-1438d8e36462",
"downloadMode": 0,
"duration": 0.297583,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "a28cc1de-da30-4b06-9a88-8fd4c29702f9",
"downloadMode": 0,
"duration": 0.34975,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6d2cbd66-05ea-4528-82b6-e107e76af2f0",
"downloadMode": 0,
"duration": 0.323667,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "13886100-6436-4498-8717-a1b138f9ffb4",
"downloadMode": 0,
"duration": 0.454083,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "5ea0e7ae-3b15-45ee-a255-775d21139fee",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6300e084-770d-442e-a60b-b09177c80cca",
"downloadMode": 0,
"duration": 0.50625,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "4f067478-7249-4d76-a64a-59b4a27418a6",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6e384f34-295c-446b-ba97-534669602876",
"downloadMode": 0,
"duration": 0.5845,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c5070f0a-85ab-4492-a66d-a5dcff0df614",
"downloadMode": 0,
"duration": 0.2715,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "87b1ac22-58d4-423a-89db-8489648bbcaf",
"downloadMode": 0,
"duration": 0.2715,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c1fbf3c9-c6a6-4e2a-b4f0-f35614918567",
"downloadMode": 0,
"duration": 0.34975,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "cd0b536a-5b28-44e4-b613-2b432138b71d",
"downloadMode": 0,
"duration": 0.5845,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "378ec7d4-84b1-4e15-a851-2f503be930ad",
"downloadMode": 0,
"duration": 0.688833,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d4db60ba-9b41-4b2f-9c2f-363942d61d2e",
"downloadMode": 0,
"duration": 0.167167,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "183abc68-1341-4bdd-8da9-0ec133a3d745",
"downloadMode": 0,
"duration": 0.375833,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c640d65e-aecd-40bd-8bee-9bd8ff40dfcb",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "82e72153-2af4-4b33-b10a-b3c905319463",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "7b784761-5425-4a44-8c6e-c2441bb41ed4",
"downloadMode": 0,
"duration": 0.401917,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "54ce478c-ec74-4387-8834-2dcdd4a1070d",
"downloadMode": 0,
"duration": 0.34975,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "e6417643-4f95-4dae-8abe-f2afa627e7a4",
"downloadMode": 0,
"duration": 0.428,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ce04f50a-48f4-4c9f-ba08-703831fe7bfe",
"downloadMode": 0,
"duration": 0.30325,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8a1d88aa-fbe1-497d-99ee-5b6712faab50",
"downloadMode": 0,
"duration": 0.9664,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ca9942f1-5d5d-4662-94cf-d4f0c66c89a2",
"downloadMode": 0,
"duration": 2.2465,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d318534e-0a5a-4309-9400-21d1eda8f639",
"downloadMode": 0,
"duration": 0.365714,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "82b9cd3f-eb72-486d-afd1-989b6a4ff131",
"downloadMode": 0,
"duration": 2.35102,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "f51b45e4-1a1d-43eb-b63d-9614c17de731",
"subMetas": {}
}
\ No newline at end of file
{"width":256,"SubTexture":[{"width":106,"y":1,"height":104,"name":"星","x":1},{"width":57,"y":67,"height":59,"name":"1/星1","x":179},{"width":43,"y":107,"height":45,"name":"1/星2","x":1},{"width":63,"y":1,"height":64,"name":"1/星3","x":179},{"width":45,"y":128,"height":45,"name":"1/星4","x":167},{"width":68,"y":1,"height":69,"name":"1/星6","x":109},{"width":37,"y":128,"height":40,"name":"1/星7","x":214},{"width":56,"y":72,"height":57,"name":"1/星5","x":109},{"width":32,"y":107,"height":33,"name":"1/星8","x":46},{"width":36,"y":170,"height":37,"name":"1/星9","x":214}],"height":256,"name":"正确效果","imagePath":"正确效果_tex.png"}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "ac3ab2af-1ea5-4ff3-8e24-d401777f807a",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "9ea21947-2ffb-456c-9f64-93d66c295dec",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 256,
"platformSettings": {},
"subMetas": {
"正确效果_tex": {
"ver": "1.0.4",
"uuid": "6cec3366-f109-498a-a0eb-0c577385d667",
"rawTextureUuid": "9ea21947-2ffb-456c-9f64-93d66c295dec",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -2,
"offsetY": 24,
"trimX": 1,
"trimY": 1,
"width": 250,
"height": 206,
"rawWidth": 256,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{ {
"ver": "1.1.0", "ver": "1.1.0",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1", "uuid": "f6f4bb21-6533-4562-8e7e-0b5ed54f2290",
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "407c61c3-c5e1-4946-8cfd-43aa5d1fc923",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{ {
"ver": "1.2.9", "ver": "1.2.9",
"uuid": "57ea7c61-9b8b-498a-b024-c98ee9124beb", "uuid": "693eb20e-8b2b-40ca-aca5-9f087d6936ac",
"asyncLoadAssets": false, "asyncLoadAssets": false,
"autoReleaseAssets": true, "autoReleaseAssets": true,
"subMetas": {} "subMetas": {}
......
This diff is collapsed.
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "f4ede462-f8d7-4069-ba80-915611c058ca", "uuid": "4d1e2036-4c4e-4ddd-8f9a-7654da4dec3d",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
import { letterData, letterWidthData, letterPosOffset } from "./letterPointData";
import { asyncDelay } from "./utils";
cc.Class({
extends: cc.Component,
properties: {
drawNode: cc.Node,
letter: 'A'
},
ctor() {
},
start() {
this.initData();
this.initListener();
},
initData() {
console.log('initData');
this._writingIdx = 0;
this.letterPosList = {};
for (const key in letterData) {
if (Object.hasOwnProperty.call(letterData, key)) {
this.letterPosList[key] = letterData[key].map(pen => {
return pen.map(pos => cc.v2(pos.x, pos.y));
});
}
}
},
initListener() {
const BtnNext = cc.find('BtnNext', this.node);
BtnNext.on('click', () => {
const posList = this.letterPosList[this.letter];
posList.push([]);
this.updateEditMode();
});
const BtnBack = cc.find('BtnBack', this.node);
BtnBack.on('click', () => {
const posList = this.letterPosList[this.letter];
const lastPen = posList[posList.length - 1];
if (lastPen && lastPen.length > 0) {
lastPen.pop();
} else {
if (posList.length > 0) {
posList.pop();
}
}
this.updateEditMode();
});
const BtnShow = cc.find('BtnShow', this.node);
BtnShow.on('click', () => {
this.showLetterAnimation();
});
const BtnSave = cc.find('BtnSave', this.node);
BtnSave.on('click', () => {
const posList = this.letterPosList[this.letter];
console.log(JSON.stringify(posList.map(list => list.map(pos => {
return { x: pos.x, y: pos.y };
}))));
});
this.drawNode.off('touchstart', this.onEditModeDrawNodeTouchStart.bind(this));
this.drawNode.off('touchmove', this.onEditModeDrawNodeTouchMove.bind(this));
this.drawNode.on('touchstart', this.onEditModeDrawNodeTouchStart.bind(this));
this.drawNode.on('touchmove', this.onEditModeDrawNodeTouchMove.bind(this));
this.updateEditMode();
},
setDrawNode(drawNode) {
this.drawNode = drawNode;
this.drawNode.off('touchstart', this.onEditModeDrawNodeTouchStart.bind(this));
this.drawNode.off('touchmove', this.onEditModeDrawNodeTouchMove.bind(this));
this.drawNode.on('touchstart', this.onEditModeDrawNodeTouchStart.bind(this));
this.drawNode.on('touchmove', this.onEditModeDrawNodeTouchMove.bind(this));
this.updateEditMode();
},
_targetPos: null,
onEditModeDrawNodeTouchStart(event) {
const touchLocation = event.getLocation();
const pos = this.drawNode.convertToNodeSpaceAR(touchLocation);
const posList = this.letterPosList[this.letter];
const targetPos = posList.flat().find(penPos => this.getDistance(penPos, pos) < 5);
if (targetPos) {
targetPos.x = pos.x;
targetPos.y = pos.y;
this._targetPos = targetPos;
} else {
if (posList.length == 0) {
posList.push([]);
}
posList[posList.length - 1].push(pos);
this._targetPos = pos;
}
this.updateEditMode();
},
onEditModeDrawNodeTouchMove(event) {
const touchLocation = event.getLocation();
const pos = this.drawNode.convertToNodeSpaceAR(touchLocation);
this._targetPos.x = pos.x;
this._targetPos.y = pos.y;
this.updateEditMode();
},
_writingIdx: 0,
async showLetterAnimation() {
this._writingIdx++;
const writingIdx = this._writingIdx;
const graphsmall = this.drawNode.getComponent(cc.Graphics);
graphsmall.clear();
const posList = this.letterPosList[this.letter];
const lineList = this.getLineList(posList);
for (const pen of lineList) {
for (const line of pen) {
if (writingIdx == this._writingIdx) {
this.drawALine(this.drawNode, line.startPos, line.endPos, cc.color(181, 39, 48));
}
await asyncDelay(0.02);
}
await asyncDelay(0.1);
}
},
updateEditMode() {
const graph = this.drawNode.getComponent(cc.Graphics)
graph.clear();
const posList = this.letterPosList[this.letter];
const lineList = this.getLineList(posList);
for (const pen of lineList) {
for (const line of pen) {
this.drawALine(this.drawNode, line.startPos, line.endPos, cc.color(0, 0, 255));
}
}
posList.forEach((pen, i) => {
const newPen = this.interpolatePos(pen, 10);
for (const pos of newPen) {
let color = cc.color(50, 50, 50);
if (i == posList.length - 1) {
color = cc.color(255, 0, 0);
}
const idx = pen.findIndex(penPos => penPos.x == pos.x && penPos.y == pos.y);
if (idx == -1) {
this.drawSmallDot(this.drawNode, pos, color);
} else {
this.drawBigCircle(this.drawNode, pos, color);
}
}
});
},
getLineList(posList) {
const lineList = [];
for (const pen of posList) {
const newPen = this.interpolatePos(pen, 10);
const newLine = [];
newPen.forEach((pos, idx) => {
if (idx < newPen.length - 1) {
newLine.push({
startPos: pos,
endPos: newPen[idx + 1]
});
}
});
if (pen.length == 1) {
newLine.push({
startPos: pen[0],
endPos: cc.v2(pen[0].x, pen[0].y + 0.001)
});
}
lineList.push(newLine);
}
return lineList;
},
interpolatePos(posList, maxLength) {
let newposList = [];
if (posList.length <= 1) {
return posList;
}
for (let i = 0; i < posList.length - 1; i++) {
const pos = posList[i];
const nextPos = posList[i + 1];
const distance = this.getDistance(pos, nextPos);
newposList.push(pos);
if (distance > maxLength) {
const middlePoint = this.getMiddlePoint(pos, nextPos);
newposList.push(middlePoint);
}
}
newposList.push(posList[posList.length - 1]);
if (newposList.length > posList.length) {
newposList = this.interpolatePos(newposList, maxLength);
}
return newposList;
},
getMiddlePoint(pos1, pos2) {
return cc.v2((pos1.x + pos2.x) / 2, (pos1.y + pos2.y) / 2);
},
getDistance(pos1, pos2) {
return pos1.sub(pos2).mag();
},
drawALine(drawNode, fromPos, toPos, color) {
const graph = drawNode.getComponent(cc.Graphics);
if (color) {
graph.strokeColor = color;
}
if (letterWidthData[this.letter]) {
graph.lineWidth = letterWidthData[this.letter];
} else {
graph.lineWidth = letterWidthData.defaultWidth;
}
graph.moveTo(fromPos.x, fromPos.y);
graph.lineTo(toPos.x, toPos.y);
graph.stroke();
},
drawBigCircle(drawNode, centerPos, color) {
const graph = drawNode.getComponent(cc.Graphics);
graph.lineWidth = 5;
graph.strokeColor = color;
graph.arc(centerPos.x, centerPos.y, 6, 0, Math.PI * 2, true);
graph.stroke();
graph.fillColor = cc.color(255, 255, 255);
graph.arc(centerPos.x, centerPos.y, 4, 0, Math.PI * 2, true);
graph.fill();
},
drawSmallDot(drawNode, centerPos, color) {
const graph = drawNode.getComponent(cc.Graphics);
graph.fillColor = color;
graph.arc(centerPos.x, centerPos.y, 3, 0, Math.PI * 2, true);
graph.fill();
},
});
{
"ver": "1.0.8",
"uuid": "8333dc53-87fd-4578-9648-2ed4a41f58de",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
export const defaultData = { export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png", letterList: [
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png", 'A', 'B', 'C', 'D', 'E', 'F', 'G',
"text": "This is a test label.", 'H', 'I', 'J', 'K', 'L', 'M', 'N',
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3" 'O', 'P', 'Q', 'R', 'S', 'T',
} 'U', 'V', 'W', 'X', 'Y', 'Z'
\ No newline at end of file ],
titleAudio:'',
debugMode: false
};
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5", "uuid": "e09b1b1d-8b06-484e-99f1-db9170ecca37",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "54bac391-3025-405d-8de4-6213b47b3733",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
cc.sys.capabilities["touches"] = true;
!(function (global) { !(function (global) {
"use strict"; "use strict";
......
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598", "uuid": "504bc64b-a6dd-4d9f-8964-cfbe0ceed5c9",
"isPlugin": true, "isPlugin": true,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
...@@ -131,224 +131,4 @@ export function btnClickAnima(btn, time=0.15, rate=1.05) { ...@@ -131,224 +131,4 @@ export function btnClickAnima(btn, time=0.15, rate=1.05) {
.to(time / 2, {scale: btn.tmpScale}) .to(time / 2, {scale: btn.tmpScale})
.start() .start()
}) })
}
export function getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
}
export function getSprNode(resName) {
const sf = cc.find('Canvas/res/img/' + resName).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
export function getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(spr);
}
})
}
export function playAudio(audioClip, cb = null) {
if (audioClip) {
const audioId = cc.audioEngine.playEffect(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
}
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
setTimeout(() => {
resolve();
}, time * 1000);
} catch (e) {
reject(e);
}
})
}
export class FireworkSettings {
baseNode; // 父节点
nodeList; // 火花节点的array
pos; // 发射点
side; // 发射方向
range; // 扩散范围
number; // 发射数量
scalseRange; // 缩放范围
constructor(baseNode, nodeList,
pos = cc.v2(0, 0),
side = cc.v2(0, 100),
range = 50,
number = 100,
scalseRange = 0
) {
this.baseNode = baseNode;
this.nodeList = nodeList;
this.pos = pos;
this.side = side;
this.range = range;
this.number = number;
this.scalseRange = scalseRange;
}
static copy(firework) {
return new FireworkSettings(
firework.baseNode,
firework.nodeList,
firework.pos,
firework.side,
firework.range,
firework.number,
);
}
}
export async function showFireworks(fireworkSettings) {
const { baseNode, nodeList, pos, side, range, number, scalseRange } = fireworkSettings;
new Array(number).fill(' ').forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
node.scale = (Math.random() - 0.5) * scalseRange + 1;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(rabbonNode, 0.3, {
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate
}, {
easing: 'quadIn'
});
cc.tween(rabbonNode)
.by(8, { y: -2000 })
.start();
cc.tween(rabbonNode)
.to(5, { scale: (Math.random() - 0.5) * scalseRange + 1 })
.start();
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: offsetX * 60 / 200 });
rabbonFall(node);
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
} catch (e) {
reject(e);
}
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
try {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
} catch (e) {
reject(e);
}
});
}
export function showTrebleFirework(baseNode, rabbonList) {
const middle = new FireworkSettings(baseNode, rabbonList);
middle.pos = cc.v2(0, -400);
middle.side = cc.v2(0, 1000);
middle.range = 200;
middle.number = 100;
middle.scalseRange = 0.4;
const left = FireworkSettings.copy(middle);
left.pos = cc.v2(-600, -400);
left.side = cc.v2(200, 1000);
const right = FireworkSettings.copy(middle);
right.pos = cc.v2(600, -400);
right.side = cc.v2(-200, 1000);
showFireworks(middle);
showFireworks(left);
showFireworks(right);
}
export function onHomeworkFinish() {
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish');
}
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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