Other Functions
The following functions are available globally.
-
Send an alert. This a convenience utility to create an NSAlert with some properties.
Declaration
Swift
func sendAlert(_ message: String, withTitle: String?, level: NSAlert.Style, handler: @escaping ((NSApplication.ModalResponse) -> Void))Parameters
messageThe message of the alert.
withTitleThe title of the alert.
levelThe level of importance for the alert.
handlerAn escaping closure that handles the alert’s response when given.
-
Send an alert. This a convenience utility to create an NSAlert with some properties.
Declaration
Swift
func sendAlert(_ message: String, withTitle: String?, level: NSAlert.Style, attachToMainWindow: Bool, handler: @escaping ((NSApplication.ModalResponse) -> Void))Parameters
messageThe message of the alert.
withTitleThe title of the alert.
levelThe level of importance for the alert.
attachToMainWindowWhether to attach the alert to the main window.
handlerAn escaping closure that handles the alert’s response when given.
-
Send a confirmation alert. This a convenience utility to create an NSAlert with some properties.
Declaration
Swift
func confirm(_ message: String, withTitle: String?, level: NSAlert.Style, handler: @escaping ((NSApplication.ModalResponse) -> Void))Parameters
messageThe message of the alert.
withTitleThe title of the alert.
levelThe level of importance for the alert.
handlerAn escaping closure that handles the alert’s response when given.
-
Get a list of frames from an atlas.
Declaration
Swift
public func animated(fromAtlas atlas: SKTextureAtlas, reversable: Bool = false) -> [SKTexture]Parameters
atlasThe atlas to read animation frames from.
reversableWhether the animation should play in reverse afterwards. Defaults to false.
Return Value
A list of textures that make up the animation.
-
Get the type of tile from a given definition.
Declaration
Swift
public func getTileType(fromDefinition tile: SKTileDefinition) -> GameTileTypeParameters
tileThe tile definition to look up the type for.
Return Value
The respective tile type as
GameTileType. -
Create a physics body for a wall with a given texture.
Declaration
Swift
public func getWallPhysicsBody(with texture: SKTexture) -> SKPhysicsBodyParameters
textureThe texture to assign the wall’s physics body to.
Return Value
A physics body that matches the texture.
-
Create a physics body for a wall with a given texture.
Declaration
Swift
public func getWallPhysicsBody(with textureName: String) -> SKPhysicsBodyParameters
textureThe texture to assign the wall’s physics body to.
Return Value
A physics body that matches the texture.
-
Create a physics body for a heavy object with a given texture.
Declaration
Swift
public func getHeavyObjectPhysicsBody(with texture: SKTexture) -> SKPhysicsBodyParameters
textureThe texture to assign the object’s physics body to.
Return Value
A physics body that matches the texture.
-
Create a physics body for a heavy object with a given texture.
Declaration
Swift
public func getHeavyObjectPhysicsBody(with textureName: String) -> SKPhysicsBodyParameters
textureThe name of the texture to assign the object’s physics body to.
Return Value
A physics body that matches the texture.
-
Read a property list file and get the contents as a dictionary.
Declaration
Swift
func plist(from plistName: String) -> NSDictionary?Parameters
plistNameThe name of the property lsit file to get the data of.
Return Value
A dictionary representation of the file, or a null value if none is found.
-
Returns the level properties file as a list of level items.
Declaration
Swift
func getLevelProperties() -> [GameLevelItem]?Return Value
A list of level items, or nil if an unexpected error occurs.
-
Returns the level properties file as a list of level items.
Declaration
Swift
func getRecordableLevelProperties() -> [GameLevelItem]?Return Value
A list of level items, or nil if an unexpected error occurs.