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

up

描述

up方法用于车辆的加速。该方法需要传入一个参数,表示加速度。

语法

vehicle.up(acceleration);

参数

  • acceleration:必填。表示车辆加速度,为一个浮点型数值(单位:米/秒²)。

示例

const car = new Vehicle();
car.up(5); // 表示车辆以5米/秒²加速

注意事项

  • acceleration参数必须为一个正数。

  • 当车辆在行驶中时,调用up方法可以让车辆加速,反之调用down方法可以让车辆减速。

  • 当车辆速度达到了最高限制速度,再次调用up方法将不会让车辆加速,车速将保持不变。

  • 本方法仅适用于cVehicle类及其子类的实例对象。

举例

// 示例1:车辆加速
const car = new Vehicle();
car.up(5); // 车辆加速

// 示例2:不合法参数
const car = new Vehicle();
car.up(-5); // 抛出异常,加速度参数不能为负数

返回值

本方法不返回任何值。