本文整理汇总了C#中IHTMLElement.requestPointerLock方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLElement.requestPointerLock方法的具体用法?C# IHTMLElement.requestPointerLock怎么用?C# IHTMLElement.requestPointerLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHTMLElement
的用法示例。
在下文中一共展示了IHTMLElement.requestPointerLock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Spawn
//async Task __buttryfly()
//{
// //Task.Factory.
//}
//async
void Spawn(IHTMLElement e)
{
Native.Document.body.style.margin = "0px";
Native.Document.body.style.padding = "0px";
Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;
e.style.position = IStyle.PositionEnum.absolute;
e.style.left = "0px";
e.style.top = "0px";
e.style.right = "0px";
e.style.bottom = "0px";
e.style.backgroundColor = Color.FromRGB(209, 245, 245);
IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");
loading.style.SetLocation(64, 64, 200, 64);
e.appendChild(loading);
//await __buttryfly();
new global::ButterFly.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
img =>
{
loading.FadeOut();
try
{
//IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFly.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
}
catch (Exception exc)
{
new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
}
e.style.backgroundImage = "url(" + img.src + ")";
e.style.backgroundRepeat = "no-repeat";
e.DisableContextMenu();
var x = 0;
var y = 0;
Action update =
delegate
{
e.style.backgroundPosition = x + "px " + y + "px";
};
e.onmousemove +=
delegate(IEvent i)
{
#region where is the cursor?
if (Native.Document.pointerLockElement == e)
{
x += i.movementX;
y += i.movementY;
}
else
{
x = i.CursorX;
y = i.CursorY;
}
if (x < -img.width / 2)
x += Native.window.Width;
if (y < -img.height / 2)
y += Native.window.Height;
x = x % Native.window.Width;
y = y % Native.window.Height;
#endregion
update();
};
e.onclick +=
delegate
{
e.requestPointerLock();
};
//.........这里部分代码省略.........
示例2: Spawn
//.........这里部分代码省略.........
IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");
loading.style.SetLocation(64, 64, 200, 64);
e.appendChild(loading);
//await __buttryfly();
new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
img =>
{
loading.FadeOut();
try
{
//IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
//IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
}
catch (Exception exc)
{
new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
}
e.style.backgroundImage = "url(" + img.src + ")";
e.style.backgroundRepeat = "no-repeat";
e.DisableContextMenu();
var x = 0;
var y = 0;
var overlay = new IHTMLDiv();
overlay.style.border = "1px solid red";
overlay.style.SetSize(64, 64);
overlay.AttachToDocument();
Native.window.onframe +=
delegate
{
e.style.backgroundPosition = x + "px " + y + "px";
overlay.style.SetLocation(
// how does this work with the background compiler?
// once browser clicks save, visual studio asks if
// to accept, and bacground compiler
// starts a new compilation
// so, the running app could first be able
// to inspect, whats new?
// and if only the same constant was changed,
// it can be discarded. same with comments.
x + 67.ToInteractiveInt32Form(),
y + 2.ToInteractiveInt32Form()
);
};
e.onmousemove +=
delegate(IEvent i)
{
#region where is the cursor?
if (Native.Document.pointerLockElement == e)
{
x += i.movementX;
y += i.movementY;
}
else
{
x = i.CursorX;
y = i.CursorY;
}
if (x < -img.width / 2)
x += Native.window.Width;
if (y < -img.height / 2)
y += Native.window.Height;
x = x % Native.window.Width;
y = y % Native.window.Height;
#endregion
};
e.onclick +=
delegate
{
e.requestPointerLock();
};
});
}