Pop.Box/docs/Pop.md

2.0 KiB

pop Module

pop is the name of the Pop.Box module. You are expected to require it and then define the following callbacks in LÖVE's callbacks: pop.update(dt), pop.draw(), pop.textinput(text), pop.mousepressed(button, x, y), pop.mousereleased(button, x, y), pop.keypressed(key), pop.keyreleased(key)

Once that has been done (or at the very least, pop has been required and a callback is set up for pop.draw), you can start creating Elements and drawing them.

Also look into Skins, which can make it easy to apply styles to many elements at once.

pop Values / Methods

  • pop.window is the top level element. It essentially represents the game window.
  • pop.create(element, parent, ...) is how elements are actually created, element is a string naming the desired element. There are wrappers around any element that doesn't conflict with a key in the pop module so that you can call pop.element(parent, ...) instead.
  • pop.load() loads elements and skins, and sets up pop.window. This is used internally, and will probably lead to issues if you use it (namely, destroying Pop.Box's access to any existing GUI).
  • pop.skin(element, skin, stop) will apply the specified skin to the specified element and its children (unless stop is set).

pop Callbacks

  • pop.update(dt) is used so that any element can have a frame-by-frame update attached to it.

  • pop.draw() is used to draw everything.

  • pop.textinput(text) is used to grab text input for any focused element that can accept it.

  • pop.mousepressed(button, x, y) is used to detect and handle when an element is clicked on. (Not actually used yet.)

  • pop.mousereleased(button, x, y) is not used yet, but probably will be used in the future.

  • pop.keypressed(key) is not used yet, but probably will be used in the future.

  • pop.keyreleased(key) is also not used yet, but probably will be used in the future.