section Components API section

Description

"Components" are the Object Oriented classes that are created by your game code, added to your game loop and rendered on the screen.

Classes

  • Component

    An abstract base class for game components. It cannot be instantiated directly, but its subclasses are the building blocks for SGF games.

  • Container

    A Container is a concrete Component subclass, that acts similar to the main Screen itself. That is, you can add Components into a container just like you would in your game. Components placed inside containers are rendered with their attributes relative to the Container's attributes. Container supports all the regular Component properties (i.e. width, height, x, y, opacity, rotation, and zIndex). Changing the properties on a Container affect the global properties of the Components placed inside.

  • DumbContainer

    There are plenty of cases where a large amount of Components are going to be placed inside of a Container, BUT NEVER CHANGE. This scenario can be brought up by creating a tile based map using Sprite. Map's don't change beyond their initialization (usually), so it's a waste of CPU to re-render and check for updates of each individual tile, because we know that they will never need to change. That very scenario is why DumbContainer exists. Using a DumbContainer, all the tile sprites that were added to the container will only be rendered once, and then re-blitted to the screen for maximum speed.

  • Rectangle

    A Component that renders a single rectangle onto the screen as a solid color.

  • Shape

    Another abstract class, not meant to be instantiated directly. All "shape" type Component classes use this class as a base class. The only functionality that this class itself adds to a regular Component is Shape#color, since all shapes can have a color set for them.

  • Sprite

    Probably the most used Class in SGF to develop your games. Represents a single sprite state on a spriteset as a Component. The state of the sprite can be changed at any time.