Commit b4bec0b3 authored by LWD's avatar LWD

代码提交

parent ce304201
<div class="model-content"> <div class="model-content">
<div style="padding: 10px;">
<div style="width: 500px; margin-top: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 15px;">
答对所有题或答题满<input style="width: 50px;" type="number" nz-input [(ngModel)]="item.maxWrongNumber"
(blur)="save()">次自动结束游戏
</div>
</div>
<div style="padding: 10px;"> <div style="padding: 10px;">
<div style="width: 300px;" align='center'> <div *ngFor="let q of questionArr; let i = index;"
style="width: 500px; margin-top: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 15px;">
<div style=" display: flex; align-items: center;">
<h3 style="margin-top: 5px">question-{{i+1}}:</h3>
<app-audio-recorder style="margin-left: 10px; " [audioUrl]="q.question_audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'question_audio_url', q)"></app-audio-recorder>
<button *ngIf="q.option_arr.length < 5" nz-button nzType="primary" (click)="addOptionBtnClick(q)"
style="margin-left: 15px;">
+
</button>
<button nz-button nzType="danger" (click)="deleteQuestionBtnClick(i)" style="margin-left: 5px;">
x
</button>
</div>
<div *ngFor="let o of q.option_arr; let oi = index" style="margin-top: 5px; display: flex;">
<div style="width: 200px;">
<app-upload-image-with-preview [picUrl]="o.pic_url"
(imageUploaded)="onImageUploadSuccess($event, 'pic_url', o)">
</app-upload-image-with-preview>
</div>
<div style="margin-left: 10px">
<h4>option-{{oi+1}} : </h4>
<div style="width: 300px; margin-top: 15px;">
<span>文本: </span>
<input type="text" nz-input [(ngModel)]="o.text" (blur)="save()">
</div>
<app-audio-recorder [audioUrl]="o.audio_url" (audioUploaded)="onAudioUploadSuccess($event, 'audio_url', o)">
</app-audio-recorder>
<div style="display: flex; align-items: center; margin-top: 10px;">
<nz-switch [(ngModel)]="o.is_right" (ngModelChange)="save()"></nz-switch>
<button nz-button nzType="danger" (click)="deleteOptionBtnClick(q.option_arr, oi)"
style="margin-left: 5px;">
delete
</button>
</div>
</div>
</div>
</div>
<button nz-button nzType="dashed" (click)="addQuestionBtnClick()" style="height: 70px; margin-top: 20px;">
<i nz-icon nzType="plus-circle" nzTheme="outline"></i>
Add Question
</button>
<!-- <div style="width: 300px;" align='center'>
<span>图1: </span> <span>图1: </span>
<app-upload-image-with-preview <app-upload-image-with-preview
[picUrl]="item.pic_url" [picUrl]="item.pic_url"
...@@ -29,8 +89,8 @@ ...@@ -29,8 +89,8 @@
[audioUrl]="item.audio_url" [audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')" (audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder> ></app-audio-recorder>
</div> </div> -->
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -10,32 +10,22 @@ import { JsonPipe } from '@angular/common'; ...@@ -10,32 +10,22 @@ import { JsonPipe } from '@angular/common';
export class FormComponent implements OnInit, OnChanges, OnDestroy { export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用 // 储存数据用
saveKey = "test_001"; saveKey = "op_09";
// 储存对象 // 储存对象
item; item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { questionArr = [];
}
createShell() { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
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 = {
maxWrongNumber: 4,
question_arr: []
};
// 获取存储的数据 // 获取存储的数据
(<any>window).courseware.getData((data) => { (<any>window).courseware.getData((data) => {
...@@ -44,6 +34,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -44,6 +34,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this.item = data; this.item = data;
} }
console.log('data: ', data);
this.init(); this.init();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
...@@ -59,17 +51,49 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -59,17 +51,49 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
init() { init() {
if (!this.item.question_arr) {
this.item.question_arr = [];
}
this.questionArr = this.item.question_arr;
}
addQuestionBtnClick() {
this.questionArr.push({
question_audio_url: '',
option_arr: [ //选项 (多选)
]
})
this.save();
} }
addOptionBtnClick(question) {
question.option_arr.push({
text: '',
pic_url: '', // 图片路径
audio_url: '', //音频路径
is_right: false, //是否正确
})
this.save();
}
deleteQuestionBtnClick(index) {
this.questionArr.splice(index, 1);
this.save();
}
deleteOptionBtnClick(option, index) {
option.splice(index, 1)
this.save();
}
/** /**
* 储存图片数据 * 储存图片数据
* @param e * @param e
*/ */
onImageUploadSuccess(e, key) { onImageUploadSuccess(e, key, item) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
...@@ -77,8 +101,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -77,8 +101,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据 * 储存音频数据
* @param e * @param e
*/ */
onAudioUploadSuccess(e, key) { onAudioUploadSuccess(e, key, item) {
this.item[key] = e.url; item[key] = e.url;
this.save(); this.save();
} }
......
This diff is collapsed.
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b", "uuid": "616654f9-f059-4475-a5c8-c16f8ae28510",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.626939,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "98c9432f-962f-4d0a-8548-382b4e22b33e",
"downloadMode": 0,
"duration": 0.168,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8317732e-565e-4b5f-8021-190ff7ba427d",
"downloadMode": 0,
"duration": 0.365714,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ee4ab879-bb2e-4351-887a-d63651305737",
"downloadMode": 0,
"duration": 1.476,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ac1c4f2f-b8a5-4276-ac02-328d57c329a5",
"downloadMode": 0,
"duration": 1.188,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "2cfe31da-7088-483a-b4a4-4c385f425896",
"downloadMode": 0,
"duration": 0.972,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d7c7c1c2-b419-4848-b006-d53f8fb66071",
"downloadMode": 0,
"duration": 0.864,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "97ca1d92-03be-469f-adff-758682ad46ab",
"downloadMode": 0,
"duration": 1.188,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "7fc4afe9-9e57-42bd-a355-2f4143c11216",
"downloadMode": 0,
"duration": 0.936,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "f05c5856-4bbf-4a16-86dc-42a999b85a10",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "ddb7b5bb-8a40-4ba5-b16b-bae45b1da380",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8e5dee94-edd4-44d5-bb05-798f0d436886",
"downloadMode": 0,
"duration": 0.365714,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "6679e31f-b07a-4500-8c8d-a82c8493a4c4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "600b0af1-92f2-4139-8ae5-b53eb5cd9bec",
"subMetas": {}
}
\ No newline at end of file
{"name":"mao","imagePath":"mao_tex.png","SubTexture":[{"name":"猫01/影子","x":1,"height":66,"y":343,"width":337},{"name":"猫01/尾巴","x":1,"height":109,"y":188,"width":175},{"name":"猫01/右腿","x":178,"height":117,"y":188,"width":104},{"name":"猫01/左腿","x":1,"height":115,"y":569,"width":64},{"name":"猫01/右手","x":427,"height":122,"y":590,"width":69},{"name":"猫01/左手","x":301,"height":74,"y":590,"width":124},{"name":"猫01伸/左手伸直","x":299,"height":169,"y":172,"width":168},{"name":"猫01伸/右手伸直","x":299,"height":169,"y":1,"width":168},{"name":"猫01/身体","x":340,"height":180,"y":343,"width":122},{"name":"猫01/领带","x":1,"height":156,"y":411,"width":120},{"name":"猫01/右耳","x":155,"height":76,"y":602,"width":90},{"name":"猫01/左耳","x":67,"height":85,"y":602,"width":86},{"name":"猫01/组_1","x":1,"height":185,"y":1,"width":296},{"name":"猫01/右眼","x":1,"height":60,"y":686,"width":59},{"name":"猫01/右眉毛","x":67,"height":5,"y":595,"width":33},{"name":"猫01/左眼","x":247,"height":60,"y":666,"width":59},{"name":"猫01/左眉毛","x":247,"height":12,"y":602,"width":31},{"name":"猫01/眼镜","x":301,"height":63,"y":525,"width":170},{"name":"猫01/胡子","x":123,"height":85,"y":515,"width":176},{"name":"猫01/鼻子","x":67,"height":24,"y":569,"width":28},{"name":"猫01/嘴","x":1,"height":30,"y":299,"width":65},{"name":"猫01/帽子","x":123,"height":102,"y":411,"width":158}],"height":1024,"width":512}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "da99fa22-02ff-4d47-a6d2-34d0447f83db",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "bfb55d5d-2afe-468f-baf4-5190c9310f99",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 1024,
"platformSettings": {},
"subMetas": {
"mao_tex": {
"ver": "1.0.4",
"uuid": "d0882ce3-0831-4bc1-befd-3856e5ba0ca7",
"rawTextureUuid": "bfb55d5d-2afe-468f-baf4-5190c9310f99",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7.5,
"offsetY": 138.5,
"trimX": 1,
"trimY": 1,
"width": 495,
"height": 745,
"rawWidth": 512,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "de93dea6-de18-4f49-abf1-86bd2ea3662b",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "8549fef3-5ffa-4e88-9496-13fe5201e87d",
"subMetas": {}
}
\ No newline at end of file
{"name":"lion","imagePath":"lion_tex.png","SubTexture":[{"name":"正常-影子","x":1,"height":140,"y":2137,"width":958},{"name":"正常-身体","x":1,"height":274,"y":1344,"width":840},{"name":"正常-手上","x":1736,"height":167,"y":2452,"width":291},{"name":"正常-下巴","x":1064,"height":119,"y":2495,"width":254},{"name":"正常-嘴巴","x":992,"height":71,"y":1263,"width":211},{"name":"正常-脸","x":843,"height":374,"y":1619,"width":417},{"name":"正常-耳朵","x":711,"height":162,"y":2660,"width":351},{"name":"正常-睁眼","x":498,"height":115,"y":700,"width":209},{"name":"正常-半睁眼","x":982,"height":94,"y":2923,"width":198},{"name":"正常-闭眼","x":1544,"height":115,"y":2826,"width":198},{"name":"正常-头","x":498,"height":492,"y":850,"width":492},{"name":"正常-鼻子","x":774,"height":94,"y":2824,"width":214},{"name":"正常-手右","x":992,"height":294,"y":850,"width":232},{"name":"正常尾巴","x":1,"height":87,"y":2764,"width":554},{"name":"皱眉-影子","x":843,"height":140,"y":1995,"width":958},{"name":"皱眉-摆手胳膊","x":774,"height":96,"y":2920,"width":206},{"name":"皱眉-摆手","x":1670,"height":278,"y":1619,"width":286},{"name":"皱眉-尾巴-后","x":1607,"height":73,"y":2751,"width":419},{"name":"皱眉-身体","x":1,"height":400,"y":1,"width":739},{"name":"皱眉-正常收上","x":1733,"height":168,"y":1063,"width":292},{"name":"皱眉-脸","x":1,"height":397,"y":899,"width":420},{"name":"皱眉-正常脸","x":1,"height":444,"frameY":-39,"y":1620,"frameHeight":483,"frameX":0,"frameWidth":417,"width":417},{"name":"皱眉-耳朵","x":357,"height":163,"y":2421,"width":352},{"name":"皱眉-睁眼","x":992,"height":115,"y":1146,"width":209},{"name":"皱眉-半睁眼","x":1064,"height":115,"y":2806,"width":199},{"name":"皱眉-头发","x":1,"height":494,"y":403,"width":495},{"name":"皱眉-正常头发","x":1239,"height":492,"y":352,"width":492},{"name":"皱眉-闭眼","x":1841,"height":115,"y":1467,"width":199},{"name":"皱眉-鼻子","x":1466,"height":94,"y":2943,"width":215},{"name":"皱眉-手1","x":1733,"height":295,"y":300,"width":231},{"name":"皱眉-尾巴-前","x":1,"height":87,"y":2586,"width":557},{"name":"张嘴-影子","x":1,"height":140,"y":2279,"width":958},{"name":"张嘴-身体","x":742,"height":349,"y":1,"width":842},{"name":"张嘴-上手","x":1733,"height":169,"y":892,"width":292},{"name":"张-下巴","x":1334,"height":122,"y":2677,"width":271},{"name":"张-鼻","x":1331,"height":181,"y":2494,"width":403},{"name":"张嘴-耳朵","x":711,"height":163,"y":2495,"width":351},{"name":"张嘴-脸","x":1331,"height":213,"y":2279,"width":366},{"name":"张嘴-下巴","x":1064,"height":127,"y":2677,"width":268},{"name":"张嘴-张嘴","x":1736,"height":128,"y":2621,"width":285},{"name":"张嘴-闭嘴嘴","x":711,"height":71,"y":2421,"width":212},{"name":"张嘴-脸-中","x":1262,"height":229,"y":1619,"width":406},{"name":"张嘴-脸-上","x":961,"height":214,"y":2279,"width":368},{"name":"张嘴-睁眼","x":1334,"height":114,"y":2801,"width":208},{"name":"张嘴-半眼","x":1744,"height":114,"y":2826,"width":198},{"name":"张嘴-闭眼","x":1265,"height":114,"y":2917,"width":199},{"name":"张嘴-头发","x":1239,"height":492,"y":846,"width":492},{"name":"张嘴-鼻子","x":1744,"height":95,"y":2942,"width":214},{"name":"张嘴-手下","x":1733,"height":293,"y":597,"width":232},{"name":"张嘴-尾巴","x":1,"height":87,"y":2675,"width":555},{"name":"嚼--影子","x":961,"height":140,"y":2137,"width":958},{"name":"嚼-身体","x":992,"height":277,"y":1340,"width":847},{"name":"嚼-手-上-完整","x":1699,"height":171,"y":2279,"width":294},{"name":"lian","x":420,"height":297,"y":1620,"width":406},{"name":"嚼-脸_拷贝","x":1586,"height":297,"y":1,"width":406},{"name":"嚼-左耳","x":1,"height":163,"y":2421,"width":354},{"name":"嚼-脸-上","x":420,"height":214,"y":1919,"width":368},{"name":"嚼-睁眼","x":1803,"height":115,"y":1989,"width":210},{"name":"嚼-半睁眼","x":1841,"height":115,"y":1233,"width":199},{"name":"嚼-毛发","x":742,"height":496,"y":352,"width":495},{"name":"嚼-闭眼","x":1841,"height":115,"y":1350,"width":199},{"name":"嚼-鼻子_","x":557,"height":94,"y":2824,"width":215},{"name":"嚼-手-下","x":498,"height":295,"y":403,"width":233},{"name":"嚼-尾巴-前","x":1262,"height":88,"y":1899,"width":559},{"name":"皱眉-正常-半睁眼 ","x":982,"height":94,"y":3019,"width":198}],"height":4096,"width":2048}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "27736c82-e8ad-4ec9-9aa8-93dd4278069b",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "2.3.5",
"uuid": "c2512365-4d01-4adf-8d7f-8795350351bc",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2048,
"height": 4096,
"platformSettings": {},
"subMetas": {
"lion_tex": {
"ver": "1.0.4",
"uuid": "66dffee1-ad24-4305-8968-d8506f180d7e",
"rawTextureUuid": "c2512365-4d01-4adf-8d7f-8795350351bc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -3.5,
"offsetY": 491,
"trimX": 1,
"trimY": 1,
"width": 2039,
"height": 3112,
"rawWidth": 2048,
"rawHeight": 4096,
"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": "e012dbb9-b2af-4912-928a-4c116ab481a2",
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "15613a02-554e-4382-b722-cc551a8d7220",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"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": "c0ae4d78-ee2f-4c93-8923-048b80f19b07",
"asyncLoadAssets": false, "asyncLoadAssets": false,
"autoReleaseAssets": true, "autoReleaseAssets": false,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
This diff is collapsed.
import { onHomeworkFinish } from "../script/util";
import { defaultData } from "../script/defaultData";
cc.Class({
extends: cc.Component,
properties: {
},
// 生命周期 onLoad
onLoad() {
this.initSceneData();
this.initSize();
},
_imageResList: null,
_audioResList: null,
_animaResList: null,
initSceneData() {
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
},
_designSize: null, // 设计分辨率
_frameSize: null, // 屏幕分辨率
_mapScaleMin: null, // 场景中常用缩放(取大值)
_mapScaleMax: null, // 场景中常用缩放(取小值)
_cocosScale: null, // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
},
// 生命周期 start
start() {
let getData = this.getData.bind(this);
if (window && window.courseware) {
getData = window.courseware.getData;
}
getData((data) => {
console.log('data:', data);
this.data = data || this.getDefaultData();
this.data = JSON.parse(JSON.stringify(this.data))
this.preloadItem()
})
},
getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'scene');
return;
}
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData(func);
return;
}
func(this.getDefaultData());
},
getDefaultData() {
return defaultData;
},
preloadItem() {
this.addPreloadImage();
this.addPreloadAudio();
this.addPreloadAnima();
this.preload();
},
addPreloadImage() {
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
},
addPreloadAudio() {
this._audioResList.push({ url: this.data.audio_url });
},
addPreloadAnima() {
},
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
this.loadEnd();
if (window && window["air"]) {
window["air"].hideAirClassLoading();
}
cc.debug.setDisplayStats(false);
});
},
loadEnd() {
this.initData();
this.initAudio();
this.initView();
// this.initListener();
},
_cantouch: null,
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
},
audioBtn: null,
initAudio() {
const audioNode = cc.find('Canvas/res/audio');
const getAudioByResName = (resName) => {
return audioNode.getChildByName(resName).getComponent(cc.AudioSource);
}
this.audioBtn = getAudioByResName('btn');
},
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
},
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
},
pic1: null,
pic2: null,
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
},
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
},
curPage: null,
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
cc.audioEngine.play(this.audioBtn.clip, false, 0.8)
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
cc.audioEngine.play(this.audioBtn.clip, false, 0.5)
})
},
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
},
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
},
// update (dt) {},
// ------------------------------------------------
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;
},
getSpriteFrimeByUrl(url, cb) {
cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img)
if (cb) {
cb(spriteFrame);
}
})
},
getSprNodeByUrl(url, cb) {
const node = new cc.Node();
const spr = node.addComponent(cc.Sprite);
this.getSpriteFrimeByUrl(url, (sf) => {
spr.spriteFrame = sf;
if (cb) {
cb(node);
}
})
},
playAudioByUrl(audio_url, cb = null) {
if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
});
}
},
// ------------------------------------------
});
{
"ver": "1.1.2",
"uuid": "5c5117fc-a35a-442f-b2f5-0c431572d3c2",
"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,
......
This diff is collapsed.
{ {
"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,
......
This diff is collapsed.
{
"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
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "39d2496b-65e0-4525-8411-51d9926950b8",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"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
g.enum = {
E_Audio: {
AllPop: 0,//全部弹出
BtnCommom: 1,//按钮
CatComplete: 2,
CatHint: 3,
CatRight1: 4,
CatRight2: 5,
CatError1: 6,
CatError2: 7,
Right: 8,
Error: 9,
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "abd266cd-33d4-4036-8f6a-950c340d5fed",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"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.
{
"ver": "1.0.8",
"uuid": "8b0b794c-7f5e-4e94-82b8-d1c85bc69eb8",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "e729b387-9d1a-47a4-9d3d-076fd1ddc360",
"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.
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