ComposedComponent mixin

A mixin that helps you to make a Component wraps other components. It is useful to group visual components through a hierarchy. When implemented, makes every item in its components collection field be updated and rendered with the same conditions.

Example of usage, where visibility of two components are handled by a wrapper:

 class GameOverPanel extends PositionComponent with Resizable, ComposedComponent {
  bool visible = false;

  GameOverText gameOverText;
  GameOverButton gameOverButton;

  GameOverPanel(Image spriteImage) : super() {
    gameOverText = GameOverText(spriteImage); // GameOverText is a Component
    gameOverButton = GameOverButton(spriteImage); // GameOverRestart is a SpriteComponent

    components..add(gameOverText)..add(gameOverButton);
  }

  @override
  void render(Canvas canvas) {
    if (visible) {
      super.render(canvas);
    } // If not, neither of its `components` will be rendered
  }
}
Superclass Constraints

Constructors

ComposedComponent()

Properties

components OrderedSet<Component>
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
gameRef Game
read / write, inherited

Methods

render(Canvas canvas) → void
Renders this component on the provided Canvas c.
override
update(double t) → void
This method is called periodically by the game engine to request that your component updates itself. [...]
override
add(Component c) → void
markToRemove(Component component) → void
tapableChildren() Iterable<Tapable>
Overwrite this to add children to this Tapable. [...]
override
resizableChildren() Iterable<Resizable>
resize(Size size) → void
This is a hook called by BaseGame to let this component know that the screen (or flame draw area) has been update. [...]
inherited
loaded() bool
Whether this component has been loaded yet. If not loaded, BaseGame will not try to render it. [...]
inherited
destroy() bool
Whether this should be destroyed or not. [...]
inherited
isHud() bool
Whether this component is HUD object or not. [...]
inherited
priority() int
Render priority of this component. This allows you to control the order in which your components are rendered. [...]
inherited
onMount() → void
Called when the component has been added and preperad by the game instance. [...]
inherited
onDestroy() → void
Called right before the component is destroyed and removed from the game
inherited
toString() String
Returns a string representation of this object.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toRect() Rect
inherited
onTapCancel() → void
inherited
onTapDown(TapDownDetails details) → void
inherited
onTapUp(TapUpDetails details) → void
inherited
checkTapOverlap(Offset o) bool
inherited
handleTapDown(int pointerId, TapDownDetails details) → void
inherited
handleTapUp(int pointerId, TapUpDetails details) → void
inherited
handleTapCancel(int pointerId) → void
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited