本文整理汇总了C#中MouseState.IsPressed方法的典型用法代码示例。如果您正苦于以下问题:C# MouseState.IsPressed方法的具体用法?C# MouseState.IsPressed怎么用?C# MouseState.IsPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MouseState
的用法示例。
在下文中一共展示了MouseState.IsPressed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update()
{
if (mouse.Acquire().IsSuccess)
{
mousestate = mouse.GetCurrentState();
oldTrigger = Trigger;
Trigger = mousestate.IsPressed((int)MouseObject.Button1);
if (timer > 0)
{
timer--;
pixelX = ((Cursor.Position.X - winPosX) * 256) / videoW;
if (pixelX < 0 || pixelX >= 256)
{
State = false;
return;
}
pixelY = ((Cursor.Position.Y - winPosY) * scanlinesCount) / videoH;
if (pixelY < 0 || pixelY >= scanlinesCount)
{
State = false;
return;
}
//System.Console.WriteLine(pixelX + ", " + pixelY);
for (int x = -15; x < 15; x++)
{
for (int y = -15; y < 15; y++)
{
if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < scanlinesCount && pixelY + y >= 0)
{
c = NesEmu.GetPixel(pixelX + x, pixelY + y);
r = (byte)(c >> 0x10); // R
g = (byte)(c >> 0x08); // G
b = (byte)(c >> 0x00); // B
State = (r > 85 && g > 85 && b > 85);//bright color ?
}
if (State)
break;
}
if (State)
break;
}
}
else
State = false;
if (!Trigger && oldTrigger)
timer = 6;
}
}
示例2: GetMouseButtonState
private MouseButtonState GetMouseButtonState(MouseState mouseState, DIButton button)
{
if (mouseState == null)
return MouseButtonState.Released;
return mouseState.IsPressed((int)button) ? MouseButtonState.Pressed : MouseButtonState.Released;
}