Commit 1334df83 authored by 范雪寒's avatar 范雪寒

feat: 屏幕适配

parent 5a133171
{
"ver": "2.0.1",
"uuid": "d7ee13c8-7c6f-4ed4-bf81-c85ae91edfa9",
"downloadMode": 0,
"duration": 7.74,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "fc2be55f-3d94-44e0-9ebf-09e0eaa47873",
"downloadMode": 0,
"duration": 10.944,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "4d2df5f4-a774-4e06-a410-4e38195952ad",
"downloadMode": 0,
"duration": 0.972,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "0d2dd7a8-9bc2-4cd5-a432-a13f8fb43033",
"downloadMode": 0,
"duration": 1.188,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ac17bb63-beac-4d42-bc52-1d53b848082f",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "42cb15db-315a-4d11-9814-0fe5f8808a72",
"subMetas": {}
}
\ No newline at end of file
{"name":"mao","imagePath":"mao_tex.png","SubTexture":[{"name":"猫01/影子","x":1,"height":66,"y":343,"width":337},{"name":"猫01/尾巴","x":1,"height":109,"y":188,"width":175},{"name":"猫01/右腿","x":178,"height":117,"y":188,"width":104},{"name":"猫01/左腿","x":1,"height":115,"y":569,"width":64},{"name":"猫01/右手","x":427,"height":122,"y":590,"width":69},{"name":"猫01/左手","x":301,"height":74,"y":590,"width":124},{"name":"猫01伸/左手伸直","x":299,"height":169,"y":1,"width":168},{"name":"猫01伸/右手伸直","x":299,"height":169,"y":172,"width":168},{"name":"猫01/身体","x":340,"height":180,"y":343,"width":122},{"name":"猫01/领带","x":1,"height":156,"y":411,"width":120},{"name":"猫01/右耳","x":155,"height":76,"y":602,"width":90},{"name":"猫01/左耳","x":67,"height":85,"y":602,"width":86},{"name":"猫01/组_1","x":1,"height":185,"y":1,"width":296},{"name":"猫01/右眼","x":1,"height":60,"y":686,"width":59},{"name":"猫01/右眉毛","x":67,"height":5,"y":595,"width":33},{"name":"猫01/左眼","x":247,"height":60,"y":666,"width":59},{"name":"猫01/左眉毛","x":247,"height":12,"y":602,"width":31},{"name":"猫01/眼镜","x":301,"height":63,"y":525,"width":170},{"name":"猫01/胡子","x":123,"height":85,"y":515,"width":176},{"name":"猫01/鼻子","x":67,"height":24,"y":569,"width":28},{"name":"猫01/嘴","x":1,"height":30,"y":299,"width":65},{"name":"猫01/帽子","x":123,"height":102,"y":411,"width":158}],"height":1024,"width":512}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "b2242a6f-c54f-4b2d-8151-89a713576e41",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c8f02f6a-80f7-4712-8a8c-26db0a90ab03",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 1024,
"platformSettings": {},
"subMetas": {
"mao_tex": {
"ver": "1.0.4",
"uuid": "837a88a0-d171-4421-8e58-63a525eabc62",
"rawTextureUuid": "c8f02f6a-80f7-4712-8a8c-26db0a90ab03",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7.5,
"offsetY": 138.5,
"trimX": 1,
"trimY": 1,
"width": 495,
"height": 745,
"rawWidth": 512,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
import { onHomeworkFinish, randomSortByArr } from "../script/util"; import { onHomeworkFinish, randomSortByArr, playDragonBoneAnimation } from "../script/util";
import { defaultData } from "../script/defaultData"; import { defaultData } from "../script/defaultData";
cc.Class({ cc.Class({
...@@ -150,9 +150,24 @@ cc.Class({ ...@@ -150,9 +150,24 @@ cc.Class({
}, },
initView() { initView() {
this.refreshCoolCatPosition();
this.coolCatSpeakStart(() => { this.coolCatSpeakStart(() => {
const audioUrl = this.data.question_arr[this.status.currentQuestionIdx].question_audio_url;
this.playAudioByUrl(audioUrl, () => {
this.jumpToQuestion(this.status.currentQuestionIdx); this.jumpToQuestion(this.status.currentQuestionIdx);
}); });
});
},
refreshCoolCatPosition() {
const cat = cc.find('Canvas/bg/catFrame/CoolCat');
const canvasWidth = cc.find('Canvas').width;
const canvasHeight = cc.find('Canvas').height;
console.log('canvasWidth = ' + canvasWidth);
console.log('canvasHeight = ' + canvasHeight);
}, },
jumpToQuestion(questionIdx) { jumpToQuestion(questionIdx) {
...@@ -171,8 +186,12 @@ cc.Class({ ...@@ -171,8 +186,12 @@ cc.Class({
optionNode.name = `option_${idx}`; optionNode.name = `option_${idx}`;
optionNode.x = (maxOptionWidth) * (idx + 0.5) - canvasWidth / 2 - box.x; optionNode.x = (maxOptionWidth) * (idx + 0.5) - canvasWidth / 2 - box.x;
optionNode.y = canvasHeight / 2 - box.y - 300; optionNode.y = canvasHeight / 2 - box.y - 300;
optionNode.scale = Math.min(1, (maxOptionWidth - 10) / optionNode.width, maxOptionHeight / optionNode.height); optionNode.scale = 0;
optionNode.parent = box; optionNode.parent = box;
cc.tween(optionNode)
.to(0.1, { scale: Math.min(1, (maxOptionWidth - 10) / optionNode.width, maxOptionHeight / optionNode.height) })
.start();
}); });
}, },
...@@ -266,12 +285,13 @@ cc.Class({ ...@@ -266,12 +285,13 @@ cc.Class({
if (box.children.every(child => child.optionData.selected == child.optionData.is_right)) { if (box.children.every(child => child.optionData.selected == child.optionData.is_right)) {
this.onAnswerRight(); this.onAnswerRight();
} else { } else {
this.coolCatSpeakWrong(() => {
if (!this.status.wrongOnce) { if (!this.status.wrongOnce) {
this.status.wrongOnce = true;
this.onAnswerWrong(); this.onAnswerWrong();
} else { } else {
this.onAnswerWrongTwice(); this.onAnswerWrongTwice();
} }
});
} }
}); });
...@@ -282,10 +302,13 @@ cc.Class({ ...@@ -282,10 +302,13 @@ cc.Class({
}, },
onAnswerRight() { onAnswerRight() {
this.coolCatSpeakRight(() => {
this.nextQuestion(); this.nextQuestion();
});
}, },
onAnswerWrong() { onAnswerWrong() {
this.status.wrongOnce = true;
const box = cc.find('Canvas/bg/box'); const box = cc.find('Canvas/bg/box');
box.children box.children
.filter(child => child.optionData.selected) .filter(child => child.optionData.selected)
...@@ -320,8 +343,10 @@ cc.Class({ ...@@ -320,8 +343,10 @@ cc.Class({
this.jumpToQuestion(this.status.currentQuestionIdx); this.jumpToQuestion(this.status.currentQuestionIdx);
}, 0.1 * 1000); }, 0.1 * 1000);
} else { } else {
this.coolCatSpeakEnd(() => {
this.submitBtnMoveOut(); this.submitBtnMoveOut();
this.showNextBtn(); this.showNextBtn();
});
} }
}, },
...@@ -354,9 +379,40 @@ cc.Class({ ...@@ -354,9 +379,40 @@ cc.Class({
}, },
coolCatSpeakStart(cb) { coolCatSpeakStart(cb) {
const cat = cc.find('Canvas/bg/catFrame/CoolCat');
playDragonBoneAnimation(cat, 'begin', -1);
this.playEffect('CoolCatBegin', () => {
playDragonBoneAnimation(cat, 'normal', -1);
cb();
});
},
coolCatSpeakRight(cb) {
const cat = cc.find('Canvas/bg/catFrame/CoolCat');
playDragonBoneAnimation(cat, 'right', -1);
this.playEffect('CoolCatRight', () => {
playDragonBoneAnimation(cat, 'normal', -1);
cb();
});
},
coolCatSpeakWrong(cb) {
const cat = cc.find('Canvas/bg/catFrame/CoolCat');
playDragonBoneAnimation(cat, 'wrong', -1);
this.playEffect('CoolCatWrong', () => {
playDragonBoneAnimation(cat, 'normal', -1);
cb(); cb();
});
}, },
coolCatSpeakEnd(cb) {
const cat = cc.find('Canvas/bg/catFrame/CoolCat');
playDragonBoneAnimation(cat, 'finish', -1);
this.playEffect('CoolCatFinish', () => {
playDragonBoneAnimation(cat, 'normal', -1);
});
cb();
},
......
...@@ -352,3 +352,37 @@ export function onHomeworkFinish() { ...@@ -352,3 +352,37 @@ export function onHomeworkFinish() {
console.log('onHomeworkFinish'); console.log('onHomeworkFinish');
} }
} }
export async function asyncPlayDragonBoneAnimation(node, animationName, time = 1, onFrameEvent = null) {
return new Promise((resolve, reject) => {
const armatureDisplay = node.getComponent(dragonBones.ArmatureDisplay);
armatureDisplay.timeScale = 1;
armatureDisplay.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
});
armatureDisplay.on(dragonBones.EventObject.FRAME_EVENT, (event) => {
if (onFrameEvent) {
onFrameEvent(event);
}
});
armatureDisplay.playAnimation(animationName, time);
});
}
export function playDragonBoneAnimation(node, animationName, time = 1, onFinish = null, onFrameEvent = null) {
const armatureDisplay = node.getComponent(dragonBones.ArmatureDisplay);
armatureDisplay.timeScale = 1;
armatureDisplay.once(dragonBones.EventObject.COMPLETE, () => {
if (onFinish) {
onFinish();
}
});
armatureDisplay.on(dragonBones.EventObject.FRAME_EVENT, (event) => {
if (onFrameEvent) {
onFrameEvent(event);
}
});
armatureDisplay.playAnimation(animationName, time);
}
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