SKSpriteNode
The SKSpriteNode
class is a root node class which is used to draw texture images with many customizations; it is inherited from the SKNode
class. We can simply draw an image, or we can add some effects, such as custom shader or shadows to it. For this, we have to first know about the SKSpriteNode
class and the functionality it offers.
Initializing a sprite
To make a sprite in a game, we have to make an instance of the SKSpriteNode
class. Sprite Kit provides us with many ways to initialize an instance of the SKSpriteNode
class. Some of them are as follows:
init(name: String){ //it is designated initializer . initialization part } convenience init(){ //Calling the Designated Initializer in same class self.init(name: "Hello") }
In Swift, one has to initialize a class by making an object of structure. There are two initializers provided for this purpose, that is, designated initializers and convenience initializers.
Designated initializers perform actual initialization...