Commit 120594e1 authored by 杨一航's avatar 杨一航

feat: 优化调整

parent 3e3e3954
This diff is collapsed.
import { asyncDelay, asyncPlayDragonBoneAnimation, getSpriteFrimeByUrl, onHomeworkFinish } from "../script/util_DG23"; import { asyncDelay, asyncPlayDragonBoneAnimation, getSpriteFrimeByUrl, goNextPage, onHomeworkFinish } from "../script/util_DG23";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG23"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG23";
import Boy from "../script/items/boy_DG23"; import Boy from "../script/items/boy_DG23";
import TouchLogic from "../script/items/TouchLogic_DG23"; import TouchLogic from "../script/items/TouchLogic_DG23";
...@@ -70,6 +70,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -70,6 +70,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio() { addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源 // TODO 根据自己的配置预加载音频资源
this.data.audio_url_guide = this.data.global_setting[0].audio_arr[0].value;
this.data.audio_url_success = this.data.global_setting[0].audio_arr[1].value;
this._audioResList.push({ url: this.data.audio_url_guide }); this._audioResList.push({ url: this.data.audio_url_guide });
this._audioResList.push({ url: this.data.audio_url_success }); this._audioResList.push({ url: this.data.audio_url_success });
...@@ -80,6 +82,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -80,6 +82,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async onLoadEnd() { async onLoadEnd() {
cc.log(JSON.stringify(this.data, null, 2))
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考 // TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initBg(); this.initBg();
this.initData(); this.initData();
...@@ -131,6 +135,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -131,6 +135,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
const bgNode = cc.find('Canvas/bg'); const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax; bgNode.scale = this._mapScaleMax;
this.btn_quit.getChildByName("lb").getComponent(cc.Label).string = this.data.global_setting[0].text_arr[0].value
this.boyNode.active = false; this.boyNode.active = false;
cc.tween(this.btn_start).to(0.3, { scale: 1.1 }).to(0.2, { scale: 1 }).delay(1).union().repeatForever().start(); cc.tween(this.btn_start).to(0.3, { scale: 1.1 }).to(0.2, { scale: 1 }).delay(1).union().repeatForever().start();
cc.tween(this.btn_quit).to(0.3, { scale: 1.1 }).to(0.2, { scale: 1 }).delay(1).union().repeatForever().start(); cc.tween(this.btn_quit).to(0.3, { scale: 1.1 }).to(0.2, { scale: 1 }).delay(1).union().repeatForever().start();
...@@ -141,14 +146,10 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -141,14 +146,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_next.on("click", this.onClickNext, this) this.btn_next.on("click", this.onClickNext, this)
this.btn_restart.on("click", this.initView, this) this.btn_restart.on("click", this.initView, this)
this.btn_quit.on("click", () => { this.btn_quit.on("click", () => {
this.playLocalAudio("btn") this.playLocalAudio("btn")
this.playLocalAudio("btn") goNextPage();
if (!cc.find('middleLayer')) {
console.log("==点击了下一页按钮==")
return;
}
const middleLayer = cc.find('middleLayer').getComponent('middleLayer');
middleLayer.goNextPage(); // 跳转到下一页
}, this) }, this)
} }
...@@ -235,7 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -235,7 +236,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
await asyncDelay(1); await asyncDelay(1);
await this.leftAcation(); await this.leftAcation();
await this.rightAction(); await this.rightAction();
await asyncDelay(1); await asyncDelay(0.1);
await this.playResultAni(); await this.playResultAni();
this.btn_next.active = true; this.btn_next.active = true;
...@@ -243,11 +244,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -243,11 +244,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
async rightAction() { async rightAction() {
if (this.rightStr) { if (this.rightStr || this.rightPic) {
this.rightGuideNode.active = true; this.rightGuideNode.active = true;
this.rightGuideNode.opacity = this.roundIndex == 0 ? 255 : 0; this.rightGuideNode.opacity = this.roundIndex == 0 ? 255 : 0;
this.rightGuideNode.getComponent(TouchLogic).checkAnge(145, () => { this.rightGuideNode.getComponent(TouchLogic).checkAnge(145, () => {
this._touchRight && this._touchRight(); this._touchRight && this._touchRight();
this._touchRight = null;
this.playLocalAudio("click"); this.playLocalAudio("click");
this.rightGuideNode.active = false; this.rightGuideNode.active = false;
}) })
...@@ -272,26 +274,28 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -272,26 +274,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.rightGuideNode.opacity = 0; this.rightGuideNode.opacity = 0;
done = true; done = true;
this.unschedule(func) this.unschedule(func)
cc.log("check done"); cc.log("check done right");
await asyncPlayDragonBoneAnimation(this.rightBox, "normal", 1); await asyncPlayDragonBoneAnimation(this.rightBox, "normal", 1);
this.banNode.x = -260; this.banNode.x = -260;
asyncPlayDragonBoneAnimation(this.candleNode, "fire", -1); asyncPlayDragonBoneAnimation(this.candleNode, "fire", -1);
this.playLocalAudio("lotspp") this.playLocalAudio("lotspp")
this.minpao.active = true; this.minpao.active = true;
this.playLocalAudio("phappy");
await asyncPlayDragonBoneAnimation(this.ppNode, "right", 1); await asyncPlayDragonBoneAnimation(this.ppNode, "right", 1);
asyncPlayDragonBoneAnimation(this.ppNode, "normal", -1); asyncPlayDragonBoneAnimation(this.ppNode, "normal", -1);
this.playLocalAudio("phappy");
await asyncDelay(1);
this.minpao.active = false; this.minpao.active = false;
} }
} }
async leftAcation() { async leftAcation() {
if (this.letfStr) { if (this.letfStr || this.letfPic) {
this.leftGuideNode.active = true; this.leftGuideNode.active = true;
this.leftGuideNode.opacity = this.roundIndex == 0 ? 255 : 0; this.leftGuideNode.opacity = this.roundIndex == 0 ? 255 : 0;
this.leftGuideNode.getComponent(TouchLogic).checkAnge(30, () => { this.leftGuideNode.getComponent(TouchLogic).checkAnge(30, () => {
this._touchRight && this._touchRight(); this._touchRight && this._touchRight();
this._touchRight = null;
this.playLocalAudio("click"); this.playLocalAudio("click");
this.leftGuideNode.active = false; this.leftGuideNode.active = false;
}) })
...@@ -316,16 +320,17 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -316,16 +320,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.unschedule(func) this.unschedule(func)
done = true; done = true;
this.leftGuideNode.opacity = 0; this.leftGuideNode.opacity = 0;
cc.log("check done"); cc.log("check done left");
await asyncPlayDragonBoneAnimation(this.leftBox, "normal", 1); await asyncPlayDragonBoneAnimation(this.leftBox, "normal", 1);
this.banNode.x = -260; this.banNode.x = -260;
asyncPlayDragonBoneAnimation(this.candleNode, "fire", -1); asyncPlayDragonBoneAnimation(this.candleNode, "fire", -1);
this.playLocalAudio("lotspp") this.playLocalAudio("lotspp")
this.minpao.active = true; this.minpao.active = true;
this.playLocalAudio("phappy");
await asyncPlayDragonBoneAnimation(this.ppNode, "right", 1); await asyncPlayDragonBoneAnimation(this.ppNode, "right", 1);
asyncPlayDragonBoneAnimation(this.ppNode, "normal", -1); asyncPlayDragonBoneAnimation(this.ppNode, "normal", -1);
this.playLocalAudio("phappy");
await asyncDelay(1);
this.minpao.active = false; this.minpao.active = false;
} }
...@@ -366,58 +371,85 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -366,58 +371,85 @@ export default class SceneComponent extends MyCocosSceneComponent {
initRoudData() { initRoudData() {
let data = this.data.group_arr[this.roundIndex]; let data = this.data.group_arr[this.roundIndex];
this.resultStr = data.text_arr[0].value; this.resultStr = data.text_arr[0]?.value;
this.resultPic = data.image_arr[0].value; this.resultPic = data.image_arr[0]?.value;
this.rightStr = data.group_arr[0]?.text_arr[0]?.value; this.rightStr = data.group_arr[0]?.text_arr[1]?.value;
this.letfStr = data.group_arr[0]?.text_arr[1]?.value; this.letfStr = data.group_arr[0]?.text_arr[0]?.value;
this.rightPic = data.group_arr[0]?.image_arr[0]?.value; this.rightPic = data.group_arr[0]?.image_arr[1]?.value;
this.letfPic = data.group_arr[0]?.image_arr[1]?.value; this.letfPic = data.group_arr[0]?.image_arr[0]?.value;
cc.log("=============data===============")
cc.log("resultStr:" + this.resultStr)
cc.log("resultPic:" + this.resultPic)
cc.log("rightStr:" + this.rightStr)
cc.log("letfStr:" + this.letfStr)
cc.log("rightPic:" + this.rightPic)
cc.log("letfPic:" + this.letfPic)
} }
initRoundView() { initRoundView() {
if (this.resultStr) { if (this.resultStr) {
this.bigpao.getChildByName("root").getChildByName("lb").active = true;
this.bigpao.getChildByName("root").getChildByName("lb").getComponent(cc.Label).string = this.resultStr;
this.bigpao.getChildByName("lb").getComponent(cc.Label).string = this.resultStr; } else {
this.bigpao.getChildByName("root").getChildByName("lb").active = false;
} }
if (this.resultPic) { if (this.resultPic) {
this.bigpao.getChildByName("root").getChildByName("icon").active = true
getSpriteFrimeByUrl(this.rightPic, (spf) => { this.bigpao.getChildByName("root").getChildByName("icon").getComponent(cc.Sprite).spriteFrame = null;
this.bigpao.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spf; getSpriteFrimeByUrl(this.resultPic, (spf) => {
this.bigpao.getChildByName("root").getChildByName("icon").getComponent(cc.Sprite).spriteFrame = spf;
}) })
} else {
this.bigpao.getChildByName("root").getChildByName("icon").active = false
} }
if (this.rightStr) { if (this.rightStr) {
this.rightBox.active = true; this.rightBox.active = true;
this.rightStrNode.active = true;
this.rightStrNode.getComponent(cc.Label).string = this.rightStr; this.rightStrNode.getComponent(cc.Label).string = this.rightStr;
} else {
this.rightStrNode.active = false;
} }
if (this.letfStr) { if (this.letfStr) {
this.leftBox.active = true; this.leftBox.active = true;
this.leftStrNode.active = true;
this.leftStrNode.getComponent(cc.Label).string = this.letfStr; this.leftStrNode.getComponent(cc.Label).string = this.letfStr;
} else {
this.leftStrNode.active = false;
} }
if (this.rightPic) { if (this.rightPic) {
this.rightBox.active = true;
this.rightPicNode.active = true;
this.rightPicNode.getComponent(cc.Sprite).spriteFrame = null;
getSpriteFrimeByUrl(this.rightPic, (spf) => { getSpriteFrimeByUrl(this.rightPic, (spf) => {
this.rightPicNode.getComponent(cc.Sprite).spriteFrame = spf; this.rightPicNode.getComponent(cc.Sprite).spriteFrame = spf;
this.rightPicNode.scale = Math.min(280 / this.rightPicNode.width, 240 / this.rightPicNode.height) this.rightPicNode.scale = Math.min(280 / this.rightPicNode.width, 240 / this.rightPicNode.height)
}) })
} else {
this.rightPicNode.active = false;
} }
if (this.letfPic) { if (this.letfPic) {
this.leftBox.active = true;
this.leftPicNode.active = true;
this.leftPicNode.getComponent(cc.Sprite).spriteFrame = null;
getSpriteFrimeByUrl(this.letfPic, (spf) => { getSpriteFrimeByUrl(this.letfPic, (spf) => {
this.leftPicNode.getComponent(cc.Sprite).spriteFrame = spf; this.leftPicNode.getComponent(cc.Sprite).spriteFrame = spf;
this.leftPicNode.scale = Math.min(280 / this.leftPicNode.width, 240 / this.leftPicNode.height) this.leftPicNode.scale = Math.min(280 / this.leftPicNode.width, 240 / this.leftPicNode.height)
}) })
} else {
this.leftPicNode.active = false;
} }
} }
initListener() { initListener() {
......
...@@ -4,34 +4,66 @@ export const defaultData = ...@@ -4,34 +4,66 @@ export const defaultData =
{ {
"text_arr": [ "text_arr": [
{ {
"value": "police officer" "value": "tree house"
} }
], ],
"anim_arr": [], "anim_arr": [],
"image_arr": [ "image_arr": [],
"audio_arr": [
{
"value": "http://staging-teach.cdn.ireadabc.com/09478cf67b92f742576faa352843b352.mp3"
},
{ {
"value": "http://staging-teach.cdn.ireadabc.com/8eedbd4f65189b4029ac0a3364e27628.png" "value": "http://staging-teach.cdn.ireadabc.com/80e065274b51e1899b7ae60a0e3fc2dd.mp3"
} }
], ],
"audio_arr": [],
"video_arr": [], "video_arr": [],
"group_arr": [ "group_arr": [
{ {
"text_arr": [ "text_arr": [
{ {
"value": "police" "value": "tree"
}, },
{ {
"value": "officer" "value": "house"
} }
], ],
"anim_arr": [], "anim_arr": [],
"image_arr": [ "image_arr": [
{ {
"value": "http://staging-teach.cdn.ireadabc.com/8665e52ed373c524f55743bd21e7d606.png" "value": "http://staging-teach.cdn.ireadabc.com/b12b8c8f04c1b17915a2457cf6fb63a7.png"
}, },
{ {
"value": "http://staging-teach.cdn.ireadabc.com/063784f68bdbb03a37d0e52b481a8095.png" "value": "http://staging-teach.cdn.ireadabc.com/e1a7be51cbf0298630abf00f712eb7f7.png"
}
],
"audio_arr": [],
"video_arr": [],
"group_arr": []
}
]
},
{
"text_arr": [],
"anim_arr": [],
"image_arr": [
{
"value": "http://staging-teach.cdn.ireadabc.com/0e9cd5cadfd84c93dbdf166fb34546fe.png"
}
],
"audio_arr": [],
"video_arr": [],
"group_arr": [
{
"text_arr": [
{
"value": "house"
}
],
"anim_arr": [],
"image_arr": [
{
"value": "http://staging-teach.cdn.ireadabc.com/a04e56abefd5829357eceba26bff2377.png"
} }
], ],
"audio_arr": [], "audio_arr": [],
...@@ -43,13 +75,13 @@ export const defaultData = ...@@ -43,13 +75,13 @@ export const defaultData =
{ {
"text_arr": [ "text_arr": [
{ {
"value": "police officer" "value": "mud house"
} }
], ],
"anim_arr": [], "anim_arr": [],
"image_arr": [ "image_arr": [
{ {
"value": "http://staging-teach.cdn.ireadabc.com/8eedbd4f65189b4029ac0a3364e27628.png" "value": "http://staging-teach.cdn.ireadabc.com/117d58acf9dfe9018f77b1428003cdb7.png"
} }
], ],
"audio_arr": [], "audio_arr": [],
...@@ -58,16 +90,18 @@ export const defaultData = ...@@ -58,16 +90,18 @@ export const defaultData =
{ {
"text_arr": [ "text_arr": [
{ {
"value": "police" "value": ""
}, },
{
"value": "house"
}
], ],
"anim_arr": [], "anim_arr": [],
"image_arr": [ "image_arr": [
{ {
"value": "http://staging-teach.cdn.ireadabc.com/8665e52ed373c524f55743bd21e7d606.png" "value": "http://staging-teach.cdn.ireadabc.com/afcc6f29845c2c4377c86102cb86fd15.png"
}, },
{}
], ],
"audio_arr": [], "audio_arr": [],
"video_arr": [], "video_arr": [],
...@@ -76,7 +110,106 @@ export const defaultData = ...@@ -76,7 +110,106 @@ export const defaultData =
] ]
} }
], ],
"audio_url_guide": "http://staging-teach.cdn.ireadabc.com/4c8ade54b7a1ff2192f066e64d6579b0_l.mp3", "global_setting": [
"audio_url_success": "http://staging-teach.cdn.ireadabc.com/067b86719184f5a2fee78f4fbc640e76_l.mp3", {
"text_arr": [
{
"value": "去交际广场"
}
],
"anim_arr": [],
"image_arr": [],
"audio_arr": [
{
"value": "http://staging-teach.cdn.ireadabc.com/e66bac8d77385b01ce180987c9a0c601.mp3"
},
{
"value": "http://staging-teach.cdn.ireadabc.com/9541b250b13a284ca28abf87ab0bdedb.mp3"
}
],
"video_arr": [],
"group_arr": []
}
]
}
// {
// "group_arr": [
// {
// "text_arr": [
// {
// "value": "police officer"
// }
// ],
// "anim_arr": [],
// "image_arr": [
// {
// "value": "http://staging-teach.cdn.ireadabc.com/8eedbd4f65189b4029ac0a3364e27628.png"
// }
// ],
// "audio_arr": [],
// "video_arr": [],
// "group_arr": [
// {
// "text_arr": [
// {
// "value": "police"
// },
// {
// "value": "officer"
// }
// ],
// "anim_arr": [],
// "image_arr": [
// {
// "value": ""//"http://staging-teach.cdn.ireadabc.com/8665e52ed373c524f55743bd21e7d606.png"
// },
// {
// "value": "http://staging-teach.cdn.ireadabc.com/063784f68bdbb03a37d0e52b481a8095.png"
// }
// ],
// "audio_arr": [],
// "video_arr": [],
// "group_arr": []
// }
// ]
// },
// {
// "text_arr": [
// {
// "value": "police officer"
// }
// ],
// "anim_arr": [],
// "image_arr": [
// {
// "value": "http://staging-teach.cdn.ireadabc.com/8eedbd4f65189b4029ac0a3364e27628.png"
// }
// ],
// "audio_arr": [],
// "video_arr": [],
// "group_arr": [
// {
// "text_arr": [
// // {
// // "value": "police"
// // },
// ],
// "anim_arr": [],
// "image_arr": [
// {
// "value": "http://staging-teach.cdn.ireadabc.com/8665e52ed373c524f55743bd21e7d606.png"
// },
// ],
// "audio_arr": [],
// "video_arr": [],
// "group_arr": []
// }
// ]
// }
// ],
// "audio_url_guide": "http://staging-teach.cdn.ireadabc.com/4c8ade54b7a1ff2192f066e64d6579b0_l.mp3",
// "audio_url_success": "http://staging-teach.cdn.ireadabc.com/067b86719184f5a2fee78f4fbc640e76_l.mp3",
} // }
\ No newline at end of file \ No newline at end of file
...@@ -416,3 +416,13 @@ export function getMinLv(num) { ...@@ -416,3 +416,13 @@ export function getMinLv(num) {
} }
} }
export function goNextPage() {
if (!cc.find('middleLayer')) {
console.log("==点击了下一页按钮==")
return;
}
const middleLayer = cc.find('middleLayer').getComponent('middleLayer');
middleLayer.goNextPage();
}
{
"ver": "2.3.5",
"uuid": "a742d2c4-7f12-46f8-8166-1f9f6e34a0f6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1920,
"height": 78,
"platformSettings": {},
"subMetas": {
"DG23_bottom": {
"ver": "1.0.4",
"uuid": "cd2418c1-5066-42a5-9361-bc82d74df61b",
"rawTextureUuid": "a742d2c4-7f12-46f8-8166-1f9f6e34a0f6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1920,
"height": 78,
"rawWidth": 1920,
"rawHeight": 78,
"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