我一直在尝试来回尝试,但我无法弄清楚在使用轻弹手势时如何滚动视图(或者更确切地说是偏移所有对象)的数学运算。我希望滚动有某种缓和。
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
{
float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
//Some math to change 'matrixOffsetY'
//I use 'matrixOffsetY' to offset my objects in Draw()
base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
}
这是手势事件
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
while (TouchPanel.IsGestureAvailable)
{
GestureSample gesture = TouchPanel.ReadGesture();
switch (gesture.GestureType)
{
case GestureType.Flick:
{
//Set a variable with some math? Using:
//gesture.Delta
//gesture.Delta gives us pixels/sec
break;
}
default: return;
}
}
}
这不应该那么难,但我有一个大脑冻结:) 请帮帮我!