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 concreteComponent
subclass, that acts similar to the mainScreen
itself. That is, you can addComponent
s 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 regularComponent
properties (i.e.width
,height
,x
,y
,opacity
,rotation
, andzIndex
). 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
Component
s are going to be placed inside of aContainer
, BUT NEVER CHANGE. This scenario can be brought up by creating a tile based map usingSprite
. 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 whyDumbContainer
exists. Using aDumbContainer
, 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 regularComponent
isShape#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.