Frame-based input handling

In all the previous examples, we used property change signal handlers to execute code when the state of the logical device or object picker changes. This allows you, for example, to execute a function at the moment a button is pressed or released. However, sometimes you want to execute a continuous action (for example, accelerate an object) while a button is pressed. This is easy to do with just a few changes to the code.

First, you need to attach an id to the object with interesting properties (for example Action, Axis, or ObjectPicker):

LogicalDevice {    actions: [        Action {            id: myAction            inputs: ActionInput {                sourceDevice: keyboardDevice                buttons: [Qt.Key_A]            }        }    ]}

This will allow you to refer to its properties. Next, ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.