Studio › Manual › Code and objects

GML Visual blocks

Any object event or script can be blocks instead of code. Each block is one step, written as a sentence ("If move_x is not 0"), coloured by its group. The blocks run from top to bottom; blocks inside an If, a loop or a With are indented on a coloured rail.

  • Code or Blocks: the switch in the editor header (⇧⌘B, Code > Blocks > Show as Blocks / Show as Code). Blocks to code always works: you get the GML the blocks make. Code to blocks turns each statement into a block; anything blocks cannot show becomes a Code block that shows the code and can still be edited, so nothing is lost. Each switch is one undo step.
  • Add a block: click it in the library on the left (⇧⌘L shows or hides it), or drag it into place. Type in the search box ("Type to find a block", ⌥⌘L) to find one by what it does; Return adds the first match. Rest the pointer on a block in the library to see it and the GML it makes.
  • Change a value: click a pill in the sentence. Code pills complete GML names as you type (↑ ↓ to choose, Tab or Return to take one, Esc to stop). Assets open a picker with pictures; on/off values are switches; choices are menus; colours open the colour panel; keys have a menu and Press a Key…. Words with ⇄ (like "to" / "up by") switch when clicked. Return on a selected block edits its first value; double-click a block does the same.
  • Who runs it: blocks that can run as other instances show a small pill (self, other, or an object) on the right.
  • Move: drag a block; a line shows where it will go. Drop it under an If's header to put it inside. Drag a block out of the canvas (onto the library, say) to delete it. ⌥↑ and ⌥↓ move the selection; ⌥→ puts it inside the block above; ⌥← takes it out of its container.
  • Select: click; ⇧-click selects a range, ⌘-click adds or removes one. ↑ ↓ move the selection, ⌘A selects all, Esc clears.
  • Edit: ⌘C, ⌘X and ⌘V copy, cut and paste (copied blocks also paste as GML into code); ⌘D duplicates; Delete removes; ⌘/ disables or enables (a disabled block is dimmed, struck through, and makes no code). Right-click a block for Wrap in If, Wrap in Repeat, Wrap in With (⌃⌘I, ⌃⌘R, ⌃⌘W) and Unwrap (⌃⌘U).
  • Otherwise blocks belong to the If above them: they are drawn joined to it, move and delete with it, and can only be dropped right after an If.
  • Undo ⌘Z and Redo ⇧⌘Z undo every change, one step at a time.
  • Code preview: the panel on the right (⌥⌘P) shows the GML the blocks make, updated as you edit, in the code editor's colours. The selected blocks' lines are highlighted; click a line to select the block that makes it.
  • Studio blocks: the Studio group adds seven blocks of Studio's own (glide, head for a point, move and slide, signals, timers, watch). GameMaker opens them as code blocks and runs them; projects that use glide or signals need Studio's runtime script.
  • Saving (⌘S) writes the event exactly in GameMaker's GML Visual format and turns the event's GML Visual flag on or off to match, so GameMaker opens it the same way.
  • An empty event shows six blocks to start with: Set Variable, If, Create Instance, Play Sound, Go to Room and Draw Self.

Keys are shown as on the Mac: ⌘ Command, ⌥ Option, ⌃ Control, ⇧ Shift. Studio for Windows shows its own keys beside each menu item.