Tutorial: Adding a fadeout animation

Report 7 Downloads 42 Views
Tutorial: Adding a fadeout animation This tutorial walks you through the steps to add a fadeout animation, including adding a Fader component to a menu element, saving the canvas, loading the canvas with a Flow Graph, and then animating the Fader from the Flow Graph. Animating a Fader is a great way to smooth out transitions when the user loads or leaves a game menu. You will learn how to do the following:   

Add a Fader component Save the canvas Animate the Fader with Flow Graph

Prerequisites 

It is recommended that you have completed the previous tutorial: Aligning Your Buttons

* This tutorial requires you use the SamplesProject supplied with the Lumberyard.

Step 1: Add the Fader component The first step in the tutorial is to add a Fader component to your background element. To add a Fader component Make sure all elements are children of the Background element Select the Background element and click the Component button in the Properties pane to add a Fader component 3. Look at the top of the Background's Properties and make note of its Element ID for later 1. 2.

Step 2: Save the canvas Your menu UI is now complete. To be able to load it and animate it from a Flow Graph, you will need to save it first. To save the canvas 1. 2.

Click File in the Menu bar If you have previously saved the canvas, click Save to save your latest changes. Otherwise:

o o o

Click Save As… Navigate to /dev/SamplesProject Save the canvas as mydemo.uicanvas

Step 3: Trigger a fade animation with Flow Graph After you save your canvas, you will use a Flow Graph to load the canvas and animate the Fader. For the sake of simplicity, the UiDemo level comes with a completed Flow Graph that loads the canvas and triggers the fade animation when the user clicks on the Play button. In this step you’ll examine that Flow Graph. Feel free to make modifications to the graph and examine the changes to learn how the graph setup works. To animate the Fader with Flow Graph 1. 2. 3. 4.

In the main editor, click View, Open View Pane, Flow Graph In the Graphs pane, expand Level Flowgraphs, Entities, UiDemoFlowGraph Select UiDemoFlowGraph If the nodes are greyed out, make sure the Ui layer is selectable  Find the Rollup Bar in the main editor  If you can’t find it, click View, Show Rollup Bar  Select the Layers tab (the icon looks like a stack of papers)  Make sure the box to the left of the Ui layer has an arrow icon in it. If not, click it to make the layer selectable

5.

Examine the UI Flow Graph nodes  The Game:Start node triggers the UI:Canvas:Load node, which loads a canvas  The UI:Canvas:Load node’s CanvasPathname property is relative to the project folder, so you can double-click it and type in mydemo.uicanvas to make it point to your canvas (Note: You may need to use the scroll wheel to zoom in to be able to edit the field)  When the canvas loads, the UI:Canvas:ActionListener node registers with the canvas to listen for an action  Check that the UI:Canvas:ActionListener node has the action name you typed into the Play button  As soon as the canvas sends the action, the UI:Fader:Animation node fades out the UI  Check that the UI:Fader:Animation node has the element ID of the Background element  Once the UI has finished fading out, UI:Canvas:Unload unloads the canvas

Congratulations! You have successfully added a fadeout animation to your game menu.

Related tasks and tutorials From this point forward, you can continue the Your First Game Menu tutorial series and test your game menu. Continue on to the next tutorial: 

Testing your UI

We’d love to hear from you! Head to our Tutorial Discussion forum to share any feedback you have, including what you do or don’t like about our tutorials or new content you’d like to see in the near future.