# CompositeMotionHandle

Collect motion handles and request cancellation or completion for the group.

Namespace: MeatMotion

Assembly: MeatMotion

```csharp
public sealed class CompositeMotionHandle : ICollection<MotionHandle>
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L25](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L25)

## Cancel two tweens together

Add `using MeatMotion;`. Collect the motions owned by one screen and stop them together when it closes.

```csharp
var group = new CompositeMotionHandle();
using var world = new MotionWorld();
var first = MMotion.Create(0f, 1f, 1f).WithScheduler(world)
    .RunWithoutBinding().AddTo(group);
var second = MMotion.Create(1f, 0f, 1f).WithScheduler(world)
    .RunWithoutBinding().AddTo(group);
group.Cancel();
```

## CompositeMotionHandle

Create an empty collection, optionally reserving its initial capacity.

```csharp
public CompositeMotionHandle()
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L28](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L28)

```csharp
public CompositeMotionHandle(int capacity)
```

Parameters

- `capacity` (`int`) Number of entries to reserve.

[Runtime/Lifecycle/MotionHandleExtensions.cs · L29](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L29)

## Count

Number of stored handles, regardless of whether their motions are still active.

```csharp
public int Count { get; }
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L30](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L30)

## IsReadOnly

Returns false. The collection accepts additions and removals.

```csharp
public bool IsReadOnly { get; }
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L31](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L31)

## Add

Append the handle to this collection.

```csharp
public void Add(MotionHandle handle)
```

Parameters

- `handle` (`MotionHandle`) Handle to control or link.

[Runtime/Lifecycle/MotionHandleExtensions.cs · L32](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L32)

## Clear

Remove all registrations. Use Cancel to stop the motions.

```csharp
public void Clear()
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L33](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L33)

## Contains

Return whether the collection contains the handle.

```csharp
public bool Contains(MotionHandle item)
```

Parameters and return value

- `item` (`MotionHandle`) Entry operated on by the collection.
- Returns: `bool`

[Runtime/Lifecycle/MotionHandleExtensions.cs · L34](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L34)

## CopyTo

Copy the stored handles into an array at the specified destination index.

```csharp
public void CopyTo(MotionHandle[] array, int arrayIndex)
```

Parameters

- `array` (`MotionHandle[]`) Destination array for the handles.
- `arrayIndex` (`int`) First destination index in the array.

[Runtime/Lifecycle/MotionHandleExtensions.cs · L35](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L35)

## Remove

Remove a matching handle from the collection and leave its motion running.

```csharp
public bool Remove(MotionHandle item)
```

Parameters and return value

- `item` (`MotionHandle`) Entry operated on by the collection.
- Returns: `bool`

[Runtime/Lifecycle/MotionHandleExtensions.cs · L36](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L36)

## GetEnumerator

Enumerate the stored handles in list order.

```csharp
public List<MotionHandle>.Enumerator GetEnumerator()
```

Return value

- Returns: `List<MotionHandle>.Enumerator`

[Runtime/Lifecycle/MotionHandleExtensions.cs · L37](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L37)

## Complete

Complete active entries. If one completion throws, retain the failed and unprocessed entries.

```csharp
public void Complete()
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L40](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L40)

## Cancel

Cancel active handles in the batch and remove processed registrations.

```csharp
public void Cancel()
```

[Runtime/Lifecycle/MotionHandleExtensions.cs · L41](../../../source/Runtime/Lifecycle/MotionHandleExtensions.cs.html#L41)
