Commit fde501d7 authored by asdf's avatar asdf

.

parent 173afde1
...@@ -13,9 +13,11 @@ ...@@ -13,9 +13,11 @@
</div> </div>
<div class="section-content;text-align:center "> <div class="section-content;text-align:center ">
<span style="margin-bottom: 10px;margin-left: 20px;">字母(小写,无需符号隔开。例如:ab): </span> <span style="margin-bottom: 10px;margin-left: 20px;">匹配字母(每个输入框只能输入一个字母): </span>
<input style="width: 200px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input <input style="width: 35px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(ngModel)]="contentObj.letter" (ngModelChange)="handleTextChange2($event)"> [(ngModel)]="contentObj.letter1" (ngModelChange)="handleTextChange2($event)">
<input style="width: 35px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(ngModel)]="contentObj.letter2" (ngModelChange)="handleTextChange3($event)">
</div> </div>
</div> </div>
</div> </div>
...@@ -59,9 +61,11 @@ ...@@ -59,9 +61,11 @@
<input style="width: 200px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input <input style="width: 200px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(ngModel)]="item.text" (ngModelChange)="handleTextChange($event, i)"> [(ngModel)]="item.text" (ngModelChange)="handleTextChange($event, i)">
</div> </div>
</div>
<div class="card-item-content border" style="margin-top: 10px;"> <div class="section-content;text-align:center ">
<span style="margin-bottom: 10px;margin-left: 20px;">点击选择变色字母 </span>
</div>
<div *ngFor="let word of item.text.split(''); let j = index" class="section-content;text-align:center" <div *ngFor="let word of item.text.split(''); let j = index" class="section-content;text-align:center"
style="padding: 0.5vw; display: inline-block"> style="padding: 0.5vw; display: inline-block">
<button nz-button [nzType]=getButtonType(item,j) (click)="setButtonType(item,j)"> <button nz-button [nzType]=getButtonType(item,j) (click)="setButtonType(item,j)">
...@@ -70,7 +74,6 @@ ...@@ -70,7 +74,6 @@
</div> </div>
</div> </div>
<div class="card-item-content border" style="margin-top: 10px;"> <div class="card-item-content border" style="margin-top: 10px;">
<span style="margin-left: 10px;">骨骼动画 : </span> <span style="margin-left: 10px;">骨骼动画 : </span>
<div class="section-content;text-align:center" style="margin-top: 10px"> <div class="section-content;text-align:center" style="margin-top: 10px">
......
...@@ -31,7 +31,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -31,7 +31,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
contentObj = { contentObj = {
"version": "1.1", "version": "1.1",
bgm_url: "", bgm_url: "",
letter: "", letter1: "",
letter2: "",
dataArray: [] dataArray: []
} }
/** /**
...@@ -40,7 +41,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -40,7 +41,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* shortAudio_url:'', * shortAudio_url:'',
* image_url:'', * image_url:'',
* isRight:false, * isRight:false,
* letters:[] * letterIndex:-1
* } * }
*/ */
...@@ -58,17 +59,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -58,17 +59,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
handleTextChange(text, index) { handleTextChange(text, index) {
let item = this.contentObj.dataArray[index]; let item = this.contentObj.dataArray[index];
item.text = text; item.text = text;
for (let i = 0; i < text.length; i++) {
if (!item.letters[i]) {
item.letters[i] = 0;
}
}
this.saveItem() this.saveItem()
this.refresh(); this.refresh();
} }
handleTextChange2(text) { handleTextChange2(text) {
this.contentObj.letter = text; this.contentObj.letter1 = text;
this.saveItem()
this.refresh();
}
handleTextChange3(text) {
this.contentObj.letter2 = text;
this.saveItem() this.saveItem()
this.refresh(); this.refresh();
} }
...@@ -137,16 +138,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -137,16 +138,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
setButtonType(item, j) { setButtonType(item, j) {
if (item.letters[j] == 1) { item.letterIndex = j;
item.letters[j] = 0;
} else {
item.letters[j] = 1;
}
this.save() this.save()
} }
getButtonType(item, j) { getButtonType(item, j) {
if (item.letters[j] == 1) { if (item.letterIndex == j) {
return 'primary'; return 'primary';
} }
return 'text'; return 'text';
...@@ -162,7 +159,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy { ...@@ -162,7 +159,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
} }
addItem(item) { addItem(item) {
item.push({ text: "", isRight: false, shortAudio_url: '', image_url: "", letters: {} }) item.push({ text: "", isRight: false, shortAudio_url: '', image_url: "", letterIndex: -1 })
this.saveItem(); this.saveItem();
setTimeout(() => { setTimeout(() => {
window.scrollTo(0, document.body.scrollHeight); window.scrollTo(0, document.body.scrollHeight);
......
...@@ -14,31 +14,31 @@ ...@@ -14,31 +14,31 @@
"x": [ "x": [
{ {
"frame": 0, "frame": 0,
"value": 690 "value": 613.022
}, },
{ {
"frame": 0.08333333333333333, "frame": 0.08333333333333333,
"value": 690 "value": 613.022
}, },
{ {
"frame": 0.16666666666666666, "frame": 0.16666666666666666,
"value": 900 "value": 820.305
}, },
{ {
"frame": 0.25, "frame": 0.25,
"value": 900 "value": 820.305
}, },
{ {
"frame": 0.3333333333333333, "frame": 0.3333333333333333,
"value": 1108 "value": 1026.796
}, },
{ {
"frame": 0.4166666666666667, "frame": 0.4166666666666667,
"value": 1108 "value": 1026.796
}, },
{ {
"frame": 0.5, "frame": 0.5,
"value": 1315 "value": 1233.686
} }
], ],
"active": [ "active": [
......
{
"__type__": "cc.AnimationClip",
"_name": "result1",
"_objFlags": 0,
"_native": "",
"_duration": 0.6666666666666666,
"sample": 60,
"speed": 1,
"wrapMode": 1,
"curveData": {
"paths": {
"dragonBone": {
"props": {
"position": [
{
"frame": 0,
"value": [
250,
218
],
"motionPath": [
[
-38,
266,
69,
256,
-158,
277
]
]
},
{
"frame": 0.2,
"value": [
-216.2,
260.2
],
"motionPath": [
[
-248.8,
215.5,
-261.2,
238.8,
-240.2,
199.3
],
[
-167.7,
160.7,
-232.5,
188.4,
-73.7,
127.3
]
]
},
{
"frame": 0.4166666666666667,
"value": [
-2,
110.8
],
"motionPath": []
}
],
"scale": [
{
"frame": 0,
"value": {
"__type__": "cc.Vec2",
"x": 0.1,
"y": 0.1
}
},
{
"frame": 0.4166666666666667,
"value": {
"__type__": "cc.Vec2",
"x": 1,
"y": 1
}
}
]
}
},
"lettters": {
"props": {
"scaleX": [
{
"frame": 0.5,
"value": 0,
"curve": "quintOut"
},
{
"frame": 0.6666666666666666,
"value": 1
}
],
"angle": [
{
"frame": 0.5,
"value": -45
},
{
"frame": 0.6666666666666666,
"value": 0
}
]
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "15ba7314-ae90-4f24-82d2-41fafddb7553",
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "result2",
"_objFlags": 0,
"_native": "",
"_duration": 0.21666666666666667,
"sample": 60,
"speed": 1,
"wrapMode": 1,
"curveData": {
"paths": {
"wrong": {
"props": {
"scale": [
{
"frame": 0,
"value": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
}
},
{
"frame": 0.21666666666666667,
"value": {
"__type__": "cc.Vec2",
"x": 1,
"y": 1
}
}
]
}
}
}
},
"events": []
}
\ No newline at end of file
{
"ver": "2.1.0",
"uuid": "380b1c1a-7cb2-484d-88ea-a56bdb59cb4a",
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "3b4d792e-6e1e-4a06-9f07-8368268755b7", "uuid": "dcd876c9-19be-4007-8074-069e28524108",
"downloadMode": 0, "downloadMode": 0,
"duration": 1.184417, "duration": 1.477333,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "a709194a-2a36-4d5d-9af5-3a2235e573c5",
"downloadMode": 0,
"duration": 0.6131,
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "a7e0fc53-293f-4b46-81ca-8e1c62a84a9c", "uuid": "97bbdd40-339a-4483-8495-cad59f594c4c",
"downloadMode": 0, "downloadMode": 0,
"duration": 9.351837, "duration": 4.5803,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6c517aba-74b4-4a4d-ba9c-ebcff8396b4c",
"downloadMode": 0,
"duration": 0.7079,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ccc98fd8-785a-4bc1-ac6e-1854b10ffb08",
"downloadMode": 0,
"duration": 0.333333,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "77d0d09c-25c7-46b8-86e3-ac2def488077",
"downloadMode": 0,
"duration": 0.195894,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "da6d6e4f-aa6c-4aba-8a9a-9038c82af8a3",
"downloadMode": 0,
"duration": 3.3701,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "059d55e5-a26c-4b9e-9806-b32e350a8b79",
"downloadMode": 0,
"duration": 1.7258,
"subMetas": {}
}
\ No newline at end of file
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-28.37, 0,
0, 0,
0, 0,
0, 0,
......
This diff is collapsed.
{
"ver": "1.2.7",
"uuid": "08949af0-f133-4990-8a03-95403eb67c2d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 107.44999999999999, "width": 15.35,
"height": 37.8 "height": 37.8
}, },
"_anchorPoint": { "_anchorPoint": {
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
"_enabled": true, "_enabled": true,
"_layoutSize": { "_layoutSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 107.44999999999999, "width": 15.35,
"height": 37.8 "height": 37.8
}, },
"_resize": 1, "_resize": 1,
......
This diff is collapsed.
...@@ -34,34 +34,39 @@ cc.Class({ ...@@ -34,34 +34,39 @@ cc.Class({
color = 'blue'; color = 'blue';
} }
let letter = this.data.text.charAt(i); let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) { if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter); node.getComponent('ItemLetter').setData(color, letter);
} else { } else {
node.getComponent('ItemLetter').setData('normal', letter); node.getComponent('ItemLetter').setData('normal', letter);
} }
} }
this.layerLetters.getComponent(cc.Layout).updateLayout(); this.layerLetters.getComponent(cc.Layout).updateLayout();
if (this.data.text.length <= 7) { if (this.data.text.length <= 7) {
return; return;
} }
let maxWidth = 107.45; let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width; let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){ if (!window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
}else if(scale < window.minWordScale){ } else if (scale < window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
} }
}, },
initLayerLettersScale() { initLayerLettersScale() {
this.scheduleOnce(()=>{ this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale; this.layerLetters.scale = window.minWordScale;
}) })
}, },
onClick() { onClick() {
console.log(this.data.text); if (window.isPlayEnter) {
return
}
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, },
// update (dt) {}, // update (dt) {},
}); });
...@@ -34,34 +34,39 @@ cc.Class({ ...@@ -34,34 +34,39 @@ cc.Class({
color = 'blue'; color = 'blue';
} }
let letter = this.data.text.charAt(i); let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) { if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter); node.getComponent('ItemLetter').setData(color, letter);
} else { } else {
node.getComponent('ItemLetter').setData('normal', letter); node.getComponent('ItemLetter').setData('normal', letter);
} }
} }
this.layerLetters.getComponent(cc.Layout).updateLayout(); this.layerLetters.getComponent(cc.Layout).updateLayout();
if (this.data.text.length <= 7) { if (this.data.text.length <= 7) {
return; return;
} }
let maxWidth = 107.45; let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width; let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){ if (!window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
}else if(scale < window.minWordScale){ } else if (scale < window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
} }
}, },
initLayerLettersScale() { initLayerLettersScale() {
this.scheduleOnce(()=>{ this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale; this.layerLetters.scale = window.minWordScale;
}) })
}, },
onClick() { onClick() {
console.log(this.data.text); if (window.isPlayEnter) {
return
}
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, },
// update (dt) {}, // update (dt) {},
}); });
...@@ -34,34 +34,39 @@ cc.Class({ ...@@ -34,34 +34,39 @@ cc.Class({
color = 'blue'; color = 'blue';
} }
let letter = this.data.text.charAt(i); let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) { if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter); node.getComponent('ItemLetter').setData(color, letter);
} else { } else {
node.getComponent('ItemLetter').setData('normal', letter); node.getComponent('ItemLetter').setData('normal', letter);
} }
} }
this.layerLetters.getComponent(cc.Layout).updateLayout(); this.layerLetters.getComponent(cc.Layout).updateLayout();
if (this.data.text.length <= 7) { if (this.data.text.length <= 7) {
return; return;
} }
let maxWidth = 107.45; let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width; let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){ if (!window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
}else if(scale < window.minWordScale){ } else if (scale < window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
} }
}, },
initLayerLettersScale() { initLayerLettersScale() {
this.scheduleOnce(()=>{ this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale; this.layerLetters.scale = window.minWordScale;
}) })
}, },
onClick() { onClick() {
console.log(this.data.text); if (window.isPlayEnter) {
return
}
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, },
// update (dt) {}, // update (dt) {},
}); });
...@@ -34,34 +34,39 @@ cc.Class({ ...@@ -34,34 +34,39 @@ cc.Class({
color = 'blue'; color = 'blue';
} }
let letter = this.data.text.charAt(i); let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) { if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter); node.getComponent('ItemLetter').setData(color, letter);
} else { } else {
node.getComponent('ItemLetter').setData('normal', letter); node.getComponent('ItemLetter').setData('normal', letter);
} }
} }
this.layerLetters.getComponent(cc.Layout).updateLayout(); this.layerLetters.getComponent(cc.Layout).updateLayout();
if (this.data.text.length <= 7) { if (this.data.text.length <= 7) {
return; return;
} }
let maxWidth = 107.45; let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width; let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){ if (!window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
}else if(scale < window.minWordScale){ } else if (scale < window.minWordScale) {
window.minWordScale = scale; window.minWordScale = scale;
} }
}, },
initLayerLettersScale() { initLayerLettersScale() {
this.scheduleOnce(()=>{ this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale; this.layerLetters.scale = window.minWordScale;
}) })
}, },
onClick() { onClick() {
console.log(this.data.text); if (window.isPlayEnter) {
return
}
let event = new cc.Event.EventCustom('showResult', true);
event.setUserData(this.index);
this.node.dispatchEvent(event);
}, },
// update (dt) {}, // update (dt) {},
}); });
...@@ -7,13 +7,16 @@ cc.Class({ ...@@ -7,13 +7,16 @@ cc.Class({
colorRed: '#E11C24', colorRed: '#E11C24',
colorBlue: '#0093CD', colorBlue: '#0093CD',
colorNormal: '#3C3048', colorNormal: '#3C3048',
colorRed2: '#ff1200',
}, },
onLoad() { onLoad() {
this.label = this.getComponent(cc.Label); this.label = this.getComponent(cc.Label);
}, },
setData(strColor, letter) { setData(strColor, letter, fontSize = 30) {
this.label.fontSize = fontSize;
this.label.lineHeight = fontSize;
this.label.string = letter; this.label.string = letter;
let color = this.colorNormal; let color = this.colorNormal;
if (strColor == 'yellow') { if (strColor == 'yellow') {
...@@ -26,6 +29,8 @@ cc.Class({ ...@@ -26,6 +29,8 @@ cc.Class({
color = this.colorBlue; color = this.colorBlue;
} else if (strColor == 'normal') { } else if (strColor == 'normal') {
color = this.colorNormal; color = this.colorNormal;
} else if (strColor == 'red2') {
color = this.colorRed2;
} }
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
this.node.color = new cc.Color().fromHEX(color); this.node.color = new cc.Color().fromHEX(color);
......
cc.Class({
extends: cc.Component,
properties: {
pfbLetter: cc.Prefab,
dragonBone: dragonBones.ArmatureDisplay,
},
onLoad() {
this.layerLetters = this.node.getChildByName('lettters');
this.layerRightLetters = cc.find('wrong/rightLetters/layout', this.node);
},
setData(data, index) {
this.data = data;
this.index = index;
this.item = this.data.dataArray[this.index];
this.loadDragonBone();
this.initLetters();
this.initRightLetters();
this.setRightLettersX();
this.playerResult();
},
loadDragonBone() {
this.dragonBone.dragonAtlasAsset = null;
this.dragonBone.dragonAsset = null;
this.dragonBone.armatureName = '';
var imageUrl = this.item.tex_png;
var skeUrl = this.item.ske_json;
var atlasUrl = this.item.tex_json;
imageUrl = 'http://127.0.0.1/walkingfish_tex.png';
skeUrl = 'http://127.0.0.1/walkingfish_ske.json';
atlasUrl = 'http://127.0.0.1/walkingfish_tex.json';
cc.assetManager.loadAny([{ url: atlasUrl, ext: '.txt' }, { url: skeUrl, ext: '.txt' }], (error, assets) => {
if (error) {
console.log(error)
}
else {
cc.assetManager.loadRemote(imageUrl, (error, texture) => {
if (error) {
console.log(error)
}
else {
var atlas = new dragonBones.DragonBonesAtlasAsset();
atlas._uuid = atlasUrl;
atlas.atlasJson = assets[0];
atlas.texture = texture;
var asset = new dragonBones.DragonBonesAsset();
asset._uuid = skeUrl;
asset.dragonBonesJson = assets[1];
this.dragonBone.dragonAtlasAsset = atlas;
this.dragonBone.dragonAsset = asset;
let data = asset._dragonBonesJsonData.armature[0];
if(!data){
return;
}
this.dragonBone.armatureName = data.name;
this.animationName = data.animation[0].name;
}
});
}
});
},
initLetters() {
let text = this.item.text;
for (let i = 0; i < text.length; i++) {
let node = cc.instantiate(this.pfbLetter);
node.parent = this.layerLetters;
let colorType = this.index % 4;
let color = 'normal';
if (colorType == 0) {
color = 'yellow';
} else if (colorType == 1) {
color = 'green';
} else if (colorType == 2) {
color = 'red';
} else if (colorType == 3) {
color = 'blue';
}
let letter = text.charAt(i);
if (this.item.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter, 96);
} else {
node.getComponent('ItemLetter').setData('normal', letter, 96);
}
}
this.layerLetters.getComponent(cc.Layout).updateLayout();
},
initRightLetters() {
if (/[a-z]/.test(this.data.letter1) || /[A-Z]/.test(this.data.letter1)) {
let letter = this.data.letter1.toLowerCase();
let node1 = cc.instantiate(this.pfbLetter);
node1.parent = this.layerRightLetters;
let node2 = cc.instantiate(this.pfbLetter);
node2.parent = this.layerRightLetters;
node1.getComponent('ItemLetter').setData('red2', letter, 48);
node2.getComponent('ItemLetter').setData('red2', letter.toUpperCase(), 48);
if (/[a-z]/.test(this.data.letter2) || /[A-Z]/.test(this.data.letter2)) {
let node = cc.instantiate(this.pfbLetter);
node.parent = this.layerRightLetters;
node.getComponent('ItemLetter').setData('red2', '', 48);
}
}
if (/[a-z]/.test(this.data.letter2) || /[A-Z]/.test(this.data.letter2)) {
let letter = this.data.letter2.toLowerCase();
let node1 = cc.instantiate(this.pfbLetter);
node1.parent = this.layerRightLetters;
let node2 = cc.instantiate(this.pfbLetter);
node2.parent = this.layerRightLetters;
node1.getComponent('ItemLetter').setData('red2', letter, 48);
node2.getComponent('ItemLetter').setData('red2', letter.toUpperCase(), 48);
}
this.layerRightLetters.getComponent(cc.Layout).updateLayout();
},
setRightLettersX() {
let x = this.layerLetters.children[0].x;
let x2 = x - 3;
this.layerRightLetters.parent.x = x2;
},
playerResult() {
let isRight = this.item.isRight;
if(isRight){
this.playRightResult();
}else{
this.playWrongResult();
}
},
playRightResult(){
this.playAudMove();
this.getComponent(cc.Animation).play('result1');
this.scheduleOnce(() => {
this.playAudWord(() => {
this.playDragonBone();
this.playAudRight();
this.onPlayResultDone();
});
}, 0.5)
},
playWrongResult(){
this.playAudMove();
this.getComponent(cc.Animation).play('result1');
this.scheduleOnce(() => {
this.playAudWord(() => {
this.playDragonBone();
this.playAudWrong();
this.getComponent(cc.Animation).play('result2');
this.onPlayResultDone();
});
}, 0.5)
},
playDragonBone(){
this.dragonBone.playAnimation(this.animationName, 1);
},
playAudMove() {
},
playAudWord(cb) {
this.item.shortAudio_url = 'http://127.0.0.1/imdrivingmycar.mp3'
cc.assetManager.loadRemote(this.item.shortAudio_url, null, (err, clip) => {
if (err) {
console.log(err)
return;
}
let id = cc.audioEngine.play(clip, false, 1);
let duration = cc.audioEngine.getDuration(id);
this.scheduleOnce(() => {
cb && cb();
}, duration)
});
},
playAudRight(){
},
playAudWrong(){
},
onPlayResultDone(){
cc.tween(this.node)
.to(0.3,{opacity:0})
.call(()=>{
this.node.destroy();
})
.start()
},
// node.getComponent('ItemLetter').setData('red2', letter,48);
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "1a39f83c-c8a2-40d7-99dd-2928815eab0d",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -8,12 +8,14 @@ cc.Class({ ...@@ -8,12 +8,14 @@ cc.Class({
audEnter: cc.AudioClip, audEnter: cc.AudioClip,
audTrain: cc.AudioClip, audTrain: cc.AudioClip,
layerCoach: cc.Node, layerCoach: cc.Node,
pfbLayerResult:cc.Prefab,
pfbItemCoaches: [cc.Prefab], pfbItemCoaches: [cc.Prefab],
}, },
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
this.initNodes(); this.initNodes();
this.initData();
this.initSceneData(); this.initSceneData();
this.initSize(); this.initSize();
}, },
...@@ -27,21 +29,49 @@ cc.Class({ ...@@ -27,21 +29,49 @@ cc.Class({
}, },
onEnable() { onEnable() {
this.speedLevels.on('touchend',this.onSpeedTouchend,this); this.speedLevels.on('touchend', this.onSpeedTouchend, this);
this.node.on('showResult',this.onShowResult,this);
}, },
onDisable() { onDisable() {
this.speedLevels.off('touchend',this.onSpeedTouchend,this); this.speedLevels.off('touchend', this.onSpeedTouchend, this);
this.node.off('showResult',this.onShowResult,this);
},
initData() {
// 所有全局变量 默认都是null
this.speedLevel = 1;
window.minWordScale = 1;
}, },
onSpeedTouchend(e){ onSpeedTouchend(e) {
console.log('onToggleTouchend') if (window.isPlayEnter) {
return
}
let pos = e.getLocation(); let pos = e.getLocation();
console.log(pos.x,pos.y)
pos = this.speedLevels.convertToNodeSpaceAR(pos); pos = this.speedLevels.convertToNodeSpaceAR(pos);
console.log(pos.x,pos.y) if (pos.x < -this.speedLevels.width / 6) {
this.level1.active = true;
this.level2.active = false;
this.level3.active = false;
this.speedLevel = 1;
this.restartRunTrain();
} else if (pos.x < this.speedLevels.width / 6) {
this.level1.active = false;
this.level2.active = true;
this.level3.active = false;
this.speedLevel = 2;
this.restartRunTrain();
} else {
this.level1.active = false;
this.level2.active = false;
this.level3.active = true;
this.speedLevel = 3;
this.restartRunTrain();
}
}, },
_imageResList: null, _imageResList: null,
_audioResList: null, _audioResList: null,
_animaResList: null, _animaResList: null,
...@@ -108,7 +138,7 @@ cc.Class({ ...@@ -108,7 +138,7 @@ cc.Class({
getDefaultData() { getDefaultData() {
let dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","haveCover":true,"dataArray":[{"type":"Image","text":"没 有 数 据","image_url":""},{"type":"Spine","text":"没 有 数 据","image_url":""}]}}' let dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","haveCover":true,"dataArray":[{"type":"Image","text":"没 有 数 据","image_url":""},{"type":"Spine","text":"没 有 数 据","image_url":""}]}}'
dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","dataArray":[{"text":"computer","isRight":false,"shortAudio_url":"","image_url":"","letters":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0}},{"text":"apple","isRight":true,"shortAudio_url":"","image_url":"","letters":{"0":1,"1":0,"2":0,"3":0,"4":0}},{"text":"cat","isRight":false,"shortAudio_url":"","image_url":"","letters":{"0":1,"1":0,"2":0}},{"text":"bear","isRight":true,"shortAudio_url":"","image_url":"","letters":{"0":1,"1":0,"2":0,"3":0}},{"text":"banana","isRight":true,"shortAudio_url":"","image_url":"","letters":{"0":0,"1":1,"2":0,"3":1,"4":0,"5":1}}]}}'; dataJson = '{"contentObj":{"version":"1.1","key":"DataKey_Cocos_Test","dataArray":[{"text":"apple","isRight":true,"shortAudio_url":"","image_url":"","letterIndex":0},{"text":"banana","isRight":true,"shortAudio_url":"","image_url":"","letterIndex":0},{"text":"cat","isRight":false,"shortAudio_url":"","image_url":"","letterIndex":0},{"text":"test","isRight":false,"shortAudio_url":"","image_url":"","letterIndex":0}],"letter1":"a","letter2":"b"}}';
let data = JSON.parse(dataJson); let data = JSON.parse(dataJson);
return data; return data;
}, },
...@@ -156,11 +186,12 @@ cc.Class({ ...@@ -156,11 +186,12 @@ cc.Class({
}, },
initLayerTrainPosition() { initLayerTrainPosition() {
this.layerTrain.x = cc.view.getFrameSize().width / 2 - 1320; this.layerTrain.x = cc.view.getFrameSize().width / 2 - 1220;
this.dragonBone.playAnimation('normal', -1); this.dragonBone.playAnimation('normal', -1);
}, },
playAudioEntrer() { playAudioEntrer() {
window.isPlayEnter = true;
let id = cc.audioEngine.play(this.audEnter, false, 1); let id = cc.audioEngine.play(this.audEnter, false, 1);
let duration = cc.audioEngine.getDuration(id); let duration = cc.audioEngine.getDuration(id);
this.scheduleOnce(() => { this.scheduleOnce(() => {
...@@ -186,6 +217,7 @@ cc.Class({ ...@@ -186,6 +217,7 @@ cc.Class({
}, },
playAudioTrain() { playAudioTrain() {
window.isPlayEnter = false;
cc.tween(this.layerTrain) cc.tween(this.layerTrain)
.to(0.2, { opacity: 0 }) .to(0.2, { opacity: 0 })
.call(() => { .call(() => {
...@@ -217,13 +249,21 @@ cc.Class({ ...@@ -217,13 +249,21 @@ cc.Class({
}, },
startRunTrain() { startRunTrain() {
if (window.isPlayEnter) {
return
}
this.layerTrain.x = cc.view.getFrameSize().width / 2; this.layerTrain.x = cc.view.getFrameSize().width / 2;
this.isTrainMove = true; this.isTrainMove = true;
this.dragonBone.playAnimation('move', -1); this.dragonBone.playAnimation('move', -1);
}, },
restartRunTrain() {
this.stopAudioTrain();
this.playAudioTrain();
},
checkTrainMoveDone() { checkTrainMoveDone() {
let width = this.layerCoach.width + 770; let width = this.layerCoach.width + 680;
let width2 = cc.view.getFrameSize().width; let width2 = cc.view.getFrameSize().width;
if (this.layerTrain.x < -width2 / 2 - width) { if (this.layerTrain.x < -width2 / 2 - width) {
console.log('结束'); console.log('结束');
...@@ -232,18 +272,25 @@ cc.Class({ ...@@ -232,18 +272,25 @@ cc.Class({
} }
}, },
getSpeed() {
if (this.speedLevel == 1) {
return 50;
} else if (this.speedLevel == 2) {
return 120;
} else if (this.speedLevel == 3) {
return 200;
}
},
update(dt) { update(dt) {
if (!this.isTrainMove) { if (!this.isTrainMove) {
return; return;
} }
this.layerTrain.x -= dt * 50; this.layerTrain.x -= dt * this.getSpeed();
this.checkTrainMoveDone(); this.checkTrainMoveDone();
}, },
initData() {
// 所有全局变量 默认都是null
},
initCoaches() { initCoaches() {
let l = this.data.contentObj.dataArray.length; let l = this.data.contentObj.dataArray.length;
...@@ -257,7 +304,12 @@ cc.Class({ ...@@ -257,7 +304,12 @@ cc.Class({
} }
}, },
onShowResult(event){
let index = event.getUserData();
let node = cc.instantiate(this.pfbLayerResult);
node.parent = this.node;
node.getComponent('LayerResult').setData(this.data.contentObj,index);
},
......
{ {
"last-module-event-record-time": 1605580932326, "last-module-event-record-time": 1606577997127,
"migrate-history": [ "migrate-history": [
"cloud-function" "cloud-function"
], ],
......
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