Contents

init(imageNamed:normalMapped:)

Initializes a textured sprite using an image file, optionally adding a normal map to simulate 3D lighting.

Declaration

convenience init(imageNamed name: String, normalMapped generateNormalMap: Bool)

Parameters

  • name:

    The name of an image file stored in the app bundle.

  • generateNormalMap:

    If True, a normal map is generated from the image texture without applying any filter to it (SKTextureNormalMapFilteringTypeNone). If False, no normal map is generated (matching the behavior of the Spritenodewithimagenamed: class method).

Return Value

A newly initialized sprite object.

Discussion

The normal map is used only when lighting is enabled in the scene. For more information, see SKSpriteNode and SKLightNode.

See Also

Creating a Sprite from an Image Filename