Commit 2e65d385 authored by huoshizhe's avatar huoshizhe

fix: 屏幕适配

parent cc4a5aab
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "BgNode",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 6
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 10
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_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": "BgUpper",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_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__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "2df498b6-dc6f-40a9-a300-976925bd6038"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9a5b96dc-35a4-464e-a0b2-d1a27aee336d"
},
"fileId": "cdUw0yGvRMF7Ad4xjjpDkI",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "BgLower",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 9
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_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": {
"__uuid__": "8860b7d9-c838-473b-86c9-1f49139d9c27"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9a5b96dc-35a4-464e-a0b2-d1a27aee336d"
},
"fileId": "513EdjIndCGqHOWGtXbdR0",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "9a5b96dc-35a4-464e-a0b2-d1a27aee336d"
},
"fileId": "f2TzlzWsxAE6C3uqBJmfOH",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.7",
"uuid": "9a5b96dc-35a4-464e-a0b2-d1a27aee336d",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -22,9 +22,13 @@
}
],
"_active": true,
"_components": [],
"_components": [
{
"__id__": 15
}
],
"_prefab": {
"__id__": 15
"__id__": 16
},
"_opacity": 255,
"_color": {
......@@ -48,8 +52,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
640,
360,
0,
0,
0,
......@@ -577,6 +581,33 @@
"fileId": "1ehiErIutOS7lPFFxGZbcG",
"sync": false
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
......
......@@ -5191,8 +5191,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-140.45,
-60.480000000000004,
0,
0,
0,
0,
0,
......@@ -5215,7 +5215,7 @@
"_groupIndex": 0,
"groupIndex": 0,
"showInEditor": false,
"_id": "95TzRfxGtAPqVBIKFshkGt"
"_id": "69nWzLIYNMwauJ9GPokmW0"
},
{
"__type__": "cc.Label",
......@@ -5251,7 +5251,7 @@
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "42JZmLHc5Ba5H5wNk+kNn1"
"_id": "25xftLEw5F3bU+eITQPqtc"
},
{
"__type__": "cc.PrivateNode",
......@@ -5290,8 +5290,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-74.68999999999998,
-60.480000000000004,
0,
0,
0,
0,
0,
......@@ -5314,7 +5314,7 @@
"_groupIndex": 0,
"groupIndex": 0,
"showInEditor": false,
"_id": "95EExnKwRMZLqjBpCXr0KG"
"_id": "45bILtc5JFTJ4LFjGX4uZr"
},
{
"__type__": "cc.Label",
......@@ -5350,7 +5350,7 @@
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "d0eezZzRhNtb1VZq22uP/y"
"_id": "09yEsNnBhETY0sv8qY+gFE"
},
{
"__type__": "cc.RichText",
......@@ -6635,6 +6635,9 @@
},
"_enabled": true,
"letter": "d",
"bgNode": {
"__uuid__": "9a5b96dc-35a4-464e-a0b2-d1a27aee336d"
},
"monkeyUpperNode": {
"__uuid__": "a615b738-a1c5-47a0-b26c-b447b56e596a"
},
......
......@@ -23,6 +23,11 @@ cc.Class({
letter: 'b',
bgNode: {
type: cc.Prefab,
default: null,
},
monkeyUpperNode: {
type: cc.Prefab,
default: null,
......@@ -516,27 +521,6 @@ cc.Class({
letterNodeBase.name = 'letterNodeBase';
letterNodeBase.parent = this.node;
letterNodeBase.addComponent(cc.Button);
letterNodeBase.on('click', () => { });
letterNodeBase.addComponent(cc.Widget);
const widgetComponent = letterNodeBase.getComponent(cc.Widget);
widgetComponent.isAlignTop = true;
widgetComponent.isAlignBottom = true;
widgetComponent.isAlignLeft = true;
widgetComponent.isAlignRight = true;
widgetComponent.top = 0;
widgetComponent.bottom = 0;
widgetComponent.left = 0;
widgetComponent.right = 0;
widgetComponent.updateAlignment();
if (letter == letter.toLowerCase()) {
const monkeyUpperNode = cc.instantiate(this.monkeyUpperNode);
monkeyUpperNode.parent = letterNodeBase;
monkeyUpperNode.y = -letterNodeBase.height / letterNodeBase.scaleY / 2;
}
const btnUpdate = letterNodeBase.getChildByName('BtnUpdate');
btnUpdate.on('click', () => {
this.drawCompleteLine(this._status.currentStrokeIdx);
......@@ -570,6 +554,37 @@ cc.Class({
}
const pos0 = cc.find(`Canvas/letterNodeBase/NodePosBase/NodePos_0_0`);
this.createShark(pos0, this.getSharkAngle(0, 0), showMonkey);
this.node.getComponent(cc.Widget).updateAlignment();
letterNodeBase.scaleX = this.node.height / 720;
letterNodeBase.scaleY = this.node.height / 720;
const bgNode = cc.instantiate(this.bgNode);
bgNode.parent = letterNodeBase;
bgNode.zIndex = -1;
bgNode.width = this.node.width / letterNodeBase.scaleY;
bgNode.addComponent(cc.Button);
bgNode.on('click', () => { });
if (letter !== letter.toLowerCase()) {
bgNode.getChildByName('BgLower').active = false;
}
if (letter == letter.toLowerCase()) {
const monkeyUpperNode = cc.instantiate(this.monkeyUpperNode);
monkeyUpperNode.parent = letterNodeBase;
monkeyUpperNode.scaleX = 720 / this.node.height;
monkeyUpperNode.scaleY = 720 / this.node.height;
monkeyUpperNode.y = -letterNodeBase.height / 2;
}
const drawMaskNode = cc.find('Canvas/letterNodeBase/DrawMaskNode');
const letterNode = cc.find('Canvas/letterNodeBase/bg_a');
// drawMaskNode.scaleX = letterNodeBase.height / 720;
// drawMaskNode.scaleY = letterNodeBase.height / 720;
// letterNode.scaleX = letterNodeBase.height / 720;
// letterNode.scaleY = letterNodeBase.height / 720;
},
startSpeakerAnime(speakerBase) {
......@@ -604,24 +619,32 @@ cc.Class({
getPosListByStrokeIdx(strokeIdx) {
let stepIdx = 0;
let pos0 = null;
const drawMaskNode = cc.find('Canvas/letterNodeBase/DrawMaskNode');
const posList = [];
do {
pos0 = cc.find(`Canvas/letterNodeBase/NodePosBase/NodePos_${strokeIdx}_${stepIdx}`);
stepIdx++;
if (pos0) {
posList.push(pos0);
posList.push({
x: pos0.x,
y: pos0.y
});
}
} while (pos0);
return posList;
},
getCurrentCheckPos() {
const letterNodeBase = cc.find(`Canvas/letterNodeBase`);
const nodePosBase = cc.find('Canvas/letterNodeBase/NodePosBase');
let pos1 = nodePosBase.getChildByName(`NodePos_${this._status.currentStrokeIdx}_${this._status.currentStrokeStageIdx}`);
let pos2 = nodePosBase.getChildByName(`NodePos_${this._status.currentStrokeIdx}_${this._status.currentStrokeStageIdx + 1}`);
if (pos2) {
return [pos1, pos2];
return [
{ x: pos1.x, y: pos1.y },
{ x: pos2.x, y: pos2.y }
];
}
return null;
},
......@@ -666,6 +689,7 @@ cc.Class({
createArrows(endNode, lastNode, skipIdx, stepIdx, idx) {
let letterNodeBase = cc.find(`Canvas/letterNodeBase`)
const lineVec2 = cc.v2(endNode.x - lastNode.x, endNode.y - lastNode.y);
const lineLength = lineVec2.mag();
const arrowNumber = Math.ceil(lineLength / 100);
......@@ -678,7 +702,7 @@ cc.Class({
arrowPrefab.y = lastNode.y + lineVec2.y * (k + 1) / (arrowNumber + 1);
arrowPrefab.angle = cc.v2(1, 0).signAngle(lineVec2) * 180 / Math.PI;
arrowPrefab.name = name;
arrowPrefab.parent = this.node;
arrowPrefab.parent = letterNodeBase;
this.arrowPrefabList.push(arrowPrefab);
const nodeArrow = arrowPrefab.getChildByName('NodeArrow');
......@@ -695,10 +719,11 @@ cc.Class({
},
createShark(startNode, angle, monkey = false) {
let letterNodeBase = cc.find(`Canvas/letterNodeBase`)
let sharkNode = null;
if (!this.sharkNode) {
this.sharkNode = cc.instantiate(this.sharkPreFab);
this.sharkNode.parent = this.node;
this.sharkNode.parent = letterNodeBase;
this.sharkNode.zIndex = 2;
this.sharkNode.x = startNode.x;
this.sharkNode.y = startNode.y;
......@@ -740,10 +765,12 @@ cc.Class({
if (!currentPosList) {
return;
}
const letterNodeBase = cc.find(`Canvas/letterNodeBase`);
const [pos1, pos2] = currentPosList;
const checkLine = cc.v2(pos2.x - pos1.x, pos2.y - pos1.y);
const locationPos = this.node.convertToNodeSpaceAR(location);
const locationPos = letterNodeBase.convertToNodeSpaceAR(location);
this.sharkNode.x = locationPos.x;
this.sharkNode.y = locationPos.y;
......@@ -783,7 +810,7 @@ cc.Class({
}
const posList = this.getPosListByStrokeIdx(this._status.currentStrokeIdx);
if (!this.checkPointInRangeList(this.node.convertToNodeSpaceAR(location), posList, 50)) {
if (!this.checkPointInRangeList(letterNodeBase.convertToNodeSpaceAR(location), posList, 50)) {
this._status.currentStrokeStageIdx = 0;
this.onSharkMoveEnd(event);
return;
......@@ -941,12 +968,13 @@ cc.Class({
},
createStar(endNode) {
const letterNodeBase = cc.find(`Canvas/letterNodeBase`);
if (this.starNode) {
this.starNode.parent = null;
this.starNode = null;
}
const starNode = cc.instantiate(this.starPreFab);
starNode.parent = this.node;
starNode.parent = letterNodeBase;
starNode.x = endNode.x;
starNode.y = endNode.y;
this.starNode = starNode;
......
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