本文整理汇总了C#中Controls.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Controls.Set方法的具体用法?C# Controls.Set怎么用?C# Controls.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controls
的用法示例。
在下文中一共展示了Controls.Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTouches
public void UpdateTouches(Controls controls)
{
zoom = false; // reset bool
// Zoom in/out
if (input.NumTouches == 2)
{
TouchState touch1, touch2;
touch1 = input.GetTouch(0);
touch2 = input.GetTouch(1);
// Check for zoom pattern (touches moving in opposite directions and on empty space)
if (touch1.TouchedElement != null && touch2.TouchedElement != null && ((touch1.Delta.Y > 0 && touch2.Delta.Y < 0) || (touch1.Delta.Y < 0 && touch2.Delta.Y > 0)))
zoom = true;
else
zoom = false;
if (zoom)
{
int sens = 0;
// Check for zoom direction (in/out)
if (Math.Abs(touch1.Position.Y - touch2.Position.Y) > Math.Abs(touch1.LastPosition.Y - touch2.LastPosition.Y))
sens = -1;
else
sens = 1;
CameraDistance += Math.Abs(touch1.Delta.Y - touch2.Delta.Y) * sens * touchSensitivity / 50.0f;
CameraDistance = MathHelper.Clamp(CameraDistance, CharacterDemo.CameraMinDist, CharacterDemo.CameraMaxDist); // Restrict zoom range to [1;20]
}
}
// Gyroscope (emulated by SDL through a virtual joystick)
if (UseGyroscope && input.NumJoysticks > 0) // numJoysticks = 1 on iOS & Android
{
JoystickState joystick;
if (input.TryGetJoystickState(0, out joystick) && joystick.Axes.Size >= 2)
{
if (joystick.GetAxisPosition(0) < -CharacterDemo.GyroscopeThreshold)
controls.Set(CharacterDemo.CtrlLeft, true);
if (joystick.GetAxisPosition(0) > CharacterDemo.GyroscopeThreshold)
controls.Set(CharacterDemo.CtrlRight, true);
if (joystick.GetAxisPosition(1) < -CharacterDemo.GyroscopeThreshold)
controls.Set(CharacterDemo.CtrlForward, true);
if (joystick.GetAxisPosition(1) > CharacterDemo.GyroscopeThreshold)
controls.Set(CharacterDemo.CtrlBack, true);
}
}
}