本文整理汇总了C#中Microsoft.Xna.Framework.Game.Tick方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Tick方法的具体用法?C# Game.Tick怎么用?C# Game.Tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Game
的用法示例。
在下文中一共展示了Game.Tick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunLoop
public static void RunLoop(Game game)
{
SDL.SDL_ShowWindow(game.Window.Handle);
// Which display did we end up on?
int displayIndex = SDL.SDL_GetWindowDisplayIndex(
game.Window.Handle
);
// OSX has some fancy fullscreen features, let's use them!
bool osxUseSpaces;
if (OSVersion.Equals("Mac OS X"))
{
string hint = SDL.SDL_GetHint(SDL.SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
osxUseSpaces = (String.IsNullOrEmpty(hint) || hint.Equals("1"));
}
else
{
osxUseSpaces = false;
}
// Do we want to read keycodes or scancodes?
SDL2_KeyboardUtil.UseScancodes = Environment.GetEnvironmentVariable(
"FNA_KEYBOARD_USE_SCANCODES"
) == "1";
if (SDL2_KeyboardUtil.UseScancodes)
{
Log("Using scancodes instead of keycodes!");
}
// Active Key List
List<Keys> keys = new List<Keys>();
/* Setup Text Input Control Character Arrays
* (Only 4 control keys supported at this time)
*/
bool[] INTERNAL_TextInputControlDown = new bool[4];
int[] INTERNAL_TextInputControlRepeat = new int[4];
bool INTERNAL_TextInputSuppress = false;
SDL.SDL_Event evt;
while (game.RunApplication)
{
while (SDL.SDL_PollEvent(out evt) == 1)
{
// Keyboard
if (evt.type == SDL.SDL_EventType.SDL_KEYDOWN)
{
Keys key = SDL2_KeyboardUtil.ToXNA(ref evt.key.keysym);
if (!keys.Contains(key))
{
keys.Add(key);
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = true;
INTERNAL_TextInputControlRepeat[0] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 8); // Backspace
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = true;
INTERNAL_TextInputControlRepeat[1] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 9); // Tab
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = true;
INTERNAL_TextInputControlRepeat[2] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 13); // Enter
}
else if (keys.Contains(Keys.LeftControl) && key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = true;
INTERNAL_TextInputControlRepeat[3] = Environment.TickCount + 400;
TextInputEXT.OnTextInput((char) 22); // Control-V (Paste)
INTERNAL_TextInputSuppress = true;
}
}
}
else if (evt.type == SDL.SDL_EventType.SDL_KEYUP)
{
Keys key = SDL2_KeyboardUtil.ToXNA(ref evt.key.keysym);
if (keys.Remove(key))
{
if (key == Keys.Back)
{
INTERNAL_TextInputControlDown[0] = false;
}
else if (key == Keys.Tab)
{
INTERNAL_TextInputControlDown[1] = false;
}
else if (key == Keys.Enter)
{
INTERNAL_TextInputControlDown[2] = false;
}
else if ((!keys.Contains(Keys.LeftControl) && INTERNAL_TextInputControlDown[3]) || key == Keys.V)
{
INTERNAL_TextInputControlDown[3] = false;
//.........这里部分代码省略.........