The Level Editor is where you arrange the game objects in your game to build a world, but we need to program the game objects to bring them to life.

Usually programming has to be typed out as instructions that the computer will understand, but Gamefroot's Script Editor gets rid of all that hassle.

With the Script Editor, all you need to do is drag and drop blocks of code together like lego pieces. When these blocks are snapped together, they create sets of instructions -- so you can program without needing to type out code! To open the Script Editor, clickScript Editor in the top-right corner.

These are the main areas of the Script Editor interface that you need to know:

All the script blocks are available from the sidebar on the left, and they are arranged in categories with other similar blocks. For example, all the blocks that can affect speed, gravity, and collisions are found under the Physics category.

The workspace is where you drag blocks into, and arrange them to run as a program. Blocks are snapped together to create sets of instructions that run from top to bottom. Open the different categories in the sidebar, and try dragging some blocks out into the workspace. Try snapping different blocks together to see how that works.

You can delete blocks by dragging them into the sidebar or into the trash can.

The Script Block Categories

Events:

These blocks are the triggers for other blocks. All scripts must have at least one event block, or else none of the blocks will know when to run.

Control Flow:

These blocks control how other blocks work by deciding when those blocks are run according to certain conditions. There are also blocks under this category that can destroy game objects and change the level.

Physics:

These blocks can alter the velocity, acceleration, and gravity. They can also detect collisions between game objects.

Motion:

These blocks can alter and detect the position, rotation, and scale of game objects.

Animation:

These blocks can start, stop, and change the animation sequences for a game object.

Looks:

These blocks can change the visibility and transparency of a game object, as well as changing the camera controls and stage colour.

Sensing:

These blocks sense the position of the mouse, position of fingers on a touch screen, the tags that a game object has, and a game object's class, as well as sensing a bunch of other things.

Sound:

These blocks can play and change game music and sounds.

Operators:

These blocks allow you to compare numbers and boolean states (true or false), and perform mathematical calculations. This category also has blocks for creating and investigating lists and text strings, as well as using colours.

Draw:

These blocks allow you to draw shapes and text on to the screen.

Variables:

These blocks allow you to create and use variables for remembering numbers, text, coordinates, lists, whether something is true or false, etc.

Functions:

These blocks allow you to create and run functions, which are repeatable stacks of blocks.

#

Applying scripts to game objects

Once you have created a script, you need to apply it to a game object to get the script to work in your game. To do this, click on the script from the Scripts sidebar, and then click on the game object to apply it.

The game object will then display a coloured icon so you can see which scripts have been applied to which game objects.

Note: If the script does not get applied to the game object, make sure you have the right layer selected. You can't apply scripts to game objects on layers that you don't have selected.

#

Script Properties

The Script Properties window is accessible by clicking on the 3 lines icon in the menu bar of the script editor. In the Script Properies window, you can name and describe your script, and set whether or not your variables will be public, and what those variables should have as default values.

Ticking public will make that variable available from the game object's instance properties -- this makes it really easy to have individually customized game objects.

Instance Properties

To edit the instance properties of a scripted game object, right-click on the game object and choose Edit Instance Properties.

From the instance properties window you can set values for those public variables. This makes it really easy for you to change how a scripted game object works without having to change the script for each object.

In the example above, this character can have its own message and health without those being predefined in the script -- this means the Character script can be reused on other characters, and those characters can have different messages and health.

results matching ""

    No results matching ""