samples/02_input_basics/02_mouse/app/main.rb
def tick args
  tick_instructions args, "Sample app shows how mouse events are registered and how to measure elapsed time."
  x = 460

  args.outputs.labels << small_label(args, x, 11, "Mouse input: args.inputs.mouse")

  if args.inputs.mouse.click
    args.state.last_mouse_click = args.inputs.mouse.click
  end

  if args.state.last_mouse_click
    click = args.state.last_mouse_click
    args.outputs.labels << small_label(args, x, 12, "Mouse click happened at: #{click.created_at}")
    args.outputs.labels << small_label(args, x, 13, "Mouse clicked #{click.created_at_elapsed} ticks ago")
    args.outputs.labels << small_label(args, x, 14, "Mouse click location: #{click.point.x}, #{click.point.y}")
  else
    args.outputs.labels << small_label(args, x, 12, "Mouse click has not occurred yet.")
    args.outputs.labels << small_label(args, x, 13, "Please click mouse.")
  end
end
# Saving the click in args.state can be quite useful
Saving the click in args.state can be quite useful
Saving the click in args . state can be quite useful
def tick args
  tick_instructions args, "Sample app shows how mouse events are registered and how to measure elapsed time."
  x = 460
  args.outputs.labels << small_label(args, x, 11, "Mouse input: args.inputs.mouse")
  if args.inputs.mouse.click
    args.state.last_mouse_click = args.inputs.mouse.click
  end
  if args.state.last_mouse_click
    click = args.state.last_mouse_click
    args.outputs.labels << small_label(args, x, 12, "Mouse click happened at: #{click.created_at}")
    args.outputs.labels << small_label(args, x, 13, "Mouse clicked #{click.created_at_elapsed} ticks ago")
    args.outputs.labels << small_label(args, x, 14, "Mouse click location: #{click.point.x}, #{click.point.y}")
  else
    args.outputs.labels << small_label(args, x, 12, "Mouse click has not occurred yet.")
    args.outputs.labels << small_label(args, x, 13, "Please click mouse.")
  end
end
def tick args tick_instructions args , "Sample app shows how mouse events are registered and how to measure elapsed time." x = 460 args . outputs . labels << small_label ( args , x , 11 , "Mouse input: args.inputs.mouse" ) if args . inputs . mouse . click args . state . last_mouse_click = args . inputs . mouse . click end if args . state . last_mouse_click click = args . state . last_mouse_click args . outputs . labels << small_label ( args , x , 12 , "Mouse click happened at: #{click.created_at}" ) args . outputs . labels << small_label ( args , x , 13 , "Mouse clicked #{click.created_at_elapsed} ticks ago" ) args . outputs . labels << small_label ( args , x , 14 , "Mouse click location: #{click.point.x}, #{click.point.y}" ) else args . outputs . labels << small_label ( args , x , 12 , "Mouse click has not occurred yet." ) args . outputs . labels << small_label ( args , x , 13 , "Please click mouse." ) end end
Saving the click in args.state can be quite useful
Saving the click in args . state can be quite useful
args