Getting Started

Codea Forums

Tap here to access the Codea Forums. Talk with other users, ask questions and share code.

Codea Wiki

Tap here to access the Codea Wiki. Find tutorials, help and other valuable information created by Codea users.

Lua Manual

Tap here to access the Lua Reference Manual, which describes the syntax and semantics of Lua and its standard libraries.

Project Basics

Deleting Projects

Tap and hold on a user project to delete or duplicate it.

Editor Basics

Creating New Files

Tap the plus button on the top right of the tab bar to create a new blank file or class template.

Deleting and Renaming Files

Tap and hold on a tab to rename or delete it.

Editor Features

Keyboard Pop-up Keys

Any key on the keyboard containing a circle in the upper-right corner can be long-pressed. You can then drag your finger to choose from alternate symbols and functions.

Color Picker

Any function that can use a color will display a highlight. Tapping the highlight will present a color picker you can use to select a color.

Asset Picker

When using the sprite(), music(), sound() and shader() functions you will see a highlight surrounding the parameters. Tap this highlight to bring up a visual asset picker for selecting graphics, music and more.

Caret Selection Circle

As you are typing, you will notice a small circle appear around the caret in the code editor. You can drag this circle at any time to immediately make a selection.

Search and Replace

Tap the search key to search your code and perform replacements.

Reference Documentation

Tap the reference key to browse the integrated Codea reference documentation at any time.

Play

Tap the play key to run your code.

Tab and Autocomplete

As you type, Codea will present possible word completions above the keyboard. You can tap a particular suggestion, or tap the tab key to autocomplete using the first suggestion.

Math Palette

Tap the math key to get a list of commonly used math, logic and expression symbols. You can also touch-and-drag the math key to quickly select a symbol.

Plus-Equals

A common trait found in simulations and games is incrementing values over time. In most programming languages this is performed with a += operator. That is, a += b is shorthand for a = a + b. Lua does not provide this operator, however you can use the key to expand the currently typed symbol as follows:

a

pressed

a = a +

This can be a timesaver when dealing with long variable names, such as self.position

Caret Positioning

Touch and drag to shift the text caret around your code. You can also tap the left or right edge of the key to shift the caret by one character.

Touch and drag to drag out a selection in your code.

Parentheses, Quoting and Indenting

The keys will create an enclosing pair of parentheses or quote marks with the insertion caret placed between them.

If you select some text you will see them change as follows

This indicates that pressing the parentheses or quote key will enclose the currently selected text in quotes or parentheses. Note that similar functionality is present with the square brackets and curly braces in the math palette

When a block of text is selected, the Tab key will change to Pressing it in this state will indent the entire block. You can also long-press the tab key to backwards-indent a selected block of text.

Bluetooth Keyboard Shortcuts

When using a bluetooth keyboard the following shortcuts are available.

⌘R Run Project

⌘F Search Project

⌘D Show Documentation

⌘W Close Project

⌘N New Class

⌘B New Blank File

⌘/ or ⌘- Comment Line

⌘[ or ⌘O Indent Code

⌘] or ⌘I Backwards Indent Code

⌘⇧[ or ⌘⇧O Previous Tab

⌘⇧] or ⌘⇧I Next Tab

Codea Basics

Codea Global Functions

By default your new projects will contain two functions: setup() and draw(). These will be called automatically by Codea in order to setup and draw your project. However there are a number of other functions you can implement to receive information when changes happen.

function touched( touch )

Implement this function to receive events whenever a touch on the screen begins, ends, or moves. You can use this function to receive multi-touch information and respond to complex user interaction.

function keyboard( key )

When the keyboard is shown using showKeyboard(), this function will be called when a key is pressed.

function collide( contact )

Implement this function if you are using the Physics API and wish to receive a notification any time two bodies collide with each other in your simulation.

function sizeChanged( width, height )

Implement this function to receive notification when the view size changes, usually due to the device being rotated by the user, the app entering split-view, or the sidebar being collapsed or expanded. You may wish to use this function to re-layout your scene for the new size.