Commit 072d94db authored by Tt's avatar Tt

背景板生成

parent 7111a0d2
...@@ -84,28 +84,28 @@ ...@@ -84,28 +84,28 @@
"__id__": 27 "__id__": 27
}, },
{ {
"__id__": 36 "__id__": 28
}, },
{ {
"__id__": 37 "__id__": 37
}, },
{ {
"__id__": 40 "__id__": 39
}, },
{ {
"__id__": 53 "__id__": 52
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 55 "__id__": 54
}, },
{ {
"__id__": 56 "__id__": 55
}, },
{ {
"__id__": 57 "__id__": 56
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1307,6 +1307,64 @@ ...@@ -1307,6 +1307,64 @@
"_originalHeight": 0, "_originalHeight": 0,
"_id": "89KZgyQntDip0vPVhp9mHY" "_id": "89KZgyQntDip0vPVhp9mHY"
}, },
{
"__type__": "cc.Node",
"_name": "layout_question",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 750,
"height": 430
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
569.634,
211.71,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "aejNq4aJVKWYY+QQ4LI7/T"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "block", "_name": "block",
...@@ -1316,16 +1374,16 @@ ...@@ -1316,16 +1374,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 28 "__id__": 29
}, },
{ {
"__id__": 30 "__id__": 31
}, },
{ {
"__id__": 32 "__id__": 33
}, },
{ {
"__id__": 34 "__id__": 35
} }
], ],
"_active": true, "_active": true,
...@@ -1383,13 +1441,13 @@ ...@@ -1383,13 +1441,13 @@
"_name": "New Sprite(Splash)", "_name": "New Sprite(Splash)",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 27 "__id__": 28
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 29 "__id__": 30
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1445,7 +1503,7 @@ ...@@ -1445,7 +1503,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 28 "__id__": 29
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1477,13 +1535,13 @@ ...@@ -1477,13 +1535,13 @@
"_name": "img_undone", "_name": "img_undone",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 27 "__id__": 28
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 31 "__id__": 32
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1539,7 +1597,7 @@ ...@@ -1539,7 +1597,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 30 "__id__": 31
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1571,13 +1629,13 @@ ...@@ -1571,13 +1629,13 @@
"_name": "img_focus", "_name": "img_focus",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 27 "__id__": 28
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 33 "__id__": 34
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1633,7 +1691,7 @@ ...@@ -1633,7 +1691,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 32 "__id__": 33
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1665,13 +1723,13 @@ ...@@ -1665,13 +1723,13 @@
"_name": "img_focus2", "_name": "img_focus2",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 27 "__id__": 28
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 35 "__id__": 36
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1727,7 +1785,7 @@ ...@@ -1727,7 +1785,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 34 "__id__": 35
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1754,64 +1812,6 @@ ...@@ -1754,64 +1812,6 @@
"_atlas": null, "_atlas": null,
"_id": "d3t9BYmZtDX5ZRYdEjEeyQ" "_id": "d3t9BYmZtDX5ZRYdEjEeyQ"
}, },
{
"__type__": "cc.Node",
"_name": "layout_question",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 750,
"height": 430
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
569.634,
211.71,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "aejNq4aJVKWYY+QQ4LI7/T"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "layout_blocks", "_name": "layout_blocks",
...@@ -1824,9 +1824,6 @@ ...@@ -1824,9 +1824,6 @@
"_components": [ "_components": [
{ {
"__id__": 38 "__id__": 38
},
{
"__id__": 39
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1904,38 +1901,6 @@ ...@@ -1904,38 +1901,6 @@
"_originalHeight": 0, "_originalHeight": 0,
"_id": "2eff7tjBlDJ7D7iQfB9p1/" "_id": "2eff7tjBlDJ7D7iQfB9p1/"
}, },
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 37
},
"_enabled": true,
"_layoutSize": {
"__type__": "cc.Size",
"width": 300,
"height": 200
},
"_resize": 0,
"_N$layoutType": 3,
"_N$cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_N$startAxis": 0,
"_N$paddingLeft": 0,
"_N$paddingRight": 0,
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 9,
"_N$spacingY": 10,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
"_id": "aerObXwbhE/orxs3UGhz7l"
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "word", "_name": "word",
...@@ -1945,22 +1910,22 @@ ...@@ -1945,22 +1910,22 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 41 "__id__": 40
}, },
{ {
"__id__": 43 "__id__": 42
}, },
{ {
"__id__": 45 "__id__": 44
}, },
{ {
"__id__": 47 "__id__": 46
}, },
{ {
"__id__": 49 "__id__": 48
}, },
{ {
"__id__": 51 "__id__": 50
} }
], ],
"_active": true, "_active": true,
...@@ -2018,13 +1983,13 @@ ...@@ -2018,13 +1983,13 @@
"_name": "img_keyboard_b", "_name": "img_keyboard_b",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 42 "__id__": 41
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2080,7 +2045,7 @@ ...@@ -2080,7 +2045,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 41 "__id__": 40
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2112,13 +2077,13 @@ ...@@ -2112,13 +2077,13 @@
"_name": "img_keyboard_o", "_name": "img_keyboard_o",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 44 "__id__": 43
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2174,7 +2139,7 @@ ...@@ -2174,7 +2139,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 43 "__id__": 42
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2206,13 +2171,13 @@ ...@@ -2206,13 +2171,13 @@
"_name": "img_keyboard_p", "_name": "img_keyboard_p",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 46 "__id__": 45
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2268,7 +2233,7 @@ ...@@ -2268,7 +2233,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 45 "__id__": 44
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2300,13 +2265,13 @@ ...@@ -2300,13 +2265,13 @@
"_name": "img_keyboard_g", "_name": "img_keyboard_g",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 48 "__id__": 47
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2362,7 +2327,7 @@ ...@@ -2362,7 +2327,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 47 "__id__": 46
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2394,13 +2359,13 @@ ...@@ -2394,13 +2359,13 @@
"_name": "img_keyboard_y", "_name": "img_keyboard_y",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": false, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 50 "__id__": 49
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2456,7 +2421,7 @@ ...@@ -2456,7 +2421,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 49 "__id__": 48
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2488,13 +2453,13 @@ ...@@ -2488,13 +2453,13 @@
"_name": "label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 40 "__id__": 39
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 52 "__id__": 51
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2550,7 +2515,7 @@ ...@@ -2550,7 +2515,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 51 "__id__": 50
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -2591,7 +2556,7 @@ ...@@ -2591,7 +2556,7 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 54 "__id__": 53
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -2647,7 +2612,7 @@ ...@@ -2647,7 +2612,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 53 "__id__": 52
}, },
"_enabled": false, "_enabled": false,
"alignMode": 1, "alignMode": 1,
......
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import pg from "./tool/pg";
import { GameNGT14 } from "./tool/Game";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -26,161 +28,46 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -26,161 +28,46 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.initData(); this.initData();
this.initView(); this.initView();
this.initListener(); this.initListener();
this.gameStart();
} }
_cantouch = null; _cantouch = null;
initData() { initData() {
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
this._cantouch = true; this._cantouch = true;
GameNGT14.getIns().initData(this.data);
GameNGT14.getIns().reset();
let data = GameNGT14.getIns().getCurrent();
console.log('gamestart', data)
} }
initView() { initView() {
this.initBg(); this.initBlocks();
this.initPic();
this.initBtn();
this.initIcon();
} }
initBg() { initListener() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
} }
if (this.curPage == 1) { private layout_blocks: cc.Node;
return; initBlocks() {
} this.layout_blocks = pg.view.find(this, 'layout_blocks');
this.layout_blocks.removeAllChildren()
this.curPage = 1 let block = pg.view.find(this, 'block');
this.rightMove(); //动态创建,并给每一个打上编号
let space = { x: 9 + 80, y: 10 + 80 }
// 游戏结束时需要调用这个方法通知系统作业完成 for (let y = 0; y < 9; y++) {
onHomeworkFinish(); for (let x = 0; x < 12; x++) {
let node = cc.instantiate(block);
this.playLocalAudio('btn'); let data = { x, y };
}) node.data = data;
node.x = -495 + space.x * x;
node.y = 365 - space.y * y;
node.active = !!GameNGT14.getIns().getBlockVal(x, y);
this.layout_blocks.addChild(node);
} }
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
} }
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
} }
// update (dt) {}, gameStart() {
initListener() {
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
......
{
"ver": "1.1.2",
"uuid": "4338bda3-228e-458d-974d-b89923efb091",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "layout_mouse",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 1,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 6
},
{
"__id__": 9
}
],
"_active": false,
"_components": [],
"_prefab": {
"__id__": 12
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "star_bg",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 59,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "564dd930-80a8-4d89-bf96-f0f5be1e92cb"
},
"fileId": "1a6bNni9hAzZuAOicd4es+",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "star",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
}
],
"_prefab": {
"__id__": 8
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 59,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "564dd930-80a8-4d89-bf96-f0f5be1e92cb"
},
"fileId": "0dcJdIc9BNfbQiPTRx9GVW",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "icon_bigstar",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 10
}
],
"_prefab": {
"__id__": 11
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 59,
"height": 42
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "564dd930-80a8-4d89-bf96-f0f5be1e92cb"
},
"fileId": "e8QBmuw8VOBYptnR5JD386",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "564dd930-80a8-4d89-bf96-f0f5be1e92cb"
},
"fileId": "9eIg5jomZOV5E+Yzh+2uPU",
"sync": false
},
{
"__type__": "e9eaeH4ZsVKx4dSvhRwGuVF",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"position": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"bigStarClip": {
"__uuid__": "71b51036-3bca-4d2a-84e1-fedc216ba064"
},
"starCountClip": {
"__uuid__": "71b51036-3bca-4d2a-84e1-fedc216ba064"
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "564dd930-80a8-4d89-bf96-f0f5be1e92cb"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "564dd930-80a8-4d89-bf96-f0f5be1e92cb",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import pg from "../tool/pg";
// import Game from "../../scene/Game";
const { ccclass, property } = cc._decorator;
@ccclass
export default class Ngt_star_10 extends cc.Component {
// LIFE-CYCLE CALLBACKS:
onLoad() {
pg.event.on("mouse_10_add", (isRight = true) => {
this.showBigStar(isRight);
});
pg.event.on("mouse_10_num", (max: number) => {
this.initStar(max);
});
pg.event.on("mouse_10_add_error", (isRight = true) => {
this.showErrorStar();
});
}
init(max) {
}
reviceMouse() {
}
start() {
}
//-----------------------STAR-----------------------------
bigStarArr: cc.Node[];
canvas: cc.Node;
curGroupIndex: number
@property(cc.Vec2)
position: cc.Vec2;
@property(cc.AudioClip)
bigStarClip: cc.AudioClip;
@property(cc.AudioClip)
starCountClip: cc.AudioClip;
//搭配res中的star_bg star等使用
initStar(max) {
this.curGroupIndex = 0;
this.canvas = cc.find('Canvas');
const gArr = [];
gArr.length = max;
if (gArr.length < 1) {
return;
}
this.cleanStar();
this.bigStarArr = [];
let baseX = this.position.x;
let baseY = this.position.y;
let disW = 80;// * this._mapScaleMin
// let disH = 80 * this._mapScaleMin;
let disScale = 1;
if (gArr.length > 5) {
// disH = (400 / gArr.length) * this._mapScaleMin;
// disScale = 5 / gArr.length;
}
for (let i = 0; i < gArr.length; i++) {
const starBg = this.getSprNode('star_bg');
this.canvas.addChild(starBg, 10);
// starBg.x = baseX;
// starBg.y = baseY - i * disH;
starBg.x = baseX - i * disW;
starBg.y = baseY
starBg.scale = disScale;
const starTop = this.getSprNode('star');
starBg.addChild(starTop);
starTop.active = false;
starBg.star = starTop;
const starBig = this.getSprNode('icon_bigstar');
starTop.addChild(starBig);
starBig.angle = -90;
starBg.starBig = starBig;
const star_wrong = this.getSprNode('star_wrong');
starTop.addChild(star_wrong);
star_wrong.active = false;
starBg.star_wrong = star_wrong;
this.bigStarArr.push(starBg);
}
console.log("bigStarArr: ", this.bigStarArr);
}
cleanStar() {
if (this.bigStarArr && this.bigStarArr.length > 0) {
for (let i = 0; i < this.bigStarArr.length; i++) {
this.bigStarArr[i].removeFromParent();
}
}
}
private showErrorStar() {
if (!this.bigStarArr || this.bigStarArr.length <= 0) {
// this.checkGameEnd();
return;
}
const bigStarBg = this.bigStarArr[this.curGroupIndex++];
if (!bigStarBg) return;
const star_wrong = bigStarBg.star_wrong;
star_wrong.active = true;
const starBig = bigStarBg.starBig;
// starBig.scale = 1;
starBig.active = false;
const star = bigStarBg.star;
star.active = true;
const canvas = cc.find('Canvas');
const startPos = this.exchangeNodePos(star.parent, canvas);
const middlePos = this.exchangeNodePos(star.parent, canvas);
star.x = 0;
star.y = 0;
star.scale = 1 / bigStarBg.scale;
pg.event.emit("mouse_10_num_game_end")
}
showBigStar(isRight) {
if (!this.bigStarArr || this.bigStarArr.length <= 0) {
// this.checkGameEnd();
return;
}
const bigStarBg = this.bigStarArr[this.curGroupIndex++];
if (!bigStarBg) return;
const starBig = bigStarBg.starBig;
starBig.scale = 1;
const star = bigStarBg.star;
star.active = true;
star.scaleX = 0.7 / bigStarBg.scale;
star.scaleY = 1 / bigStarBg.scale;
star.angle = 90;
const canvas = cc.find('Canvas');
const startPos = this.exchangeNodePos(star.parent, canvas);
const middlePos = this.exchangeNodePos(star.parent, canvas);
star.x = startPos.x;
star.y = startPos.y - starBig.height;
console.log('middlePos = ' + JSON.stringify(middlePos));
const time = 1;
cc.tween(star)
.to(0.3, { y: middlePos.y + 80 }, { easing: 'quadOut' })
.to(0.1, { y: middlePos.y + 40, scaleX: 1.2 / bigStarBg.scale, scaleY: 0.8 / bigStarBg.scale }, { easing: 'quadOut' })
.to(0.1, { y: middlePos.y, scaleX: 1 / bigStarBg.scale, scaleY: 1 / bigStarBg.scale }, { easing: 'quadOut' })
.delay(0.1)
.to(0.8, { angle: -720, scale: 1 })
.start();
cc.tween(star)
.delay(0.6)
.to(0.8, { x: 0 }, { easing: 'quadIn' })
.start();
cc.tween(star)
.delay(0.6)
.to(0.8, { y: 0 }, { easing: 'quadOut' })
.start();
cc.tween(starBig)
.delay(0.6)
.to(0.8, { scale: 0 }, { easing: 'quadOut' })
.call(() => {
pg.event.emit("mouse_10_num_game_end")
// this.playAudio(this.starCountClip);
})
.start();
this.playAudio(this.bigStarClip);
}
//-----------------------STAR-----------------------------
getSprNode(resName) {
const sf = pg.view.find(this, `img/${resName}`).getComponent(cc.Sprite).spriteFrame;
const node = new cc.Node();
node.addComponent(cc.Sprite).spriteFrame = sf;
return node;
}
exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y)));
}
playAudio(audioClip, cb = null) {
if (audioClip) {
const audioId = cc.audioEngine.playEffect(audioClip, false);
if (cb) {
cc.audioEngine.setFinishCallback(audioId, () => {
cb();
});
}
}
}
// update (dt) {}
}
{
"ver": "1.0.8",
"uuid": "c6d2b333-2790-41e1-a04a-dea0262fa433",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ab1ef3e6-d935-41ee-abd1-950ab001fc13",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
export enum BLOCK_TYPE {
IMG = 'img',
TXT = 'txt',
LINE = 'line',
TAG = 'tag'
}
export enum BOARD_STATE {
DEFAULT = 'default',
INPUT = 'input',
RIGHT = 'right',
ERROR = 'error',
CHECK = 'check'
}
export class Block {
public static id: number = 10000;
public id: number;
public type: BLOCK_TYPE;
public img: string;
public line: number;
public text: string;
public answer: string;//用户填写答案
public tag: string;
constructor(data) {
console.log(data);
this.id = Block.id++;
this.type = data.type;
this.img = data.image;
this.text = data.text;
this.tag = data.tag;
this.line = Number(data.line);
this.answer = '';
}
addKeyBoard(val) {
if (!this.answer) this.answer = ''
this.answer += val;
}
deleteKeyBoard() {
if (!this.answer || this.answer == '') {
this.answer = ''
return;
}
this.answer = this.answer.substring(0, this.answer.length - 1)
}
finished() {
if (this.type == BLOCK_TYPE.LINE) {
return this.answer.length != 0
} else {
return true
}
}
isRight() {
if (this.type == BLOCK_TYPE.LINE) {
return this.answer == this.text;
} else {
return true
}
}
}
export class Option {
public static id: number = 10000;
public id: number;
public list: Array<Block>;
constructor(data) {
this.id = Option.id++;
console.log(data);
this.list = data.blocks.map(block => new Block(block));
}
isDoubleLine() {
return this.list.some(block => block.type == BLOCK_TYPE.IMG)
}
getList() {
return this.list.concat();
}
finished() {
return this.list.every(block => block.finished())
}
isRight() {
return this.list.every(block => block.isRight())
}
}
export class Question {
public static id: number = 1000;
public id: number;
public list: Array<Option>;
public submit: BOARD_STATE;
constructor(data) {
this.id = Question.id++;
console.log(data);
this.list = data.options.map(option => new Option(option));
this.submit = BOARD_STATE.DEFAULT
}
setSubmit(state) {
this.submit = state
}
getSubmit() {
return this.submit;
}
getList() {
return this.list.concat();
}
finished() {
return this.list.every(option => option.finished())
}
isRight() {
return this.list.every(option => option.isRight())
}
}
export class GameNGT14 {
public questions: Array<Question>
public blocks: Array<{ val: string }>
public current: number;
public title: string;
public total: number;
public aniEnter;
public startAudio;
constructor() {
this.current = 0;
this.questions = [];
}
reset() {
this.current = 0;
}
initData(data) {
console.log(data);
this.questions = data.questions[0].parts.map(part => new Question(part));
this.blocks = data.blocks;
this.title = data.title;
this.startAudio = data.startAudio || "";
this.aniEnter = data.imgAni;
}
getBlockVal(x, y) {
if (!this.blocks[y] || !this.blocks[y][x]) return;
return this.blocks[y][x].val;
}
getCurrent(): Question {
return this.questions[this.current];
}
static ins: GameNGT14;
static getIns(): GameNGT14 {
if (!GameNGT14.ins) GameNGT14.ins = new GameNGT14();
return GameNGT14.ins;
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "52bbca66-7f98-4d59-83d2-e5fdd23b7de8",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "5fd84819-61ef-41a9-82f6-b9db5dcfb6bd",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -4588,6 +4588,7 @@ declare namespace cc { ...@@ -4588,6 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward: Vec3; forward: Vec3;
data: { x: number; y: number; };
/** /**
@param name name @param name name
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