C# Class Nez.Collider

Exibir arquivo Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
collidesWithLayers int
isTrigger bool
physicsLayer int
shape Nez.PhysicsShapes.Shape
shouldColliderScaleAndRotateWithTransform bool

Protected Properties

Property Type Description
_colliderRequiresAutoSizing bool
_isColliderRegistered bool
_isParentEntityAddedToScene bool
_localOffset Vector2

Public Methods

Method Description
clone ( ) : Component
collidesWith ( Collider collider, CollisionResult &result ) : bool

checks to see if this Collider collides with collider. If it does, true will be returned and result will be populated with collision data

collidesWith ( Collider collider, Vector2 motion, CollisionResult &result ) : bool

checks to see if this Collider with motion applied (delta movement vector) collides with collider. If it does, true will be returned and result will be populated with collision data.

collidesWithAny ( CollisionResult &result ) : bool

checks to see if this Collider collides with any other Colliders in the Scene. The first Collider it intersects will have its collision data returned in the CollisionResult.

collidesWithAny ( Vector2 &motion, CollisionResult &result ) : bool

checks to see if this Collider with motion applied (delta movement vector) collides with any collider. If it does, true will be returned and result will be populated with collision data. Motion will be set to the maximum distance the Collider can travel before colliding.

onAddedToEntity ( ) : void
onDisabled ( ) : void
onEnabled ( ) : void
onEntityTransformChanged ( Transform comp ) : void
onRemovedFromEntity ( ) : void
overlaps ( Collider other ) : bool

checks to see if this shape overlaps any other Colliders in the Physics system

registerColliderWithPhysicsSystem ( ) : void

the parent Entity will call this at various times (when added to a scene, enabled, etc)

setLocalOffset ( Vector2 offset ) : Collider

localOffset is added to entity.position to get the final position for the collider. This allows you to add multiple Colliders to an Entity and position them separately.

setShouldColliderScaleAndRotateWithTransform ( bool shouldColliderScaleAndRotateWithTransform ) : Collider

if set to true, the Collider will scale and rotate following the Transform it is attached to

unregisterColliderWithPhysicsSystem ( ) : void

the parent Entity will call this at various times (when removed from a scene, disabled, etc)

Method Details

clone() public method

public clone ( ) : Component
return Component

collidesWith() public method

checks to see if this Collider collides with collider. If it does, true will be returned and result will be populated with collision data
public collidesWith ( Collider collider, CollisionResult &result ) : bool
collider Collider Collider.
result CollisionResult Result.
return bool

collidesWith() public method

checks to see if this Collider with motion applied (delta movement vector) collides with collider. If it does, true will be returned and result will be populated with collision data.
public collidesWith ( Collider collider, Vector2 motion, CollisionResult &result ) : bool
collider Collider Collider.
motion Vector2 Motion.
result CollisionResult Result.
return bool

collidesWithAny() public method

checks to see if this Collider collides with any other Colliders in the Scene. The first Collider it intersects will have its collision data returned in the CollisionResult.
public collidesWithAny ( CollisionResult &result ) : bool
result CollisionResult Result.
return bool

collidesWithAny() public method

checks to see if this Collider with motion applied (delta movement vector) collides with any collider. If it does, true will be returned and result will be populated with collision data. Motion will be set to the maximum distance the Collider can travel before colliding.
public collidesWithAny ( Vector2 &motion, CollisionResult &result ) : bool
motion Vector2 Motion.
result CollisionResult Result.
return bool

onAddedToEntity() public method

public onAddedToEntity ( ) : void
return void

onDisabled() public method

public onDisabled ( ) : void
return void

onEnabled() public method

public onEnabled ( ) : void
return void

onEntityTransformChanged() public method

public onEntityTransformChanged ( Transform comp ) : void
comp Transform
return void

onRemovedFromEntity() public method

public onRemovedFromEntity ( ) : void
return void

overlaps() public method

checks to see if this shape overlaps any other Colliders in the Physics system
public overlaps ( Collider other ) : bool
other Collider
return bool

registerColliderWithPhysicsSystem() public method

the parent Entity will call this at various times (when added to a scene, enabled, etc)
public registerColliderWithPhysicsSystem ( ) : void
return void

setLocalOffset() public method

localOffset is added to entity.position to get the final position for the collider. This allows you to add multiple Colliders to an Entity and position them separately.
public setLocalOffset ( Vector2 offset ) : Collider
offset Vector2 Offset.
return Collider

setShouldColliderScaleAndRotateWithTransform() public method

if set to true, the Collider will scale and rotate following the Transform it is attached to
public setShouldColliderScaleAndRotateWithTransform ( bool shouldColliderScaleAndRotateWithTransform ) : Collider
shouldColliderScaleAndRotateWithTransform bool If set to true should collider scale and rotate with transform.
return Collider

unregisterColliderWithPhysicsSystem() public method

the parent Entity will call this at various times (when removed from a scene, disabled, etc)
public unregisterColliderWithPhysicsSystem ( ) : void
return void

Property Details

_colliderRequiresAutoSizing protected_oe property

protected bool _colliderRequiresAutoSizing
return bool

_isColliderRegistered protected_oe property

flag to keep track of if we registered ourself with the Physics system
protected bool _isColliderRegistered
return bool

_isParentEntityAddedToScene protected_oe property

flag to keep track of if our Entity was added to a Scene
protected bool _isParentEntityAddedToScene
return bool

_localOffset protected_oe property

protected Vector2 _localOffset
return Vector2

collidesWithLayers public_oe property

layer mask of all the layers this Collider should collide with when Entity.move methods are used. defaults to all layers.
public int collidesWithLayers
return int

isTrigger public_oe property

if this collider is a trigger it will not cause collisions but it will still trigger events
public bool isTrigger
return bool

physicsLayer public_oe property

physicsLayer can be used as a filter when dealing with collisions. The Flags class has methods to assist with bitmasks.
public int physicsLayer
return int

shape public_oe property

the underlying Shape of the Collider
public Shape,Nez.PhysicsShapes shape
return Nez.PhysicsShapes.Shape

shouldColliderScaleAndRotateWithTransform public_oe property

if true, the Collider will scale and rotate following the Transform it is attached to
public bool shouldColliderScaleAndRotateWithTransform
return bool