Documentation
¶
Overview ¶
graphics.gd/classdb/Area2D is a region of 2D space defined by one or multiple graphics.gd/classdb/CollisionShape2D or graphics.gd/classdb/CollisionPolygon2D child nodes. It detects when other [graphics.gd/classdb/CollisionObject2D]s enter or exit it, and it also keeps track of which collision objects haven't exited it yet (i.e. which one are overlapping it).
This node can also locally alter or override physics parameters (gravity, damping) and route audio to custom audio buses.
Note: Areas and bodies created with graphics.gd/classdb/PhysicsServer2D might not interact as expected with [graphics.gd/classdb/Area2D]s, and might not emit signals or track objects correctly.
Index ¶
- type Advanced
- type Any
- type Extension
- func (self *Extension[T]) AsArea2D() Instance
- func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
- func (self *Extension[T]) AsCollisionObject2D() CollisionObject2D.Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsNode2D() Node2D.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- type ID
- type Instance
- func (self Instance) AngularDamp() Float.X
- func (self Instance) AngularDampSpaceOverride() SpaceOverride
- func (self Instance) AsArea2D() Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsCollisionObject2D() CollisionObject2D.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AudioBusName() string
- func (self Instance) AudioBusOverride() bool
- func (self Instance) GetOverlappingAreas() []Instance
- func (self Instance) GetOverlappingBodies() []Node2D.Instance
- func (self Instance) Gravity() Float.X
- func (self Instance) GravityDirection() Vector2.XY
- func (self Instance) GravityPoint() bool
- func (self Instance) GravityPointCenter() Vector2.XY
- func (self Instance) GravityPointUnitDistance() Float.X
- func (self Instance) GravitySpaceOverride() SpaceOverride
- func (self Instance) HasOverlappingAreas() bool
- func (self Instance) HasOverlappingBodies() bool
- func (self Instance) ID() ID
- func (self Instance) LinearDamp() Float.X
- func (self Instance) LinearDampSpaceOverride() SpaceOverride
- func (self Instance) Monitorable() bool
- func (self Instance) Monitoring() bool
- func (self Instance) OnAreaEntered(cb func(area Instance), flags ...Signal.Flags)
- func (self Instance) OnAreaExited(cb func(area Instance), flags ...Signal.Flags)
- func (self Instance) OnAreaShapeEntered(...)
- func (self Instance) OnAreaShapeExited(...)
- func (self Instance) OnBodyEntered(cb func(body Node2D.Instance), flags ...Signal.Flags)
- func (self Instance) OnBodyExited(cb func(body Node2D.Instance), flags ...Signal.Flags)
- func (self Instance) OnBodyShapeEntered(cb func(body_rid RID.Any, body Node2D.Instance, body_shape_index int, ...), ...)
- func (self Instance) OnBodyShapeExited(cb func(body_rid RID.Any, body Node2D.Instance, body_shape_index int, ...), ...)
- func (self Instance) OverlapsArea(area Node.Instance) bool
- func (self Instance) OverlapsBody(body Node.Instance) bool
- func (self Instance) Priority() int
- func (self Instance) SetAngularDamp(value Float.X)
- func (self Instance) SetAngularDampSpaceOverride(value SpaceOverride)
- func (self Instance) SetAudioBusName(value string)
- func (self Instance) SetAudioBusOverride(value bool)
- func (self Instance) SetGravity(value Float.X)
- func (self Instance) SetGravityDirection(value Vector2.XY)
- func (self Instance) SetGravityPoint(value bool)
- func (self Instance) SetGravityPointCenter(value Vector2.XY)
- func (self Instance) SetGravityPointUnitDistance(value Float.X)
- func (self Instance) SetGravitySpaceOverride(value SpaceOverride)
- func (self Instance) SetLinearDamp(value Float.X)
- func (self Instance) SetLinearDampSpaceOverride(value SpaceOverride)
- func (self Instance) SetMonitorable(value bool)
- func (self Instance) SetMonitoring(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetPriority(value int)
- func (self Instance) Virtual(name string) reflect.Value
- type SpaceOverride
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
func (*Extension[T]) AsCollisionObject2D ¶
func (self *Extension[T]) AsCollisionObject2D() CollisionObject2D.Instance
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AngularDamp ¶
func (Instance) AngularDampSpaceOverride ¶
func (self Instance) AngularDampSpaceOverride() SpaceOverride
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AsCollisionObject2D ¶
func (self Instance) AsCollisionObject2D() CollisionObject2D.Instance
func (Instance) AudioBusName ¶
func (Instance) AudioBusOverride ¶
func (Instance) GetOverlappingAreas ¶
Returns a list of intersecting [graphics.gd/classdb/Area2D]s. The overlapping area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionLayer must be part of this area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionMask in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
func (Instance) GetOverlappingBodies ¶
Returns a list of intersecting [graphics.gd/classdb/PhysicsBody2D]s and [graphics.gd/classdb/TileMap]s. The overlapping body's graphics.gd/classdb/CollisionObject2D.Instance.CollisionLayer must be part of this area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionMask in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
func (Instance) GravityDirection ¶
func (Instance) GravityPoint ¶
func (Instance) GravityPointCenter ¶
func (Instance) GravityPointUnitDistance ¶
func (Instance) GravitySpaceOverride ¶
func (self Instance) GravitySpaceOverride() SpaceOverride
func (Instance) HasOverlappingAreas ¶
Returns true if intersecting any [graphics.gd/classdb/Area2D]s, otherwise returns false. The overlapping area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionLayer must be part of this area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionMask in order to be detected.
For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
func (Instance) HasOverlappingBodies ¶
Returns true if intersecting any [graphics.gd/classdb/PhysicsBody2D]s or [graphics.gd/classdb/TileMap]s, otherwise returns false. The overlapping body's graphics.gd/classdb/CollisionObject2D.Instance.CollisionLayer must be part of this area's graphics.gd/classdb/CollisionObject2D.Instance.CollisionMask in order to be detected.
For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
func (Instance) LinearDamp ¶
func (Instance) LinearDampSpaceOverride ¶
func (self Instance) LinearDampSpaceOverride() SpaceOverride
func (Instance) Monitorable ¶
func (Instance) Monitoring ¶
func (Instance) OnAreaEntered ¶
func (Instance) OnAreaExited ¶
func (Instance) OnAreaShapeEntered ¶
func (Instance) OnAreaShapeExited ¶
func (Instance) OnBodyEntered ¶
func (Instance) OnBodyExited ¶
func (Instance) OnBodyShapeEntered ¶
func (Instance) OnBodyShapeExited ¶
func (Instance) OverlapsArea ¶
Returns true if the given graphics.gd/classdb/Area2D intersects or overlaps this graphics.gd/classdb/Area2D, false otherwise.
Note: The result of this test is not immediate after moving objects. For performance, the list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
func (Instance) OverlapsBody ¶
Returns true if the given physics body intersects or overlaps this graphics.gd/classdb/Area2D, false otherwise.
Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
The 'body' argument can either be a graphics.gd/classdb/PhysicsBody2D or a graphics.gd/classdb/TileMap instance. While TileMaps are not physics bodies themselves, they register their tiles with collision shapes as a virtual physics body.
func (Instance) SetAngularDamp ¶
func (Instance) SetAngularDampSpaceOverride ¶
func (self Instance) SetAngularDampSpaceOverride(value SpaceOverride)
func (Instance) SetAudioBusName ¶
func (Instance) SetAudioBusOverride ¶
func (Instance) SetGravity ¶
func (Instance) SetGravityDirection ¶
func (Instance) SetGravityPoint ¶
func (Instance) SetGravityPointCenter ¶
func (Instance) SetGravityPointUnitDistance ¶
func (Instance) SetGravitySpaceOverride ¶
func (self Instance) SetGravitySpaceOverride(value SpaceOverride)
func (Instance) SetLinearDamp ¶
func (Instance) SetLinearDampSpaceOverride ¶
func (self Instance) SetLinearDampSpaceOverride(value SpaceOverride)
func (Instance) SetMonitorable ¶
func (Instance) SetMonitoring ¶
func (Instance) SetPriority ¶
type SpaceOverride ¶
type SpaceOverride int //gd:Area2D.SpaceOverride
const ( // This area does not affect gravity/damping. SpaceOverrideDisabled SpaceOverride = 0 // This area adds its gravity/damping values to whatever has been calculated so far (in [Instance.Priority] order). SpaceOverrideCombine SpaceOverride = 1 // This area adds its gravity/damping values to whatever has been calculated so far (in [Instance.Priority] order), ignoring any lower priority areas. SpaceOverrideCombineReplace SpaceOverride = 2 // This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas. SpaceOverrideReplace SpaceOverride = 3 // This area replaces any gravity/damping calculated so far (in [Instance.Priority] order), but keeps calculating the rest of the areas. SpaceOverrideReplaceCombine SpaceOverride = 4 )