BodyComponent<T extends Forge2DGame> class

Since a pure BodyComponent doesn't have anything drawn on top of it, it is a good idea to turn on debudMode for it so that the bodies can be seen

Inheritance
Mixed in types
Implementers

Constructors

BodyComponent({Paint paint})

Properties

body Body
read / write
center Vector2
read-only
children UnmodifiableListView<Component>
The children list shouldn't be modified directly, that is why an UnmodifiableListView is used. If you want to add children use the addChild method, and if you want to propagate something to the children use the propagateToChildren method.
read-only, inherited
debugColor Color
read / write, inherited
debugMode bool
This is set by the BaseGame to tell this component to render additional debug information, like borders, coordinates, etc. This is very helpful while debugging. Set your BaseGame debugMode to true. You can also manually override this for certain components in order to identify issues.
read / write, inherited
debugPaint Paint
read-only, inherited
debugTextConfig TextConfig
read-only, inherited
effects List<ComponentEffect<BaseComponent>>
Get a list of non removed effects
read-only, inherited
gameRef ↔ T
read / write, inherited
hasGameRef bool
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
isHud bool
Whether this component is HUD object or not. [...]
read / write, inherited
isMounted bool
Whether this component is currently mounted on a game or not
read-only, inherited
paint Paint
read / write
parent BaseComponent
read-only, inherited
priority int
Render priority of this component. This allows you to control the order in which your components are rendered. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shouldRemove bool
Whether this component should be removed or not. [...]
read / write, inherited
viewport Viewport
read-only
world World
read-only

Methods

addChild(Component child, {Game gameRef}) Future<void>
Uses the game passed in, or uses the game from HasGameRef otherwise, to prepare the child component before it is added to the list of children. Note that this component needs to be added to the game first if this.gameRef should be used to prepare the child. For children that don't need preparation from the game instance can disregard both the options given above.
inherited
addEffect(ComponentEffect<BaseComponent> effect) → void
Add an effect to the component
inherited
checkOverlap(Vector2 point) bool
clearChildren() → void
inherited
clearEffects() → void
Remove all effects
inherited
containsChild(Component c) bool
inherited
containsPoint(Vector2 point) bool
Called to check whether the point is to be counted as within the component It needs to be overridden to have any effect, like it is in PositionComponent.
inherited
createBody() Body
You should create the Body in this method when you extend the BodyComponent
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
onGameResize(Vector2 gameSize) → void
It receives the new game size. Executed right after the component is attached to a game and right before onMount is called
@mustCallSuper, inherited
onLoad() Future<void>
Called before the component is added to the BaseGame by the add method. Whenever this returns something, BaseGame will wait for the Future to be resolved before adding the component on the list. If null is returned, the component is added right away. [...]
inherited
onMount() → void
Called when the component has been added and prepared by the game instance. [...]
@mustCallSuper, inherited
onRemove() → void
Called right before the component is removed from the game
@mustCallSuper, inherited
prepareCanvas(Canvas canvas) → void
@protected, inherited
propagateToChildren<T extends Component>(bool handler(T)) bool
This method first calls the passed handler on the leaves in the tree, the children without any children of their own. Then it continues through all other children. The propagation continues until the handler returns false, which means "do not continue", or when the handler has been called with all children [...]
inherited
remove() → void
Remove the component from the game it is added to in the next tick
inherited
removeChild(Component c) bool
inherited
removeEffect(ComponentEffect<BaseComponent> effect) → void
Mark an effect for removal on the component
inherited
render(Canvas canvas) → void
Renders this component on the provided Canvas c.
@mustCallSuper, inherited
renderChain(Canvas canvas, List<Offset> points) → void
renderCircle(Canvas canvas, Offset center, double radius) → void
renderDebugMode(Canvas canvas) → void
override
renderEdge(Canvas canvas, Offset p1, Offset p2) → void
renderPolygon(Canvas canvas, List<Offset> points) → void
renderTree(Canvas canvas) → void
This is used to render this component and potential children on subclasses of Component on the provided Canvas c.
@mustCallSuper, inherited
toString() String
A string representation of this object. [...]
inherited
update(double dt) → void
This method is called periodically by the game engine to request that your component updates itself. [...]
@mustCallSuper, inherited

Operators

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

Constants

defaultColor → const Color
const Color.fromARGB(255, 255, 255, 255)
maxPolygonVertices → const int
8