Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We want to add possibility to set atlas texture size with static meth… #413

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cocos2d/base_nodes/CCNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2317,8 +2317,9 @@ protected virtual void Dispose(bool disposing)
if (Children != null && Children.Count > 0)
{
CCNode[] elements = Children.Elements;
foreach (CCNode child in Children.Elements)
for (var index = 0; index < Children.Elements.Length; index++)
{
var child = Children.Elements[index];
if (child != null)
{
if (!child.m_bCleaned)
Expand All @@ -2337,10 +2338,12 @@ public void CleanUpParentsProperly()
if (Children != null && Children.Count > 0)
{
CCNode[] elements = Children.Elements;
foreach (CCNode child in Children.Elements)
for (var index = 0; index < Children.Elements.Length; index++)
{
var child = Children.Elements[index];
child?.CleanUpParentsProperly();
}

Children.Clear(true);
}
Parent = null;
Expand Down
16 changes: 15 additions & 1 deletion cocos2d/label_nodes/CCLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private struct KerningInfo
}

public static CCTexture2D m_pTexture;
private static CCSize m_pAtlasTextureSize = new CCSize(0, 0);

protected static bool m_bTextureDirty = true;

protected string m_FontName;
Expand Down Expand Up @@ -93,6 +95,14 @@ public override string Text
}
}

public static void SetTTFAtlasTextureSize(float width, float height)
{
if (width > 0 && height > 0)
{
m_pAtlasTextureSize = new CCSize(width, height);
}
}

public static void InitializeTTFAtlas(int width, int height)
{
m_nWidth = width;
Expand Down Expand Up @@ -177,7 +187,11 @@ private CCBMFontConfiguration InitializeFont(string fontName, float fontSize, st

if (m_pData == null || s_pConfigurations.Count == 0)
{
if (fontSize >= 105)
if (m_pAtlasTextureSize.Width > 0 && m_pAtlasTextureSize.Height > 0)
{
InitializeTTFAtlas((int)m_pAtlasTextureSize.Width, (int)m_pAtlasTextureSize.Height);
}
else if (fontSize >= 105)
{
InitializeTTFAtlas(2048, 2048);
}
Expand Down
Loading