TextureAtlas
public class TextureAtlas
A TextureAtlas
is an object that contains multiple textures to be loaded and used as one texture.
Since this engine is tile based I wrote a rather inefficient texture packing script to be insert into the build phase. It creates two new xcassets from an existing one that packs all the sprites together and creates the JSON data.
Seealso
${PROJECT_DIR}/resources/README.md andAtlasGen.py
in the same directory.
-
Undocumented
Declaration
Swift
public class TextureAtlas
-
Designated failable initializer. Creates a new texture atlas with corresponding data to
unpack
it.Note
The name parameter will correspond to a group in your regular xcasset. If no groups are specified the name defaults to
Atlas
.discussion: This will fail if not using the scripts in ${PROJECT_DIR}/resources or if the manually generated xcasset does not match the format.
Declaration
Swift
public init?(named: String)
Parameters
named
The name of the atlas to be used. Can be found in the output of the generated xcasset.
Return Value
A new instance of
TextureAtlas
. -
Unpack
a texture from the atlas with a given name.Note
I’m still trying to decide if there is a better way to make a
copy
.Declaration
Swift
public func textureNamed(named: String) -> Texture?
Parameters
named
The name of the texture to get.
Return Value
A
Texture
copy
from the atlas.