new example: interactivity

akkartik
Nov 22, 2023, 6:04 AM
NV4WC3K4KQMF4NSGAKJG7JMN3WNDWPIA7NVYVZUOWFUKZ4562UEQC

Dependencies

  • [2] T7QIIGQ6 attempt at better error recovery
  • [3] RK2ASPN7 add lots of buttons to the toolbar
  • [4] J6O7HP7J new example: draw and update callbacks
  • [5] OOSUBWKX subject people to a tutorial
  • [*] LRDM35CE app running again

Change contents

  • edit in live.lua at line 385
    [7.9940]
    [2.1270]
    love.graphics.setCanvas() -- undo any canvas we happened to be within, otherwise LÖVE seizes up
  • replacement in 0078-Example_panes at line 43
    [4.67][4.67:172]()
    '-- For animations and interactivity, you can define various functions that will get called for you.',
    [4.67]
    [4.172]
    '-- For animations, you can define various functions that will get called for you.',
  • replacement in 0078-Example_panes at line 45
    [4.225][4.225:418]()
    '-- for example, love.draw, love.update, love.keypressed, etc.',
    "-- You can't define those directly because Carousel Shell needs to define them, but you can define your own under car.*,",
    [4.225]
    [4.418]
    '-- for example, love.draw, love.update, etc.',
    "-- You can't define those directly because Carousel Shell needs to define them for its UI, but you can define your own under car.*,",
  • edit in 0078-Example_panes at line 57
    [4.743]
    [4.743]
    'end',
    },
    {
    '-- For interactivity, LÖVE provides functions like love.keypressed, love.mousepressed, etc.',
    '-- As before, define the corresponding car.keypressed, car.mousepressed, etc.',
    "-- A pane's interactive events only activate when the editor is hidden using the 'hide' button above.",
    "-- Try running this example and then pressing and holding the mouse and pressing and releasing keys.",
    '-- Then try hiding the editor and again pressing and holding the mouse and pressing and releasing keys',
    'X, Y, dX = 100, 0, 10',
    "Log = ''",
    '',
    'function car.draw()',
    ' love.graphics.line(X,Y, X,Y+300)',
    ' love.graphics.print(Log, 50,50)',
    'end',
    '',
    'function car.update(dt)',
    ' if X > 500 then dX = -dX end',
    ' if X < 100 then dX = -dX end',
    ' X = X+dX',
  • edit in 0078-Example_panes at line 78
    [4.752]
    [5.1206]
    '',
    'function car.mousepressed(x,y, button)',
    ' Y = y',
    'end',
    '',
    'function car.mousereleased(x,y, button)',
    ' Y = 0',
    'end',
    '',
    'function car.keypressed(key)',
    ' Log = Log..key',
    'end',
  • edit in 0060-next_pane_button at line 8
    [3.6572]
    [3.6572]
    Current_pane.car = car
  • edit in 0060-next_pane_button at line 11
    [3.6661]
    [3.6661]
    car = Current_pane.car or {}
  • edit in 0059-previous_pane_button at line 8
    [3.7115]
    [3.7115]
    Current_pane.car = car
  • edit in 0059-previous_pane_button at line 11
    [3.7204]
    [3.7204]
    car = Current_pane.car or {}