Sprite Editor: Flags

The flag menus are probably the most confusing part of the editor.
And I'll probably be answering questions about them until the day I die.
But I'll try to explain it here.

What are these menus for?
These menus allow you to control when things appear in the game.

What are "flags"?
Flags are conditions.
They control when things appear and disappear in the game, and when events occur.

When a variable's value changes in the game, every sprite's "flag"
  condition is checked to figure out whether or not that sprite should still exist.

Actually, each sprite can store a set of conditions, all of which need to be true for it to appear, otherwise it disappears.


NOTE: Not all games use flags.
Platformer games usually don't need them.
With a game like that, the editor will still be able to create and display flag conditions, but the game will ignore them and simply display all the sprites, all the time.
With games like that, you don't even need to worry about these menus.
You can ignore them completely.

"Preview" flags
The list on the top-right controls which sprites you currently see in the editor.
They're temporary and are not stored in the game.
This allows you to see what the player
  will see at a given moment in the game.

When the list is empty, you'll see EVERY sprite in this level, including the ones with flags.


"appearance" flags
Each sprite has its own set of conditions that control when it appears in the game.
A sprite won't appear unless ALL of its conditions are met.
  (there can be more than one)
And it'll vanish the moment one of them is NOT met.

For example:
_myVar = true
This sprite will only appear when the variable called myVar is equal to true. And it'll disappear if myVar has any other value.

If there are no conditions, (the list is empty) then this sprite will always appear.

How do I use flags?
When you click on a sprite, you'll see the flags that control it on the left side of its options.
The sprite will only appear in the game when ALL of these conditions are met.
  (there can be more than one condition)
If the list is empty, the sprite will always be visible.

NOTE: Clicking the "apply" button updates the editor's display. If the sprite's flags are excluded by the current preview flags, it will be hidden.

What are "conditions"?
These are examples of things you can type into a flag list:
myVar = true
myObject.myVar < 9
myStory = "intro"
myObject = undefined
  fooBar != undefined
fooBar


Think of it as a bunch of "if" statements.
As you can see, you can also read variables that are inside of objects, or detect whether or not an object or variable even exists.

Also...
_myVar
Is the same as writing:
_myVar != undefined.
It's just an easy way of detecting whether it exists.

My sprite disappeared!
If you type something in the display flag list,
(on the upper-right)
the editor will only display the sprites whose flags match that condition.
To view all the sprites, including the ones with flags, simply empty the display flag list on the top-right.

To view only sprites that require a certain condition, type that condition into the top-right flag list.

How do I make a sprite vanish?
  To deliberately make a sprite disappear under certain conditions, type something like this:

myVar != undefined

The sprite will be visible until myVar gets a value. In other words:
As long as myVar doesn't exist, this sprite will display.

NOTE: Some sprites are able to remove themselves. For instance, RPG sprites can remove themselves or turn invisible using their script commands.


I'm still confused!
  I don't blame you.
Here's a video demonstrating how to use flags.

Last updated: April 27, 2010