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

fix: bugs

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