Skip to main content

Quiz

Quiz

setMode(.paddle) · posX, primaryAction

Quiz is a trivia game: four answers A–D, Open Trivia DB questions (with caching), solo or two-player rounds. The phone is the remote; questions can display on TV via AirPlay.

How you play

  1. Connect + calibrate.
  2. Open Quiz — pick category, language, solo/duo in the flow.
  3. Rotate / tilt the cap left or right to move the highlight across answers (posX → slot 0…3).
  4. Confirm an answer either by:
    • Pressing the cap button (primaryAction / click edge), or
    • Holding steady on a choice until the hold bar fills (TrikiHoldTracker in sample).
  5. Feedback shows correct/wrong; next question after a short pause.
  6. Touch still works on the phone if you disable Triki input in settings.
Focus gate

The sample uses TrikiFocusGate so the highlight does not jump instantly when posX crosses slots — it settles briefly before hold/press counts.

VeltoKit mapping

SettingValue
MotionMode.paddle
NavigationposX mapped to 4 slots via TrikiUIMath.focusedSlot
ConfirmprimaryAction (BLE click) or hold timer
Not usedshotTriggered, throwPower

Same mode as Pong, different game logic — good example of reusing .paddle for menus.

The sample flow is attached to .trikiUIScreen(...), so focus, hold, and activation are consistent with other Triki-driven screens.

Integrate in your app

let motion = MotionSDK()
motion.setMode(.paddle)
motion.connect()

func tick(dt: TimeInterval) {
let input = motion.pollInput(deltaTime: dt)
let slot = slotIndex(for: input.posX, slots: 4) ?? selected

if slot != selected { selected = slot; playFocusSound() }

if input.primaryAction {
submit(answer: selected)
}
}

Map posX to discrete slots with dead zones — copy TrikiUIMath from app/UI/TrikiUI/ or use your own thresholds.

Sample app source

FileRole
app/Games/QuizGame.swiftRounds, focus, hold, scoring
app/UI/QuizGameView.swiftQuestion UI
app/UI/Quiz/QuizExternalDisplay.swiftTV / second screen
app/Quiz/QuizSession.swiftLoader, categories, cache

TV: Enable AirPlay in the quiz flow; external display shows the question card, phone shows controls only.

Tips

  • Tune lateralDeadzone if the highlight jitters between A and B — Configuration.
  • Test hold vs press — some players prefer one confirmation style; the sample supports both.
  • Questions require network on first load; see QuizCache for offline rounds.

← Bowling · Triki UI navigation · Configuration · Demo · Help