当前位置: 首页>>代码示例>>C#>>正文


C# Cursor.SetPosition方法代码示例

本文整理汇总了C#中Cursor.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.SetPosition方法的具体用法?C# Cursor.SetPosition怎么用?C# Cursor.SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cursor的用法示例。


在下文中一共展示了Cursor.SetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateUI

		void CreateUI()
		{
			var cache = ResourceCache;

			// Set up global UI style into the root UI element
			XmlFile style = cache.GetXmlFile("UI/DefaultStyle.xml");
			UI.Root.SetDefaultStyle(style);

			// Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
			// control the camera, and when visible, it will interact with the UI
			Cursor cursor=new Cursor();
			cursor.SetStyleAuto(null);
			UI.Cursor=cursor;
			// Set starting position of the cursor at the rendering window center
			var graphics = Graphics;
			cursor.SetPosition(graphics.Width / 2, graphics.Height / 2);

			// Load UI content prepared in the editor and add to the UI hierarchy
			UI.LoadLayoutToElement(UI.Root, cache, "UI/UILoadExample.xml");

			// Subscribe to button actions (toggle scene lights when pressed then released)
			var button1 = (Button) UI.Root.GetChild("ToggleLight1", true);
			var button2 = (Button) UI.Root.GetChild("ToggleLight2", true);

			button1.SubscribeToReleased (args => ToggleLight1 ());
			button2.SubscribeToReleased (args => ToggleLight2 ());
		}
开发者ID:cianmulville,项目名称:urho-samples,代码行数:27,代码来源:SceneAndUILoad.cs

示例2: CreateUI

		void CreateUI()
		{
			var cache = ResourceCache;
			var ui = UI;
			var graphics = Graphics;

			var style = cache.GetXmlFile("UI/DefaultStyle.xml");
			var cursor = new Cursor();
			cursor.SetStyleAuto(style);
			ui.Cursor = cursor;
			cursor.SetPosition(graphics.Width / 2, graphics.Height / 2);

			SimpleCreateInstructionsWithWasd(
				"\nLMB to paint decals, RMB to rotate view\n" +
				"Space to toggle debug geometry\n" +
				"7 to toggle occlusion culling");
		}
开发者ID:cianmulville,项目名称:urho-samples,代码行数:17,代码来源:Decals.cs

示例3: CreateUI

		void CreateUI()
		{
			var cache = ResourceCache;

			// Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
			// control the camera, and when visible, it will point the raycast target
			XmlFile style = cache.GetXmlFile("UI/DefaultStyle.xml");
			Cursor cursor = new Cursor();
			cursor.SetStyleAuto(style);
			UI.Cursor = cursor;

			// Set starting position of the cursor at the rendering window center
			var graphics = Graphics;
			cursor.SetPosition(graphics.Width / 2, graphics.Height / 2);

			// Construct new Text object, set string to display and font to use
			var instructionText = new Text();

			instructionText.Value =
				"Use WASD keys to move, RMB to rotate view\n" +
				"LMB to set destination, SHIFT+LMB to spawn a Jack\n" +
				"CTRL+LMB to teleport main agent\n" +
				"MMB to add obstacles or remove obstacles/agents\n" +
				"F5 to save scene, F7 to load\n" +
				"Space to toggle debug geometry";

			instructionText.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 15);
			// The text has multiple rows. Center them in relation to each other
			instructionText.TextAlignment = HorizontalAlignment.Center;

			// Position the text relative to the screen center
			instructionText.HorizontalAlignment = HorizontalAlignment.Center;
			instructionText.VerticalAlignment = VerticalAlignment.Center;
			instructionText.SetPosition(0, UI.Root.Height / 4);
			UI.Root.AddChild(instructionText);
		}
开发者ID:xamarin,项目名称:urho-samples,代码行数:36,代码来源:CrowdNavigation.cs


注:本文中的Cursor.SetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。