Commit d4a89711 authored by 范雪寒's avatar 范雪寒

fix: bugs

parent f22fe366
...@@ -1072,7 +1072,7 @@ ...@@ -1072,7 +1072,7 @@
"__id__": 52 "__id__": 52
} }
], ],
"_active": false, "_active": true,
"_components": [], "_components": [],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 255,
...@@ -1097,8 +1097,8 @@ ...@@ -1097,8 +1097,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, -1301.78,
0, -858.002,
0, 0,
0, 0,
0, 0,
...@@ -1281,7 +1281,11 @@ ...@@ -1281,7 +1281,11 @@
"__id__": 26 "__id__": 26
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1327,7 +1331,7 @@ ...@@ -1327,7 +1331,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 272, "width": 272,
"height": 173 "height": 111
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1339,7 +1343,7 @@ ...@@ -1339,7 +1343,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -437,
0, 0,
0, 0,
0, 0,
...@@ -1371,7 +1375,11 @@ ...@@ -1371,7 +1375,11 @@
"__id__": 28 "__id__": 28
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1429,7 +1437,7 @@ ...@@ -1429,7 +1437,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -874,
0, 0,
0, 0,
0, 0,
...@@ -1461,7 +1469,11 @@ ...@@ -1461,7 +1469,11 @@
"__id__": 30 "__id__": 30
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1519,7 +1531,7 @@ ...@@ -1519,7 +1531,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -1312,
0, 0,
0, 0,
0, 0,
...@@ -1551,7 +1563,11 @@ ...@@ -1551,7 +1563,11 @@
"__id__": 32 "__id__": 32
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1609,7 +1625,7 @@ ...@@ -1609,7 +1625,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -1749,
0, 0,
0, 0,
0, 0,
...@@ -1641,7 +1657,11 @@ ...@@ -1641,7 +1657,11 @@
"__id__": 34 "__id__": 34
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1699,7 +1719,7 @@ ...@@ -1699,7 +1719,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -2186,
0, 0,
0, 0,
0, 0,
...@@ -1731,7 +1751,11 @@ ...@@ -1731,7 +1751,11 @@
"__id__": 36 "__id__": 36
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1789,7 +1813,7 @@ ...@@ -1789,7 +1813,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -2623,
0, 0,
0, 0,
0, 0,
...@@ -1821,7 +1845,11 @@ ...@@ -1821,7 +1845,11 @@
"__id__": 38 "__id__": 38
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1879,7 +1907,7 @@ ...@@ -1879,7 +1907,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -3060,
0, 0,
0, 0,
0, 0,
...@@ -1911,7 +1939,11 @@ ...@@ -1911,7 +1939,11 @@
"__id__": 40 "__id__": 40
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -1969,7 +2001,7 @@ ...@@ -1969,7 +2001,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -3498,
0, 0,
0, 0,
0, 0,
...@@ -2001,7 +2033,11 @@ ...@@ -2001,7 +2033,11 @@
"__id__": 42 "__id__": 42
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -2059,7 +2095,7 @@ ...@@ -2059,7 +2095,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, -3935,
0, 0,
0, 0,
0, 0,
...@@ -2091,7 +2127,11 @@ ...@@ -2091,7 +2127,11 @@
"__id__": 44 "__id__": 44
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
...@@ -2199,7 +2239,7 @@ ...@@ -2199,7 +2239,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 0, "width": 0,
"height": 0 "height": 50.4
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -2243,10 +2283,13 @@ ...@@ -2243,10 +2283,13 @@
"__id__": 47 "__id__": 47
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_useOriginalSize": true,
"_string": "", "_string": "",
"_N$string": "", "_N$string": "",
"_fontSize": 40, "_fontSize": 40,
...@@ -2587,6 +2630,7 @@ ...@@ -2587,6 +2630,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "2bgNQWML5NoI5NN3xFICEC" "_id": "2bgNQWML5NoI5NN3xFICEC"
...@@ -2667,6 +2711,7 @@ ...@@ -2667,6 +2711,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "d3HMEKe4hJ8pNnOWwOEFnm" "_id": "d3HMEKe4hJ8pNnOWwOEFnm"
...@@ -2747,6 +2792,7 @@ ...@@ -2747,6 +2792,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "85ZuYVTNhKM7trkp5cUpAP" "_id": "85ZuYVTNhKM7trkp5cUpAP"
...@@ -2827,6 +2873,7 @@ ...@@ -2827,6 +2873,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "e6VxQUDwxOVZIjcSdLwu2P" "_id": "e6VxQUDwxOVZIjcSdLwu2P"
...@@ -2907,6 +2954,7 @@ ...@@ -2907,6 +2954,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "85s2/eMydCnK2yLnJ985x0" "_id": "85s2/eMydCnK2yLnJ985x0"
...@@ -2987,6 +3035,7 @@ ...@@ -2987,6 +3035,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "dbhz2oR+BEa6asX+FGfdBH" "_id": "dbhz2oR+BEa6asX+FGfdBH"
...@@ -3067,6 +3116,7 @@ ...@@ -3067,6 +3116,7 @@
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
"_loop": false, "_loop": false,
"_firstlyEnabled": true,
"playOnLoad": false, "playOnLoad": false,
"preload": false, "preload": false,
"_id": "94X7MHa+1DeLeObX0wxwvS" "_id": "94X7MHa+1DeLeObX0wxwvS"
......
// import { getSprNode } from "./util"; // import { getSprNode } from "./util";
import { getSprNode, playAudioByUrl, randomSortByArr, playAudio, showTrebleFirework, RandomInt } from "./util"; import { getSprNode, playAudioByUrl, randomSortByArr, playAudio, showTrebleFirework, RandomInt, asyncDelay } from "./util";
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
baseWidth: { baseWidth: 1280,
default: 1280, baseHeight: 720
type: cc.Integer
},
baseHeight: {
default: 720,
type: cc.Integer
}
}, },
onLoad() { onLoad() {
...@@ -60,11 +54,7 @@ cc.Class({ ...@@ -60,11 +54,7 @@ cc.Class({
}, },
start() { start() {
let getData = this.getData.bind(this); this.getData((data) => {
if (window && window.courseware) {
getData = window.courseware.getData;
}
getData((data) => {
console.log('data:', data); console.log('data:', data);
this.data = data || this.getDefaultData(); this.data = data || this.getDefaultData();
this.preloadItem() this.preloadItem()
...@@ -77,16 +67,28 @@ cc.Class({ ...@@ -77,16 +67,28 @@ cc.Class({
preloadItem() { preloadItem() {
this.addPreloadImage(); this.addPreloadImage();
this.addPreloadAudio(); this.addPreloadAudio();
// this.addPreloadAnima(); this.addPreloadAnima();
this.preload(); this.preload();
}, },
getData(func) { getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'Z_05_nxuan1');
return;
}
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData(func);
return;
}
func(this.getDefaultData()); func(this.getDefaultData());
}, },
getDefaultData() { getDefaultData() {
const dataJson = '{"groupArr":[{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"aaaaa","audio_url":"http://staging-teach.cdn.ireadabc.com/5285e1e88a26a08783757e9c43a8653f.mp3"},{"type":"text","isRight":"0","text":"bbbbb","audio_url":"http://staging-teach.cdn.ireadabc.com/440cf9d57752b30691d90ed565e8c924.mp3"},{"type":"pic","isRight":"1","audio_url":"http://staging-teach.cdn.ireadabc.com/66878465ec50d162bd60fcdaa641933b.mp3","pic_url":"http://staging-teach.cdn.ireadabc.com/7709a0ddfde321cb70fc3099da32c35b.png"}],"audio_url":"http://staging-teach.cdn.ireadabc.com/85cff126986f5cc11b05e95181da5869.mp3"},{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"444","audio_url":"http://staging-teach.cdn.ireadabc.com/a5fa20e0c6024421b0d9a7007c303503.mp3"},{"type":"pic","isRight":"0","pic_url":"http://staging-teach.cdn.ireadabc.com/1c9a510039065355e8f2402227cf8ef0.png"},{"type":"text","isRight":"0","text":"!!!!!"}],"audio_url":"http://staging-teach.cdn.ireadabc.com/a5fa20e0c6024421b0d9a7007c303503.mp3"}],"pic_url_2":"http://staging-teach.cdn.ireadabc.com/f6f4bbef497409fef3c8f1d375893829.png"}'; const dataJson = '{"groupArr":[{"ques":"","optionArr":[{"type":"text","isRight":"1","text":"aaa"},{"type":"text","isRight":"0","text":"bbb"},{"type":"text","isRight":"0","text":"ccc"}]}]}';
const data1 = JSON.parse(dataJson); const data1 = JSON.parse(dataJson);
return data1; return data1;
}, },
...@@ -236,7 +238,7 @@ cc.Class({ ...@@ -236,7 +238,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;
} }
...@@ -309,16 +311,15 @@ cc.Class({ ...@@ -309,16 +311,15 @@ cc.Class({
}, },
startBtnClicked() { startBtnClicked() {
this.showQuestion();
playAudio(this.btnClip, () => {
cc.tween(this) cc.tween(this)
.delay(0.3) .delay(0.3)
.call(() => { .call(() => {
this.showPenguin(); this.showPenguin();
}) })
.start(); .start();
});
this.showQuestion();
playAudio(this.btnClip);
}, },
restartBtnClicked() { restartBtnClicked() {
...@@ -391,6 +392,10 @@ cc.Class({ ...@@ -391,6 +392,10 @@ cc.Class({
showOnePenguin() { showOnePenguin() {
if (this.checkIsGroupEnd()) {
return;
}
const hole = this.getFreeHole(); const hole = this.getFreeHole();
if (hole) { if (hole) {
...@@ -515,7 +520,8 @@ cc.Class({ ...@@ -515,7 +520,8 @@ cc.Class({
node.addChild(d, 20); node.addChild(d, 20);
d.x = 0; d.x = 0;
d.y = node.penguin.height / 2; d.y = node.textPanel.y;
}, },
...@@ -591,11 +597,24 @@ cc.Class({ ...@@ -591,11 +597,24 @@ cc.Class({
const star = bigStarBg.star; const star = bigStarBg.star;
star.active = true; star.active = true;
star.opacity = 0; star.opacity = 0;
star.scale = 3 * this._mapScaleMin; star.scale = 7 * this._mapScaleMin;
star.rotation = 0; star.rotation = 0;
const canvas = cc.find('Canvas');
const pos = star.parent.convertToNodeSpaceAR(canvas.convertToWorldSpaceAR(cc.v2(0, -canvas.height / 2)));
star.x = pos.x;
star.y = pos.y;
const time = 1; const time = 1;
cc.tween(star)
.delay(time / 3)
.to(time * 2 / 3, { x: 0 })
.start();
cc.tween(star)
.to(time, { y: 0 }, { easing: 'quadInOut' })
.start();
cc.tween(star) cc.tween(star)
.to(time, { scale: 1, opacity: 255, rotation: 360 }, { easing: 'quadOut' }) .to(time, { scale: 1, opacity: 255, rotation: 360 }, { easing: 'quadOut' })
.call(() => { .call(() => {
...@@ -606,7 +625,7 @@ cc.Class({ ...@@ -606,7 +625,7 @@ cc.Class({
playAudio(this.bigStarClip); playAudio(this.bigStarClip);
}, },
checkGameEnd() { async checkGameEnd() {
this.groupIndex++; this.groupIndex++;
...@@ -615,6 +634,8 @@ cc.Class({ ...@@ -615,6 +634,8 @@ cc.Class({
return; return;
} }
await asyncDelay(3);
this.initCurGroup(); this.initCurGroup();
this.showOnePenguin(); this.showOnePenguin();
this.showQuestion(); this.showQuestion();
...@@ -700,6 +721,7 @@ cc.Class({ ...@@ -700,6 +721,7 @@ cc.Class({
const label = labelNode.addComponent(cc.Label) const label = labelNode.addComponent(cc.Label)
textPanel.addChild(labelNode, 5); textPanel.addChild(labelNode, 5);
label.fontSize = 54; label.fontSize = 54;
label.lineHeight = 54;
label.font = cc.find('Canvas/res/font/Berlin Sans FB').getComponent(cc.Label).font; label.font = cc.find('Canvas/res/font/Berlin Sans FB').getComponent(cc.Label).font;
...@@ -947,8 +969,6 @@ cc.Class({ ...@@ -947,8 +969,6 @@ cc.Class({
cc.loader.load({ url: this.data.bgItem.url }, (err, img) => { cc.loader.load({ url: this.data.bgItem.url }, (err, img) => {
// this.addMask(this.hotZoneBg);
this.hotZoneBg.width = img.width; this.hotZoneBg.width = img.width;
this.hotZoneBg.height = img.height; this.hotZoneBg.height = img.height;
...@@ -1018,19 +1038,9 @@ cc.Class({ ...@@ -1018,19 +1038,9 @@ cc.Class({
this.setOneAction(item); this.setOneAction(item);
} }
}); });
},
addMask(node) {
const mask = node.addComponent(cc.Mask);
mask.type = cc.Mask.Type.RECT;
}, },
setOneAction(data) { setOneAction(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width; const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rectNode = new cc.Node(); const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index; rectNode.name = 'rect' + data.index;
......
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