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 字符串转换成 PursuitBehavior 类型的实例。

语法

PursuitBehavior.fromJSON(jsonString);

参数

  • jsonString:必需,一个符合 JSON 格式的字符串。

返回值

返回一个新的 PursuitBehavior 实例。

示例

const jsonStr = '{"type":"PursuitBehavior","radius":100,"maxSpeed":10,"target":{"x":50,"y":50},"player":{"x":100,"y":100},"targetRadius":5,"special":true}';
const pursuitBehavior = PursuitBehavior.fromJSON(jsonStr);

属性

  • type:行为的类型,固定值为字符串 "PursuitBehavior"。
  • radius:追击范围半径。
  • maxSpeed:最大移动速度。
  • target:目标对象的坐标,包含 xy 两个属性。
  • player:当前对象的坐标,包含 xy 两个属性。
  • targetRadius:目标半径。
  • special:是否为特殊的 Pursuit 行为。

异常

如果传入的字符串无法转换成 PursuitBehavior 类型的实例,将会抛出异常。