@physion/app / Exports / BodyNode
Class: BodyNode
This is the base class for all bodies.
Hierarchy
-
↳
BodyNode↳↳
CapsuleNode↳↳
CircleNode
Constructors
constructor
• new BodyNode(): BodyNode
Returns
Overrides
Properties
userData
• userData: Record<string, unknown>
Inherited from
EVT_CHILD_ADDED
▪ Static Readonly EVT_CHILD_ADDED: "childAdded"
The name of the event that is emitted whenever a child is added to this node.
The argument supplied is the child that was just added to this node.
Inherited from
EVT_CHILD_REMOVED
▪ Static Readonly EVT_CHILD_REMOVED: "childRemoved"
The name of the event that is emitted whenever a child is removed from this node.
The argument supplied is the child that was just removed from this node.
Inherited from
GraphicsNode.EVT_CHILD_REMOVED
EVT_CHILD_REORDERED
▪ Static Readonly EVT_CHILD_REORDERED: "childReordered"
The name of the event that is emitted whenever a child of this node is reordered.
The arguments supplied are: (1) The child that was just reordered (2) the old index of the child and (3) the new index of the child.
Inherited from
GraphicsNode.EVT_CHILD_REORDERED
EVT_NAME_CHANGED
▪ Static Readonly EVT_NAME_CHANGED: "nameChanged"
The name of the event that is emitted whenever the name of this object changes.
The argument suplied is the new CoreObject.name of the object.
Inherited from
EVT_PROPERTY_CHANGED
▪ Static Readonly EVT_PROPERTY_CHANGED: "propertyChanged"
The name of the event that is emitted whenever a property of this object changes.
The arguments supplied are: (1) The name of the property that has changed and (2) the new value of that property.
Inherited from
GraphicsNode.EVT_PROPERTY_CHANGED
EVT_TRANSFORM_CHANGED
▪ Static Readonly EVT_TRANSFORM_CHANGED: "transformChanged"
The name of the event that is emitted whenever the x, y or angle properties of this Node are changed.
Note that this event is not emitted when x, y or angle properties are changed as a result of
an update().
Inherited from
GraphicsNode.EVT_TRANSFORM_CHANGED
ID_LENGTH
▪ Static Readonly ID_LENGTH: 12
Inherited from
MAX_NAME_LENGTH
▪ Static Readonly MAX_NAME_LENGTH: 128
Inherited from
Accessors
active
• get active(): boolean
Returns true if this body is active, otherwise returns false.
An inactive body will be visualized but it won't participate in the simulation.
Returns
boolean
• set active(v): void
Sets this body's active property
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
allowSleep
• get allowSleep(): boolean
Returns true if this body is allowed to sleep, otherwise returns false.
By default, all bodies are allowed to sleep. This basically means that when a body has come to rest and it has no collisions then it will go to sleep. Setting a body to sleep reduces then number of object we have to simulated (thus increasing performance).
Returns
boolean
• set allowSleep(v): void
Sets this body's allowSleep property
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
alpha
• get alpha(): number
Node's alpha
This value is between 0 (transparent) and 1.0 (opaque). This property can be considered as the "master" opacity of the node. Defaults to 1 (fully opaque)
Returns
number
Inherited from
GraphicsNode.alpha
• set alpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.alpha
angle
• get angle(): number
Returns the angle (in degrees) of this body
Returns
number
Overrides
GraphicsNode.angle
• set angle(v): void
Sets the angle (in degrees) of this body
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.angle
angularDamping
• get angularDamping(): number
Returns
number
• set angularDamping(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
angularVelocity
• get angularVelocity(): number
Returns
number
• set angularVelocity(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
blendMode
• get blendMode(): BLEND_MODES
Returns
BLEND_MODES
Inherited from
GraphicsNode.blendMode
• set blendMode(v): void
Parameters
| Name | Type |
|---|---|
v | BLEND_MODES |
Returns
void
Inherited from
GraphicsNode.blendMode
body
• get body(): undefined | b2Body
Returns
undefined | b2Body
bodyType
• get bodyType(): BodyType
Returns the body type of this body.
Returns
BodyType
• set bodyType(v): void
Sets this body's bodyType property
Parameters
| Name | Type |
|---|---|
v | BodyType |
Returns
void
bullet
• get bullet(): boolean
Returns true if this body is a bullet, otherwise returns false.
This property only affects dynamic bodies. If a dynamic body is set to be a bullet then continuous collision detection (CCD) will be used and scenarios where a fast moving object tunels through other bodies are avoided. Note that bullets are more computational expensive.
Returns
boolean
• set bullet(v): void
Sets this body's bullet property
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
childCount
• get childCount(): number
Returns the number of children this node contains.
Returns
number
Inherited from
GraphicsNode.childCount
children
• get children(): Node[]
Returns the children of this node.
Returns
Node[]
Inherited from
GraphicsNode.children
density
• get density(): number
Returns
number
• set density(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
fillAlpha
• get fillAlpha(): number
Returns
number
Inherited from
GraphicsNode.fillAlpha
• set fillAlpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.fillAlpha
fillColor
• get fillColor(): number
Returns
number
Inherited from
GraphicsNode.fillColor
• set fillColor(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.fillColor
fillMatrix
• get fillMatrix(): IMatrix
Returns
IMatrix
Inherited from
GraphicsNode.fillMatrix
• set fillMatrix(v): void
Parameters
| Name | Type |
|---|---|
v | IMatrix |
Returns
void
Inherited from
GraphicsNode.fillMatrix
fillStyle
• get fillStyle(): FillStyle
Returns
FillStyle
Inherited from
GraphicsNode.fillStyle
fillTexture
• get fillTexture(): string
Returns
string
Inherited from
GraphicsNode.fillTexture
• set fillTexture(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
Inherited from
GraphicsNode.fillTexture
filterCategoryBits
• get filterCategoryBits(): number
Returns
number
• set filterCategoryBits(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
filterGroupIndex
• get filterGroupIndex(): number
Returns
number
• set filterGroupIndex(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
filterMaskBits
• get filterMaskBits(): number
Returns
number
• set filterMaskBits(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
fixedRotation
• get fixedRotation(): boolean
Returns true if this body has fixed rotation, otherwise returns false.
When a body has fixed rotation then it will maintain its original rotation.
Returns
boolean
• set fixedRotation(v): void
Sets this body's fixedRotation property
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
fixtures
• get fixtures(): b2Fixture[]
Returns
b2Fixture[]
flags
• get flags(): CoreObjectFlags
Returns
CoreObjectFlags
Inherited from
GraphicsNode.flags
freeBodyDiagram
• get freeBodyDiagram(): IFreeBodyDiagram
The forces drawn on top of this body, keyed by types.ForceKey. See FreeBodyDiagramMixin.
Returns
IFreeBodyDiagram
• set freeBodyDiagram(v): void
Parameters
| Name | Type |
|---|---|
v | IFreeBodyDiagram |
Returns
void
friction
• get friction(): number
Returns
number
• set friction(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
graphics
• get graphics(): Graphics
Returns
Graphics
Inherited from
GraphicsNode.graphics
gravityScale
• get gravityScale(): number
Returns
number
• set gravityScale(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
id
• get id(): string
Object's (unique) id
Note that the id of the object cannot be set (it is automatically assigned upon construction)
Returns
string
Inherited from
GraphicsNode.id
lineAlignment
• get lineAlignment(): number
Returns
number
Inherited from
GraphicsNode.lineAlignment
• set lineAlignment(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineAlignment
lineAlpha
• get lineAlpha(): number
The line alpha used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineAlpha
• set lineAlpha(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineAlpha
lineColor
• get lineColor(): number
The line color used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineColor
• set lineColor(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineColor
lineNative
• get lineNative(): boolean
Returns
boolean
Inherited from
GraphicsNode.lineNative
• set lineNative(v): void
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
Inherited from
GraphicsNode.lineNative
lineStyle
• get lineStyle(): LineStyle
Returns
LineStyle
Inherited from
GraphicsNode.lineStyle
lineWidth
• get lineWidth(): number
The line width used when drawing the graphics.
Returns
number
Inherited from
GraphicsNode.lineWidth
• set lineWidth(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.lineWidth
linearDamping
• get linearDamping(): number
Returns
number
• set linearDamping(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
linearVelocity
• get linearVelocity(): number
Returns
number
linearVelocityX
• get linearVelocityX(): number
Returns
number
• set linearVelocityX(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
linearVelocityY
• get linearVelocityY(): number
Returns
number
• set linearVelocityY(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
mass
• get mass(): undefined | number
Returns
undefined | number
metaObject
• get metaObject(): MetaObject
Returns the MetaObject that describes this class
Returns
Overrides
GraphicsNode.metaObject
name
• get name(): string
The object's name
The object's name is a free text value which defaults to an empty string.
Note that when the name of the object changes, the CoreObject.EVT_NAME_CHANGED signal will be emitted.
Returns
string
Inherited from
GraphicsNode.name
• set name(v): void
Parameters
| Name | Type |
|---|---|
v | string |
Returns
void
Inherited from
GraphicsNode.name
parent
• get parent(): undefined | Node
Returns the parent of this node (or undefined if this node has no parent).
Returns
undefined | Node
Inherited from
GraphicsNode.parent
restitution
• get restitution(): number
Returns
number
• set restitution(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
scripts
• get scripts(): IScript[]
Returns
IScript[]
Inherited from
GraphicsNode.scripts
• set scripts(v): void
Parameters
| Name | Type |
|---|---|
v | IScript[] |
Returns
void
Inherited from
GraphicsNode.scripts
sensor
• get sensor(): boolean
Returns
boolean
• set sensor(v): void
Parameters
| Name | Type |
|---|---|
v | boolean |
Returns
void
ttl
• get ttl(): number
Node's time-to-live, in milliseconds.
A value of -1 (the default) means this node has no ttl and will never be automatically removed. Any other value counts down while the simulation is running; once it reaches 0 the node (and any nodes that depend on it) is removed from the Scene.
Has no effect on the Scene node itself, which never counts down or gets removed via ttl.
Returns
number
Inherited from
GraphicsNode.ttl
• set ttl(v): void
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Inherited from
GraphicsNode.ttl
visualFilters
• get visualFilters(): IVisualFilters
The visual effects drawn over this node and its children, keyed by types.VisualFilterKey. See VisualFiltersMixin.
Returns
IVisualFilters
Inherited from
GraphicsNode.visualFilters
• set visualFilters(v): void
Parameters
| Name | Type |
|---|---|
v | IVisualFilters |
Returns
void
Inherited from
GraphicsNode.visualFilters
x
• get x(): number
Returns the x position of this body
Returns
number
Overrides
GraphicsNode.x
• set x(v): void
Sets the x position of this body
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.x
y
• get y(): number
Returns the y position of this body
Returns
number
Overrides
GraphicsNode.y
• set y(v): void
Sets the y position of this body
Parameters
| Name | Type |
|---|---|
v | number |
Returns
void
Overrides
GraphicsNode.y
Methods
addChild
▸ addChild(child): boolean
Adds the given child to this node.
If the given child is already contained in this node or it already has a Node.parent then this method will fail (false will be returned).
Otherwise the child will be added to this node and the Node.EVT_CHILD_ADDED signal will be emitted.
Parameters
| Name | Type | Description |
|---|---|---|
child | Node | The child to be added to this node. |
Returns
boolean
True on success otherwise false.
Inherited from
addChildren
▸ addChildren(children): void
Convenience method for adding multiple children to this node.
Parameters
| Name | Type |
|---|---|
children | Node[] |
Returns
void
Inherited from
addScript
▸ addScript(assetId, params?): undefined | IScript
Adds a new script to this node.
Convenience wrapper around the scripts property, which validates the entry and rejects it if
malformed. An entry whose asset is not available yet stays inert until it is.
Parameters
| Name | Type | Description |
|---|---|---|
assetId | string | The id of the script's TextAsset. |
params | ScriptParams | Initial values for the script's editable properties. |
Returns
undefined | IScript
A copy of the added script entry, or undefined if it was rejected.
Use its id with getNodeScript() or removeScript().
Inherited from
applyAngularImpulse
▸ applyAngularImpulse(impulse, wake?): void
Parameters
| Name | Type |
|---|---|
impulse | number |
wake? | boolean |
Returns
void
applyForce
▸ applyForce(force, point?, wake?): void
Parameters
| Name | Type |
|---|---|
force | IPoint |
point? | IPoint |
wake? | boolean |
Returns
void
applyLinearImpulse
▸ applyLinearImpulse(impulse, point?, wake?): void
Parameters
| Name | Type |
|---|---|
impulse | IPoint |
point? | IPoint |
wake? | boolean |
Returns
void
autoAdjustFillTexture
▸ autoAdjustFillTexture(): Promise<void>
Returns
Promise<void>
Inherited from
GraphicsNode.autoAdjustFillTexture
callMethodForAllNodeScripts
▸ callMethodForAllNodeScripts<T>(methodName, ...args): void
Type parameters
| Name | Type |
|---|---|
T | extends NodeScriptMethodName |
Parameters
| Name | Type |
|---|---|
methodName | T |
...args | Parameters<NonNullable<INodeScriptValue[T]>> |
Returns
void
Inherited from
GraphicsNode.callMethodForAllNodeScripts
canAddChild
▸ canAddChild(child): boolean
Returns true if the given child can be added to this node
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
canRemoveChild
▸ canRemoveChild(child): boolean
Returns true if the given child can be removed from this node
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
childIndex
▸ childIndex(child): number
Returns the index of the given child (or -1 if child is not contained in thie node).
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
number
Inherited from
clone
▸ clone(): BodyNode
Creates and returns a clone of this node.
The clone returned will have the same property values as this node except from its CoreObject.id.
Returns
A clone of this node.
Inherited from
containsChild
▸ containsChild(child): boolean
Returns true if this node contains the given child
Parameters
| Name | Type |
|---|---|
child | Node |
Returns
boolean
Inherited from
copyFillTextureFrom
▸ copyFillTextureFrom(source): void
Copies the source's already-resolved texture directly, instead of just the fillTexture id (which would force a fresh async reload and flash the default white fill in the meantime).
Note: this node may not be attached to a scene yet, so don't call updateFillTexture() here to "double check" - it can't find its asset without a scene and would reset us back to white. onEnterScene() re-resolves the texture once the node actually gets attached.
Parameters
| Name | Type |
|---|---|
source | GraphicsNode |
Returns
void
Inherited from
GraphicsNode.copyFillTextureFrom
destroy
▸ destroy(): void
Returns
void
Overrides
findAncestorByClassName
▸ findAncestorByClassName(className): undefined | Node
Parameters
| Name | Type |
|---|---|
className | string |
Returns
undefined | Node
Inherited from
GraphicsNode.findAncestorByClassName
findChildById
▸ findChildById(id): undefined | Node
Finds and returns the child with the given id.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The CoreObject.id of the child to search for. |
Returns
undefined | Node
The child with the given id or undefined if no such child exists.
Inherited from
findChildByName
▸ findChildByName(name): undefined | Node
Finds and returns the first child node with the given name.
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The CoreObject.name of the child to search for. |
Returns
undefined | Node
The first child with the given name or undefined if no such child exists.
Inherited from
findDescendantById
▸ findDescendantById(id): undefined | Node
Finds and returns the descendant with the given id.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The CoreObject.id of the descendant to search for. |
Returns
undefined | Node
The descendant with the given id or undefined if no such descendant exists.
Inherited from
GraphicsNode.findDescendantById
findSceneAssetById
▸ findSceneAssetById(id): undefined | Asset
Finds and returns the asset specified by the given id. Note that the node needs to be parented to a Scene for this method to work.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The id of the asset to search for. |
Returns
undefined | Asset
The matched Asset of undefined if no such asset exists in the scene.
Inherited from
GraphicsNode.findSceneAssetById
findSceneAssetByName
▸ findSceneAssetByName(name): undefined | Asset
Finds and returns the asset specified by the given name. Note that the node needs to be parented to a Scene for this method to work. Asset names are not unique, so if more than one asset shares the given name the first match is returned.