Signal1
Signal support.
CollisionObject2D.swift:1052class Signal1
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (43) members.
Types
enum DisableMode
class Signal2
Signal support.
class Signal3
Signal support.
Type members
Instance members
var collisionLayer: UInt32
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also
collisionMask
.var collisionMask: UInt32
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also
collisionLayer
.var collisionPriority: Double
The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
var disableMode: CollisionObject2D.DisableMode
Defines the behavior in physics when
processMode
is set todisabled
. SeeDisableMode
for more details about the different modes.var inputEvent: Signal1
Emitted when an input event occurs. Requires
inputPickable
to betrue
and at least onecollisionLayer
bit to be set. See_inputEvent(viewport:event:shapeIdx:)
for details.var inputPickable: Bool
If
true
, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least onecollisionLayer
bit to be set.var mouseEntered: SimpleSignal
Emitted when the mouse pointer enters any of this object’s shapes. Requires
inputPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject2D
won’t cause this signal to be emitted.var mouseExited: SimpleSignal
Emitted when the mouse pointer exits all this object’s shapes. Requires
inputPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject2D
won’t cause this signal to be emitted.var mouseShapeEntered: Signal2
Emitted when the mouse pointer enters any of this object’s shapes or moves from one shape to another.
shapeIdx
is the child index of the newly enteredShape2D
. RequiresinputPickable
to betrue
and at least onecollisionLayer
bit to be set.var mouseShapeExited: Signal3
Emitted when the mouse pointer exits any of this object’s shapes.
shapeIdx
is the child index of the exitedShape2D
. RequiresinputPickable
to betrue
and at least onecollisionLayer
bit to be set.func createShapeOwner(Object?
) -> UInt32 Creates a new shape owner for the given object. Returns
owner_id
of the new owner for future reference.func getCollisionLayerValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
collisionLayer
is enabled, given alayerNumber
between 1 and 32.func getCollisionMaskValue(layerNumber: Int32
) -> Bool Returns whether or not the specified layer of the
collisionMask
is enabled, given alayerNumber
between 1 and 32.func getRid(
) -> RID Returns the object’s
RID
.func getShapeOwnerOneWayCollisionMargin(ownerId: UInt32
) -> Double Returns the
one_way_collision_margin
of the shape owner identified by givenownerId
.func getShapeOwners(
) -> PackedInt32Array Returns an
GArray
ofowner_id
identifiers. You can use these ids in other methods that takeowner_id
as an argument.func isShapeOwnerDisabled(ownerId: UInt32
) -> Bool If
true
, the shape owner and its shapes are disabled.func isShapeOwnerOneWayCollisionEnabled(ownerId: UInt32
) -> Bool Returns
true
if collisions for the shape owner originating from thisCollisionObject2D
will not be reported to collided withCollisionObject2D
s.func removeShapeOwner(ownerId: UInt32
) Removes the given shape owner.
func setCollisionLayerValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecollisionLayer
, given alayerNumber
between 1 and 32.func setCollisionMaskValue(layerNumber: Int32, value: Bool
) Based on
value
, enables or disables the specified layer in thecollisionMask
, given alayerNumber
between 1 and 32.func shapeFindOwner(shapeIndex: Int32
) -> UInt32 Returns the
owner_id
of the given shape.func shapeOwnerAddShape(ownerId: UInt32, shape: Shape2D?
) Adds a
Shape2D
to the shape owner.func shapeOwnerClearShapes(ownerId: UInt32
) Removes all shapes from the shape owner.
func shapeOwnerGetOwner(ownerId: UInt32
) -> Object? Returns the parent object of the given shape owner.
func shapeOwnerGetShape(ownerId: UInt32, shapeId: Int32
) -> Shape2D? Returns the
Shape2D
with the given ID from the given shape owner.func shapeOwnerGetShapeCount(ownerId: UInt32
) -> Int32 Returns the number of shapes the given shape owner contains.
func shapeOwnerGetShapeIndex(ownerId: UInt32, shapeId: Int32
) -> Int32 Returns the child index of the
Shape2D
with the given ID from the given shape owner.func shapeOwnerGetTransform(ownerId: UInt32
) -> Transform2D Returns the shape owner’s
Transform2D
.func shapeOwnerRemoveShape(ownerId: UInt32, shapeId: Int32
) Removes a shape from the given shape owner.
func shapeOwnerSetDisabled(ownerId: UInt32, disabled: Bool
) If
true
, disables the given shape owner.func shapeOwnerSetOneWayCollision(ownerId: UInt32, enable: Bool
) If
enable
istrue
, collisions for the shape owner originating from thisCollisionObject2D
will not be reported to collided withCollisionObject2D
s.func shapeOwnerSetOneWayCollisionMargin(ownerId: UInt32, margin: Double
) Sets the
one_way_collision_margin
of the shape owner identified by givenownerId
tomargin
pixels.func shapeOwnerSetTransform(ownerId: UInt32, transform: Transform2D
) Sets the
Transform2D
of the given shape owner.
Show implementation details (5)
Hide implementation details
func _inputEvent(viewport: Viewport?, event: InputEvent?, shapeIdx: Int32
) Accepts unhandled
InputEvent
s.shapeIdx
is the child index of the clickedShape2D
. Connect to [signal input_event] to easily pick up these events.func _mouseEnter(
) Called when the mouse pointer enters any of this object’s shapes. Requires
inputPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject2D
won’t cause this function to be called.func _mouseExit(
) Called when the mouse pointer exits all this object’s shapes. Requires
inputPickable
to betrue
and at least onecollisionLayer
bit to be set. Note that moving between different shapes within a singleCollisionObject2D
won’t cause this function to be called.func _mouseShapeEnter(shapeIdx: Int32
) Called when the mouse pointer enters any of this object’s shapes or moves from one shape to another.
shapeIdx
is the child index of the newly enteredShape2D
. RequiresinputPickable
to betrue
and at least onecollisionLayer
bit to be called.func _mouseShapeExit(shapeIdx: Int32
) Called when the mouse pointer exits any of this object’s shapes.
shapeIdx
is the child index of the exitedShape2D
. RequiresinputPickable
to betrue
and at least onecollisionLayer
bit to be called.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ viewport: Node, _ event: InputEvent, _ shapeIdx: Int64) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)