How to Add Sound to your Game

There’s a fantastic new feature in our editor, it’s an asset of the audible nature: it’s sound and music! We’ve had the code blocks for some time, but no way to add your own sounds, but now that’s all possible. Let me talk you through it.

The first thing you need is a script to trigger the sound to play. Click on “Add new” in the scripts panel.

Screen Shot 2015-10-19 at 10.04.08 am

Next you’ll need to write your script; use the code blocks to create the image below. This script simply plays some music when the object the script is attached to is created.

Screen Shot 2015-10-19 at 10.06.45 am

Save your script, giving it a name and making sure that “The Music” variable has “Public” checked.

Screen Shot 2015-10-19 at 10.09.06 am

Now we’ve got our script, we need some music to play. Open the “Asset Manager” by clicking on “Assets” in the top right of the screen (next to preview). Create a new pack or select one you own and click the “Create New Asset” button. Select “sound/audio” and upload the music you want to use. Here’s a track to get you started;

 

Screen Shot 2015-10-19 at 10.20.40 am

Once your tracks are uploaded, the only thing left to do is add them to your level! Add a new game object and attach the “Play Music” script to it. Now right click the object and select “Edit Instance Properties.”

Screen Shot 2015-10-19 at 10.27.36 am

Then select the music you want to play from the drop-down;

Screen Shot 2015-10-19 at 10.28.39 am

And that’s it! You’re all set. Hit preview and enjoy the sweet serenade of you’re in-game music. Why not give some sounds a go now? It works the exact same way, the only difference is that multiple “Play Sound” blocks can be played over top of other sounds and the sounds you play wont loop like they do with music. Good luck Gamefrooters!

 

Quick Script Tip: Make a character move with the keyboard

Note: a more up-to-date version of this tutorial can be found here: http://gamefroot.com/knowledgebase/scripting-a-top-down-player-rpg-style/

 

Hey guys, here’s a quick rundown of how to make something move around with the keyboard.

Here’s a little game I’ve started building. I drew some terrain down, and then placed a snowman (on a regular layer).

1I want to be able to move this snowman around by pressing the arrow keys, so I need to create a script. To do this, right-click on the game object, then select Add Script.

2

First I need to be able to tell when keys on the keyboard are being pressed. We can get the Event block for this under Input, Keyboard. Click on the block “When the player presses key” and drag it out into the empty workspace.

3

This block comes with backspace selected as the default key, but I want to use the arrow keys. To change the key, click on the arrow next to backspace and select right arrow from the drop down menu.

4

I want the snowman to move around, so I need to get a block specifically for movement. Blocks for movement and physics are under Game Mechanics, ArcadePhysics. Grab the “set velocity x” block and drag it into the block we placed down before. Make sure they snap together.

5

A velocity of 0 won’t move at all, so change the velocity x number to 200. 

6

Then Save the script!

7

Hit Play (in the top-right corner) to see if your scripted snowman works.

8

Wheee! When you press the right arrow key, the snowman flies off to the right. Perfect. Let’s get the other arrow key working. Click Edit (in the top-right corner) to go back to edit mode.

9

To keep working on the script we started, right-click on the snowman and select Edit script.

10

I want the snowman to stop moving when I release the arrow key, so I need to duplicate these blocks. Right-click on the yellow event block, and select Duplicate.

11

Now we have two sets of these blocks.

12

Change one of the “presses” to “releases” by clicking on it to reveal the drop down menu.

13

When the key is released, I want the movement (velocity) to go back to being still. That means I need to set velocity to 0.

14

Now we can repeat this process to make the left arrow key make the snowman move left. Duplicate the existing blocks, and change right arrow to left arrow. Also make sure you set the velocity to -200 instead of 200. A negative velocity like -200 will move the snowman to the left instead of to the right.

15

Now save this, and Play the game. Awesome! Now your snowman can move left and right. What else would you add to this script? What other things should happen to the snowman?

If you have any cool ideas, let us know in the comments below.

– Gamefroot_Dave.

Placing objects in a Terrain Layer

You may have noticed that your character or other game object was squished when you placed it into your level. This is because you’ve placed it in a Terrain Layer.

game-object-terrain-1

Don’t worry – just make sure you place game objects on a regular Layer (this applies to characters, or anything else interactive).

game-object-terrain-2

Terrain layers are a bit different to regular layers. Anything that is placed in a terrain layer will be resized to fit the terrain tilemap grid, and anything in that grid becomes solid and won’t move – this makes calculating collisions in your game far easier, and your game will run smoother.

Note: if the game object is animated, it will appear in terrain with the last frame from the last animation sequence (for characters this usually makes them appear as lying down).

 If you want your game objects to become terrain, then place them in a terrain layer. Otherwise, place them in a regular layer.

New Gamefroot Replacing Old Gamefroot

We’re really excited by how well the new version of Gamefroot has been received. Over the coming weeks, we’ll be ensuring all your games from the old Gamefroot are accessible in the new Gamefroot editor at make.gamefroot.com. Once this process is complete, we’ll be taking down the old Gamefroot so that we can focus on maintaining a single game making environment. With that focus, we can continue to make Gamefroot more powerful and easy to use.

The old Gamefroot was designed to create Flash games, but the new Gamefroot creates HTML5 / Javascript games, which means your games will run not just in your web browser, but also on modern devices such as your Android or iPhone. Old technologies become obsolete – such is the way of Flash, and the Flash games era has been rapidly drawing to a close. We realised HTML5 was going to be the future of the web, and now that future has become a reality (even Youtube has stopped displaying videos in Flash, and now uses HTML5 video).

We hope you continue to enjoy using Gamefroot. We’d love to hear your feedback, so please send us a message here with your questions or comments.

Regards,
The Gamefroot Team

Gamefroot Game Creator 2.1 Beta!

We’ve been working on a new and improved version of Gamefroot for the past few months, and it’s finally ready to unveil. Gamefroot 2.1 is a quite a change from the older version of Gamefroot.

gamefroot-update

This new version boasts a brand new HTML5 game engine, a new visual coding editor powered by Google Blockly, and an improved user interface. We’ve taken the emphasis away from forcing our users to make platform games – now you can make any kind of game you want, as long as you create or choose the assets and scripts you need. Gamefroot is now a blank slate, awaiting your command.

New features include:

Continue reading “Gamefroot Game Creator 2.1 Beta!”