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

touching

介绍

touching是RectangleTriggerRegion对象中的一个方法,用于判断当前鼠标/触摸点是否在触发区域内。

语法

RectangleTriggerRegion.touching(event)

参数

event: Object - 监听到的触摸/鼠标事件对象。

返回值

  • 若当前鼠标/触摸点在触发区域内,则返回true。
  • 若当前鼠标/触摸点不在触发区域内,则返回false。

使用示例

var triggerRegion = new RectangleTriggerRegion(0, 0, 100, 100);
document.addEventListener('touchstart', function(event) {
  if (triggerRegion.touching(event)) {
    console.log('触发区域被点击了!');
  }
}, false);

注意事项

  • 鼠标事件和触摸事件的event对象需要分别传递给touching方法。
  • 触发区域的位置和大小需要在创建RectangleTriggerRegion对象时指定。