Commit 2f224257 authored by 范雪寒's avatar 范雪寒

fix: bugs

parent 618dfdb1
This diff is collapsed.
...@@ -99,7 +99,7 @@ cc.Class({ ...@@ -99,7 +99,7 @@ cc.Class({
}, },
getDefaultData() { getDefaultData() {
const dataJson = '{"groupArr":[{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"aaa"},{"type":"text","isRight":"0","text":"bbb"},{"type":"text","isRight":"0","text":"ccc"}]}]}'; const dataJson = '{"groupArr":[{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"pad"},{"type":"text","isRight":"0","text":"bdpq"},{"type":"text","isRight":"0","text":"ooo"}]},{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"pad"},{"type":"text","isRight":"0","text":"ggff"},{"type":"text","isRight":"0","text":"OOO"}]}]}';
const data1 = JSON.parse(dataJson); const data1 = JSON.parse(dataJson);
return data1; return data1;
}, },
...@@ -249,7 +249,7 @@ cc.Class({ ...@@ -249,7 +249,7 @@ cc.Class({
bigStarArr: null, bigStarArr: null,
initStar() { initStar() {
const gArr = this.data.groupArr; const gArr = this.data.groupArr;
if (gArr.length < 1) { if (gArr.length <= 1) {
return; return;
} }
...@@ -269,6 +269,11 @@ cc.Class({ ...@@ -269,6 +269,11 @@ cc.Class({
starTop.active = false; starTop.active = false;
starBg.star = starTop; starBg.star = starTop;
const starBig = getSprNode('icon_bigstar');
starBg.addChild(starBig);
starBig.active = false;
starBg.starBig = starBig;
this.bigStarArr.push(starBg); this.bigStarArr.push(starBg);
} }
}, },
...@@ -322,8 +327,7 @@ cc.Class({ ...@@ -322,8 +327,7 @@ cc.Class({
}, },
startBtnClicked() { startBtnClicked() {
this.showQuestion(); this.showQuestion(() => {
playAudio(this.btnClip, () => {
cc.tween(this) cc.tween(this)
.delay(0.3) .delay(0.3)
.call(() => { .call(() => {
...@@ -331,6 +335,7 @@ cc.Class({ ...@@ -331,6 +335,7 @@ cc.Class({
}) })
.start(); .start();
}); });
playAudio(this.btnClip);
}, },
restartBtnClicked() { restartBtnClicked() {
...@@ -341,6 +346,9 @@ cc.Class({ ...@@ -341,6 +346,9 @@ cc.Class({
}, },
hideBigStar() { hideBigStar() {
if (!this.bigStarArr) {
return;
}
for (let i = 0; i < this.bigStarArr.length; i++) { for (let i = 0; i < this.bigStarArr.length; i++) {
cc.tween(this.bigStarArr[i].star) cc.tween(this.bigStarArr[i].star)
.to(0.5, { scale: 0 }, { easing: 'cubicOut' }) .to(0.5, { scale: 0 }, { easing: 'cubicOut' })
...@@ -353,18 +361,22 @@ cc.Class({ ...@@ -353,18 +361,22 @@ cc.Class({
const btn = cc.find('Canvas/btn_laba') const btn = cc.find('Canvas/btn_laba')
btn.addComponent(cc.Button); btn.addComponent(cc.Button);
btn.on('click', () => { btn.on('click', () => {
this.showQuestion(); playAudio(this.btnClip, () => {
playAudio(this.btnClip); this.showQuestion();
});
}) })
}, },
showQuestion() { showQuestion(func) {
var anim = cc.find('Canvas/btn_laba').getComponent(cc.Animation); var anim = cc.find('Canvas/btn_laba').getComponent(cc.Animation);
anim.play(); anim.play();
playAudioByUrl(this.curGroup.audio_url, () => { playAudioByUrl(this.curGroup.audio_url, () => {
anim.stop(); anim.stop();
if (func && typeof (func) == 'function') {
func();
}
}); });
...@@ -604,35 +616,54 @@ cc.Class({ ...@@ -604,35 +616,54 @@ cc.Class({
}, },
showBigStar() { showBigStar() {
if (!this.bigStarArr || this.bigStarArr.length <= 0) {
this.checkGameEnd();
return;
}
const bigStarBg = this.bigStarArr[this.groupIndex]; const bigStarBg = this.bigStarArr[this.groupIndex];
const star = bigStarBg.star; const star = bigStarBg.star;
star.active = true; star.active = true;
star.opacity = 0; star.opacity = 0;
star.scale = 7 * this._mapScaleMin; star.scale = 1;
star.rotation = 0; star.angle = 0;
const canvas = cc.find('Canvas'); const starBig = bigStarBg.starBig;
starBig.active = true;
starBig.scale = 1;
starBig.angle = -90;
const pos = star.parent.convertToNodeSpaceAR(canvas.convertToWorldSpaceAR(cc.v2(0, -canvas.height / 2))); const canvas = cc.find('Canvas');
const startPos = star.parent.convertToNodeSpaceAR(canvas.convertToWorldSpaceAR(cc.v2(0, -canvas.height / 2)));
star.x = pos.x; starBig.x = startPos.x;
star.y = pos.y; starBig.y = startPos.y;
star.x = startPos.x;
star.y = startPos.y;
const time = 1; const time = 1;
cc.tween(star) cc.tween(star)
.delay(time / 3) .to(time, { x: 0 }, { easing: 'quadIn' })
.to(time * 2 / 3, { x: 0 })
.start(); .start();
cc.tween(star) cc.tween(star)
.to(time, { y: 0 }, { easing: 'quadInOut' }) .to(time, { angle: -720 })
.start(); .start();
cc.tween(star) cc.tween(star)
.to(time, { scale: 1, opacity: 255, rotation: 360 }, { easing: 'quadOut' }) .to(time, { y: 0, scale: 1, opacity: 255 }, { easing: 'quadOut' })
.call(() => { .call(() => {
this.checkGameEnd(); this.checkGameEnd();
}) })
.start(); .start();
cc.tween(starBig)
.to(time, { x: 0 }, { easing: 'quadIn' })
.start();
cc.tween(starBig)
.to(time, { angle: -720 - 90 })
.start();
cc.tween(starBig)
.to(time, { y: 0, scale: 0 }, { easing: 'quadOut' })
.start();
playAudio(this.bigStarClip); playAudio(this.bigStarClip);
}, },
...@@ -645,11 +676,13 @@ cc.Class({ ...@@ -645,11 +676,13 @@ cc.Class({
return; return;
} }
await asyncDelay(3); await asyncDelay(1);
this.initCurGroup(); this.initCurGroup();
this.showOnePenguin();
this.showQuestion(); this.showQuestion(()=>{
this.showOnePenguin();
});
}, },
gameEnd() { gameEnd() {
...@@ -741,7 +774,7 @@ cc.Class({ ...@@ -741,7 +774,7 @@ cc.Class({
cc.Color.fromHEX(color, 'c1431d'); cc.Color.fromHEX(color, 'c1431d');
labelNode.color = color; labelNode.color = color;
labelNode.y = 5; labelNode.y = -2.5;
textPanel.label = label; textPanel.label = label;
......
...@@ -72,7 +72,7 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) { ...@@ -72,7 +72,7 @@ export function setSprNodeMaxLen(sprNode, maxW, maxH) {
export function getSpriteFrimeByUrl(url, cb) { export function getSpriteFrimeByUrl(url, cb) {
cc.loader.load({url}, (err, img) => { cc.loader.load({ url }, (err, img) => {
const spriteFrame = new cc.SpriteFrame(img) const spriteFrame = new cc.SpriteFrame(img)
if (cb) { if (cb) {
cb(spriteFrame); cb(spriteFrame);
...@@ -100,24 +100,28 @@ export function getSprNodeByUrl(url, cb) { ...@@ -100,24 +100,28 @@ export function getSprNodeByUrl(url, cb) {
export function playAudio(audioClip, cb=null) { export function playAudio(audioClip, cb = null) {
if (audioClip) { if (audioClip) {
const audioId = cc.audioEngine.playEffect(audioClip, false, 0.8); const audioId = cc.audioEngine.playEffect(audioClip, false, 0.8);
if (cb) { if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => { cc.audioEngine.setFinishCallback(audioId, () => {
cb(); cb();
}); });
} }
} }
} }
export function playAudioByUrl(audio_url, cb=null) { export function playAudioByUrl(audio_url, cb = null) {
if (audio_url) { if (audio_url) {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => { cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
playAudio(audioClip, cb); playAudio(audioClip, cb);
}); });
} } else {
if (cb && typeof (cb) == 'function') {
cb();
}
}
} }
......
{
"ver": "2.3.5",
"uuid": "d3a49532-95aa-4e7c-928b-a27b02497a8f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 278,
"height": 275,
"platformSettings": {},
"subMetas": {
"icon_bigstar": {
"ver": "1.0.4",
"uuid": "34d97abe-f3fb-4599-9d5a-55e730f6d897",
"rawTextureUuid": "d3a49532-95aa-4e7c-928b-a27b02497a8f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 278,
"height": 275,
"rawWidth": 278,
"rawHeight": 275,
"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