GearNode
@physion/app / Exports / GearNode
Class: GearNode
Represents a simple spur gear.
The gear geometry is specified by 3 parameters:
Radius is essentially the outer radius of the gear. The height of each gear tooth is defined by toothHeight. This means that the inner radius of the gear is radius - toothHeight. Finally the density of the gear teeth is specified by toothDensity.
Hierarchy
↳
GearNode
Constructors
constructor
• new GearNode(radius?
, toothHeight?
, toothDensity?
): GearNode
Parameters
Name | Type | Default value |
---|---|---|
radius | number | defaultRadius |
toothHeight | number | defaultToothHeight |
toothDensity | number | defaultToothDensity |
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
MultipartBodyNode.EVT_CHILD_ADDED
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
MultipartBodyNode.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
MultipartBodyNode.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
MultipartBodyNode.EVT_NAME_CHANGED
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
MultipartBodyNode.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
MultipartBodyNode.EVT_TRANSFORM_CHANGED
MIN_RADIUS
▪ Static
Readonly
MIN_RADIUS: 0.2
MIN_TOOTH_DENSITY
▪ Static
Readonly
MIN_TOOTH_DENSITY: 1
MIN_TOOTH_HEIGHT
▪ Static
Readonly
MIN_TOOTH_HEIGHT: number
= minToothHeight
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
Inherited from
MultipartBodyNode.active
• set
active(v
): void
Sets this body's active
property
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.active
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
Inherited from
MultipartBodyNode.allowSleep
• set
allowSleep(v
): void
Sets this body's allowSleep
property
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.allowSleep
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
MultipartBodyNode.alpha
• set
alpha(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.alpha
angle
• get
angle(): number
Returns the angle
(in degrees) of this body
Returns
number
Inherited from
MultipartBodyNode.angle
• set
angle(v
): void
Sets the angle
(in degrees) of this body
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.angle
angularDamping
• get
angularDamping(): number
Returns
number
Inherited from
MultipartBodyNode.angularDamping
• set
angularDamping(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.angularDamping
angularVelocity
• get
angularVelocity(): number
Returns
number
Inherited from
MultipartBodyNode.angularVelocity
• set
angularVelocity(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.angularVelocity
blendMode
• get
blendMode(): BLEND_MODES
Returns
BLEND_MODES
Inherited from
MultipartBodyNode.blendMode
• set
blendMode(v
): void
Parameters
Name | Type |
---|---|
v | BLEND_MODES |
Returns
void
Inherited from
MultipartBodyNode.blendMode
body
• get
body(): undefined
| b2Body
Returns
undefined
| b2Body
Inherited from
MultipartBodyNode.body
bodyType
• get
bodyType(): BodyType
Returns the body type of this body.
Returns
BodyType
Inherited from
MultipartBodyNode.bodyType
• set
bodyType(v
): void
Sets this body's bodyType
property
Parameters
Name | Type |
---|---|
v | BodyType |
Returns
void
Inherited from
MultipartBodyNode.bodyType
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
Inherited from
MultipartBodyNode.bullet
• set
bullet(v
): void
Sets this body's bullet
property
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.bullet
childCount
• get
childCount(): number
Returns the number of children this node contains.
Returns
number
Inherited from
MultipartBodyNode.childCount
children
• get
children(): Node
[]
Returns the children of this node.
Returns
Node
[]
Inherited from
MultipartBodyNode.children
density
• get
density(): number
Returns
number
Inherited from
MultipartBodyNode.density
• set
density(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.density
drawPieces
• get
drawPieces(): boolean
Returns
boolean
Inherited from
MultipartBodyNode.drawPieces
• set
drawPieces(v
): void
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.drawPieces
fillAlpha
• get
fillAlpha(): number
Returns
number
Inherited from
MultipartBodyNode.fillAlpha
• set
fillAlpha(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.fillAlpha
fillColor
• get
fillColor(): number
Returns
number
Inherited from
MultipartBodyNode.fillColor
• set
fillColor(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.fillColor
fillMatrix
• get
fillMatrix(): IMatrix
Returns
IMatrix
Inherited from
MultipartBodyNode.fillMatrix
• set
fillMatrix(v
): void
Parameters
Name | Type |
---|---|
v | IMatrix |
Returns
void
Inherited from
MultipartBodyNode.fillMatrix
fillStyle
• get
fillStyle(): FillStyle
Returns
FillStyle
Inherited from
MultipartBodyNode.fillStyle
fillTexture
• get
fillTexture(): string
Returns
string
Inherited from
MultipartBodyNode.fillTexture
• set
fillTexture(v
): void
Parameters
Name | Type |
---|---|
v | string |
Returns
void
Inherited from
MultipartBodyNode.fillTexture
filterCategoryBits
• get
filterCategoryBits(): number
Returns
number
Inherited from
MultipartBodyNode.filterCategoryBits
• set
filterCategoryBits(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.filterCategoryBits
filterGroupIndex
• get
filterGroupIndex(): number
Returns
number
Inherited from
MultipartBodyNode.filterGroupIndex
• set
filterGroupIndex(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.filterGroupIndex
filterMaskBits
• get
filterMaskBits(): number
Returns
number
Inherited from
MultipartBodyNode.filterMaskBits
• set
filterMaskBits(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.filterMaskBits
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
Inherited from
MultipartBodyNode.fixedRotation
• set
fixedRotation(v
): void
Sets this body's fixedRotation
property
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.fixedRotation
fixtures
• get
fixtures(): b2Fixture
[]
Returns
b2Fixture
[]
Inherited from
MultipartBodyNode.fixtures
flags
• get
flags(): CoreObjectFlags
Returns
CoreObjectFlags
Inherited from
MultipartBodyNode.flags
friction
• get
friction(): number
Returns
number
Inherited from
MultipartBodyNode.friction
• set
friction(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.friction
graphics
• get
graphics(): Graphics
Returns
Graphics
Inherited from
MultipartBodyNode.graphics
gravityScale
• get
gravityScale(): number
Returns
number
Inherited from
MultipartBodyNode.gravityScale
• set
gravityScale(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.gravityScale
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
MultipartBodyNode.id
lineAlignment
• get
lineAlignment(): number
Returns
number
Inherited from
MultipartBodyNode.lineAlignment
• set
lineAlignment(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.lineAlignment
lineAlpha
• get
lineAlpha(): number
The line alpha used when drawing the graphics.
Returns
number
Inherited from
MultipartBodyNode.lineAlpha
• set
lineAlpha(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.lineAlpha
lineColor
• get
lineColor(): number
The line color used when drawing the graphics.
Returns
number
Inherited from
MultipartBodyNode.lineColor
• set
lineColor(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.lineColor
lineNative
• get
lineNative(): boolean
Returns
boolean
Inherited from
MultipartBodyNode.lineNative
• set
lineNative(v
): void
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.lineNative
lineStyle
• get
lineStyle(): LineStyle
Returns
LineStyle
Inherited from
MultipartBodyNode.lineStyle
lineWidth
• get
lineWidth(): number
The line width used when drawing the graphics.
Returns
number
Inherited from
MultipartBodyNode.lineWidth
• set
lineWidth(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.lineWidth
linearDamping
• get
linearDamping(): number
Returns
number
Inherited from
MultipartBodyNode.linearDamping
• set
linearDamping(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.linearDamping
linearVelocity
• get
linearVelocity(): number
Returns
number
Inherited from
MultipartBodyNode.linearVelocity
linearVelocityX
• get
linearVelocityX(): number
Returns
number
Inherited from
MultipartBodyNode.linearVelocityX
• set
linearVelocityX(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.linearVelocityX
linearVelocityY
• get
linearVelocityY(): number
Returns
number
Inherited from
MultipartBodyNode.linearVelocityY
• set
linearVelocityY(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.linearVelocityY
mass
• get
mass(): undefined
| number
Returns
undefined
| number
Inherited from
MultipartBodyNode.mass
metaObject
• get
metaObject(): MetaObject
Returns the MetaObject that describes this class
Returns
Overrides
MultipartBodyNode.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
MultipartBodyNode.name
• set
name(v
): void
Parameters
Name | Type |
---|---|
v | string |
Returns
void
Inherited from
MultipartBodyNode.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
MultipartBodyNode.parent
parts
• get
parts(): PolygonPart
[]
Returns
PolygonPart
[]
Inherited from
MultipartBodyNode.parts
radius
• get
radius(): number
The (outer) radius of the gear
Returns
number
• set
radius(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
restitution
• get
restitution(): number
Returns
number
Inherited from
MultipartBodyNode.restitution
• set
restitution(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.restitution
scripts
• get
scripts(): string
[]
Returns
string
[]
Inherited from
MultipartBodyNode.scripts
• set
scripts(v
): void
Parameters
Name | Type |
---|---|
v | string [] |
Returns
void
Inherited from
MultipartBodyNode.scripts
sensor
• get
sensor(): boolean
Returns
boolean
Inherited from
MultipartBodyNode.sensor
• set
sensor(v
): void
Parameters
Name | Type |
---|---|
v | boolean |
Returns
void
Inherited from
MultipartBodyNode.sensor
toothDensity
• get
toothDensity(): number
The tooth density. The higher this value is the more teeth the gear will have.
Returns
number
• set
toothDensity(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
toothHeight
• get
toothHeight(): number
The height of each gear tooth
Returns
number
• set
toothHeight(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
x
• get
x(): number
Returns the x
position of this body
Returns
number
Inherited from
MultipartBodyNode.x
• set
x(v
): void
Sets the x
position of this body
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.x
y
• get
y(): number
Returns the y
position of this body
Returns
number
Inherited from
MultipartBodyNode.y
• set
y(v
): void
Sets the y
position of this body
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Inherited from
MultipartBodyNode.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
applyAngularImpulse
▸ applyAngularImpulse(impulse
, wake?
): void
Parameters
Name | Type |
---|---|
impulse | number |
wake? | boolean |
Returns
void
Inherited from
MultipartBodyNode.applyAngularImpulse
applyForce
▸ applyForce(force
, point?
, wake?
): void
Parameters
Name | Type |
---|---|
force | IPoint |
point? | IPoint |
wake? | boolean |
Returns
void
Inherited from
applyLinearImpulse
▸ applyLinearImpulse(impulse
, point?
, wake?
): void
Parameters
Name | Type |
---|---|
impulse | IPoint |
point? | IPoint |
wake? | boolean |
Returns
void
Inherited from
MultipartBodyNode.applyLinearImpulse
autoAdjustFillTexture
▸ autoAdjustFillTexture(): void
Returns
void
Inherited from
MultipartBodyNode.autoAdjustFillTexture
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
MultipartBodyNode.canRemoveChild
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(): Node
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
MultipartBodyNode.containsChild
destroy
▸ destroy(): void
Returns
void
Inherited from
findAncestorByClassName
▸ findAncestorByClassName(className
): undefined
| Node
Parameters
Name | Type |
---|---|
className | string |
Returns
undefined
| Node
Inherited from
MultipartBodyNode.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
MultipartBodyNode.findChildById
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
MultipartBodyNode.findChildByName
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
MultipartBodyNode.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
MultipartBodyNode.findSceneAssetById
findSceneNode
▸ findSceneNode(): undefined
| Node
Uses the Node.findAncestorByClassName to find the Scene that this node is added to. If this node has not yet been added to a scene then this method will return undefined.
Returns
undefined
| Node
Inherited from
MultipartBodyNode.findSceneNode
fromScreen
▸ fromScreen(position
, from?
, skipUpdate?
): IPointData
Parameters
Name | Type |
---|---|
position | IPoint |
from? | Node |
skipUpdate? | boolean |
Returns
IPointData
Inherited from
getAncestors
▸ getAncestors(): Node
[]
Returns the ancestors of this node
Returns
Node
[]
Inherited from
MultipartBodyNode.getAncestors
getAssetIds
▸ getAssetIds(): string
[]
Returns the ids of the assets that are used by this Node.
Returns
string
[]
The ids of the assets that are used by this Node.
Inherited from
getBoundingRect
▸ getBoundingRect(): Rectangle
Returns the bounding rectangle of this node in local coordinates.
The default implementation returns the local bounds of the underlying PIXI container but subclasses can re-implement this method to return their custom bounding rectangle.
Returns
Rectangle
Inherited from
MultipartBodyNode.getBoundingRect
getDescendants
▸ getDescendants(reversed?
): Node
[]
Returns the descendants of this node.
A descendant is node that has this node as an ancestor. Consider for example the following tree of nodes:
- NodeA
- NodeB
- NodeD
- NodeE
- NodeC
- NodeB
If we ask for the descendants of NodeA we'll get back: [NodeB, NodeD, NodeE, NodeC]
If reversed is set to true then this method will return the reversed descendants. For the example above, that would be: [NodeC, NodeE, NodeD, NodeB, NodeA]. Note that the first item of the reversed descendants has the highest z-index.
Parameters
Name | Type | Default value |
---|---|---|
reversed | boolean | false |
Returns
Node
[]
A list of this node's descendants
Inherited from
MultipartBodyNode.getDescendants
getExtras
▸ getExtras(): any
Returns any extra data that this object needs to save during serialization.
In some cases an object might need to save some extra data without necessarily this extra data being part of its state (e.g. the AssetsLibrary of a Scene). In these cases subclasses can re-implement this method and return the data required.
The default implementation returns undefined
meaning that no extra data
needs to be saved during serialization.
Returns
any
Inherited from
getFilteredDescendants
▸ getFilteredDescendants\<T
>(cls
): T
[]
Returns the descendants of this node that are instances of the class cls
Type parameters
Name | Type |
---|---|
T | extends Node |
Parameters
Name | Type |
---|---|
cls | Constructor \<T > |
Returns
T
[]
Inherited from
MultipartBodyNode.getFilteredDescendants
getFilteredDescendantsByClassName
▸ getFilteredDescendantsByClassName(className
): Node
[]
Returns the descendants of this node that are instances of the class className
Parameters
Name | Type |
---|---|
className | string |
Returns
Node
[]
Inherited from
MultipartBodyNode.getFilteredDescendantsByClassName
getLinearVelocity
▸ getLinearVelocity(): IPoint
Convenience method which returns the node's linear velocity as a x,y object
Returns
IPoint
Inherited from
MultipartBodyNode.getLinearVelocity
getLocalTransform
▸ getLocalTransform(): Matrix
Returns a copy of this node's (local) transformation matrix.
Returns
Matrix
Inherited from
MultipartBodyNode.getLocalTransform
getNodeScript
▸ getNodeScript(assetId
): undefined
| NodeScript
Returns the NodeScript that corresponds to the given asset id.
Parameters
Name | Type |
---|---|
assetId | string |
Returns
undefined
| NodeScript
Inherited from
MultipartBodyNode.getNodeScript
getNodeScriptByClassName
▸ getNodeScriptByClassName(className
): undefined
| NodeScript
Returns the NodeScript that corresponds to the given class name.
Parameters
Name | Type |
---|---|
className | string |
Returns
undefined
| NodeScript
Inherited from
MultipartBodyNode.getNodeScriptByClassName
getNodeScripts
▸ getNodeScripts(): NodeScript
[]
Returns all NodeScripts of this Node.
Returns
NodeScript
[]
Inherited from
MultipartBodyNode.getNodeScripts
getPosition
▸ getPosition(): IPoint
Convenience method which returns the node's position as a x,y object
Returns
IPoint
Inherited from
getSceneBoundingRect
▸ getSceneBoundingRect(): Rectangle
Returns the bounding rect of this node in scene coordinates.
Returns
Rectangle
Inherited from
MultipartBodyNode.getSceneBoundingRect
getScenePosition
▸ getScenePosition(): IPoint
Returns the Node's position in Scene coordinates.
Returns
IPoint
Inherited from
MultipartBodyNode.getScenePosition
getSceneTransform
▸ getSceneTransform(): Matrix
Returns a copy of this node's scene transformation matrix. Use this matrix to map coordinates from this node's local coordinate system to the scene's coordinate system. To map coordinates from the scene, you must first invert the returned matrix.
Unlike getLocalTransform(), which returns only the local transformation, this function includes the node's (and any parents') position, and all the transfomation properties.
Returns
Matrix
Inherited from
MultipartBodyNode.getSceneTransform
getShape
▸ getShape(): Polygon
Returns the shape of this Node in local coordinates.
Note that the returned shape might be empty.
The shape of a Node is used for many things, including boolean operations and selection.
The default implementation calls getBoundingRect() to return a simple rectangular shape, but subclasses can reimplement this function to return a more accurate shape for non-rectangular items.
Returns
Polygon
Inherited from
getSnapPoints
▸ getSnapPoints(snapMode
): ISnapPoint
[]
Snap Points
Parameters
Name | Type |
---|---|
snapMode | number |
Returns
ISnapPoint
[]
Inherited from
MultipartBodyNode.getSnapPoints
getState
▸ getState(minified?
): any
Returns this object's state
The object's state is an object containing key/value pairs corresponding to this object's properties. For example:
{
id: "Ssba4ch5ruok",
name: "Circle",
radius: 2,
// ...
}
To avoid including properties that are currently in their default value you can set minified = true when calling getState.
Note that read-only properties are not part of the object's state (with the exception of the id)
Parameters
Name | Type | Default value | Description |
---|---|---|---|
minified | boolean | false | Whether to return a minified state or not |
Returns
any
Inherited from
getTransformedShape
▸ getTransformedShape(): Polygon
Returns the shape of this Node in scene coordinates.
Note that the returned shape might be empty.
Returns
Polygon
Inherited from
MultipartBodyNode.getTransformedShape
handleBeginContact
▸ handleBeginContact(contact
): void
Parameters
Name | Type |
---|---|
contact | b2Contact |
Returns
void
Inherited from
MultipartBodyNode.handleBeginContact
handleEndContact
▸ handleEndContact(contact
): void
Parameters
Name | Type |
---|---|
contact | b2Contact |
Returns
void
Inherited from
MultipartBodyNode.handleEndContact
index
▸ index(): number
Returns the index of this Node relatively to its parent. If this Node has no parent then -1 is returned.
Returns
number
Inherited from
initGraphicsNode
▸ initGraphicsNode(x
, y
, angle
, lineStyle?
, fillStyle?
): void
Parameters
Name | Type |
---|---|
x | number |
y | number |
angle | number |
lineStyle? | LineStyle |
fillStyle? | FillStyle |
Returns
void
Inherited from
MultipartBodyNode.initGraphicsNode
initNode
▸ initNode(x?
, y?
, angle?
): void
Convenience method for setting node's Node.x, Node.y and Node.angle
Parameters
Name | Type | Default value |
---|---|---|
x | number | 0 |
y | number | 0 |
angle | number | 0 |
Returns
void
Inherited from
insertChild
▸ insertChild(child
, index
): boolean
Parameters
Name | Type |
---|---|
child | Node |
index | number |
Returns
boolean
Inherited from
isDestroyed
▸ isDestroyed(): boolean
Returns true if this node has been destroyed via destroy(). A destroyed Node should not be used.
Returns
boolean
Inherited from
isSelected
▸ isSelected(): boolean
Returns true if this node is currently selected.
Returns
boolean
Inherited from
move
▸ move(d
): void
Moves this node by the given d.x, d.y
Parameters
Name | Type |
---|---|
d | IPoint |
Returns
void
Inherited from
removeAllChildren
▸ removeAllChildren(): void
Convenience method which removes all children of this node
Returns
void
Inherited from
MultipartBodyNode.removeAllChildren
removeChild
▸ removeChild(child
): boolean
Parameters
Name | Type |
---|---|
child | Node |
Returns
boolean
Inherited from
removeChildren
▸ removeChildren(children
): void
Convenience method for removing multiple children from this node.
Parameters
Name | Type |
---|---|
children | Node [] |
Returns
void
Inherited from
MultipartBodyNode.removeChildren
reorderChild
▸ reorderChild(child
, newIndex
): boolean
Moves a child node to a different position (order) among the other children If the operation is successul then the EVT_CHILD_REORDERED signal will be emitted
Parameters
Name | Type | Description |
---|---|---|
child | Node | The child node to be moved |
newIndex | number | The new index where the child node will be moved |
Returns
boolean
true on success otherwise false
Inherited from
MultipartBodyNode.reorderChild
setExtras
▸ setExtras(_x
): boolean
Sets any extra data that this object needs during de-serialization.
Returns true on success, otherwise returns false.
The default implementation does nothing and returns true.
Parameters
Name | Type |
---|---|
_x | any |
Returns
boolean
Inherited from
setFlag
▸ setFlag(flag
, on?
): void
Parameters
Name | Type | Default value |
---|---|---|
flag | CoreObjectFlags | undefined |
on | boolean | true |
Returns
void
Inherited from
setLinearVelocity
▸ setLinearVelocity(v
): void
Convenience method for setting the node's linear velocity to the given x,y
Parameters
Name | Type |
---|---|
v | IPoint |
Returns
void
Inherited from
MultipartBodyNode.setLinearVelocity
setPosition
▸ setPosition(v
): void
Convenience method for setting the node's position to the given x,y
Parameters
Name | Type |
---|---|
v | IPoint |
Returns
void
Inherited from
setScenePosition
▸ setScenePosition(v
): void
Sets the Node's scene position.
Parameters
Name | Type |
---|---|
v | IPoint |
Returns
void
Inherited from
MultipartBodyNode.setScenePosition
setSelected
▸ setSelected(selected
): void
Parameters
Name | Type |
---|---|
selected | boolean |
Returns
void
Inherited from
setState
▸ setState(state
, updateId?
): boolean
Sets the object's state
Parameters
Name | Type | Default value | Description |
---|---|---|---|
state | any | undefined | The state to be set |
updateId | boolean | true | Whether to also update the id property |
Returns
boolean
True on success otherwise false
Inherited from
testFlag
▸ testFlag(flag
): boolean
Parameters
Name | Type |
---|---|
flag | CoreObjectFlags |
Returns
boolean
Inherited from
toGlobal
▸ toGlobal(position
): Point
Parameters
Name | Type |
---|---|
position | IPoint |
Returns
Point
Inherited from
toLocal
▸ toLocal(position
): Point
Parameters
Name | Type |
---|---|
position | IPoint |
Returns
Point
Inherited from
toScreen
▸ toScreen(position
, skipUpdate?
): IPointData
Parameters
Name | Type |
---|---|
position | IPoint |
skipUpdate? | boolean |
Returns
IPointData
Inherited from
update
▸ update(delta
): void
Updates this node.
The default update will do the following:
- If this node has a script attached to it then it will call the script's update method
- Call update for each child of this node.
Parameters
Name | Type | Description |
---|---|---|
delta | number | Not currently used |
Returns
void