Commit a9c5babd authored by Lwd's avatar Lwd

aaaa

parent c6c7de31
export class Course {
sheepfoldArr: Array<Sheepfold> = [];
sheepArr: Array<Sheep> = [];
title: 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" </div>
(imageUploaded)="onImageUploadSuccess($event, 'pic_url')"> </div>
</app-upload-image-with-preview>
</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 style="width: 300px; margin-top: 15px;"> <nz-divider nzText="类别" nzOrientation="left"></nz-divider>
<span>文本: </span> <!-- <div nz-row>
<input type="text" nz-input [(ngModel)]="item.text" (blur)="save()"> <nz-form-item>
</div> <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}}" [nzExtra]="extraTemplate" 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 style="margin-top: 5px"> </div>
<span>音频: </span> </div>
<app-audio-recorder <nz-divider nzText="选项" nzOrientation="left"></nz-divider>
[audioUrl]="item.audio_url" <div nz-row>
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')" <nz-form-item>
></app-audio-recorder> <nz-form-label [nzSpan]="6" nzFor="add-btn" nzNoColon=true>选项</nz-form-label>
</div> <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> <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>
\ 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({
selector: 'app-form', selector: 'app-form',
templateUrl: './form.component.html', templateUrl: './form.component.html',
styleUrls: ['./form.component.css'] styleUrls: ['./form.component.css']
}) })
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: '', ngOnInit() {
audio: '', this.item = new Course();
backWord: '',
backWordAudio: '', // 获取存储的数据
}); (<any>window).courseware.getData((data) => {
this.save(); if (data) {
} this.item = data;
}
removeShell(idx) { console.log(data);
this.item.wordList.splice(idx, 1); this.init();
this.save(); this.changeDetectorRef.markForCheck();
} this.changeDetectorRef.detectChanges();
this.refresh();
ngOnInit() {
}, this.saveKey);
this.item = {}; console.log(this.item);
}
// 获取存储的数据
(<any>window).courseware.getData((data) => {
ngOnChanges() {
if (data) { }
this.item = data;
} ngOnDestroy() {
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh(); init() {
if (!this.item) {
}, this.saveKey); this.item = new Course();
} }
if (this.item && (this.item.sheepfoldArr.length < 1)) {
ngOnChanges() { for (var i = 0; i < 2; i++) {
} this.addSheepfold();
}
ngOnDestroy() { }
} }
init() {
/**
} * 储存图片数据
* @param e
*/
/** onImageUploadSuccess(e, item, key) {
* 储存图片数据
* @param e item[key] = e.url;
*/ this.save();
onImageUploadSuccess(e, key) { }
this.item[key] = e.url; /**
this.save(); * 储存音频数据
} * @param e
*/
/** onAudioUploadSuccess(e, item, key) {
* 储存音频数据
* @param e item[key] = e.url;
*/ this.save();
onAudioUploadSuccess(e, key) { }
this.item[key] = e.url;
this.save();
}
/**
onWordAudioUploadSuccess(e, idx) { * 储存数据
this.item.wordList[idx].audio = e.url; */
this.save(); save() {
} (<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh();
onBackWordAudioUploadSuccess(e, idx) { console.log(this.item);
this.item.wordList[idx].backWordAudio = e.url;
this.save(); console.log(JSON.stringify(this.item));
} }
/** /**
* 储存数据 * 刷新 渲染页面
*/ */
save() { refresh() {
(<any>window).courseware.setData(this.item, null, this.saveKey); setTimeout(() => {
this.appRef.tick();
this.refresh(); }, 1);
console.log('this.item = ' + JSON.stringify(this.item)); }
}
randomChar() {
/** var x = "0123456789qwertyuioplkjhgfdsazxcvbnm";
* 刷新 渲染页面 var tmp = "";
*/ var timestamp = new Date().getTime();
refresh() { for (var i = 0; i < 6; i++) {
setTimeout(() => { tmp += x.charAt(Math.ceil(Math.random() * 100000000) % x.length);
this.appRef.tick(); }
}, 1);
} return timestamp + tmp;
}
}
\ No newline at end of file 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();
}
}
{ {
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"baseUrl": "./", "baseUrl": "./",
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,
"downlevelIteration": true, "downlevelIteration": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"importHelpers": true, "importHelpers": true,
"target": "es2015", "target": "es2015",
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
], ],
"lib": [ "lib": [
"es2018", "es2018",
"dom" "dom"
] ]
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"fullTemplateTypeCheck": true, "fullTemplateTypeCheck": true,
"strictInjectionParameters": true "strictInjectionParameters": true
} }
} }
\ No newline at end of file
This diff is collapsed.
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "24c4d28a-b9c9-4d73-8bd6-bd2101ffba7c", "uuid": "ae65e299-f876-41c4-838d-8baa87f66f83",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.556563, "duration": 0.216,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "c533d5b8-bf5c-48ce-aa60-ccc7195ec880", "uuid": "24c4d28a-b9c9-4d73-8bd6-bd2101ffba7c",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.938688, "duration": 0.556563,
"subMetas": {} "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.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.
// 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 } 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();
},
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
...@@ -6,13 +6,7 @@ var game = cc.Class({ ...@@ -6,13 +6,7 @@ var game = cc.Class({
properties: { properties: {
Item_0: { Item_0: {
default: null, default: [],
type: cc.Node,
displayName: "空节点"
},
Item_1: {
default: null,
type: cc.Node, type: cc.Node,
displayName: "预制体" displayName: "预制体"
}, },
...@@ -23,12 +17,24 @@ var game = cc.Class({ ...@@ -23,12 +17,24 @@ var game = cc.Class({
displayName: "底下内容" displayName: "底下内容"
}, },
contentArr_2: {
default: [],
type: cc.Node,
displayName: "底下内容2"
},
contentArr_1: { contentArr_1: {
default: [], default: [],
type: cc.Node, type: cc.Node,
displayName: "目标位置" displayName: "目标位置"
}, },
lb_title: {
default: null,
type: cc.Label,
displayName: "大标题"
},
// btnList: { // btnList: {
// default: [], // default: [],
// type: cc.Button, // type: cc.Button,
...@@ -48,9 +54,8 @@ var game = cc.Class({ ...@@ -48,9 +54,8 @@ var game = cc.Class({
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
// //初始化游戏 //初始化游戏
// this.initGame(); this.initGame();
this.UpdataUi();
if (window.addEventListener) { if (window.addEventListener) {
window.addEventListener('resize', this.scaleEventCallBack, false) window.addEventListener('resize', this.scaleEventCallBack, false)
} else if (window.attachEvent) { } else if (window.attachEvent) {
...@@ -65,13 +70,8 @@ var game = cc.Class({ ...@@ -65,13 +70,8 @@ var game = cc.Class({
//初始化游戏 //初始化游戏
initGame: function () { initGame: function () {
//重置游戏数据游戏数据
g.data_mgr.resGameData();
//获得数据 //获得数据
g.res_mgr.getFormData(); g.res_mgr.getFormData();
let rec1 = new cc.Rect(10, 10, 100, 50);//声明矩形区域
}, },
setAABB(Id) { setAABB(Id) {
...@@ -108,47 +108,72 @@ var game = cc.Class({ ...@@ -108,47 +108,72 @@ var game = cc.Class({
}, },
//添加节点 //添加节点
addItem2: function (Info) { addItem: function () {
for (var i = 0; i < 30; i++) { let itemArr = g.data_mgr.getSheepArr();
//for (var i = 0; i < Info.length; i++) { this.idx = this.checkNodeParent();
let newItem_0 = cc.instantiate(this.Item_0); g.data_mgr.nowNum = itemArr.length;
for (var i = 0; i < itemArr.length; i++) {
let newItem_0 = cc.instantiate(this.Item_0[this.idx]);
let newItem_1 = cc.instantiate(this.Item_1); //let newItem_1 = cc.instantiate(this.Item_1);
//更新子项 //更新子项
//var com = newItem.getComponent("item"); var com = newItem_0.getChildByName("item").getComponent("item");
//com.updateUI(Info[i]); let itemInfo = itemArr[i > 3 ? 1 : i];
//newItem.scale = this.checkScale(Info.length); com.updateUI(itemInfo);
//newItem.y = 0; newItem_0.active = true;
// newItem_1.active = true;
newItem_1.active = true; //设置类别
newItem_1.type = 1; let sheepInfo = g.data_mgr.getSheep(i > 3 ? 1 : i);
newItem_1.parent = newItem_0; newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId);
// newItem_1.parent = newItem_0;
newItem_0.parent = this.contentArr; // newItem_0.parent = this.contentArr;
// if (i == 1 && Info.length == 2) { // var idx = this.checkNodeParent(i);
// newItem.parent = this.contentArr[2];
// this.contentArr[2].active = true; newItem_0.parent = this.contentArr_2[this.idx];
// //this.contentArr[2].height *= this.checkScale(Info.length);
// }
// else {
// var num_1 = Math.ceil((i + 1) / 2) - 1;
// newItem.parent = this.contentArr[num_1]
// this.contentArr[num_1].active = true;
// this.contentArr[num_1].height == 300 && (this.contentArr[num_1].height = this.contentArr[num_1].height * this.checkScale(Info.length));
// }
}; };
}, },
//更新界面信息 //检测放到哪个节点底下
UpdataUi: function () { checkNodeParent: function () {
// //获得当前页的关卡 //获取到总列表
// var itemInfo = g.data_mgr.getPageInfo(); var itemArr = g.data_mgr.getSheepArr();
//第几排的第几个来算这个位置 //
if (itemArr.length <= 7) {
this.contentArr_2[1].active = true;
var idx = 1;
} else {
this.contentArr_2[0].active = true;
var idx = 0;
}
return idx;
},
//检查类别
checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) {
return ~~i + 1;
}
}
return -1;
},
//更新界面信息
UpdataUi: function () {
//设置大标题
this.lb_title.string = g.data_mgr.getTitle();
//设置俩个标题
this.contentArr_1[0].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(0).word;
//设置俩个标题
this.contentArr_1[1].getChildByName("title").getComponent(cc.Label).string = g.data_mgr.getSheepfold(1).word;
//重置UI界面
this.resetUI(); this.resetUI();
//添加项 //添加项
this.addItem2(); this.addItem();
// //设置上下页按钮状态 // //设置上下页按钮状态
// this.setButtonState(); // this.setButtonState();
...@@ -165,14 +190,7 @@ var game = cc.Class({ ...@@ -165,14 +190,7 @@ var game = cc.Class({
}, },
//播放音乐
PlayAudio: function () {
//获得播放路径
var path = g.data_mgr.getPlayUrl();
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url);
});
},
//游戏开始 //游戏开始
......
...@@ -11,6 +11,11 @@ cc.Class({ ...@@ -11,6 +11,11 @@ cc.Class({
type: cc.Label, type: cc.Label,
displayName: "名字" displayName: "名字"
}, },
Item_redName: {
default: null,
type: cc.Label,
displayName: "红色名字"
},
Item_photo: { Item_photo: {
default: null, default: null,
type: cc.Node, type: cc.Node,
...@@ -30,13 +35,15 @@ cc.Class({ ...@@ -30,13 +35,15 @@ cc.Class({
touchBegan: function (event) { touchBegan: function (event) {
this.isMove = false; this.isMove = false;
this.deltaPos = this.node.x + this.node.y; this.deltaPos = this.node.x + this.node.y;
// this.node.parent = g.game.inst.temp_contentArr;
}, },
//触摸移动 //触摸移动
touchMove: function (event) { touchMove: function (event) {
var posScreen = event.getLocation(); //点击事件获取位置 if (this.node.isComplent) {
var posNode = this.node.parent.convertToNodeSpaceAR(posScreen); return
}
// var posScreen = event.getLocation(); //点击事件获取位置
// var posNode = this.node.parent.convertToNodeSpaceAR(posScreen);
// var iposTouch = this.getFormatIPos(posNode); // var iposTouch = this.getFormatIPos(posNode);
var delta = event.getDelta(); var delta = event.getDelta();
this.node.x += delta.x; this.node.x += delta.x;
...@@ -46,34 +53,6 @@ cc.Class({ ...@@ -46,34 +53,6 @@ cc.Class({
if (Math.abs(this.deltaPos - deltaPos) > 10) { if (Math.abs(this.deltaPos - deltaPos) > 10) {
this.isMove = true; this.isMove = true;
} }
var contentArrPos = g.game.inst.setAABB(1);
var contentArrPos_0 = g.game.inst.setAABB(0);
// 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标
let svLeftBottomPoint = this.node.parent.convertToWorldSpaceAR(
cc.v2(
this.node.x - this.node.anchorX * this.node.width,
this.node.y - this.node.anchorY * this.node.height
)
);
// 求出 ScrollView 可视区域在世界坐标系中的矩形(碰撞盒)
var posNode_1 = cc.rect(
svLeftBottomPoint.x,
svLeftBottomPoint.y,
this.node.width,
this.node.height
);
var isIntersect_1 = contentArrPos.containsRect(posNode_1);//判断是否被包含
var isIntersect_2 = contentArrPos_0.containsRect(posNode_1);
// console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1);
if (isIntersect_1) {
console.log("被1包含" + isIntersect_1);
}
if (isIntersect_2) {
console.log("被2包含" + isIntersect_2);
}
}, },
//触摸结束 //触摸结束
...@@ -116,44 +95,57 @@ cc.Class({ ...@@ -116,44 +95,57 @@ cc.Class({
// console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1); // console.log("坐标" + svLeftBottomPoint.x + "," + svLeftBottomPoint.y + "是否包含" + isIntersect_1);
if (isIntersect_1) { if (isIntersect_1) {
if (this.node.type == 1) { if (this.node.type == 1) {
this.node.isComplent = true;
g.data_mgr.nowNum -= 1;
if (g.data_mgr.nowNum == 0) {
g.effect.inst.showEffect();
}
g.speaker.inst.play_good(); g.speaker.inst.play_good();
var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
g.game.inst.contentArr_1[1].getChildByName("db").active = true; g.game.inst.contentArr_1[1].getChildByName("db").active = true;
g.game.inst.contentArr_1[1].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1); g.game.inst.contentArr_1[1].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
this.node.parent = g.game.inst.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout"); if (g.game.inst.idx == 1) {
this.node.scale = 0.666;
this.node.x = 0;
}
this.node.parent = newItem_temp;
newItem_temp.parent = g.game.inst.contentArr_1[1].getChildByName("connent_3").getChildByName("Layout");
this.node.x = 0;
this.node.y = 0;
} }
else { else {
g.speaker.inst.play_error(); this.errorEffect();
this.node.getChildByName("red").active = true;
setTimeout(() => {
this.node.getChildByName("red").active = false;
//回到原来的位置
this.node.x = 0;
this.node.y = 0;
}, 1000)
} }
console.log("被1包含" + isIntersect_1); console.log("被1包含" + isIntersect_1);
} else } else
if (isIntersect_0) { if (isIntersect_0) {
if (this.node.type == 2) { if (this.node.type == 2) {
this.node.isComplent = true;
g.data_mgr.nowNum -= 1;
if (g.data_mgr.nowNum == 0) {
g.effect.inst.showEffect();
}
g.speaker.inst.play_good(); g.speaker.inst.play_good();
var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
g.game.inst.contentArr_1[0].getChildByName("db").active = true; g.game.inst.contentArr_1[0].getChildByName("db").active = true;
g.game.inst.contentArr_1[0].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1); g.game.inst.contentArr_1[0].getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
this.node.parent = g.game.inst.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout"); if (g.game.inst.idx == 1) {
this.node.scale = 0.666;
this.node.x = 0;
}
this.node.parent = newItem_temp;
newItem_temp.parent = g.game.inst.contentArr_1[0].getChildByName("connent_3").getChildByName("Layout");
this.node.x = 0;
this.node.y = 0;
console.log("被2包含" + isIntersect_0); console.log("被2包含" + isIntersect_0);
} }
else { else {
g.speaker.inst.play_error(); this.errorEffect();
this.node.getChildByName("red").active = true;
setTimeout(() => {
this.node.getChildByName("red").active = false;
//回到原来的位置
this.node.x = 0;
this.node.y = 0;
}, 1000)
} }
} }
else { else {
...@@ -163,6 +155,23 @@ cc.Class({ ...@@ -163,6 +155,23 @@ cc.Class({
} }
}, },
errorEffect: function () {
g.speaker.inst.play_error();
this.node.getChildByName("red").active = true;
cc.tween(this.node)
.to(0.1, { scaleY: 0.9, scaleX: 1.1 })
.to(0.15, { scaleY: 1.1, scaleX: 0.9 })
.to(0.1, { scaleY: 1, scaleX: 1 })
.start()
setTimeout(() => {
this.node.getChildByName("red").active = false;
//回到原来的位置
this.node.x = 0;
this.node.y = 0;
}, 500)
},
//触摸取消 //触摸取消
touchCancel: function (event) { touchCancel: function (event) {
//回到原来的位置 //回到原来的位置
...@@ -179,10 +188,18 @@ cc.Class({ ...@@ -179,10 +188,18 @@ cc.Class({
//初始化数据 //初始化数据
this.InitData(); this.InitData();
//是否已经完成了
this.node.isComplent = false;
}, },
//点击翻面 //点击翻面
onBtnRotate: function () { onBtnRotate: function () {
//翻面音效
g.snd_mgr.playEffect(this.eff_btn);
var scaleX = this.node.scaleY;
cc.tween(this.node) cc.tween(this.node)
.to(0.3, { scaleX: 0 }) .to(0.3, { scaleX: 0 })
.call(() => { .call(() => {
...@@ -194,19 +211,27 @@ cc.Class({ ...@@ -194,19 +211,27 @@ cc.Class({
this.Item_photo.active = false; this.Item_photo.active = false;
} }
}) })
.to(0.3, { scaleX: 1 }) .to(0.3, { scaleX: scaleX })
.start(); .start();
}, },
//初始化信息 //初始化信息
InitData: function () { InitData: function () {
this.eff_window[0].scaleX = 1; //设置图片
this.eff_window[1].scaleX = 1; g.res_mgr.getSpriteFrimeByUrl(this.itemInfo.picUrl, (list) => {
this.Item_photo.getComponent(cc.Sprite).spriteFrame = list;
this.photoScare(this.Item_photo, g.game.inst.idx);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
});
//设置名字
this.Item_name.string = this.itemInfo.word;
//设置红色名字
this.Item_redName.string = this.itemInfo.word;
}, },
//图片适配 //图片适配
photoScare: function (node, type) { photoScare: function (node, type) {
var maxNum = type == 1 ? 160 : 190; var maxNum = type == 0 ? 50 : 75;
let maxSize = Math.min(maxNum / node.height, maxNum / node.width); let maxSize = Math.min(maxNum / node.height, maxNum / node.width);
if (node.perScale == undefined) { if (node.perScale == undefined) {
node.perScale = node.scaleX; node.perScale = node.scaleX;
......
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "e5afe4a3-c16b-4f1d-acd8-c5eb68d573b3",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -2,33 +2,18 @@ ...@@ -2,33 +2,18 @@
* 数据管理器 * 数据管理器
*/ */
g.data_mgr = { g.data_mgr = {
playId: null,//播放id
playType: null,//播放类型
temPlayAudio: [],//临时的播放列表
data: null,//表所有数据 data: null,//表所有数据
pageId: 0,//页id
dragonName: null,//龙骨动画名字
lineColor: ['#2AFF51', '#FF0000', '#FF51E0', '#E5FB31', '#43DFEF', '#FFC788', ' #FFFFFF', ' #FF7474'],//线的颜色 nowNum: null,//剩余个数
_imageResList: [],//图片资源列表
_audioResList: [],//音频资源列表
_animaResList: [],//动画资源列表
//获得默认数据 //获得默认数据
getDefaultData() { getDefaultData() {
const dataJson = { const dataJson = {
"contentObj": { "sheepfoldArr": [
"pageArr": [{ { "id": "162373800016117r8ti", "word": "标题1" },
"pageInfo": [ { "id": "1623738000162o9u566", "word": "标题2" }],
{ "colorList": "1", "fontSize": 50, "fontList": "1,3", "groupLabel": "I saw a purple #11plentpp #00sdfasdf on the #10sky on the sky", "groupPic": "", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "I saw a purple #11plent on the sky #00on the sky", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "" }, { "groupLabel": "33#013#103#003", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "", "groupPic": "https://adsfs.heytapimage.com/ads-material-depot/image/9db677f693622128668326572dd8d6d2.jpg", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "", "groupPic": "", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }] "sheepArr": [{ "sheepfoldId": "162373800016117r8ti", "word": "aaa", "picUrl": "http://staging-teach.cdn.ireadabc.com/77d34b5a7f2895e9319d4485a84a1b2b.png" }, { "word": "aa", "sheepfoldId": "1623738000162o9u566", "picUrl": "http://staging-teach.cdn.ireadabc.com/be3debcc0598cfdde8a9e1ad2324743e.png" }, { "sheepfoldId": "1623738000162o9u566", "picUrl": "http://staging-teach.cdn.ireadabc.com/be3debcc0598cfdde8a9e1ad2324743e.png", "word": "fgsdfg" }, { "sheepfoldId": "162373800016117r8ti", "picUrl": "http://staging-teach.cdn.ireadabc.com/77d34b5a7f2895e9319d4485a84a1b2b.png", "word": "gdfa" }],
}, { "title": "asdfa"
"pageInfo": [
{ "groupLabel": "22222", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "33333", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "11111", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }, { "groupLabel": "11111", "groupPic": "http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png", "group_audio_url": "http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3" }]
}]
}
} }
const data = dataJson; const data = dataJson;
// const data = JSON.parse(dataJson); // const data = JSON.parse(dataJson);
...@@ -36,23 +21,29 @@ g.data_mgr = { ...@@ -36,23 +21,29 @@ g.data_mgr = {
return data; return data;
}, },
//{"contentObj":{"pageArr":[{"pageInfo":[{"a_pic_url":"http://staging-teach.cdn.ireadabc.com/4c987bc8980e235c6b6e2ae9a409cfc1.png","b_pic_url":"http://staging-teach.cdn.ireadabc.com/1ffb03273ae56047adab077dc8cc794c.png","a_audio_url":"","b_audio_url":"","groupLabel":"11111","groupPic":"http://staging-teach.cdn.ireadabc.com/2d349cf780b1fcec761a2350936183f0.png","type":"Image"},{"a_pic_url":"","b_pic_url":"","a_audio_url":"","b_audio_url":"","groupLabel":"a","groupPic":"" ,"type":"Spine","ske_json":"http://staging-teach.cdn.ireadabc.com/e48564e39f64ef92dee4309b3493652a.json","ske_json_name":"mao_ske.json","tex_json":"http://staging-teach.cdn.ireadabc.com/233b2f102f321086b70c239a1bd4ba1a.json","tex_json_name":"mao_tex.json","tex_png":"http://staging-teach.cdn.ireadabc.com/d5c00d0cf339484801dc235ed33200d0.png","tex_png_name":"mao_tex.png"}]},{"pageInfo":[]},{"pageInfo":[{"a_pic_url":"","b_pic_url":"","a_audio_url":"","b_audio_url":"","groupLabel":"","groupPic":"","type":"Spine","uploadData":"","uploadUrl":"","ske_json":"http://staging-teach.cdn.ireadabc.com/e48564e39f64ef92dee4309b3493652a.json","ske_json_name":"mao_ske.json"}]}],"title":"16516510","audio_url":"http://staging-teach.cdn.ireadabc.com/bfcd329e246551615375ce0788fc397e.mp3"},"type":"Image"} //获得标题
//重置数据 getTitle() {
resGameData() { return this.data.title;
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
this.temPlayAudio = [];
}, },
//获得播放路径 //获得表单信息
getPlayUrl: function () { getSheepfoldArr() {
for (var i in this._audioResList) { return this.data.sheepfoldArr;
var audioInfo = this._audioResList[i]; },
if (this.playId == audioInfo.typeId && this.playType == audioInfo.positionId) {
return audioInfo.url; //获得表单信息
} getSheepfold(num) {
} return this.data.sheepfoldArr[num];
},
//获得所有选项
getSheepArr() {
return this.data.sheepArr;
},
//获得单项信息
getSheep(num) {
return this.data.sheepArr[num];
}, },
//获取当前整页数据 //获取当前整页数据
...@@ -66,53 +57,14 @@ g.data_mgr = { ...@@ -66,53 +57,14 @@ g.data_mgr = {
return pageInfo[id]; return pageInfo[id];
}, },
//获得图片信息 type 1上面,type 2下面
getImgInfo: function (type) {
var list = [];
for (var i in g.data_mgr._imageResList) {
var imgList = g.data_mgr._imageResList[i];
if (imgList.positionId == type) {
list.push(imgList)
}
}
return list;
},
//处理数据 //处理数据
proGameData: function () { proGameData: function () {
// this.addPreloadImage();
// this.addPreloadAudio();
// this.addPreloadAnima();
this.preload(); this.preload();
console.log("数据处理完毕:"); console.log("数据处理完毕:");
}, },
//预加载图片
addPreloadImage() {
//btnState 0正常显示,1显示成功,2显示灰色,3连线完成
var pageInfo = this.data.contentObj.pageArr[this.pageId].pageInfo;
for (var i in pageInfo) {
this._imageResList.push({ url: pageInfo[i].groupPic, typeId: i });
}
},
//预加载声音
addPreloadAudio() {
var pageInfo = this.data.contentObj.pageArr[this.pageId].pageInfo;
for (var i in pageInfo) {
this._audioResList.push({ url: pageInfo[i].a_audio_url, typeId: i, positionId: 1, isPlay: false });
this._audioResList.push({ url: pageInfo[i].b_audio_url, typeId: i, positionId: 2, isPlay: false });
this.temPlayAudio.push(i);
}
},
addPreloadAnima() {
},
preload() { preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList); cc.assetManager.loadAny(null, null, null, (err, data) => {
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
//结束回调 //结束回调
this.loadEnd(); this.loadEnd();
if (window && window["air"]) { if (window && window["air"]) {
......
{
"ver": "2.3.5",
"uuid": "56d2223c-07c0-4715-a592-b607902a0e17",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 29,
"height": 29,
"platformSettings": {},
"subMetas": {
"Img_paper": {
"ver": "1.0.4",
"uuid": "e73ee213-5760-4419-a7ca-7ef48e02f398",
"rawTextureUuid": "56d2223c-07c0-4715-a592-b607902a0e17",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 29,
"height": 29,
"rawWidth": 29,
"rawHeight": 29,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "824dddb5-6d27-48f4-99aa-a4c123c9f848",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 308,
"height": 172,
"platformSettings": {},
"subMetas": {
"item_bg2": {
"ver": "1.0.4",
"uuid": "18f1dd43-5fb1-48a2-96ad-ec7a1b5d83e9",
"rawTextureUuid": "824dddb5-6d27-48f4-99aa-a4c123c9f848",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 154,
"height": 86,
"rawWidth": 154,
"rawHeight": 86,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment