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
staticObject
is 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 x
Number x-coordinate of center
y
Number y-coordinate of center
r
Number radius
options
Circle options
- Source:
Returns:
- Type
- PhSim.DynObject
-
<static> createMatterObject(staticObject)
-
Create a matter.js object from a DynSim static object
Parameters:
Name Type Description staticObject
StaticObject - Source:
Returns:
- Type
- MatterBody
-
<static> createPath(vectorSet, options)
-
Create path
Parameters:
Name Type Description vectorSet
Array.<Vector> options
Path - Source:
-
<static> createRectangle(x, y, w, h, options)
-
Create rectangle
Parameters:
Name Type Description x
Number x-coordinate of upper left corner
y
Number y-coordinate of upper left corner
w
Number Width
h
Number Height
options
Rectangle - Source:
Returns:
- The rectangle
- Type
- PhSim.DynObject
-
<static> createRegPolygon(x, y, r, n, options)
-
Create regular polgyon.
Parameters:
Name Type Description x
Number x-coordinate of center
y
Number y-coordinate of center
r
Number radius
n
Number number of sides
options
RegPolygon options
- Source:
Returns:
- Type
- PhSim.DynObject
-
<static> flattenComposite(composite)
-
Parameters:
Name Type Description composite
PhSimObject 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_object
PhSim.DynObject colorStr
String - Source:
-
<static> setColor(dyn_object, colorStr)
-
Set color for dynObject. This can be done alternatively by setting
dynObject.fillStyle
directly.Parameters:
Name Type Description dyn_object
PhSim.DynObject Dynamic Object
colorStr
String Color String
- Source:
-
<static> setLineWidth(dyn_object, lineWidth)
-
Parameters:
Name Type Description dyn_object
PhSim.DynObject lineWidth
Number - Source:
-
callEventClass(event)
-
Parameters:
Name Type Description event
PhSim.Events.PhSimEvent Event Object
- Mixes In:
- Source:
-
off(eventStr, call)
-
Parameters:
Name Type Description eventStr
String call
PhSimEventCall - Mixes In:
- Source:
-
on(eventStr, call [, options])
-
Used to add events to a PhSim simulation
Parameters:
Name Type Argument Default Description eventStr
string String representing the event.
call
PhSimEventCall Function to run when event is executed.
options
object <optional>
{} Event Listener Options.
Properties
Name Type Argument Description once
boolean <optional>
If true, the function is executed only once.
slEvent
boolean <optional>
If true, the event will be removed when the simulation changes
- Mixes In:
- Source:
-
setBorderColor(colorStr)
-
Set border color.
Parameters:
Name Type Description colorStr
String - Source:
-
setColor(colorStr)
-
Set color for dynObject. This can be done alternatively by setting
dynObject.fillStyle
directly.Parameters:
Name Type Description colorStr
String Color String
- Source: