UDN
Search public documentation:

GFxKeyFiltersCH
English Translation
日本語訳
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 主页 > 用户界面 & HUD > Scaleform GFx > bCaptureInput, AddCaptureKey和AddFocusIgnoreKey指南

bCaptureInput, AddCaptureKey和AddFocusIgnoreKey指南


概述


我们需要筛选输入,这样当玩家按下一个按钮或移动了一个模拟杆时,就能给出正确的反应。 这大大改善了用户界面的使用情况。

bCaptureInput


在您类的默认设置中将此项设置成true(真值)可以将所有的输入(鼠标、键盘和游戏控制器)发送到Flash类/SWF,而不是发送到游戏。 将它设置为false(假值),则所有的输入都会传输到游戏。

Unrealscript
defaultproperties
{
  bCaptureInput=true or false
}

AddFocusIgnoreKey


如果您将bCaptureInput设置为true(真值),SWF文件就不能捕捉单独的帧,而是使用AddFocusIgnoreKey将单独的帧传入游戏中。

Unrealscript
AddFocusIgnoreKey('W');

AddCaptureKey


如果您将bCaptureInput设置为false(假值),SWF文件就能捕捉单独的帧,而不是将单独的帧传入游戏。

Unrealscript
AddCaptureKey('W');

可捕捉帧的示例列表


当捕捉或忽略帧时,以下列表可以使用:

  • 1 - 0, A - Z, F1 - F12
  • 上、下、左、右
  • Spacebar, Enter, Escape
  • BackSpace、左Control键、右Control键
  • 左Shift键、右Shift键、PageUp
  • PageDown键、Home键、Insert键
  • 等号、加号、Tab键
  • 左Alt键、右Alt键

在Kismet中,当使用Set GFx Captured Keys(设置GFx捕捉键)节点,您可能需要使用拼写出来的数字,而不是阿拉伯数字。

  • one, two, three, ...

在ActionScript(动作脚本)中拦截输入


一旦您通过UnrealScript(虚幻脚本)或Kismet拦截一个帧时候,您可以使用以下代码监听在ActionScript(动作脚本)中的那些帧。

ActionScript
import flash.external.ExternalInterface;

var keyboardInput:Object = new Object(); // creates a new object to hold keyboard input.
Key.addListener(keyboardInput); // uses the object to listen for keyboard input.

/* when a key is pressed, execute this function. */
keyboardInput.onKeyDown = function()
{
    /* store the keyboard input ASCII code inside 'keyPressed'. */
    var keyPressed:Number = Key.getCode();
    trace("Key Pressed" + keyPressed);

    /* Call the UnrealScript function 'KeyPressed' and send it the 'keyPressed' value. */
    ExternalInterface.call("KeyPressed", keyPressed);
}

在keyPressed中存储的代码是ASCII值。

ALERT! 注意: 我们偏向使用的键盘输入的路径是在DefaultInput.ini文件中所定义函数的绑定键位。 然后这些UnrealScript(虚幻脚本)可以告知Flash视频短片做什么。但是在如果您想要一些特定的帧在特定的时间到Flash文件的话,就另当别论了。