examples

drag-drop.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
box = display.rect(display.center, 50, 50)

box2 = display.rect(100, 100, 50, 50)

box2.point((e) => {
  if (e.updated) {
    box2.position = e.position
  }
  if (e.ended) {
    if (box2.collide(box)) {
      box2.height += box.height
      box.destroy()
      box = null
    }
  }
})