# Live Edit

### Introduction

The Live Edit feature in FlatRedBall enables making a change to your game when in *edit mode* and applying those changes without restarting your application. It enables a variety of types of editing, and this list is continually growing.

### Enabling Live Edit

To enable Live Edit in your game:

1. Click the Editor Settings button. This brings up the Editor Settings tab

   ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-b88a13a9b24508bf9bac2b0411572d273a4d3bb9%2F2023-08-img_64dc3d61e692a.png?alt=media)
2. Check the option to Enable Live Edit

   ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-b148ce7c97b4db83991563582b16861723dfeb1d%2F2023-08-img_64dc3dd4da7b9.png?alt=media)

Once this option is checked, FlatRedBall generates the necessary code to enable Live Edit in your game. This includes a connection between the FlatRedBall Editor and your game, using the port specified in the Port Number text box. Usually you do not need to change this port, but it can be changed if it conflicts with other applications. Once Live Edit is enabled, you can run your game and enable live edit in a number of ways.

* Run in Edit Mode - You can directly launch your game by clicking the **Run in Edit Mode** button

  ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-e8a52dd93611ab277af64854094607c4f9b8b3b0%2F2023-08-img_64dc3f5ac404a.png?alt=media)
* Alternatively, you can launch your game in the FRB Editor...

  ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-d676b5721347674113fb2b6d28339bec7e86e2be%2F2023-08-img_64dc3f84aec51.png?alt=media)

  ... and then switch to edit mode

  ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-704c4c18c4f9e9efae5c6c814a2c9e1596b4d688%2F2023-08-img_64dc3fb4045da.png?alt=media)
* Run your game in Visual Studio. FRB automatically detects when the game is running and displays the edit mode button. You can run your game in edit mode even if you didn't launch it through FRB

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-ce60eab8f6550697adde8e7c5adfa6779548ff97%2F2023-08-15_21-18-51.gif?alt=media" alt=""><figcaption></figcaption></figure>

As shown above, you can tell that your game is in edit mode if it displays a grid. You can switch between Edit and Play mode anytime by toggling the play and edit buttons.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-2ea973dc86cd3bb16d51b0dd53b16f8c4b4eb607%2F2023-08-15_22-16-16.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Selecting and Previewing

If in edit mode, the selected level displays in the game. You can change selections and the game will switch what is displayed in realtime.

* Select a Screen (or Level)

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-937ad76733c84554c6f0d20b656778bbb53ba31f%2F2023-08-15_22-20-12.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Select an entity to view it in game. The game creates a preview screen allowing you to view and edit the entity by itself.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-101d82c115031ba08145b5550eef2857c87142bd%2F2023-08-15_22-24-55.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Select an object in a Screen or Entity to highlight it

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-317f12ab18dc7c3c75976d75e61299860b41f540%2F2023-08-15_22-26-37.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Select a state to preview it

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a02153b42a34ed28d1ca89a00a008c0387e60f41%2F2023-08-15_22-29-12.gif?alt=media" alt=""><figcaption></figcaption></figure>

* States can also be previewed by selecting a state in the StateData editor grid to preview it as well

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-3a59172d011338a1f2cd1676276cedc38c9696ce%2F2023-08-15_22-29-45.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Select an object in a screen by clicking on it in game and it will select in the tree view

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-e14667f5751c276efae7b917f2903b2aaaf9d9d6%2F2023-08-15_22-30-47.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Double-click to *punch through* and select overlapping objects

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-3b351e72b4de4e1c938349db3ea7a4fd5dfb3f7d%2F2023-08-15_22-31-21.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Camera Controls

The Camera in Edit mode can be controlled using the following methods:

* Hold the middle mouse button to pan

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-37f0dd83b5062847052da60f461d137267db96c3%2F2021-08-2021_August_10_112219.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Hold the CTRL key and press the arrow keys. Holding the arrow keys will continue to pan.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-e66e3597264df5a6c4c9b8cd615f3b80d4d29280%2F2021-08-2021_August_10_111520.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Push+hold the left mouse button and move to the edge of the screen

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-0002c7bebb5f3c75eceb6d2bb3c560e8240a7e08%2F2021-08-2021_August_10_111021.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Scroll the mouse wheel to zoom in and out

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-8e4cd646489b0134a318f0d3972edc4e24a1071c%2F2021-08-2021_August_10_114921.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Hold the CTRL key and press + or - to zoom in and out

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-7383c3325080711cf92593631eecced227c87b8f%2F2021-08-2021_August_10_114022.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Moving and Changing Object Variables

Changes in FlatRedBall immediately apply if the game is in edit mode. The following edits are supported in Live Edit:

* Change a value (such as X or Y) in the Variables tab to see the change in your game

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-6acdf2762c997d36b182bdea2eaa6c32c9abe94c%2F2023-08-15_22-32-46.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Push+drag to move objects in the game - the variables will update automatically in Glue to match the new position

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-12c6d3fd6be617f779d890914f87f9e8cf58002a%2F2023-08-15_22-33-12.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Drag objects to the edge of the screen to pan the camera if they need to be placed off screen

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-97a38255fc808619377ceed46d5f02743f03fdb8%2F2023-08-15_22-34-13.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Multiple objects can be selected and moved at once by holding down the CTRL key and clicking each object

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-205186bf43340444b8097666f7a55a85e18bcf1c%2F2023-08-15_22-34-48.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Pushing the left mouse button in a blank space and dragging results in a rectangle which can be used to select multiple objects

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a862c51434d47502b73ed08513641fa1efecf626%2F2023-08-15_22-35-38.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Math operations can be used to change numerical values

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-2e507919ab94c3d95daa952abaa4055501824279%2F2023-08-15_22-36-18.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Along with primitive types (such as numerical values), states can also be set on instances

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a91f107116acfe57ad346881b33599e62bb72a6c%2F2023-08-15_22-38-42.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Creating New Objects

Creating a new object in FlatRedBall automatically updates the game with the new object. New objects can be added to levels or entities.

* New level objects can be added through the Add Object Quick Action

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-5ede87be916b61bccc0258fa356cb53282ecfa5b%2F2023-08-15_22-39-53.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Glue also supports Drag+drop to add objects to a level

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-3d9f5f0ceb4c1e38d6a5a21eeaa645b2abe0329c%2F2023-08-15_22-40-29.gif?alt=media" alt=""><figcaption></figcaption></figure>

* New objects can also be added by selecting their list and using the Quick Action button

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-7fff545d3b0bf02adb07f18ef83cfbbf4d7fb2bc%2F2023-08-15_22-41-37.gif?alt=media" alt=""><figcaption></figcaption></figure>

* New objects can be created by using the CTRL+C, CTR+V shortcut in game. This is especially useful when placing multiple objects in game. When pasting a grabbed object, the new object will be placed at the location of the crusor.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-6a0c181087765aab5b95af6a64b09026643b4680%2F2023-08-15_22-42-59.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Objects added to Entities will automatically appear on instances of that entity

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a4e801cff3ee67103c09876ac0789e05feb1ae88%2F2023-08-15_22-43-47.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Working with Files

FlatRedBall supports adding files at runtime and automatically updating to changes.

* New files can be added from the file system to Screens or Entities. If these files are then referenced by an object (such as a Sprite), they will be displayed in game.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-a62ddc8299589544c4c1e3af7c7ef763bf80f8ee%2F2021-08-2021_August_10_164735.gif?alt=media" alt=""><figcaption></figcaption></figure>

* External changes to files are automatically reloaded

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-45ff4414aaa05c66bd70d80703c80269eb4d38e8%2F2021-08-2021_August_10_160041.gif?alt=media" alt=""><figcaption></figcaption></figure>

* Changes to TMX files which can create entities and collision will automatically update these objects so they can be tested immediately. For example, painting collision tiles immediately allows testing the new level without restarting.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-4de0ee6d64948345c68e0c5f4592e69925d4d1cc%2F2021-08-2021_August_10_162846.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Editing Polygons

Polygons can be edited in real time when your game is running in live edit.

* Change the number of points by clicking the rectangle button or the button to create an equilateral polygon of a given number of points.<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FDIzMXRqwcxA6v14rNUMj%2F07_06%2037%2042.gif?alt=media&#x26;token=d2aa5751-8497-4e99-a0aa-9b48b9f8fb36" alt=""><figcaption><p>Set the number of points using the rectangle or set points button</p></figcaption></figure>
* Push+drag on a point to change its position or type in a desired value by selecting the point. The selected point has an animated rectangle selector.<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FlVdXa9wy8oueusXx32km%2F07_06%2040%2020.gif?alt=media&#x26;token=fdfeec40-3417-41bf-bf5f-b2a04bcbfe52" alt=""><figcaption><p>Change point positions in the game window or by typing in new values in the Points tab</p></figcaption></figure>
* Reorder points by using the up and down arrow buttons.<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FEMg6zvbhzjw4TSnmH0Xh%2F07_06%2043%2030.gif?alt=media&#x26;token=63f4c2a6-9113-47e1-8464-e83e6967eeab" alt=""><figcaption><p>Reorder polygon points with the up and down buttons</p></figcaption></figure>
* Adjust the size of a polygon by using the scale button. X and Y scaling can be performed independently.<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FJaBivNSm61l78cTyEriw%2F07_06%2044%2057.gif?alt=media&#x26;token=59f5ffb7-a2f0-4fc1-ae31-f4fd8d6b9afd" alt=""><figcaption><p>Resizing polygon height and width</p></figcaption></figure>
* Points can be deleted by clicking on a particular point then pressing the delete key.<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FITCJ22yXCYsoTlSMNU5v%2F07_07%2047%2048.gif?alt=media&#x26;token=030ef270-8c7e-4074-a0bd-462daa419b87" alt=""><figcaption><p>Delete points with the delete key</p></figcaption></figure>
* Hold the plus (+) key then click to add points to a polygon<br>

  <figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FvqhkcsGYoopiu9n7VGjt%2F07_07%2051%2041.gif?alt=media&#x26;token=518b9506-6d02-4a73-9fac-27cd23641cb2" alt=""><figcaption><p>Add points by holding down the plus key and clicking</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flatredball.com/flatredball/glue-reference/enable-live-edit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
