Commit ec014a3d authored by 李维's avatar 李维

修改背景图的适配

以左上角为基准,高度铺满屏幕,横向保持相同比例
parent 5af51b9d
......@@ -75,28 +75,28 @@
"__id__": 5
},
{
"__id__": 12
"__id__": 15
},
{
"__id__": 30
"__id__": 33
},
{
"__id__": 44
"__id__": 47
},
{
"__id__": 46
"__id__": 49
}
],
"_active": true,
"_components": [
{
"__id__": 49
"__id__": 52
},
{
"__id__": 50
"__id__": 53
},
{
"__id__": 51
"__id__": 54
}
],
"_prefab": null,
......@@ -257,16 +257,19 @@
"__id__": 6
},
{
"__id__": 8
"__id__": 9
},
{
"__id__": 11
}
],
"_active": true,
"_components": [
{
"__id__": 10
"__id__": 13
},
{
"__id__": 11
"__id__": 14
}
],
"_prefab": null,
......@@ -319,7 +322,7 @@
},
{
"__type__": "cc.Node",
"_name": "booble",
"_name": "startBg",
"_objFlags": 0,
"_parent": {
"__id__": 5
......@@ -329,6 +332,128 @@
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": null,
"_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,
"y": 1
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-640,
360,
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": "612ySNbM1DopmzZb+mVlRj"
},
{
"__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": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "c7vmkEvcVK3YtSgJJGm4AO"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": false,
"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": 0,
"_originalHeight": 0,
"_id": "89EgX5Cu5DHa9olJi4Pb6R"
},
{
"__type__": "cc.Node",
"_name": "booble",
"_objFlags": 0,
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 10
}
],
"_prefab": null,
......@@ -384,7 +509,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 9
},
"_enabled": true,
"_materials": [
......@@ -422,7 +547,7 @@
"_active": true,
"_components": [
{
"__id__": 9
"__id__": 12
}
],
"_prefab": null,
......@@ -478,7 +603,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 11
},
"_enabled": true,
"_materials": [
......@@ -573,13 +698,13 @@
},
"_children": [
{
"__id__": 13
"__id__": 16
},
{
"__id__": 26
"__id__": 29
},
{
"__id__": 28
"__id__": 31
}
],
"_active": true,
......@@ -637,20 +762,20 @@
"_name": "pad",
"_objFlags": 0,
"_parent": {
"__id__": 12
"__id__": 15
},
"_children": [
{
"__id__": 14
"__id__": 17
},
{
"__id__": 18
"__id__": 21
}
],
"_active": true,
"_components": [
{
"__id__": 25
"__id__": 28
}
],
"_prefab": null,
......@@ -706,17 +831,17 @@
"_name": "mask",
"_objFlags": 0,
"_parent": {
"__id__": 13
"__id__": 16
},
"_children": [
{
"__id__": 15
"__id__": 18
}
],
"_active": true,
"_components": [
{
"__id__": 17
"__id__": 20
}
],
"_prefab": null,
......@@ -772,13 +897,13 @@
"_name": "page",
"_objFlags": 0,
"_parent": {
"__id__": 14
"__id__": 17
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 16
"__id__": 19
}
],
"_prefab": null,
......@@ -834,7 +959,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 15
"__id__": 18
},
"_enabled": true,
"_materials": [
......@@ -866,7 +991,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
"__id__": 17
},
"_enabled": true,
"_materials": [
......@@ -886,14 +1011,14 @@
"_name": "circle",
"_objFlags": 0,
"_parent": {
"__id__": 13
"__id__": 16
},
"_children": [
{
"__id__": 19
"__id__": 22
},
{
"__id__": 21
"__id__": 24
}
],
"_active": false,
......@@ -951,13 +1076,13 @@
"_name": "countDown_black",
"_objFlags": 0,
"_parent": {
"__id__": 18
"__id__": 21
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 20
"__id__": 23
}
],
"_prefab": null,
......@@ -1013,7 +1138,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 19
"__id__": 22
},
"_enabled": true,
"_materials": [
......@@ -1045,17 +1170,17 @@
"_name": "progress",
"_objFlags": 0,
"_parent": {
"__id__": 18
"__id__": 21
},
"_children": [
{
"__id__": 22
"__id__": 25
}
],
"_active": true,
"_components": [
{
"__id__": 24
"__id__": 27
}
],
"_prefab": null,
......@@ -1111,13 +1236,13 @@
"_name": "countDown_blue",
"_objFlags": 0,
"_parent": {
"__id__": 21
"__id__": 24
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 23
"__id__": 26
}
],
"_prefab": null,
......@@ -1173,7 +1298,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 22
"__id__": 25
},
"_enabled": true,
"_materials": [
......@@ -1205,12 +1330,12 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
"__id__": 24
},
"_enabled": true,
"_N$totalLength": 1,
"_N$barSprite": {
"__id__": 23
"__id__": 26
},
"_N$mode": 2,
"_N$progress": 1,
......@@ -1222,7 +1347,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 13
"__id__": 16
},
"_enabled": true,
"_materials": [
......@@ -1254,13 +1379,13 @@
"_name": "book_left",
"_objFlags": 0,
"_parent": {
"__id__": 12
"__id__": 15
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 27
"__id__": 30
}
],
"_prefab": null,
......@@ -1316,7 +1441,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
"__id__": 29
},
"_enabled": true,
"_materials": [
......@@ -1348,13 +1473,13 @@
"_name": "book_right",
"_objFlags": 0,
"_parent": {
"__id__": 12
"__id__": 15
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 29
"__id__": 32
}
],
"_prefab": null,
......@@ -1410,7 +1535,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 28
"__id__": 31
},
"_enabled": true,
"_materials": [
......@@ -1446,7 +1571,7 @@
},
"_children": [
{
"__id__": 31
"__id__": 34
}
],
"_active": false,
......@@ -1504,20 +1629,20 @@
"_name": "pad",
"_objFlags": 0,
"_parent": {
"__id__": 30
"__id__": 33
},
"_children": [
{
"__id__": 32
"__id__": 35
},
{
"__id__": 36
"__id__": 39
}
],
"_active": true,
"_components": [
{
"__id__": 43
"__id__": 46
}
],
"_prefab": null,
......@@ -1573,17 +1698,17 @@
"_name": "mask",
"_objFlags": 0,
"_parent": {
"__id__": 31
"__id__": 34
},
"_children": [
{
"__id__": 33
"__id__": 36
}
],
"_active": true,
"_components": [
{
"__id__": 35
"__id__": 38
}
],
"_prefab": null,
......@@ -1639,13 +1764,13 @@
"_name": "page",
"_objFlags": 0,
"_parent": {
"__id__": 32
"__id__": 35
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 34
"__id__": 37
}
],
"_prefab": null,
......@@ -1701,7 +1826,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 33
"__id__": 36
},
"_enabled": true,
"_materials": [
......@@ -1733,7 +1858,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 32
"__id__": 35
},
"_enabled": true,
"_materials": [
......@@ -1753,14 +1878,14 @@
"_name": "circle",
"_objFlags": 0,
"_parent": {
"__id__": 31
"__id__": 34
},
"_children": [
{
"__id__": 37
"__id__": 40
},
{
"__id__": 39
"__id__": 42
}
],
"_active": false,
......@@ -1818,13 +1943,13 @@
"_name": "countDown_black",
"_objFlags": 0,
"_parent": {
"__id__": 36
"__id__": 39
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 38
"__id__": 41
}
],
"_prefab": null,
......@@ -1880,7 +2005,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 37
"__id__": 40
},
"_enabled": true,
"_materials": [
......@@ -1912,17 +2037,17 @@
"_name": "progress",
"_objFlags": 0,
"_parent": {
"__id__": 36
"__id__": 39
},
"_children": [
{
"__id__": 40
"__id__": 43
}
],
"_active": true,
"_components": [
{
"__id__": 42
"__id__": 45
}
],
"_prefab": null,
......@@ -1978,13 +2103,13 @@
"_name": "countDown_blue",
"_objFlags": 0,
"_parent": {
"__id__": 39
"__id__": 42
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 41
"__id__": 44
}
],
"_prefab": null,
......@@ -2040,7 +2165,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 40
"__id__": 43
},
"_enabled": true,
"_materials": [
......@@ -2072,12 +2197,12 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 39
"__id__": 42
},
"_enabled": true,
"_N$totalLength": 1,
"_N$barSprite": {
"__id__": 41
"__id__": 44
},
"_N$mode": 2,
"_N$progress": 1,
......@@ -2089,7 +2214,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 31
"__id__": 34
},
"_enabled": true,
"_materials": [
......@@ -2127,7 +2252,7 @@
"_active": true,
"_components": [
{
"__id__": 45
"__id__": 48
}
],
"_prefab": null,
......@@ -2183,7 +2308,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 44
"__id__": 47
},
"_enabled": true,
"_materials": [
......@@ -2225,10 +2350,10 @@
"_active": true,
"_components": [
{
"__id__": 47
"__id__": 50
},
{
"__id__": 48
"__id__": 51
}
],
"_prefab": null,
......@@ -2284,7 +2409,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 46
"__id__": 49
},
"_enabled": true,
"_materials": [
......@@ -2324,7 +2449,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 46
"__id__": 49
},
"_enabled": true,
"alignMode": 1,
......
......@@ -14,10 +14,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
this._imageResList.push({ url: page.startBg });
});
const bgNode = cc.find('Canvas/bg');
const bgNode = cc.find('Canvas/bg/startBg');
bgNode.color = cc.color(255, 255, 255);
const startBg = this.data.pageArr[this.currentPageIdx].startBg;
this.setNodeSpirteFrameByUrl(startBg, bgNode, resolve);
this.setNodeSpirteFrameByUrl(startBg, bgNode, (frame)=>{
bgNode.x = bgNode.parent.width / -2;
bgNode.y = bgNode.parent.height / 2;
bgNode.scale = bgNode.parent.height / frame.height;
});
})
}
......@@ -294,10 +299,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
book_right.active = true;
}
const bgNode = cc.find('Canvas/bg');
const bgNode = cc.find('Canvas/bg/startBg');
bgNode.color = cc.color(255, 255, 255);
const startBg = this.data.pageArr[this.currentPageIdx].startBg;
this.setNodeSpirteFrameByUrl(startBg, bgNode);
this.setNodeSpirteFrameByUrl(startBg, bgNode, (frame)=>{
bgNode.x = bgNode.parent.width / -2;
bgNode.y = bgNode.parent.height / 2;
bgNode.scale = bgNode.parent.height / frame.height;
});
}
showTips(tips) {
......@@ -332,7 +341,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
setNodeSpirteFrameByUrl(url: string, node: cc.Node, callBack = null) {
cc.assetManager.loadRemote(url, (err, tex) => {
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(tex);
callBack && callBack();
callBack && callBack(tex);
});
}
}
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