Draggable
Something the player picks up with the mouse and drops somewhere else: a card, a puzzle piece, an item in an inventory, a word to put in order. Press on it to pick it up (it’s drawn on top while held), let go to drop it. Dropped on a DropTarget that takes it, it lands in the target’s middle; dropped on one that doesn’t (full, or for other kinds), it slides back where it came from. With a controller or keys, a Grabber picks it up instead.
It’s picked up by its collider’s shape, or its sprite’s if it has no collider, and lands by its middle. In a network game the host moves it for whoever holds it, and two players can’t hold the same thing.
Works with: DropTarget (places to drop it); Grabber (picks it up with a button)
Changes how its entity is drawn (a tint, a shake or drawing it on top).
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
kind: text = null. What kind of thing it is, e.g. “Card” or “Red Gem”: a DropTarget’s Accepts names the kinds it takes. (Names a draggable kind: this entity’s own, which other fields can name.) (Field: a name.)onlyOnTargets: true or false = false. True if it only goes on targets: let go anywhere else, it slides back where it was picked up. Otherwise it stays where it’s let go. (Field: on or off.)grid: a number = 0. Let go off a target, it lands in the middle of a square this big (1 matches a tilemap’s cells), so things line up. 0 leaves it where it’s let go. (Field: a number.)staysOnTarget: true or false = false. True if it stays on the first target it’s dropped on that takes it: a jigsaw piece in its place, a word in its gap. It can’t be picked up again. (Field: on or off.)slideTime: a number = 0.1. Seconds it takes to slide into place: onto a target’s middle, the grid, or back where it came from. 0 jumps. (Field: a number.)
Sound and Messages
Section titled “Sound and Messages”pickUpSound: text = null. A sound played when it’s picked up, e.g. “Sounds/pick.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)dropSound: text = null. A sound played when it’s let go, e.g. “Sounds/drop.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)pickUpMessage: text = null. A message sent with Game.Send when it’s picked up, with this entity as its data. (Names a message.) (Field: a name.)dropMessage: text = null. A message sent with Game.Send when it’s let go, with this entity as its data. (Names a message.) (Field: a name.)
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
isHeld: true or false. True while someone holds it, with the mouse or a Grabber.target: an entity: its name, id or path. The drop target it’s on, or null. It’s on a target while it rests with its middle inside the target’s shape.
Scripts use it as Draggable: its methods, events and values that aren’t saved with the scene.