Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NJ_MonkyTree
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
NJ_MonkyTree
Commits
6f11e2c9
Commit
6f11e2c9
authored
Sep 16, 2022
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 文字换图片
parent
889a065b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
238 additions
and
39 deletions
+238
-39
.DS_Store
.DS_Store
+0
-0
NJ_MonkyTree.fire
assets/NJ_MonkyTree/scene/NJ_MonkyTree.fire
+157
-2
NJ_MonkyTree.ts
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
+45
-37
Game.png
assets/NJ_MonkyTree/textures/units/Game.png
+0
-0
Game.png.meta
assets/NJ_MonkyTree/textures/units/Game.png.meta
+36
-0
No files found.
.DS_Store
View file @
6f11e2c9
No preview for this file type
assets/NJ_MonkyTree/scene/NJ_MonkyTree.fire
View file @
6f11e2c9
...
...
@@ -81,10 +81,10 @@
"_active": true,
"_components": [
{
"__id__": 42
4
"__id__": 42
7
},
{
"__id__": 42
5
"__id__": 42
8
}
],
"_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": "",
...
...
assets/NJ_MonkyTree/scene/NJ_MonkyTree.ts
View file @
6f11e2c9
...
...
@@ -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, () => {
...
...
assets/NJ_MonkyTree/textures/units/Game.png
0 → 100644
View file @
6f11e2c9
1.39 KB
assets/NJ_MonkyTree/textures/units/Game.png.meta
0 → 100644
View file @
6f11e2c9
{
"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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment