/
TouchCollectionExtensions.cs
36 lines (34 loc) · 1.21 KB
/
TouchCollectionExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#region File Description
//-----------------------------------------------------------------------------
// TouchCollectionExtensions.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
using Microsoft.Xna.Framework.Input.Touch;
namespace Platformer
{
/// <summary>
/// Provides extension methods for the TouchCollection type.
/// </summary>
public static class TouchCollectionExtensions
{
/// <summary>
/// Determines if there are any touches on the screen.
/// </summary>
/// <param name="touchState">The current TouchCollection.</param>
/// <returns>True if there are any touches in the Pressed or Moved state, false otherwise</returns>
public static bool AnyTouch(this TouchCollection touchState)
{
foreach (TouchLocation location in touchState)
{
if (location.State == TouchLocationState.Pressed || location.State == TouchLocationState.Moved)
{
return true;
}
}
return false;
}
}
}