Skip to content

Commit f66fa9d

Browse files
Added relation about touchpanel to the dungeon slime example. The gamecontroller class was updated to use the new "TouchInfo" class.
1 parent f20f79d commit f66fa9d

File tree

1 file changed

+29
-0
lines changed
  • articles/tutorials/advanced/MobileDeployment/03_touch

1 file changed

+29
-0
lines changed

articles/tutorials/advanced/MobileDeployment/03_touch/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,33 @@ public class TouchGame : Game
171171
}
172172
```
173173

174+
## Dungeon Slime Sample
175+
176+
In the _DungeonSlime_ game, touch input is encapsulated in a new **TouchInfo** class, which internally uses the **TouchPanel** API to detect and process gestures.
177+
178+
This class abstracts gesture handling and exposes methods like `IsTouchSwipeUp()`, `IsTouchSwipeDown()`, etc., making it easy to check for swipe actions.
179+
180+
The **TouchInfo** class is then integrated into the **GameController** class, allowing the game logic to respond to touch gestures in a platform-agnostic way. This modular approach keeps input handling clean and maintainable, and ensures that touch support works seamlessly alongside keyboard and gamepad input.
181+
182+
### Extending Move Functions with Touch Gestures
183+
184+
To support touch input alongside keyboard and gamepad, extend your movement functions to include checks for swipe gestures.
185+
186+
For example:
187+
188+
```csharp
189+
public static bool MoveUp()
190+
{
191+
return s_keyboard.WasKeyJustPressed(Keys.Up) ||
192+
s_keyboard.WasKeyJustPressed(Keys.W) ||
193+
s_gamePad.WasButtonJustPressed(Buttons.DPadUp) ||
194+
s_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickUp) ||
195+
IsTouchSwipeUp(); <=== extended to support touch
196+
}
197+
```
198+
199+
This approach ensures your game responds to swipe gestures for movement, providing a consistent experience across touch, keyboard, and gamepad input.
200+
201+
## Conclusion
202+
174203
This foundation enables you to respond to touch input across iOS and Android platforms using MonoGame's cross-platform gesture system.

0 commit comments

Comments
 (0)