Read Touch-Events / C# / Windows Phone

Hi,

I’ve a problem read the touch input from my windows phone with monogame.

TouchCollection touches = TouchPanel.GetState();
if (touches.Count > 0)
  {
    Debug.WriteLine(touches[0].Position.X);
  }

The problem is, that i don’t get any error message weather a positionX in the debug-output. (Version 3.2)

Before with Version 3.0.1 I always got Infinity…

Is my code above the correct approach?

I’ve used this tutorial: http://blogs.msdn.com/b/tarawalker/archive/2013/02/23/windows-8-game-development-using-c-xna-and-monogame-3-0-building-a-shooter-game-walkthrough-part-4-adding-and-processing-player-user-input.aspx

Noone has an answer ?
Push

That looks correct. My guess is that the XAML controls are not setup right causing input events to not get to the Game.

Did you fix this? I am having the same problem

@daveleaver - Have you run into this issue before?

No I haven’t seen this before.
@kitnel So you just created a game using the built in templates, ran it and you don’t get touch events?

Are you doing a touch or using the mouse? In the simulator you can chose to make touches or have the mouse be a mouse. Maybe this is set wrong?

I have this same problem, ‘code’ do not recognize any mouse points on emulator screen. I created project in Visual studio 2013 and Windows 8.1. Phone emulator is WP8.1. My code:

ctor:

TouchPanel.EnabledGestures = GestureType.FreeDrag | GestureType.Tap;

update:

var touchCollection = TouchPanel.GetState();

foreach (TouchLocation tl in touchCollection)
{
		Debug.WriteLine(tl.Position.ToString());
}

What i miss, or what is wrong?

Edit:

Ok, I know what i made wrong. When I was solving the problem ‘black screen’(3.2 on Windows Phone 8 just shows black screen) i swapped Grid xml node to DrawingSurfaceBackgroundGrid, what i thing was correct(it wasn’t). Now i was reverting this change and resolve problem correctly(commanded Grid node and uncommented DrawingSurfaceBackgroundGrid bottom node) and it works.

1 Like