Skip to reading
GUI: Knobs, Dials and Gauges

Build a four-hand clock

Edition 0.86.4.5

New 0.86.4.5 field guide. Rotary Value bindings use Raw JSON in this edition. Clock hands are independent; running-clock or geared behavior is authored separately. Examples can be built in an existing project; the optional workbench is part of the PCA3D source package.

Download PDFView illustrations
On this page

WORKED EXAMPLE / CLOCK

Read the four hands#

Gold marks the hour, ivory marks the minute and red marks the second. Cyan marks the alarm at 17 on its 24-hour scale.

Four independent hands drawn by the runtime. The cyan hand is the added alarm.

Add a Dial and choose Clock. Use Start angle 0°, Sweep 360°, Wrap on and 12 1 scale divisions. Use Add hand once. Set every Step to 1. Enter these values into the four hand records.

Source table from Build a four-hand clock, page 6
Handle IDRangeInitialLength¹Output variable
hour0–12100.48hour
minute0–6090.76minute
second0–60330.88second
alarm0–24170.62alarm

¹ Length is a fraction of the face radius. Give the alarm a separate color. All four hands share the printed 12-division face, so a 24-hour alarm value of 18 points to the printed 9.

Create four number variables with those IDs. Give them the same starting 2 values as the hands. The built-in workbench starts its hand variables at zero and writes each one on a change. Matching the defaults lets a puzzle check an untouched hand correctly.

Grab the minute hand near its tip, or focus the clock and press Down once from 3 the first hand. Move 9 to 10. The hour should stay at 10. With wrapping enabled, the minute hand moves from 59 to 0.

For a time-setting puzzle#

Each hand moves independently. Turning the minute hand through noon leaves the hour alone. If your game needs a running clock or geared movement, supply the timekeeping logic separately.

Page 6 of 11Permalink
Go to page