I'm making a game and I have a problem:
I want to control the hero in my game through swipes. For example:
My question is how to check what side a user swipes.
Thank you
in this i have checked that on which side a user has touched the screen according to player and then have given the velocity to the player in that side and similarly if user touches above the player then player jumps... this is not exactly what you need but think you can take some idea how to do your thing....
TouchCollection touchcollection = TouchPanel.GetState();
foreach (TouchLocation t1 in touchcollection)
{
if (t1.State == TouchLocationState.Pressed)
{
Vector2 touchposition = t1.Position;
if (touchposition.X >= (position.X + texture.Width))
velocity.X = 3f;
else if (touchposition.X <= position.X)
velocity.X = -3f;
else
velocity.X = 0;
if (touchposition.Y < position.Y && hasjumped == false)
{
position.Y -= 10f;
velocity.Y = -5f;
hasjumped = true;
}
}
}
if (hasjumped == true)
{
velocity.Y += 1.5f;
}
if (position.Y + texture.Height > 790)
hasjumped = false;
if (hasjumped == false)
velocity.Y = 0;
position += velocity;
这篇关于Windows Phone 7上的触摸手势的简单文章正是您所需要的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.