Page History
...
English | |||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OverviewAfter completing this topic you will be able to:
Download and install the following tools:
Getting Started with the Graphical UIAfter installing the tools start Vectorian Giotto. This program will be used to create the graphical side of the UI. Setting Up the Document
First, we are going to set the document settings.
Vectorian Giotto never asks you to save your work, so make sure you save regularly as well as before closing.
Since Vectorian Giotto doesn't have a workspace or something, you will have to keep it tidy yourself.
At the top of the screen you will find the timeline. It is smart to keep the background and the components separate, on different layers.
Creating the Graphical User InterfaceCreating the Button
Now we are going to turn this shape with text into a button.
Now the shape has been replaced with your button. If you double click on it you will zoom in on it, the timeline will change and we can edit the buttons properties. It now has four states:
Creating the MessageBoxNow we will add some text to our scene which we can edit in real-time later.
Your scene should look something like this: Exporting the UINow, since we want to use the button and the text field in script, we will give them a sensible name.
Also, because we are using fonts, we need to embed them in the SWF file. At the bottom in the properties:
Now you should have the following files in your project folder:
The SWF file currently contains only the graphical part of the UI, in the next part you will be creating the code to support it. Making the User Interface InteractiveSetting Up the Project
This will place the code in a folder next to the SWF, nice and tidy. Now on the right you will see your project is created (TutorialProject(AS2)).
Now we have a project and a class which we will use to hook Flash up to CRYENGINE via Scaleform.
Let's look at the project properties.
Here you will see 5 tabs, we will be editing only 2.
Adding the ActionScriptNow the project is ready to inject your ActionScript into the SWF file. This file needs an entry point which looks like this:
This piece of code is executed in the beginning, it instantiates the ButtonTestClass and stores it in ButtonTest. This means the constructor is called, and that is where we will put everything we need to initialize. In the constructor the following code will deal with a buttonpress:
This overwrites the onPress function for the button with our own. Notice the "_root.ButtonClick". This is the path to the object, it will always start with _root, and then with whatever you named your button. "fscommand" lets the Flash object communicate with its owner, in our case the Scaleform inside the engine. This command is used to send an event to CRYENGINE which you can catch in Flow Graph and process (this process will be explained later). And finally, let's add a function to the constructor that can alter the text in the MessageBox for us:
Here again, note the "_root.MessageLabel".
Exporting the Injected Movie to the Game
This will inject the code into the given SWF file, and save it to the output file. If you want to run your project you can go to: Project > test project It won't do much at this point because clicking the button will only generate an event that needs to be processed, but you can see how your UI looks like and if it runs without errors. Now we are going to get our UI to run in a game.
Now in order for the engine to read it, it will need a UI element, which is stored in an XML file.
Setting Up the UI Inside CRYENGINETest the UI in the UI EmulatorYou can actually test your UI before dropping it in game with the help of the UI Emulator. To do this, go to: View > Open View Pane > UI Emulator
Under "Elements" there is a list of different UIs, yours should be listed among them.
Now you should see your UI in the emulator window.
Now the UI will accept mouse events and the button will react to your mouse in the previewer. You can even test the function you've just made and added.
Use FlowGraph to Display your UI in GameThe FlowGraph For Displaying the UIThe last step is to get it actually running in your level and have the button responding to your clicks.
We don't need to bother with adding anything to the level, the water will be fine for now.
Now there is a blank sheet showing, your empty FlowGraph. Let's add nodes to start, end and configure the UI.
In the three UI nodes:
Now set the following flags to true: In Config:
In Constraints:
Now link all the FlowGraph nodes together as shown below. The FlowGraph for Handling Events and FunctionsLet's add the events and functions to FlowGraph as mentioned earlier. Add the event we defined:
Add the function we made:
You should have a UI now which responds when you click on the button. The result might be skewed due to your viewport settings, in the emulator you can view it at different resolutions and see an accurate result. Tips and TricksFlashDevelop
|
...
Chinese | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
总览完成了这个主题后您将能够:
下载并安装以下工具:
图形 UI 入门知识安装工具之后开始运行 "Vectorian Giotto"。使用该程序创建 UI 的图形端。 Setting Up the Document
首先进行文档设置。
"Vectorian Giotto" 不会提示您保存工作,因此在关闭之前要确保随时保存。
由于 "Vectorian Giotto" 没有工作区或诸如此类的区域,因而您将需要保持其整洁。
在屏幕的顶端您将发现时间轴。该时间轴将后景和组件智能分开在不同的图层中。
创建图形用户界面创建按钮
现在我们将使用文本将图形转换为按钮。
现在图形已被按钮替换。双击该按钮可将其放大,将更改时间轴并且可以编辑按钮属性。 目前该按钮包括四种状态:悬上、接触、按下和点击。
现在我们可以改变不同状态下的按钮外观。
创建消息框现在将添加一些文本到我们的场景中,稍后我们可以在该场景中实时编辑。
您的场景外观应该是这样。 导出 UI现在,由于我们想要使用脚本中的按钮和文本字段,我们可以使用适当的名称为其命名。
而且由于我们使用的是字体文件夹,我们需要将其嵌入到 SWF 文件中。请使用“选择工具”来完成此操作,并单击中间的“消息框”。 在属性的底部:
现在您的项目文件夹中应该包含以下文件:
目前 SWF 文件中仅包含 UI 的图片部分,在下一部分中您将创建支持该图片的代码。 实现用户界面交互设置“项目”打开 FlashDevelop 并进入
此操作将会把代码放置于 SWF 旁边的文件夹,美观且整齐。 现在在右侧您将看到您已创建的项目(教程项目 (AS2))。
现在已有项目和类,并且我们将使用类经由 Scaleform 使 Flash 与 CryEngine 挂钩。
下面继续项目属性。
在此处您将看到 5 个标签,我们将仅编辑其中 2 个。
添加操作脚本现在,项目将准备注入操作脚本到 SWF 文件。 此文件需要如下所示的入口点:
起初执行代码片段,该操作将“测试按钮类”实例化并保存于“测试按钮”中。 这意味着已调用构造函数,我们需要进行实例化的所有类皆可以在此处执行。 构造函数中以下代码将处理按下按钮:
使用我们自己的按钮重写“按下”函数。注意 "_root.ButtonClick"。 命令使 Flash 对象与其所有者实现沟通,在我们的实例中是实现 CryEngine 与其内部的 Scaleform 沟通。 最后,添加可以更改消息框中文本的函数。
这里再次注意"_root.MessageLabel"。 此处是操作脚本文件的完整代码:
导出注入的影片至游戏
此操作将注入代码至给定的 SWF 文件,并将其另存至输出文件中。
由于点击按钮将仅生成即将处理的事件,因而此时不需多项操作,但您可以查看您的 UI 以及运行时未出现错误的外观。 现在将使 UI 在游戏中运行
现在为使 CryEngine 能够读取该文件,将需要一个保存在 XML 文件中的 UI 元素。
设置 CryEngine 内部的 UI测试 UI 模拟器中的 UI在 UI 模拟器的帮助下,实际上可在将 UI 置于游戏中之前对其进行测试,若要完成此操作,请进入 视图 > 打开试图窗格 > UI 模拟器 注:您在此模拟器中的所有操作都具有临时性,仅供预览而不保存任何设置。 “元素”下方是不同的 UI 列表,您的 UI 应列入其中。
现在您应该在模拟器窗口中查看您的 UI。
现在 UI 将接受鼠标事件并且按钮将对预览中的鼠标做出反应。 您可以测试刚刚设定和添加的函数。
旁注:若您的 UI 中未设置后景且文本颜色设置为黑色,由于 UI 模拟器的背景也是黑色,您将无法读取该文本。 使用 FlowGraph 以在游戏中显示您的 UI使用 FlowGraph 显示 UI最后一步是在您的关卡中实际运行 UI 并使按钮响应点击。
We don't need to bother with adding anything to the level, the water will be fine for now.
现在显示的是一个空白表格,即您的空 FlowGraph。添加节点以开始、结束程序并对 UI 进行配置。
在配置和约束中:
现在将把以下标记设置为真: 在配置中:
在约束中:
如下所示,现在链接所有 FlowGraph 节点。 处理事件和函数的 FlowGraph如前面提到的添加事件和函数至 FlowGraph 。
添加我们所设定的函数:
现在单击按钮时您的 UI 应该有所响应。由于您的视区设置,其结果可能不尽如人意,在模拟器中您可以低分辨率查看该结果并且可以得到精确的结果。 提示和诀窍FlashDevelop
|
...
English | |||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OverviewAfter completing this topic you will be able to:
Download and install the following tools:
Getting Started with the Graphical UIAfter installing the tools start Vectorian Giotto. This program will be used to create the graphical side of the UI. Setting Up the Document
First, we are going to set the document settings.
Vectorian Giotto never asks you to save your work, so make sure you save regularly as well as before closing.
Since Vectorian Giotto doesn't have a workspace or something, you will have to keep it tidy yourself.
At the top of the screen you will find the timeline. It is smart to keep the background and the components separate, on different layers.
Creating the Graphical User InterfaceCreating the Button
Now we are going to turn this shape with text into a button.
Now the shape has been replaced with your button. If you double click on it you will zoom in on it, the timeline will change and we can edit the buttons properties. It now has four states:
Creating the MessageBoxNow we will add some text to our scene which we can edit in real-time later.
Your scene should look something like this: Exporting the UINow, since we want to use the button and the text field in script, we will give them a sensible name.
Also, because we are using fonts, we need to embed them in the SWF file. At the bottom in the properties:
Now you should have the following files in your project folder:
The SWF file currently contains only the graphical part of the UI, in the next part you will be creating the code to support it. Making the User Interface InteractiveSetting Up the Project
This will place the code in a folder next to the SWF, nice and tidy. Now on the right you will see your project is created (TutorialProject(AS2)).
Now we have a project and a class which we will use to hook Flash up to CRYENGINE via Scaleform.
Let's look at the project properties.
Here you will see 5 tabs, we will be editing only 2.
Adding the ActionScriptNow the project is ready to inject your ActionScript into the SWF file. This file needs an entry point which looks like this:
This piece of code is executed in the beginning, it instantiates the ButtonTestClass and stores it in ButtonTest. This means the constructor is called, and that is where we will put everything we need to initialize. In the constructor the following code will deal with a buttonpress:
This overwrites the onPress function for the button with our own. Notice the "_root.ButtonClick". This is the path to the object, it will always start with _root, and then with whatever you named your button. "fscommand" lets the Flash object communicate with its owner, in our case the Scaleform inside the engine. This command is used to send an event to CRYENGINE which you can catch in Flow Graph and process (this process will be explained later). And finally, let's add a function to the constructor that can alter the text in the MessageBox for us:
Here again, note the "_root.MessageLabel".
Exporting the Injected Movie to the Game
This will inject the code into the given SWF file, and save it to the output file. If you want to run your project you can go to: Project > test project It won't do much at this point because clicking the button will only generate an event that needs to be processed, but you can see how your UI looks like and if it runs without errors. Now we are going to get our UI to run in a game.
Now in order for the engine to read it, it will need a UI element, which is stored in an XML file.
Setting Up the UI Inside CRYENGINETest the UI in the UI EmulatorYou can actually test your UI before dropping it in game with the help of the UI Emulator. To do this, go to: View > Open View Pane > UI Emulator
Under "Elements" there is a list of different UIs, yours should be listed among them.
Now you should see your UI in the emulator window.
Now the UI will accept mouse events and the button will react to your mouse in the previewer. You can even test the function you've just made and added.
Use FlowGraph to Display your UI in GameThe FlowGraph For Displaying the UIThe last step is to get it actually running in your level and have the button responding to your clicks.
We don't need to bother with adding anything to the level, the water will be fine for now.
Now there is a blank sheet showing, your empty FlowGraph. Let's add nodes to start, end and configure the UI.
In the three UI nodes:
Now set the following flags to true: In Config:
In Constraints:
Now link all the FlowGraph nodes together as shown below. The FlowGraph for Handling Events and FunctionsLet's add the events and functions to FlowGraph as mentioned earlier. Add the event we defined:
Add the function we made:
You should have a UI now which responds when you click on the button. The result might be skewed due to your viewport settings, in the emulator you can view it at different resolutions and see an accurate result. Tips and TricksFlashDevelop
|
...
Chinese | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
总览完成了这个主题后您将能够:
下载并安装以下工具:
图形 UI 入门知识安装工具之后开始运行 "Vectorian Giotto"。使用该程序创建 UI 的图形端。 Setting Up the Document
首先进行文档设置。
"Vectorian Giotto" 不会提示您保存工作,因此在关闭之前要确保随时保存。
由于 "Vectorian Giotto" 没有工作区或诸如此类的区域,因而您将需要保持其整洁。
在屏幕的顶端您将发现时间轴。该时间轴将后景和组件智能分开在不同的图层中。
创建图形用户界面创建按钮
现在我们将使用文本将图形转换为按钮。
现在图形已被按钮替换。双击该按钮可将其放大,将更改时间轴并且可以编辑按钮属性。 目前该按钮包括四种状态:悬上、接触、按下和点击。
现在我们可以改变不同状态下的按钮外观。
创建消息框现在将添加一些文本到我们的场景中,稍后我们可以在该场景中实时编辑。
您的场景外观应该是这样。 导出 UI现在,由于我们想要使用脚本中的按钮和文本字段,我们可以使用适当的名称为其命名。
而且由于我们使用的是字体文件夹,我们需要将其嵌入到 SWF 文件中。请使用“选择工具”来完成此操作,并单击中间的“消息框”。 在属性的底部:
现在您的项目文件夹中应该包含以下文件:
目前 SWF 文件中仅包含 UI 的图片部分,在下一部分中您将创建支持该图片的代码。 实现用户界面交互设置“项目”打开 FlashDevelop 并进入
此操作将会把代码放置于 SWF 旁边的文件夹,美观且整齐。 现在在右侧您将看到您已创建的项目(教程项目 (AS2))。
现在已有项目和类,并且我们将使用类经由 Scaleform 使 Flash 与 CryEngine 挂钩。
下面继续项目属性。
在此处您将看到 5 个标签,我们将仅编辑其中 2 个。
添加操作脚本现在,项目将准备注入操作脚本到 SWF 文件。 此文件需要如下所示的入口点:
起初执行代码片段,该操作将“测试按钮类”实例化并保存于“测试按钮”中。 这意味着已调用构造函数,我们需要进行实例化的所有类皆可以在此处执行。 构造函数中以下代码将处理按下按钮:
使用我们自己的按钮重写“按下”函数。注意 "_root.ButtonClick"。 命令使 Flash 对象与其所有者实现沟通,在我们的实例中是实现 CryEngine 与其内部的 Scaleform 沟通。 最后,添加可以更改消息框中文本的函数。
这里再次注意"_root.MessageLabel"。 此处是操作脚本文件的完整代码:
导出注入的影片至游戏
此操作将注入代码至给定的 SWF 文件,并将其另存至输出文件中。
由于点击按钮将仅生成即将处理的事件,因而此时不需多项操作,但您可以查看您的 UI 以及运行时未出现错误的外观。 现在将使 UI 在游戏中运行
现在为使 CryEngine 能够读取该文件,将需要一个保存在 XML 文件中的 UI 元素。
设置 CryEngine 内部的 UI测试 UI 模拟器中的 UI在 UI 模拟器的帮助下,实际上可在将 UI 置于游戏中之前对其进行测试,若要完成此操作,请进入 视图 > 打开试图窗格 > UI 模拟器 注:您在此模拟器中的所有操作都具有临时性,仅供预览而不保存任何设置。 “元素”下方是不同的 UI 列表,您的 UI 应列入其中。
现在您应该在模拟器窗口中查看您的 UI。
现在 UI 将接受鼠标事件并且按钮将对预览中的鼠标做出反应。 您可以测试刚刚设定和添加的函数。
旁注:若您的 UI 中未设置后景且文本颜色设置为黑色,由于 UI 模拟器的背景也是黑色,您将无法读取该文本。 使用 FlowGraph 以在游戏中显示您的 UI使用 FlowGraph 显示 UI最后一步是在您的关卡中实际运行 UI 并使按钮响应点击。
We don't need to bother with adding anything to the level, the water will be fine for now.
现在显示的是一个空白表格,即您的空 FlowGraph。添加节点以开始、结束程序并对 UI 进行配置。
在配置和约束中:
现在将把以下标记设置为真: 在配置中:
在约束中:
如下所示,现在链接所有 FlowGraph 节点。 处理事件和函数的 FlowGraph如前面提到的添加事件和函数至 FlowGraph 。
添加我们所设定的函数:
现在单击按钮时您的 UI 应该有所响应。由于您的视区设置,其结果可能不尽如人意,在模拟器中您可以低分辨率查看该结果并且可以得到精确的结果。 提示和诀窍FlashDevelop
|
...