Commit fde501d7 authored by asdf's avatar asdf

.

parent 173afde1
......@@ -13,9 +13,11 @@
</div>
<div class="section-content;text-align:center ">
<span style="margin-bottom: 10px;margin-left: 20px;">字母(小写,无需符号隔开。例如:ab): </span>
<input style="width: 200px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(ngModel)]="contentObj.letter" (ngModelChange)="handleTextChange2($event)">
<span style="margin-bottom: 10px;margin-left: 20px;">匹配字母(每个输入框只能输入一个字母): </span>
<input style="width: 35px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(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>
......@@ -59,9 +61,11 @@
<input style="width: 200px; margin-bottom: 10px;margin-left: 10px;" type="text" nz-input
[(ngModel)]="item.text" (ngModelChange)="handleTextChange($event, i)">
</div>
<div class="section-content;text-align:center ">
<span style="margin-bottom: 10px;margin-left: 20px;">点击选择变色字母 </span>
</div>
<div class="card-item-content border" style="margin-top: 10px;">
<div *ngFor="let word of item.text.split(''); let j = index" class="section-content;text-align:center"
style="padding: 0.5vw; display: inline-block">
<button nz-button [nzType]=getButtonType(item,j) (click)="setButtonType(item,j)">
......@@ -70,7 +74,6 @@
</div>
</div>
<div class="card-item-content border" style="margin-top: 10px;">
<span style="margin-left: 10px;">骨骼动画 : </span>
<div class="section-content;text-align:center" style="margin-top: 10px">
......
......@@ -31,7 +31,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
contentObj = {
"version": "1.1",
bgm_url: "",
letter: "",
letter1: "",
letter2: "",
dataArray: []
}
/**
......@@ -40,7 +41,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* shortAudio_url:'',
* image_url:'',
* isRight:false,
* letters:[]
* letterIndex:-1
* }
*/
......@@ -58,17 +59,17 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
handleTextChange(text, index) {
let item = this.contentObj.dataArray[index];
item.text = text;
for (let i = 0; i < text.length; i++) {
if (!item.letters[i]) {
item.letters[i] = 0;
}
}
this.saveItem()
this.refresh();
}
handleTextChange2(text) {
this.contentObj.letter = text;
this.contentObj.letter1 = text;
this.saveItem()
this.refresh();
}
handleTextChange3(text) {
this.contentObj.letter2 = text;
this.saveItem()
this.refresh();
}
......@@ -137,16 +138,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
setButtonType(item, j) {
if (item.letters[j] == 1) {
item.letters[j] = 0;
} else {
item.letters[j] = 1;
}
item.letterIndex = j;
this.save()
}
getButtonType(item, j) {
if (item.letters[j] == 1) {
if (item.letterIndex == j) {
return 'primary';
}
return 'text';
......@@ -162,7 +159,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
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();
setTimeout(() => {
window.scrollTo(0, document.body.scrollHeight);
......
......@@ -14,31 +14,31 @@
"x": [
{
"frame": 0,
"value": 690
"value": 613.022
},
{
"frame": 0.08333333333333333,
"value": 690
"value": 613.022
},
{
"frame": 0.16666666666666666,
"value": 900
"value": 820.305
},
{
"frame": 0.25,
"value": 900
"value": 820.305
},
{
"frame": 0.3333333333333333,
"value": 1108
"value": 1026.796
},
{
"frame": 0.4166666666666667,
"value": 1108
"value": 1026.796
},
{
"frame": 0.5,
"value": 1315
"value": 1233.686
}
],
"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",
"uuid": "3b4d792e-6e1e-4a06-9f07-8368268755b7",
"uuid": "dcd876c9-19be-4007-8074-069e28524108",
"downloadMode": 0,
"duration": 1.184417,
"duration": 1.477333,
"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",
"uuid": "a7e0fc53-293f-4b46-81ca-8e1c62a84a9c",
"uuid": "97bbdd40-339a-4483-8495-cad59f594c4c",
"downloadMode": 0,
"duration": 9.351837,
"duration": 4.5803,
"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 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-28.37,
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 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 107.44999999999999,
"width": 15.35,
"height": 37.8
},
"_anchorPoint": {
......@@ -264,7 +264,7 @@
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 107.44999999999999,
"width": 15.35,
"height": 37.8
},
"_resize": 1,
......
This diff is collapsed.
......@@ -34,7 +34,7 @@ cc.Class({
color = 'blue';
}
let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) {
if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter);
} else {
node.getComponent('ItemLetter').setData('normal', letter);
......@@ -47,21 +47,26 @@ cc.Class({
}
let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){
if (!window.minWordScale) {
window.minWordScale = scale;
}else if(scale < window.minWordScale){
} else if (scale < window.minWordScale) {
window.minWordScale = scale;
}
},
initLayerLettersScale() {
this.scheduleOnce(()=>{
this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale;
})
},
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) {},
});
......@@ -34,7 +34,7 @@ cc.Class({
color = 'blue';
}
let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) {
if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter);
} else {
node.getComponent('ItemLetter').setData('normal', letter);
......@@ -47,21 +47,26 @@ cc.Class({
}
let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){
if (!window.minWordScale) {
window.minWordScale = scale;
}else if(scale < window.minWordScale){
} else if (scale < window.minWordScale) {
window.minWordScale = scale;
}
},
initLayerLettersScale() {
this.scheduleOnce(()=>{
this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale;
})
},
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) {},
});
......@@ -34,7 +34,7 @@ cc.Class({
color = 'blue';
}
let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) {
if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter);
} else {
node.getComponent('ItemLetter').setData('normal', letter);
......@@ -47,21 +47,26 @@ cc.Class({
}
let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){
if (!window.minWordScale) {
window.minWordScale = scale;
}else if(scale < window.minWordScale){
} else if (scale < window.minWordScale) {
window.minWordScale = scale;
}
},
initLayerLettersScale() {
this.scheduleOnce(()=>{
this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale;
})
},
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) {},
});
......@@ -34,7 +34,7 @@ cc.Class({
color = 'blue';
}
let letter = this.data.text.charAt(i);
if (this.data.letters[i] == 1) {
if (this.data.letterIndex == i) {
node.getComponent('ItemLetter').setData(color, letter);
} else {
node.getComponent('ItemLetter').setData('normal', letter);
......@@ -47,21 +47,26 @@ cc.Class({
}
let maxWidth = 107.45;
let scale = maxWidth / this.layerLetters.width;
if(!window.minWordScale){
if (!window.minWordScale) {
window.minWordScale = scale;
}else if(scale < window.minWordScale){
} else if (scale < window.minWordScale) {
window.minWordScale = scale;
}
},
initLayerLettersScale() {
this.scheduleOnce(()=>{
this.scheduleOnce(() => {
this.layerLetters.scale = window.minWordScale;
})
},
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) {},
});
......@@ -7,13 +7,16 @@ cc.Class({
colorRed: '#E11C24',
colorBlue: '#0093CD',
colorNormal: '#3C3048',
colorRed2: '#ff1200',
},
onLoad() {
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;
let color = this.colorNormal;
if (strColor == 'yellow') {
......@@ -26,6 +29,8 @@ cc.Class({
color = this.colorBlue;
} else if (strColor == 'normal') {
color = this.colorNormal;
} else if (strColor == 'red2') {
color = this.colorRed2;
}
this.scheduleOnce(()=>{
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({
audEnter: cc.AudioClip,
audTrain: cc.AudioClip,
layerCoach: cc.Node,
pfbLayerResult:cc.Prefab,
pfbItemCoaches: [cc.Prefab],
},
// 生命周期 onLoad
onLoad() {
this.initNodes();
this.initData();
this.initSceneData();
this.initSize();
},
......@@ -27,21 +29,49 @@ cc.Class({
},
onEnable() {
this.speedLevels.on('touchend',this.onSpeedTouchend,this);
this.speedLevels.on('touchend', this.onSpeedTouchend, this);
this.node.on('showResult',this.onShowResult,this);
},
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){
console.log('onToggleTouchend')
onSpeedTouchend(e) {
if (window.isPlayEnter) {
return
}
let pos = e.getLocation();
console.log(pos.x,pos.y)
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,
_audioResList: null,
_animaResList: null,
......@@ -108,7 +138,7 @@ cc.Class({
getDefaultData() {
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);
return data;
},
......@@ -156,11 +186,12 @@ cc.Class({
},
initLayerTrainPosition() {
this.layerTrain.x = cc.view.getFrameSize().width / 2 - 1320;
this.layerTrain.x = cc.view.getFrameSize().width / 2 - 1220;
this.dragonBone.playAnimation('normal', -1);
},
playAudioEntrer() {
window.isPlayEnter = true;
let id = cc.audioEngine.play(this.audEnter, false, 1);
let duration = cc.audioEngine.getDuration(id);
this.scheduleOnce(() => {
......@@ -186,6 +217,7 @@ cc.Class({
},
playAudioTrain() {
window.isPlayEnter = false;
cc.tween(this.layerTrain)
.to(0.2, { opacity: 0 })
.call(() => {
......@@ -217,13 +249,21 @@ cc.Class({
},
startRunTrain() {
if (window.isPlayEnter) {
return
}
this.layerTrain.x = cc.view.getFrameSize().width / 2;
this.isTrainMove = true;
this.dragonBone.playAnimation('move', -1);
},
restartRunTrain() {
this.stopAudioTrain();
this.playAudioTrain();
},
checkTrainMoveDone() {
let width = this.layerCoach.width + 770;
let width = this.layerCoach.width + 680;
let width2 = cc.view.getFrameSize().width;
if (this.layerTrain.x < -width2 / 2 - width) {
console.log('结束');
......@@ -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) {
if (!this.isTrainMove) {
return;
}
this.layerTrain.x -= dt * 50;
this.layerTrain.x -= dt * this.getSpeed();
this.checkTrainMoveDone();
},
initData() {
// 所有全局变量 默认都是null
},
initCoaches() {
let l = this.data.contentObj.dataArray.length;
......@@ -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": [
"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