Contents

TabletopInteraction

A protocol for objects that manage the entire flow of players interacting with equipment.

Declaration

class TabletopInteraction

Overview

Conform to the TabletopInteraction.Delegate protocol to take an appropriate action, depending on the equipment and the phase of the interaction. For example, move equipment or toss a die when a gesture ends.

struct MoveInteraction: TabletopInteraction.Delegate {
    func update(interaction: TabletopKit.TabletopInteraction) {
        let equipment = interaction.value.controlledEquipmentID
        guard let destination = interaction.value.proposedDestination else {
            return
        }
        
        if interaction.value.phase == .ended {
            interaction.addAction(.moveEquipment(matching: equipment, childOf: destination.equipmentID, pose: destination.pose))
        }
    }
}

To get information about the equipment that the interaction applies to, use the value property. To get the phase of the interaction or gesture, use the Value gesturePhase or phase properties.

Then execute actions — for example, move equipment when the phase ends — using the addAction(_:) or addActions(_:) method.

To start an interaction programmatically, use the TabletopGame startInteraction(onEquipmentID:) method.

Topics

Performing actions

Getting the value of the interaction

Setting information about the equipment and pose

Managing the interaction destination

Getting the interaction identifier

Determining the dead zone

Handling collision behavior

Handling interaction intents

See Also

Interactions