當前位置: 首頁>>代碼示例>>C#>>正文


C# Game.Tick方法代碼示例

本文整理匯總了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;
//.........這裏部分代碼省略.........
開發者ID:clarvalon,項目名稱:FNA,代碼行數:101,代碼來源:SDL2_FNAPlatform.cs


注:本文中的Microsoft.Xna.Framework.Game.Tick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。