AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

fromJSON

fromJSON方法将一个JSON对象转换为ArriveBehavior类型的对象。ArriveBehavior表示当元素出现在DOM中时要执行的操作。

参数

fromJSON方法有一个参数,即要转换的JSON对象。

返回值

fromJSON方法返回一个与JSON对象对应的ArriveBehavior对象。

示例

下面是一个JSON对象的示例:

{
  "target": "#myElement",
  "handler": function() {
    alert("myElement已经被添加到DOM中了!");
  }
}

调用fromJSON方法将该JSON对象转换为ArriveBehavior对象的示例代码如下:

var json = {
  "target": "#myElement",
  "handler": function() {
    alert("myElement已经被添加到DOM中了!");
  }
};
var behavior = ArriveBehavior.fromJSON(json);

现在,behavior变量就包含了一个ArriveBehavior对象,可以用来监听#myElement添加到DOM中的事件并执行定义的操作。