本文整理汇总了C#中Window.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GetKey方法的具体用法?C# Window.GetKey怎么用?C# Window.GetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Window
的用法示例。
在下文中一共展示了Window.GetKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePhysics
public void UpdatePhysics(Window window)
{
if (window.GetKey(KeyCode.Right))
{
angle += 0.5f * window.deltaTime;
}
if (window.GetKey(KeyCode.Left))
{
angle -= 0.5f * window.deltaTime;
}
if (window.GetKey(KeyCode.Up))
{
currentLength -= 60 * window.deltaTime;
if (currentLength < 10)
currentLength = 10;
}
if (window.GetKey(KeyCode.Down))
{
currentLength += 60 * window.deltaTime;
if (currentLength > maxLength)
currentLength = maxLength;
}
float angleAccel = -9.8f * (float)Math.Sin(angle);
angleVelocity += angleAccel * window.deltaTime;
angle += angleVelocity * window.deltaTime;
SetDestination(this.position.X + (float)Math.Sin(angle) * currentLength, this.position.Y + (float)Math.Cos(angle) * currentLength);
}
示例2: Main
//.........这里部分代码省略.........
0, 0, 1, 0.5f
};
colouredTriangle.UpdateVertexColor();
Texture alien2 = new Texture("aiv_fast2d_example.Assets.2.png");
RenderTexture maskedAlien = new RenderTexture(alien2.Width, alien2.Height);
Sprite spriteMask = new Sprite(50, 50);
Texture circleMask = new Texture("aiv_fast2d_example.Assets.mask_circle.png");
Texture circleMask2 = new Texture("aiv_fast2d_example.Assets.mask_circle2.png");
Sprite maskedObject = new Sprite(alien2.Width, alien2.Height);
maskedObject.position = new Vector2(200, 200);
Sprite maskedBackground = new Sprite(alien2.Width, alien2.Height);
PostProcessingEffect mainEffect = window.AddPostProcessingEffect(new GrayscaleEffect());
mainEffect.enabled = false;
window.AddPostProcessingEffect(new MaskEffect("aiv_fast2d_example.Assets.mask_circle.png"));
window.AddPostProcessingEffect(new BlackBands());
window.AddPostProcessingEffect(new RedBands());
// insert a postprocessing effect at the specific position
window.SetPostProcessingEffect(1, new WASDEffect());
window.SetPostProcessingEffect(1, new WobbleEffect(5));
Tilemap tileMap = new Tilemap("Assets/map001.csv", "Assets/tiles_spritesheet.png");
while (window.opened)
{
if (window.GetKey(KeyCode.Right))
{
tileMap.position += new Vector2(1, 0) * window.deltaTime * 300;
}
if (window.GetKey(KeyCode.Left))
{
tileMap.position += new Vector2(-1, 0) * window.deltaTime * 300;
}
if (window.GetKey(KeyCode.Up))
{
tileMap.position += new Vector2(0, -1) * window.deltaTime * 300;
}
if (window.GetKey(KeyCode.Down))
{
tileMap.position += new Vector2(0, 1) * window.deltaTime * 300;
}
tileMap.position += window.JoystickAxisRight(0) * window.deltaTime * 300;
tileMap.Draw();
for (int i = 0; i < tiles2.Instances; i++)
{
tiles2.SetPosition(i, new Vector2(20 * i, 20 * i), true);
if (i % 2 == 0)
{
tiles2.SetAdditiveColor(i, new Vector4(1, -1, -1, 1), true);
}
}
tiles2.UpdatePositions();
tiles2.UpdateAdditiveColors();
ship.position.Y = 10;