More about sprites

You’ve learnt how to use quite a few useful sprite properties so far, like x, y, visible, and rotation that give you a lot of control over a sprite’s position and appearance. But Pixi Sprites also have many more useful properties that are fun to play with. Here’s the full list.

How does Pixi’s class inheritance system work? (What is a class and what is inheritance? Click this link to find out.) Pixi’s sprites are built on an inheritance model that follows this chain:

  1. DisplayObject > Container > Sprite

Inheritance just means that the classes later in the chain use properties and methods from classes earlier in the chain. That means that even though Sprite is the last class in the chain, has all the same properties as DisplayObject and Container, in addition to its own unique properties. The most basic class is DisplayObject. Anything that’s a DisplayObject can be rendered on the stage. Container is the next class in the inheritance chain. It allows DisplayObjects to act as containers for other DisplayObjects. Third up the chain is the Sprite class. Sprites can both be displayed on the stage and be containers for other sprites.