SpriteBodyComponent class

Inheritance

Constructors

SpriteBodyComponent(Sprite sprite, Vector2 spriteSize)
Make sure that the size of the sprite matches the bounding shape of the body that is create in createBody()

Properties

body Body
read / write, inherited
center Vector2
read-only, inherited
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 Forge2DGame
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, inherited
parent BaseComponent
read-only, inherited
positionComponent PositionComponent
read / write, 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
size Vector2
read / write, inherited
viewport Viewport
read-only, inherited
world World
read-only, inherited

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
inherited
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
inherited
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. [...]
@mustCallSuper, 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
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
inherited
renderCircle(Canvas canvas, Offset center, double radius) → void
inherited
renderDebugMode(Canvas canvas) → void
inherited
renderEdge(Canvas canvas, Offset p1, Offset p2) → void
inherited
renderPolygon(Canvas canvas, List<Offset> points) → void
inherited
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. [...]
inherited
updatePositionComponent() → void
inherited

Operators

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