Skip to main content

FlixelAssetPaths

View source

class

org.flixelgdx.asset.FlixelAssetPaths

public final class FlixelAssetPaths

Canonical path helpers for internal asset keys used with FlixelAssetManager and libGDX file APIs.

Accidentally duplicated slashes (for example "ui//mainmenu/bg.png") or backslashes can confuse loaders, especially on HTML backends where manifest paths often match internal keys literally.

This helper collapses duplicate separators into one forward slash and maps '\' to '/', matching the common layout used inside assets/. Call sites include FlixelDefaultAssetManager.

Note: This is aimed at internal resource paths such as "fonts/foo.ttf", not arbitrary URLs or UNC paths.

Methods

normalizeAssetPath(String)

public static String normalizeAssetPath(String path)

Returns the same path with redundant slashes collapsed and backslashes converted to forward slashes.

If the input already looks canonical, the original reference may be returned to avoid allocating.

Parameters:

NameDescription
pathInternal asset path. Must not be null.

Returns: Canonical internal-style path (never null; empty stays empty).


resolveCompressedTexturePath(String)

public static String resolveCompressedTexturePath(String path)

Returns the best available path for loading a texture when compressed textures are enabled.

For .png paths the method checks whether a .ktx2 sibling exists and prefers it; if not, the original PNG path is returned as-is so the caller can fall back to the uncompressed version. For .ktx2 paths the file is verified to exist and, if it does not, the method tries the matching .png sibling instead. Every other extension is returned unchanged.

Callers are expected to only invoke this when FlixelAssetManager.isCompressedTexturesEnabled() is true, since the existence check touches the file system. Returns path unchanged when libGDX is not yet initialized.

Parameters:

NameDescription
pathInternal asset path. Must not be null.

Returns: The best available path for this texture, never null.