Commit 4c9504c2 authored by LWD's avatar LWD

代码提交

parent ce304201
export class Course {
sheepfoldArr: Array<Sheepfold> = [];
sheepArr: Array<Sheep> = [];
title: string;
audio_url: string;
}
export class Sheepfold {
id: string;
word: string;
// audioUrl: string;
picUrl: string;
// /**P-图片,T-文字 */
// contentType = 'T';
}
export class Sheep {
sheepfoldId: string;
word: string;
picUrl: string;
// /**P-图片,T-文字 */
// contentType = 'T';
// audioUrl: string;
}
\ No newline at end of file
...@@ -6,30 +6,3 @@ ...@@ -6,30 +6,3 @@
height: 100%; height: 100%;
} }
.radioPaire {
float: left;
margin: 3px;
border-style: dashed;
border-color: #000;
border-width: 1px;
}
.border {
border-radius: 20px;
border-style: dashed;
padding: 20px;
margin: 20px;
/*width: 500px; */
/*//border-radius: 20px;*/
/*//border-width: 2px;*/
/*//border-color: #000000;*/
}
.border-lite {
border: 2px dashed #ddd;
border-radius: 0.5rem;
padding: 10px;
margin: 10px;
}
<div class="model-content"> <div class="model-content">
<nz-card nzTitle="课程练习内容编辑" style="margin:5vw;" nzType="inner">
<div style="padding: 10px;"> <nz-divider nzText="标题" nzOrientation="left"></nz-divider>
<div nz-row>
<div style="width: 300px;" align='center'> <div style="width: 300px; margin-top: 15px;">
<span>图1: </span> <span>点击输入标题: </span>
<app-upload-image-with-preview <input type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
[picUrl]="item.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')">
</app-upload-image-with-preview>
</div> </div>
<div style="width: 300px; margin-top: 5px;" align='center'>
<span>图2: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url_2"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url_2')">
</app-upload-image-with-preview>
</div> </div>
<div style="width: 300px; margin-top: 15px;"> <nz-form-control [nzSpan]="18">
<span>文本: </span> <span>标题声音: </span>
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()"> <app-audio-recorder [audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, item, 'audio_url')">
</app-audio-recorder>
</nz-form-control>
<nz-divider nzText="类别" nzOrientation="left"></nz-divider>
<!-- <div nz-row>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="add-btn" nzNoColon=true>龙巢</nz-form-label>
<nz-form-control [nzXs]='24' [nzSm]='12' [nzMd]='12' [nzLg]='6'>
<button nz-button nzType="dashed" class="add-btn" id="add-btn"
[disabled]="item.sheepfoldArr.length==2" (click)="addSheepfold()">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>添加
</button>
</nz-form-control>
</nz-form-item>
</div> -->
<div nz-row>
<div *ngFor="let data of item.sheepfoldArr;let i = index" style="margin: 2vw;">
<div nz-col [nzXs]='24' [nzSm]='12' [nzMd]='12' [nzLg]='9'>
<nz-card nzTitle="类别-{{i + 1}}" style="height: 150px; margin: 1vw;">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{i}}.word">标题</nz-form-label>
<nz-form-control [nzSpan]="12">
<input nz-input type="text" id="{{i}}.word" placeholder="请输入标题" [(ngModel)]="data.word"
(blur)="save()">
</nz-form-control>
</nz-form-item>
</nz-card>
</div> </div>
<div style="margin-top: 5px">
<span>音频: </span>
<app-audio-recorder
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
</div> </div>
</div>
<nz-divider nzText="选项" nzOrientation="left"></nz-divider>
<div nz-row>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="add-btn" nzNoColon=true>选项</nz-form-label>
<nz-form-control [nzXs]='24' [nzSm]='12' [nzMd]='12' [nzLg]='6'>
<button nz-button nzType="dashed" class="add-btn" id="sheep-add-btn" (click)="addSheep()">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>添加
</button>
</nz-form-control>
</nz-form-item>
</div> </div>
<div nz-row>
<div *ngFor="let data of item.sheepArr;let i = index" style="margin: 1vw;">
<div nz-col [nzXs]='24' [nzSm]='12' [nzMd]='12' [nzLg]='8'>
<nz-card nzTitle="选项-{{i + 1}}" [nzExtra]="extraTemplate1" style="height: 400px; margin: 1vw;">
<nz-form-item>
<nz-form-label [nzSpan]="6">类别</nz-form-label>
<nz-form-control [nzSpan]="12">
<nz-radio-group [(ngModel)]="data.sheepfoldId"
(ngModelChange)="setSheepfoldId($event, data)">
<label nz-radio [nzValue]="option.id"
*ngFor="let option of item.sheepfoldArr; let j = index">类别-{{j +
1}}({{option.word}})</label>
</nz-radio-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{i}}.picUrl">图片</nz-form-label>
<nz-form-control [nzSpan]="12">
<app-upload-image-with-preview style="width: 100%" [picUrl]="data.picUrl"
(imageUploaded)="onImageUploadSuccess($event, data, 'picUrl')">
</app-upload-image-with-preview>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="{{i}}.word">文本</nz-form-label>
<nz-form-control [nzSpan]="12">
<input nz-input type="text" id="{{i}}.word" placeholder="请录入内容" [(ngModel)]="data.word"
(blur)="save()">
</nz-form-control>
</nz-form-item>
</nz-card>
<ng-template #extraTemplate1>
<button style="margin: 10px;" nz-button nzType="danger" (click)="delSheep(i)">
<span>删除</span>
</button>
</ng-template>
</div>
</div>
</div>
</nz-card>
</div> </div>
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core'; import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { JsonPipe } from '@angular/common'; import { Sheepfold, Sheep, Course } from './Course';
@Component({ @Component({
...@@ -10,56 +11,52 @@ import { JsonPipe } from '@angular/common'; ...@@ -10,56 +11,52 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_001"; saveKey = "LST07";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
} constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
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 = new Course();
this.item = {};
// 获取存储的数据 // 获取存储的数据
(<any>window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
if (data) { if (data) {
this.item = data; this.item = data;
} }
console.log(data);
this.init(); this.init();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
this.refresh(); this.refresh();
}, this.saveKey); }, this.saveKey);
console.log(this.item);
} }
ngOnChanges() { ngOnChanges() {
} }
ngOnDestroy() { ngOnDestroy() {
} }
init() {
init() {
if (!this.item) {
this.item = new Course();
}
if (this.item && (this.item.sheepfoldArr.length < 1)) {
for (var i = 0; i < 2; i++) {
this.addSheepfold();
}
}
} }
...@@ -67,9 +64,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -67,9 +64,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, item, key) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
...@@ -77,29 +74,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -77,29 +74,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, item, key) {
this.item[key] = e.url;
this.save();
}
onWordAudioUploadSuccess(e, idx) { item[key] = e.url;
this.item.wordList[idx].audio = e.url;
this.save(); this.save();
} }
onBackWordAudioUploadSuccess(e, idx) {
this.item.wordList[idx].backWordAudio = e.url;
this.save();
}
/** /**
* 储存数据 * 储存数据
*/ */
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);
console.log(JSON.stringify(this.item));
} }
/** /**
...@@ -111,4 +102,65 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -111,4 +102,65 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}, 1); }, 1);
} }
randomChar() {
var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
var tmp = "";
var timestamp = new Date().getTime();
for (var i = 0; i < 6; i++) {
tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
}
return timestamp + tmp;
}
addSheepfold() {
let sheepfold = new Sheepfold();
sheepfold.id = this.randomChar();
this.item.sheepfoldArr.push(sheepfold);
this.save();
}
delSheepfold(index) {
if (index !== -1) {
this.item.sheepfoldArr.splice(index, 1);
this.save();
}
}
addSheep() {
let sheep = new Sheep();
this.item.sheepArr.push(sheep);
this.save();
}
delSheep(index) {
if (index !== -1) {
this.item.sheepArr.splice(index, 1);
this.save();
}
}
setSheepfoldId(event, item) {
item.sheepfoldId = event;
this.save();
}
setContentType(e, item) {
item['contentType'] = e;
if ("T" == e) {
item['picUrl'] = "";
}
else if ("P" == e) {
item['word'] = "";
}
this.save();
}
} }
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541", "uuid": "d3ad24ed-9c8b-421d-934f-f93f1acf3060",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b", "uuid": "1da4a1eb-1b7f-4c66-b682-afb2bb2c25f8",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.141083,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "897db934-b5dd-4d83-b482-45c92812366e",
"downloadMode": 0,
"duration": 4.179592,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6c4277af-aebb-470b-bce6-5215a5edee90",
"downloadMode": 0,
"duration": 1.688,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8e061c88-bf21-44e1-8360-13bd6085b2bf",
"downloadMode": 0,
"duration": 1.044898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "e84b4934-1211-4c2b-86c8-b0cb8ff50ab2",
"downloadMode": 0,
"duration": 0.19325,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "326dee4a-6daf-4748-86a3-acecad20fc07",
"downloadMode": 0,
"duration": 0.20898,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "4cd1a303-1f39-40a3-9127-5afcad88e2af",
"downloadMode": 0,
"duration": 3.343673,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "be885015-b019-4b28-8900-dcb6b18752f3",
"downloadMode": 0,
"duration": 1.3865,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ae65e299-f876-41c4-838d-8baa87f66f83",
"downloadMode": 0,
"duration": 0.216,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "a9d1d994-0776-4dcf-9bb7-eac5dbee2854",
"downloadMode": 0,
"duration": 3.787755,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "24c4d28a-b9c9-4d73-8bd6-bd2101ffba7c",
"downloadMode": 0,
"duration": 0.556563,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "c533d5b8-bf5c-48ce-aa60-ccc7195ec880",
"downloadMode": 0,
"duration": 0.938688,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "bf718d00-23b5-4393-8285-ef7a241b9afa",
"subMetas": {}
}
\ No newline at end of file
{"name":"正确效果","SubTexture":[{"name":"1/勾","x":1,"height":112,"y":1,"width":128},{"name":"1/星1","x":196,"height":59,"y":72,"width":57},{"name":"1/星2","x":1,"height":45,"y":192,"width":43},{"name":"1/星3","x":131,"height":64,"y":72,"width":63},{"name":"1/星4","x":201,"height":45,"y":1,"width":45},{"name":"1/星6","x":131,"height":69,"y":1,"width":68},{"name":"1/星7","x":1,"height":40,"y":115,"width":37},{"name":"1/星5","x":196,"height":57,"y":133,"width":56},{"name":"1/星8","x":78,"height":33,"y":115,"width":32},{"name":"1/星9","x":40,"height":37,"y":115,"width":36}],"imagePath":"正确效果_tex.png","height":256,"width":256}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "2a1c4975-20c7-425f-a159-537a0e44fbcb",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ff0f9fe1-277f-4d06-9a86-2b838f49e899",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 256,
"height": 256,
"platformSettings": {},
"subMetas": {
"正确效果_tex": {
"ver": "1.0.4",
"uuid": "ef344e8b-5ff7-495c-8441-7891c9963a6f",
"rawTextureUuid": "ff0f9fe1-277f-4d06-9a86-2b838f49e899",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1,
"offsetY": 9,
"trimX": 1,
"trimY": 1,
"width": 252,
"height": 236,
"rawWidth": 256,
"rawHeight": 256,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "455577d8-9fe9-451b-8bb0-241ffe3d08ef",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.1.0",
"uuid": "ac5cd74f-7311-4fae-a586-f37a87e61455",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.1.0",
"uuid": "ce2d6cce-f4b4-4f14-b57c-f026dc181a88",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "61fcc759-2eb5-4e50-a2f3-0cc3393881d8",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "4fe6019f-f84c-439f-97b8-a4cfe2ddc7ca",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "f0214b38-1b2a-41ef-aa3e-1d6949fd3b12",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "1fc51dd0-d295-4a33-8b99-adcb5978c932",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "5c0041d0-ccbd-4069-bc12-73a47695ed52",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "a777fdf7-eb0b-41df-b0f7-ada8ed99b97d",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "c020c4aa-c261-4e24-ae6e-a564a5bb6865",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "8b78aa33-0eb9-4b52-ae1b-3abacd0ee4f2",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.1.2",
"uuid": "7488de23-e223-4a1c-9a61-a332a676694e",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// 全局环境预声明
window.g = window.g || {}; // 全局
\ No newline at end of file
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5", "uuid": "a9bcccd1-c2b7-4db1-8744-3c0fcb95b824",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
/**
* eff_welldown
*/
var eff_well = cc.Class({
extends: cc.Component,
properties: {
eff_welldown: {
default: null,
type: cc.Animation,
displayName: "撒花特效"
},
},
ctor: function () {
eff_well.inst = this;
g.eff_well = eff_well;
},
//显示特效
showEff: function () {
this.node.active = true;
this.eff_welldown.play();
//播放撒花音效
g.speaker.inst.play_congratulation();
setTimeout(() => {
this.node.active = false;
}, 2000)
}
});
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "ade7af40-d56d-4087-bbc6-2888fef55353", "uuid": "872df374-a19c-4662-9d3d-1f85329b5d49",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
g.utils = {
// 范围随机
randFromTo: function (_min, _max) {
var min = parseFloat(_min);
var max = parseFloat(_max);
return (min + Math.random() * (max - min));
},
// 范围随机一个整数
// 例:1~3,返回的可能值为:1、2、3
randFromTo_Int: function (min, max) {
var val = this.randFromTo(min, max + 1 - 0.0001);
return Math.floor(val);
},
// 深拷贝
deepCopy: function (src) {
var cpy = src instanceof Array ? [] : {};
for (var i in src) {
cpy[i] = typeof src[i] === 'object' ? this.deepCopy(src[i]) : src[i];
}
return cpy;
},
//生成唯一标识
generateUUID: function () {
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
return uuid;
},
deletList: function (list, val) {
var index = list(val);
if (index > -1) {
this.splice(index, 1);
}
}
}
export function getPosByAngle(angle, len) {
const radian = angle * Math.PI / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor(180 / (Math.PI / radina) * 100) / 100; // 将弧度转换成角度
if (mx > px && my > py) {// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {// 鼠标在第二象限
angle = 360 - angle;
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
export function Between(a, b, c) {
return [a, b, c].sort((a, b) => a - b)[1];
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent) {
return new Promise((resolve, reject) => {
node.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
});
node.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof (onFrameEvent) == 'function') {
onFrameEvent(name);
}
});
node.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
}
export async function asyncPlayEffectByUrl(url, loop = false) {
return new Promise((resolve, reject) => {
cc.assetManager.loadRemote(url, (err, clip) => {
console.log(clip);
cc.audioEngine.playEffect(clip, loop);
resolve();
});
});
}
export async function jelly(node) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 })
.to(0.1, { scaleX: 1, scaleY: 1 })
.call(resolve)
.start();
});
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, time * 1000);
})
}
export async function showFireworks(baseNode, nodeList, pos = cc.v2(0, 0), side = cc.v2(0, 100), range = 50, number = 100) {
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;
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();
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);
}
\ No newline at end of file
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "f4ede462-f8d7-4069-ba80-915611c058ca", "uuid": "3cf09c30-536f-42ae-83bb-cbb3c5cd93eb",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
/**
* 适配
*/
cc.Class({
extends: cc.Component,
properties: {
UIMax: {
default: [],
type: cc.Node,
displayName: "等比放大"
},
topUI: {
default: [],
type: cc.Widget,
},
bgScaleMax: {
default: [],
type: cc.Node,
displayName: "背景适配"
},
nodeUIOffset: {
default: [],
type: cc.Node,
displayName: "节点偏移"
},
canvasView: {
default: null,
type: cc.Canvas,
displayName: "根节点"
},
isCanvas: {
default: false,
}
},
onLoad: function () { //开启适配
this.widgetList = [];
this.scheduleOnce(function () {
if (!this.isCanvas) {
this.init();
} else {
var canvaSize = this.findCanvas();
var w = (canvaSize.width) / 720;
var h = (canvaSize.height) / 1280;
this.MaxSize = w / h > 1 ? w / h : h / w;
this.setUIMax(this.MaxSize);
this.settopUI(this.MaxSize);
this.setBgScale();
this.setUiPositon();
var scene = cc.director.getScene();
var list = scene.getComponentsInChildren(cc.Widget)
for (var i in list) {
list[i].updateAlignment();
}
}
}, 0);
g.event_mgr.reg("adjustUI", () => {
this.setBgScale();
this.setUiPositon();
});
this.MaxSize = 1;
},
init: function () {
var canvaSize = this.findCanvas();
var diff = canvaSize.width / canvaSize.height;
var bili = 750 / 1334;
if (diff > bili) {
this.canvasView.fitWidth = false;
this.canvasView.fitHeight = true;
} else if (diff < bili) {
this.canvasView.fitWidth = true;
this.canvasView.fitHeight = false;
} else {
this.canvasView.fitWidth = true;
this.canvasView.fitHeight = true;
}
var w = (canvaSize.width) / 750;
var h = (canvaSize.height) / 1334;
this.MaxSize = w / h > 1 ? w / h : h / w;
g.data_mgr.MaxSize = this.MaxSize;
this.setUIMax(this.MaxSize);
this.settopUI(this.MaxSize);
this.setBgScale();
this.setUiPositon();
var scene = cc.director.getScene();
var list = scene.getComponentsInChildren(cc.Widget)
for (var i in list) {
list[i].updateAlignment();
}
},
onDestroy: function () {
g.event_pump.unReg("adjustUI");
},
settopUI: function (s) {
if (!g.data_mgr.phoneInfo) {
return;
}
var top = g.data_mgr.phoneInfo;
top = top * s;
for (var i in this.topUI) {
if (this.topUI[i].perTop == undefined) {
this.topUI[i].perTop = this.topUI[i].top;
} else {
this.topUI[i].top = this.topUI[i].perTop;
}
this.topUI[i].top += top;
console.log(this.topUI[i].top);
}
},
//背景适配
setBgScale: function () {
for (var i in this.bgScaleMax) {
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let scaleForShowAll = Math.min(
cc.view.getCanvasSize().width / this.bgScaleMax[i].width,
cc.view.getCanvasSize().height / this.bgScaleMax[i].height
);
let realWidth = this.bgScaleMax[i].width * scaleForShowAll;
let realHeight = this.bgScaleMax[i].height * scaleForShowAll;
// 2. 基于第一步的数据,再做缩放适配
this.bgScaleMax[i].scale = Math.max(
cc.view.getCanvasSize().width / realWidth,
cc.view.getCanvasSize().height / realHeight
);
}
},
//适配节点位置
setUiPositon: function () {
for (var i in this.nodeUIOffset) {
// 1. 先找到 SHOW_ALL 模式适配之后,本节点的实际宽高以及初始缩放值
let srcScaleForShowAll = Math.min(
cc.view.getCanvasSize().width / 1280,
cc.view.getCanvasSize().height / 720
);
let realWidth = 1280 * srcScaleForShowAll;
let realHeight = 720 * srcScaleForShowAll;
// 2. 基于第一步的数据,再做节点宽高重置
this.nodeUIOffset[i].width = 1280 * (cc.view.getCanvasSize().width / realWidth);
this.nodeUIOffset[i].height = 720 * (cc.view.getCanvasSize().height / realHeight);
}
},
setUIMax: function (size) {
for (var i in this.UIMax) {
if (this.UIMax[i].perScale == undefined) {
this.UIMax[i].perScale = this.UIMax[i].scaleX;
} else {
this.UIMax[i].scaleX = this.UIMax[i].perScale;
this.UIMax[i].scaleY = this.UIMax[i].perScale;
}
this.UIMax[i].scaleX *= size;
this.UIMax[i].scaleY *= size;
}
},
findCanvas: function () {
if (cc.sys.isNative) {
return {
width: cc.view.getFrameSize().width,
height: cc.view.getFrameSize().height
};
} else {
return {
width: cc.game.canvas.clientWidth,
height: cc.game.canvas.clientHeight
};
}
}
});
{
"ver": "1.0.8",
"uuid": "0e963fa9-ea21-492e-a9ae-92a33a8c7456",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "b62d4b1c-d7ed-4c6e-8f1f-f8695a087353",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
cc.Class({
extends: cc.Component,
properties: {
setAnswerId: {
default: "",
displayName: "类型ID"
},
labTitle: {
default: null,
type: cc.Label,
displayName: "标题"
},
},
onLoad() {
this.labTitle.string = g.data_mgr.getSheepfold(this.setAnswerId).word;
this.Event();
},
Event() {
this.m_uuid = g.utils.generateUUID(); //生成一个唯一Id
g.event_mgr.reg("reSetGame", () => {
this.node.getChildByName("Layout").removeAllChildren()
}, this.m_uuid);
},
start() {
},
setAABB() {
var node = this.node
let svLeftBottomPoint = node.parent.convertToWorldSpaceAR(
cc.v2(
node.x - node.width / 2,
node.y - node.height / 2,
)
);
console.log("世界坐标目标点" + svLeftBottomPoint);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
let svBBoxRect = cc.rect(
svLeftBottomPoint.x,
svLeftBottomPoint.y,
node.width,
node.height
);
// console.log(Id + ":" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y);
return svBBoxRect
},
});
{
"ver": "1.0.8",
"uuid": "ac02de71-2a2f-4afb-abfa-6ac661b996b7",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { asyncDelay, RandomInt, showFireworks } from "../common/utils";
var effect = cc.Class({
extends: cc.Component,
properties: {
},
ctor: function () {
effect.inst = this;
g.effect = effect;
},
showEffect: function () {
const bg = cc.find('Canvas/bg/connent');
this.showAllFirework(bg, cc.find('paperBase').children);
g.speaker.inst.play_congratulation();
},
showEffect2: function () {
const bg = cc.find('Canvas/bg/connent');
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(0, -400), cc.v2(0, 1000), 200, 200
);
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(-600, -400), cc.v2(200, 1000), 200, 200
);
showFireworks(bg, cc.find('RibbonNodeBase').children, cc.v2(600, -400), cc.v2(-200, 1000), 200, 200
);
},
async showOneFirework(pos, parentNode, nodeList) {
for (let i = 0; i < 3; i++) {
this.showFirework(pos, parentNode, nodeList, 200, 200, 15);
await asyncDelay(0.1);
}
},
async showAllFirework(parentNode, nodeList) {
for (let i = 0; i < 6; i++) {
this.showFirework(cc.v2(0, -parentNode.height / 2), parentNode, nodeList, parentNode.width * 2 / 3, parentNode.height * 1.3);
await asyncDelay(0.1);
}
},
showFirework(pos, parentNode, nodeList, width = 200, height = 200, number = 30) {
for (let i = 0; i < number; i++) {
const quad = this.createQuads(pos, parentNode, nodeList);
const targetX = RandomInt(width / 2, -width / 2);
const targetY = RandomInt(height);
cc.tween(quad)
.by(0.5, { x: targetX })
.by(3, { x: targetX * 2 })
.start();
cc.tween(quad)
.by(0.5, { y: targetY }, { easing: 'quadOut' })
.to(4, { y: -parentNode.height * 2 }, { easing: 'quadIn' })
.removeSelf()
.start();
cc.tween(quad)
.delay(1)
.to(1.5, { opacity: 0 })
.start();
}
},
createQuads(pos, parentNode, nodeList) {
const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
quadBase.x = pos.x;
quadBase.y = pos.y;
quadBase.z = pos.z;
quadBase.angle = RandomInt(180);
quadBase.parent = parentNode;
const quad = quadBase.getChildByName('quad');
quad.x = 0;
quad.y = 0;
quad.angle = RandomInt(180);
const paper = quad.getChildByName('paper');
paper.scaleX = Math.random() * 0.5 + 0.5;
paper.scaleY = Math.random() * 0.5 + 0.5;
quadBase.scaleX = Math.random();
cc.tween(quadBase)
.to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 })
.call(() => {
const time = Math.random() * 0.2;
cc.tween(quadBase)
.to(0.1 + time, { scaleX: -1 })
.to(0.1 + time, { scaleX: 1 })
.union()
.repeatForever()
.start();
})
.start();
return quadBase;
},
});
{
"ver": "1.0.8",
"uuid": "0df3ab6c-e62c-47f8-a791-56073deccaed",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
var TouchDragger = cc.Class({
extends: cc.Component,
properties: {
MaxHeight: {
default: "",
displayName: "最大高度"
},
MaxWidth: {
default: "",
displayName: "最大宽度"
},
grid: {
default: null,
type: cc.Prefab,
displayName: "格子预制体"
},
hGrid: {
default: "",
displayName: "单个高度"
},
wGrid: {
default: "",
displayName: "单个宽度"
}
},
ctor: function () {
TouchDragger.inst = this;
g.TouchDragger = TouchDragger;
},
onLoad: function () {
this.arMap = [];
this.isEnd = false;
//是否是第一次执行移动
this.isFirstMove = true;
//初始化格子数据
this.initGridInfo(g.data_mgr.challengeData.IngredientList);
},
start: function () {
this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchCancel, this);
},
//触摸开始
touchBegan: function (event) {
if (this.isEnd) return;
this.isMove = false;
var posScreen = event.getLocation();//点击事件获取位置
var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
this.iposBegan = this.getFormatIPos(posNode);
this.iposMove = cc.v2(-1, -1);
if (this.iposBegan.x == -1) return;
var ndBegan = this.arMap[this.iposBegan.y][this.iposBegan.x];
if (!ndBegan.active) {
return;
}
ndBegan.runAction(this.getAction("scale"));
ndBegan.zIndex = 1;
this.deltaPos = ndBegan.x + ndBegan.y;
},
//触摸移动
touchMove: function (event) {
if (this.isEnd || (GodGuide && GodGuide.getTask())) return;
if (this.iposBegan.x == -1) return;
var posScreen = event.getLocation(); //点击事件获取位置
var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
var iposTouch = this.getFormatIPos(posNode);
if (this.isFirstMove == true) {
this.iposBegan = this.getFormatIPos(posNode);
this.isFirstMove = false;
};
var delta = event.getDelta();
var ndBegan = this.arMap[this.iposBegan.y][this.iposBegan.x];
if (!ndBegan.active) {
return;
}
ndBegan.x += delta.x;
ndBegan.y += delta.y;
var deltaPos = ndBegan.x + ndBegan.y;
if (Math.abs(this.deltaPos - deltaPos) > 10) {
this.isMove = true;
}
this.iposMove = iposTouch;
},
//触摸结束
touchEnd: function (event) {
if (this.isEnd) return;
if (this.iposBegan.x == -1) return;
var ndBegan = this.arMap[this.iposBegan.y][this.iposBegan.x];
if (!ndBegan.active) {
this.isMove = false;
return;
}
if (!this.isMove) {
cc.log("点击了");
ndBegan.stopAllActions();
ndBegan.setScale(1);
ndBegan.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposBegan)));
ndBegan.callback && ndBegan.callback();
return
}
this.isFirstMove = true;
this.arMap[this.iposBegan.y][this.iposBegan.x].zIndex = 0;
if (this.iposBegan.x == -1 || this.iposMove.x >= 0 && this.iposMove.y >= 0) {
ndBegan.stopAllActions();
ndBegan.setScale(1);
ndBegan.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposMove)));
if (this.iposMove.x != -1) {
var ndMove = this.arMap[this.iposMove.y][this.iposMove.x];
ndMove.stopAllActions();
ndMove.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposBegan)));
this.arMap[this.iposMove.y][this.iposMove.x] = ndBegan;
this.arMap[this.iposBegan.y][this.iposBegan.x] = ndMove;
}
} else {
ndBegan.stopAllActions();
ndBegan.setScale(1);
ndBegan.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposBegan)));
if (this.iposMove.x != -1) {
var ndMove = this.arMap[this.iposMove.y][this.iposMove.x];
ndMove.stopAllActions();
ndMove.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposMove)));
}
}
this.isMove = false;
},
//触摸取消
touchCancel: function (event) {
this.arMap[this.iposBegan.y][this.iposBegan.x].zIndex = 0;
var ndBegan = this.arMap[this.iposBegan.y][this.iposBegan.x];
ndBegan.stopAllActions();
ndBegan.setScale(1);
ndBegan.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposBegan)));
if (this.iposMove.x != -1) {
var ndMove = this.arMap[this.iposMove.y][this.iposMove.x];
ndMove.stopAllActions();
ndMove.runAction(cc.moveTo(0.1, this.getGridOriginPos(this.iposMove)));
}
this.isMove = false;
},
//初始化格子数据
initGridInfo: function (list) {
for (var i = this.MaxHeight - 1; i >= 0; --i) {
this.arMap[i] = [];
for (var j = 0; j < this.MaxWidth; ++j) {
var ndGrid = cc.instantiate(this.grid);
ndGrid.parent = this.node;
//获得节点的位置
ndGrid.position = this.getGridOriginPos(cc.v2(j, i));
this.arMap[i][j] = ndGrid;
// ndGrid.getComponent("grid").updateUI(3, 30);
var num = (this.MaxHeight - i - 1) * this.MaxWidth + j;
ndGrid.active = list[num] != undefined;
ndGrid.getComponent("grid").updateUI(list[num], 0);
}
}
},
//获得动作
getAction: function (name) {
if (name === "scale") {
return cc.repeatForever(cc.sequence(cc.scaleTo(0.15, 1.3)
, cc.scaleTo(0.3, 1)));
}
else if (name === "rotate") {
return cc.repeatForever(cc.sequence(cc.rotateBy(0.15, 30), cc.rotateBy(0.3, -60), cc.rotateBy(0.15, 30)));
}
return null;
},
//获得直角坐标
getFormatIPos: function (pos) {
var ipos = cc.v2(Math.floor((pos.x - this.node.x) / this.wGrid), Math.floor((pos.y - this.node.y) / this.hGrid));
if (ipos.x < 0 || ipos.x >= this.MaxWidth || ipos.y < 0 || ipos.y >= this.MaxHeight) {
ipos.x = -1;
}
return ipos;
},
//获得格子起始坐标
getGridOriginPos: function (ipos) {
return cc.v2(10 + (ipos.x + 0.5) * this.wGrid, 10 + (ipos.y + 0.5) * this.hGrid);
},
});
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "ccc66642-cf0e-4b1b-ae3d-c4b18f4fe53a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ 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.
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