Touch Creator allows you to determine which actions are triggered on components during the runtime of a multi-touch scenario. This is achieved by Actions that convey interaction from the touches of the user to any parts of the scenario.
Various types of actions are available. For instance, pressing a button may start a video, touching one component may cause another to disappear, or pressing a button may reset the overall scene to its initial state. With special actions you may even allow users to control external devices.
Creating an Action
Select the component that is to trigger the action. Go to the Actions tab in Inspector and click the button below the Actions list. Then select the action from the pop-up menu that you would like to use.
Not all actions are applicable to all components, for instance the Toggle Visible action makes no sense for components that have no visual representation in a scene, e.g. Timer components or Network Sender components.
All actions have the same general settings. They are as follows:
- Event: Here you can select the event that will trigger the action. Learn more about events here.
- Receiver: Here you can set the component that will receive the action, i.e. the component that is affected by the action. The component triggering the action can also be the receiver.
- Idle Timeout: Here you can enter a number of milliseconds for the Idle event. Once the time has elapsed, the idle action will trigger.
- Parameter: If the selected event is a Network Message event, enter the message that your system must receive to have the action triggered.
- Send to Children: Make the child components of the receiver receive the action as well.
The way an action is displayed in the list will help you recognize its function. Here's an example:
In this example, the event to trigger the action is Clicked. The action to be carried out is Hide and the receiver is Media Player 2. The actions you see in this list are assigned to the component currently selected in the Scene Manager.
There are several events that can be set to trigger an action. You will use some of them frequently, for instance Clicked, while others may be used rarely, for instance Network Message. The following events are available.
- Pressed: Triggers the action when the component is clicked and held.
- Pressed Long: Triggers the action when the component is clicked and held for longer than 0.5 seconds.
- Released: Triggers the action when the component is pressed and then released.
- Clicked: Triggers the action when the component receives a simple click, i.e. a short tap.
- Double Clicked: Triggers the action when the component receives a double tap.
- Enter Drop Pane: Triggers the action when the component enters a Drop Pane component.
- Exit Drop Pane: Triggers the action when the component leaves a Drop Pane component.
- Opened: Triggers the action when the component is opened.
- Closed: Triggers the action when the component is closed.
- Show: Triggers the action when the component is rendered visible.
- Hide: Triggers the action when the component is rendered invisible.
- Idle: Triggers the action when the component remains idle for the time specified in the Idle Timeout field. Idle time cannot be triggered on inactive components. On active components, a user interaction is required to start the idle time counter. Any further user interaction occurring within the idle time restarts the idle time again.
- Timer Fired: Triggers the action when the selected component is a Timer component and its time elapses.
- Network Message: Triggers the action when the selected component is a Network Receiver component and it receives a network message.
Note: Some of the touch events above overlap to a degree. For instance, any Pressed, Pressed Long, and Double Clicked event includes a Clicked event. Also, with a Pressed Long event a Pressed event is always triggered.
Each component may be assigned multiple actions. This way, you can implement components that affect the multi-touch scenario beyond their basic functionality. For instance, you can assign a Style action to a Media Player component changing the component's size on a touch event.
Actions are one-time changes. This means that once you have triggered an action, such as hiding a component or changing its style, the result of that action will remain until the component is acted upon again. So the component will stay hidden or retain its new style. Because of this, it may be important to give users a way to reverse actions if required in your multi-touch scenario.
Since components often have several actions assigned to them that may have various effects, you might want to take full advantage of the Stage while composing your scenario's interaction. Since the Stage offers a live preview of the multi-touch scenario, you can test your actions immediately and then reset them. This will ensure that the desired interaction will be attained.
Sequence of Actions
You can create multiple actions assigned to an individual component. The sequence in which you create these actions has no effect on the sequence they are executed. However, two actions A and B may run in different order at different times, which may lead to different results if the same properties are changed.
Imagine action A resizing a component C in total pixels (e.g. X=500 px, Y=500), while action B scales the same component C by percentage (e.g. 50%). The sequence A→B leads to X=250 px, Y=250 px, while B→A leads to X=500 px, Y=500 px, i.e. action B is practically ignored.
This is why we don't recommend assigning multiple actions to a component affecting the same property of another component. If you require a sequence of changes to the same property of a component, you may create a chain of events that trigger the individual changes, for instance by means of Timer Fired events. Also, the use of a script is a viable option.