Commit 6f11e2c9 authored by limingzhe's avatar limingzhe

fix: 文字换图片

parent 889a065b
No preview for this file type
......@@ -81,10 +81,10 @@
"_active": true,
"_components": [
{
"__id__": 424
"__id__": 427
},
{
"__id__": 425
"__id__": 428
}
],
"_prefab": null,
......@@ -17712,6 +17712,9 @@
"_children": [
{
"__id__": 421
},
{
"__id__": 424
}
],
"_active": false,
......@@ -17923,6 +17926,158 @@
"_N$cacheMode": 0,
"_id": "2eXQdeVrRKkKLJ9ROFJKCL"
},
{
"__type__": "cc.Node",
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 420
},
"_children": [
{
"__id__": 425
}
],
"_active": true,
"_components": [],
"_prefab": null,
"_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": "e2lO0xYWNHkppJdOop4YAt"
},
{
"__type__": "cc.Node",
"_name": "Game",
"_objFlags": 0,
"_parent": {
"__id__": 424
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 426
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 151,
"height": 35
},
"_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": "3fdvLiZAtDzqTvBy0ebK0T"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 425
},
"_enabled": true,
"_materials": [],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "dd563340-84ee-4211-b768-bf66c2c34a31"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "eaQJuw1cRD3pLIVsBv9LWa"
},
{
"__type__": "cc.Canvas",
"_name": "",
......
......@@ -204,22 +204,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
lock.active = true;
const titleNode = attr.querySelector('.title');
const outline = '#000';
const name = "";
const richText = titleNode.getComponent(cc.RichText);
if ( !richText.fontSizeBase ) {
richText.fontSizeBase = richText.fontSize;
}
richText.fontSize = richText.fontSizeBase;
if (name.length > 14) {
richText.fontSize = richText.fontSizeBase * 0.7;
}
richText.font = cc.find("Canvas/res/font/BRLNSDB").getComponent(cc.Label).font;
// const outline = '#000';
// const name = "";
// const richText = titleNode.getComponent(cc.RichText);
// if ( !richText.fontSizeBase ) {
// richText.fontSizeBase = richText.fontSize;
// }
// richText.fontSize = richText.fontSizeBase;
// if (name.length > 14) {
// richText.fontSize = richText.fontSizeBase * 0.7;
// }
// richText.font = cc.find("Canvas/res/font/BRLNSDB").getComponent(cc.Label).font;
titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
width=4>${name}</outline>`
// titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
// width=4>${name}</outline>`
const textPng = this.getSprNode("Game");
titleNode.addChild(textPng);
textPng.y = -titleNode.height;
textPng.active = false;
titleNode.textPng = textPng;
});
......@@ -266,30 +271,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
const pa = parent.getComponent('Attributes');
const { outline } = pa.attrMap;
const name = lesson.name;
const richText = titleNode.getComponent(cc.RichText);
if ( !richText.fontSizeBase ) {
richText.fontSizeBase = richText.fontSize;
}
richText.fontSize = richText.fontSizeBase;
if (name.length > 14) {
richText.fontSize = richText.fontSizeBase * 0.7;
}
richText.font = cc.find("Canvas/res/font/BRLNSDB").getComponent(cc.Label).font;
console.log('idx: ', idx);
console.log("传入按钮名1:", name);
titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
width=4>${name}</outline>`;
console.log("显示按钮名1:", titleNode.getComponent(cc.RichText).string);
console.log('titleNode.x: ', titleNode.x);
console.log('titleNode.y: ', titleNode.y);
console.log('titleNode.active: ', titleNode.active);
console.log('titleNode.parent.x: ', titleNode.parent.x);
console.log('titleNode.parent.y: ', titleNode.parent.y);
console.log('titleNode.parent.active: ', titleNode.parent.active);
// const name = lesson.name;
// const richText = titleNode.getComponent(cc.RichText);
// if ( !richText.fontSizeBase ) {
// richText.fontSizeBase = richText.fontSize;
// }
// richText.fontSize = richText.fontSizeBase;
// if (name.length > 14) {
// richText.fontSize = richText.fontSizeBase * 0.7;
// }
// richText.font = cc.find("Canvas/res/font/BRLNSDB").getComponent(cc.Label).font;
// console.log('idx: ', idx);
// console.log("传入按钮名1:", name);
// titleNode.getComponent(cc.RichText).string = `<outline align=top color=${outline}
// width=4>${name}</outline>`;
// console.log("显示按钮名1:", titleNode.getComponent(cc.RichText).string);
// console.log('titleNode.x: ', titleNode.x);
// console.log('titleNode.y: ', titleNode.y);
// console.log('titleNode.active: ', titleNode.active);
// console.log('titleNode.parent.x: ', titleNode.parent.x);
// console.log('titleNode.parent.y: ', titleNode.parent.y);
// console.log('titleNode.parent.active: ', titleNode.parent.active);
titleNode.textPng.active = true;
// delayCall(1, () => {
......
{
"ver": "2.3.5",
"uuid": "6ee06d04-5730-4f73-8780-6268992ba436",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 151,
"height": 35,
"platformSettings": {},
"subMetas": {
"Game": {
"ver": "1.0.4",
"uuid": "dd563340-84ee-4211-b768-bf66c2c34a31",
"rawTextureUuid": "6ee06d04-5730-4f73-8780-6268992ba436",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 151,
"height": 35,
"rawWidth": 151,
"rawHeight": 35,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
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