UDN
Search public documentation:
ScaleformQuickStartJP
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
中国翻译
한국어
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
「Scaleform GFx」のクイックスタート
概要
シーンのセットアップ
サンプルファイル |
---|
UI_QuickStart - Part 1 |
UI_QuickStart - Part 2 |
UI_QuickStart - Part 3 |
UI_QuickStart - Part 4 |
- カーソルのムービークリップを選択し、 F9 ボタンを押して ActionScript エディタを開きます。
- 次のコードを追加します。
onClipEvent(enterFrame) { _X = _root._xmouse; _y = _root._ymouse; }
- [ Library ] (ライブラリ) パネルから画像を選択してから、右クリックし、[ Properties ] (プロパティ) を選択します。
- [ Bitmap Properties ] (ビットマップ プロパティ) で、 Allow Smoothing (スムージングを有効にする) にチェックを入れ、 Compression (圧縮) を Lossless (PNG/GIF) (ロスなし) にセットします。
- (高度) をクリックすることによって、高度なプロパティを表示します。
- [ Linkage ] (リンク) セクションで、 Export for ActionScript (ActionScript のためのエクスポート) を有効化するとともに、[ Identifier ] (識別子) フィールドで、画像名からファイルの拡張子 (ピリオドを含めて) を取り除きます。
- ボタンをクリックすることによって、変更を保存します。
- 最後に、オリジナルのソース画像ファイルは、SWF ファイルと同じ名前のフォルダに置かれなければなりません (フォルダは、SWF ファイルと同じディレクトリとなります)。
シーンをインポートする
[GameName]\Flash
ディレクトリの中に置かれなければなりません。このディレクトリは、「Unreal」においてこの .swf をインポートすべきパッケージの名前をもつフォルダ内に置かれなければなりません。このフォルダは、.swf がインポートされることになるパッケージに直接対応し、インポート時に変更することができません。オプションとして、このパッケージ フォルダ内にサブフォルダを置くことによって、パッケージ内のグループを表すことができます。
パブリッシュされた .swf ファイルが確実に正しい場所に置かれるようにするには、実際の Flash ファイル (.fla) をまず望みの場所に保存することが最も簡単です。デフォルトでは、パブリッシュされたファイルがそれといっしょに保存されます。
シーンのパブリッシュが完了すると、「Unreal」にインポートすることができます。そのためには、 Unreal Editor 内の コンテンツ ブラウザ を使用するか、あるいは、 GFXIMPORT コマンドレット を使用します。この例では、コンテンツ ブラウザ (Content Browser) を使用してうまくインポートできます。
- Unreal Editor を開き、Content Browser に進み、 ボタンをクリックします。
- ファイル ブラウザ上にあるファイルタイプフィルタを、 SWF Movie (.swf) に変更し、パブリッシュされた .swf ファイルの場所に進みます。
- ファイルを選択して、 ボタンをクリックします。
- [ Import ] (インポート) ダイアログにおいて、 Package (パッケージ)、 Group (グループ)、 Name (名前) がすべて満たされ、グレー表示されます。
ここでは、デフォルトの設定でかまいせん。 ボタンをクリックすることによって、シーンをインポートします。 - インポートのプロセスが完了すると、SWF ファイルとそれに含まれている画像がすべて、Content Browser で表示されるようになります。
シーンを接続する
Movie
プロパティを通じて、SWF ファイルと関連づけられており、イベントを受け取ったり、コマンドを渡したりすることができるとともに、関連づけられている UI 内部の要素にアクセスすることもできます。
始められたばかりの方は、新たな UnrealScript プロジェクトを追加する方法について、 カスタムの UnrealScript プロジェクト のページを参照してください。
基本的なプロセスは次のようになります。
- ムービープレイヤーがムービーを開始します。-
Start()
- ムービープレイヤーが初期化されます。-
Advance()
- enableInitCallback が有効になっているすべての要素のために WidgetInitialized が呼び出されます。 *必要とされるウィジェットに参照が保存されます。- アクセスする必要があるシーン内のあらゆるオブジェクトの参照が保存される必要があります。
- ボタンのクリックイベントのためにデリゲートがアサインされます。- ウィジェットのバインディング が利用されることによって、ボタンのために WidgetInitialized に渡されるウィジェットが、イベントリスナーを追加することができる GFxCLICKWidget となります。
- ボタンがクリックされると、デリゲートが呼び出されます。
- SaveButton - プレイヤーが入力した情報を使用してメッセージが変化します。
- ExitButton - UI を閉じます。
class UIScene_Profile extends GFxMoviePlayer; /** Reference to the label used to display the message on the UI */ var GFxObject MessageLabel; /** Reference to the text field used to enter the player's name */ var GFxObject PlayerText; /** Reference to the text field used to enter the player's title */ var GFxObject TitleText; /** Reference to the text field used to enter the player's clan */ var GFxObject ClanText; /** Reference to the button used to save the profile info - must add a widget binding since we expect a GFxCLIKWidget */ var GFxCLIKWidget SaveButton; /** Reference to the button used to close the UI - must add a widget binding since we expect a GFxCLIKWidget */ var GFxCLIKWidget ExitButton; // Called when the UI is opened to start the movie function bool Start(optional bool StartPaused = false) { // Start playing the movie Super.Start(); // Initialize all objects in the movie Advance(0); return true; } // Callback automatically called for each object in the movie with enableInitCallback enabled event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget) { // Determine which widget is being initialized and handle it accordingly switch(Widgetname) { case 'messageLabel': // Save reference to the label that displays the message to the player MessageLabel = Widget; break; case 'playerText': // Save reference to the text field for the player's name PlayerText = Widget; break; case 'titleText': // Save reference to the text field for the player's title TitleText = Widget; break; case 'clanText': // Save reference to the text field for the player's clan ClanText = Widget; break; case 'saveButton': // Save reference to the button that saves the profile info // the Widget is cast to a GFxCLIKWidget to allow for event listeners - see WidgetBindings SaveButton = GFxCLIKWidget(Widget); // Add a delegate for when this button is clicked SaveButton.AddEventListener('CLIK_click', SavePlayerData); break; case 'exitButton': // Save reference to the button that closes the UI // the Widget is cast to a GFxCLIKWidget to allow for event listeners - see WidgetBindings ExitButton = GFxCLIKWidget(Widget); // Add a delegate for when this button is clicked ExitButton.AddEventListener('CLIK_click', CloseMovie); break; default: // Pass on if not a widget we are looking for return Super.WidgetInitialized(Widgetname, WidgetPath, Widget); } return false; } // Delegate added to change the message using the data entered //In a real game situation, the data would be saved somewhere function SavePlayerData(EventData data) { // Only on left mouse button if(data.mouseIndex == 0) { // Set the text property of the message label using the profile info entered MessageLabel.SetString("text", "Welcome,"@PlayerText.GetString("text")@"("$TitleText.GetString("text")@"in"@ClanText.GetString("text")$")"); } } // Delegate added to close the movie function CloseMovie(EventData data) { // Only on left mouse button if(data.mouseIndex == 0) { // Close the UI Close(); } } defaultproperties { // The imported SWF to use MovieInfo=SwfMovie'UDNHud.UI_QuickStart' // Set widget bindings so the Widget passed to // WidgetInitialized for the buttons is a GFxCLICKWidget WidgetBindings.Add((WidgetName="saveButton",WidgetClass=class'GFxCLIKWidget')) WidgetBindings.Add((WidgetName="exitButton",WidgetClass=class'GFxCLIKWidget')) // Set properties for the movie // TimingMode=TM_Real makes the menu run while the game is paused bDisplayWithHudOff=TRUE TimingMode=TM_Real bPauseGameWhileActive=TRUE bCaptureInput=true }
シーンをテストする
- Level Loaded (レベルのロード) イベント ( New Event > Level Loaded ) と、 Open GFx Movie (「GFx」ムービーを開く) アクション ( New Action > GFx UI > Open GFx Movie ) を追加します。
- Level Loaded イベントの Beginning of Level (レベルの開始) 出力を、Open GFx Movie アクションの In 入力に接続します。
- Content Browser 内で、インポートされた SWF を選択するとともに、Open GFx Movie アクションのプロパティ内で、 Movie プロパティのための ボタンをクリックすることによって、SWF をアサインします。
- Movie Player Class を、前のセクションのクラスにセットします。(この例では、
UIScene_Profile
です)。これは、前のステップでアサインされたムービーを制御するクラスです。 - Take Focus (フォーカスをとる) プロパティと Capture Input (入力を取り込む) プロパティを有効にすることによって (HUD ではなくメニューであることが想定されています)、メニューがフォーカスされ入力が受け入れられるようにします。