States

    States are set up and used through controllers: note that only controllers,not actuators and sensors, are directly controlled by the state system.Each object has a number of states (up to 30; default = 1),and can only be in one state at any particular time.A controller must always specify the state for which it will operate — it will only give an output pulseif a) its logic conditions are met, and b) the object is currently in the specified State.States are set up and edited in the object's Controller settings (for details see below).

    Tip

    State settings are automatic in simple games. By default,the number of states for each object is 1, and all controllers are set to use State 1. So,if a game does not need multiple states, everything will work without explicitly settingstates — you do not need to bother about states at all.

    State Panel button.

    States are set up and edited using the Controller (center) column of the Game Logic Panel.To see the State panel, click on the State Panel Button shown.The panel shows two areas for each of the 30 available states; these show Visible states,and Initial states (see below). Setting up the State system for a game is performed bychoosing the appropriate state for each controller in the object's logic.

    The display of an object's state logic, and other housekeeping,is carried out using the State Panel for the object,which is switched on and off using the button shown. The panel is divided into two halves,Visible and Initial.

    In the Visible area, each of the 30 available states is represented by a light-gray square.This panel shows what logic is visible for the logic brick displayed for the object.At the right is the All button; if clicked, then all the object's logic bricks are displayed(this is a toggle), and all State Panel squares are light gray. Otherwise,individual states can be clicked to make their logic visible.(Note that you can click more than one square). Clicking the square again deselects the state.

    States for the object that are in use(i.e. the object has controllers which operate in that state) have dots in them,and squares are dark gray if these controllers are shown in the Game Logic display.The display of their connected sensors and actuators can also be controlledif the State buttons at the head of their columns are ticked.

    ../../_images/game-engine_logic_states_panel2.pngState Panel initial.

    At the right is the button; if clicked,and the Game ‣ Show Debug Properties is clicked,the current state of the object is shown in the top left-hand corner of the displaywhile the game is running.