new DynObject(staticObject [, matterBody])
Create Dynamic Object from static object
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
staticObject |
PhSimObject | Static Object |
|
matterBody |
Matter.Body |
<optional> |
Matter Body |
- Mixes In:
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
x |
Number | x position |
y |
Number | y position |
Members
-
<static> deepCloneStaticObject
-
If set to true, the
staticObjectis cloned before Object.assign is applied to the DynObject to clone it.- Source:
-
<static> DynObject.keepInstances :Boolean
-
If set to
true, all DynObject instances are put into the PhSim.DynObject.instances array. By default, this isfalse. Do not use unless you want to risk memory leaks. This is primarily for debugging purposes.Type:
- Boolean
- Default Value:
-
- false
- Source:
-
<static> instances :Array.<PhSim.DynObject>
-
Array of instances if PhSim.DynObject.keepInstances is set to true
Type:
- Array.<PhSim.DynObject>
- Source:
-
<static> obj.cloned :Boolean|undefined
-
Property telling if object is cloned.
Type:
- Boolean | undefined
- Source:
-
data :Object
-
Custom properties that can be added by the user to extend the DynObject.
Type:
- Object
- Source:
-
eventStack :PhSim.EventStack
-
Object containing array functions to be called.
Type:
- Source:
-
firstCycle :Number
-
Inital angle of object
Type:
- Number
- Source:
-
id :String
-
Object ID
Type:
- String
- Source:
-
matter :Object
-
Matter Body
Type:
- Object
- Source:
-
name :String
-
DynObject name
Type:
- String
- Source:
-
noCollision :boolean
-
Boolean that makes a dynamic object not collide with anything.
Type:
- boolean
- Default Value:
-
- false
- Source:
-
phSim :null|PhSim
-
Reference to parent simulation
Type:
- null | PhSim
- Source:
-
static :StaticObject
-
Reference to static object used to create the DynObject
Type:
- Source:
-
type :"circle"|"polygon"|"rectangle"|"regPolygon"
-
DynObject type
Type:
- "circle" | "polygon" | "rectangle" | "regPolygon"
- Source:
Methods
-
<static> createCircle(x, y, r, options)
-
Create circle
Parameters:
Name Type Description xNumber x-coordinate of center
yNumber y-coordinate of center
rNumber radius
optionsCircle options
- Source:
Returns:
- Type
- PhSim.DynObject
-
<static> createMatterObject(staticObject)
-
Create a matter.js object from a DynSim static object
Parameters:
Name Type Description staticObjectStaticObject - Source:
Returns:
- Type
- MatterBody
-
<static> createPath(vectorSet, options)
-
Create path
Parameters:
Name Type Description vectorSetArray.<Vector> optionsPath - Source:
-
<static> createRectangle(x, y, w, h, options)
-
Create rectangle
Parameters:
Name Type Description xNumber x-coordinate of upper left corner
yNumber y-coordinate of upper left corner
wNumber Width
hNumber Height
optionsRectangle - Source:
Returns:
- The rectangle
- Type
- PhSim.DynObject
-
<static> createRegPolygon(x, y, r, n, options)
-
Create regular polgyon.
Parameters:
Name Type Description xNumber x-coordinate of center
yNumber y-coordinate of center
rNumber radius
nNumber number of sides
optionsRegPolygon options
- Source:
Returns:
- Type
- PhSim.DynObject
-
<static> flattenComposite(composite)
-
Parameters:
Name Type Description compositePhSimObject The composite to be flattened.
- Source:
Returns:
- The array of objects found in the composites.
- Type
- Array.<PhSimObject>
-
<static> setBorderColor(dyn_object, colorStr)
-
Set border color.
Parameters:
Name Type Description dyn_objectPhSim.DynObject colorStrString - Source:
-
<static> setColor(dyn_object, colorStr)
-
Set color for dynObject. This can be done alternatively by setting
dynObject.fillStyledirectly.Parameters:
Name Type Description dyn_objectPhSim.DynObject Dynamic Object
colorStrString Color String
- Source:
-
<static> setLineWidth(dyn_object, lineWidth)
-
Parameters:
Name Type Description dyn_objectPhSim.DynObject lineWidthNumber - Source:
-
callEventClass(event)
-
Parameters:
Name Type Description eventPhSim.Events.PhSimEvent Event Object
- Mixes In:
- Source:
-
off(eventStr, call)
-
Parameters:
Name Type Description eventStrString callPhSimEventCall - Mixes In:
- Source:
-
on(eventStr, call [, options])
-
Used to add events to a PhSim simulation
Parameters:
Name Type Argument Default Description eventStrstring String representing the event.
callPhSimEventCall Function to run when event is executed.
optionsobject <optional>
{} Event Listener Options.
Properties
Name Type Argument Description onceboolean <optional>
If true, the function is executed only once.
slEventboolean <optional>
If true, the event will be removed when the simulation changes
- Mixes In:
- Source:
-
setBorderColor(colorStr)
-
Set border color.
Parameters:
Name Type Description colorStrString - Source:
-
setColor(colorStr)
-
Set color for dynObject. This can be done alternatively by setting
dynObject.fillStyledirectly.Parameters:
Name Type Description colorStrString Color String
- Source: