0

I'm sure I've read that there is a way of getting co-ordinates on Touch with Xna. But it's not really UIE, it's texture Draw in shapes.
For the moment I make them move like that:

void update()
  TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();            
            if (touchCap.IsConnected)
            {
                TouchCollection touches = TouchPanel.GetState();
                if (touches.Count >= 1)
                {
                    Vector2 PositionTouch = touches[0].Position;
                    Position.X = PositionTouch.X - (t_Sprite.Width / 2);
                    Position.Y = PositionTouch.Y - (t_Sprite.Height / 2);
                }
           } 

it's the method of my DragableObject Class. I have defferents DragableObject, and my problem is when I move one Element, all others move too. Anyone helps?

1 Answer 1

0

What i have finally done and "works" for the moment. But dunno if its the good way for implement collision later.

public void Update(GameTime gametime)
{
    Currentposition = Station.Position;

    TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();
    if (touchCap.IsConnected)
    {
        TouchCollection touches = TouchPanel.GetState();
        if (touches.Count >= 1)
        {
            Vector2 PositionTouch = touches[0].Position;
            for (int i = 0; i < ListDragObj.Count(); i++)
            {
                if (ListDragObj[i].Shape.Contains((int)PositionTouch.X, (int)PositionTouch.Y))
                {
                    ListDragObj[i].selected = true;
                }
                else
                {
                    ListDragObj[i].selected = false;
                }
                ListDragObj[i].Update(PositionTouch);
            }
        }
    } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.