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

active

activeGameEntity 对象的一项重要属性。通过设置 active 的值,我们可以控制一个 GameEntity 对象是否处于激活状态。当某个 GameEntityactive 值为 true 时,它会参与到游戏的运行中;而当其值为 false 时,它则不参与到游戏的运行中。

语法

object.active

其中,object 表示一个 GameEntity 对象。activeGameEntity 的一个属性,表示该对象是否激活状态。

参数

active 参数是一个布尔型,即它只能取以下两种值之一:

  • true:表示该 GameEntity 对象处于激活状态,会参与到游戏的运行中。
  • false:表示该 GameEntity 对象处于不激活状态,不会参与到游戏的运行中。

返回值

active 的返回值是一个布尔型,表示该 GameEntity 对象当前的激活状态。

例子

假设我们有一个 GameEntity 对象 enemy,其初始的激活状态为 false。现在我们想让它参与到游戏的运行中,需要将其激活。我们可以这么做:

enemy.active = true;

接下来,enemy 对象便会参与到游戏的运行中。

注意事项

  1. 对于某个 GameEntity 对象来说,将其 active 值设置为 false 后便可以将其暂时从游戏中移除,但该对象仍然存在于内存中,因此需要考虑对象的管理和内存的释放问题。
  2. 在游戏中,如果我们需要控制某个对象的显隐、运动等行为,都可以通过设置其 active 值来实现。