12:01 PM 12:01 PM12:01 PM
 

In the previous post we learn how to get the current volume.

As I said the max volume can be different according the OS version or de device.

Now let’s get the max volume in c# without native plugin:

11:47 AM 11:47 AM11:47 AM
 

To get the current volume value on Android in Unity without plugin you can use this c# script.
Thanks to the Java Native Interface.

You will get an integer between 0 and ?, 15, 13, 25, …
NB: Actually the max volume value depends of the OS version.

10:36 AM 10:36 AM10:36 AM
 

Sometimes you need to check the Wifi connection of the device on mobile for several reasons.

In order to get the permission to get the Wifi state you have to add this permission in the AndroidManifest.xml file:

Then use this code in your c# class:

11:30 AM 11:30 AM11:30 AM
 

In this tutorial I will show you how to generate and import bitmap fonts in Unity3D with ShoeBox and GlyphDesigner.

UPDATE 07.07.2016: An Unity asset store plugin can convert your bitmap fonts for free: https://github.com/lite3/Unity-BitmapFontImporter
UPDATE 11.17.2015: Littera is an online tool. It works great and it’s free: 
http://kvazars.com/littera/
UPDATE: Unity 5.x, I updated the script but there is an issue with the space interline.

EDIT: GitHub repository

You can use your own custom font in your Unity games like this:

MyCustomFont-export

Capture d’écran 2015-03-22 à 22.15.51

First of all we need to export a .xml file and a .png file.

You will also need this piece of code to generate a font compatible with Unity. I modified and found this C# script in the Unity forum.

Download and add this C# script in your Unity Assets folder: GitHub zip

The softwares

It exists several applications to export a bitmap font with a .xml file but in this tutorial we will use ShoeBox and GlyphDesigner:

Export a bitmap font with ShoeBox

Capture d’écran 2015-03-22 à 22.18.34

Capture d’écran 2015-03-23 à 11.46.51

ShoeBox is a free Adobe Air based app for Windows and Mac OSX with game and ui related tools. Each tool uses a drag and drop or clipboard interaction for a quick workflow.

How to generate the required files to import your custom font with ShoeBox?

  • Download and Install ShoeBoxhttp://renderhjs.net/shoebox/
  • You can use my custom font in this .psd file: MyCustomFont.psd
  • Watch this video bellow but export with the template: FNT-xml Starling. Yes! Starling! :). The BitmapImporterScript.cs script needs a .XML file format.

Capture d’écran 2015-03-22 à 22.24.25

The video tutorial:

  • Import the .xml and the .png files in your Unity Assets folder.

Capture d’écran 2015-03-22 à 22.06.14

Follow the next step of the tutorial in the next chapter after this one.

Export a bitmap font with GlyphDesigner

glyph

Glyph-Designer_1

Glyph Designer is a powerful bitmap font designer. Create beautiful designs using highly configurable effects, definable backgrounds and more. Make the most of your screen with smart zooming and full screen support. Target hundreds of devices on multiple platforms with support for over 15 frameworks out the box. Streamline localizations with GDCL.

How to generate the required files to import your custom font with GlyphDesigner?

  • Download and install GlyphDesigner for Mac or Windows
  • Create your own custom bitmap font with all the glyphs you need
  • Click on the Export button
  • And select Export Type > .xml (BMFont XML)

Capture d’écran 2015-03-23 à 11.52.15

  • Click Save
  • Import the .xml and the .png files in your Unity Assets folder.

Capture d’écran 2015-03-23 à 11.57.44

Follow the next step of the tutorial in the next chapter.

Import and use the bitmap font in Unity

Capture d’écran 2015-03-22 à 22.50.37

  • Import the BitmapFontImporter.cs file in your Unity Assets folder.
  • Then do a Right Click on the .xml file
  • Click Generate Bitmap Font
  • The Script should generate a .material and a .fontsettings file
  • Now we use the font you just created in your scene
  • Create an UI > Text game object in your scene
  • Select the UI Text game object
  • In the inspector go to the Text (Script) component and add the .fontsettings file in the Character >Font field
  • Then add the .mat file in the Material field
  • Never use the Font Size value in the component but use the Scale of the game object instead

Capture-d’écran-2015-03-23-à-12.15.15

12:02 PM 12:02 PM12:02 PM
 

If you do a right click above a Flash animation you will open a context menu.

You can remove all context menu items in Flash with this code:

03:42 PM 03:42 PM03:42 PM
 

Today : How to create a simple button in Flash with AS3.

Example

Sources

You can find the .fla and with the ActionScript source code inside.

Download the source code here: Simple_button_benoitfreslon.com.fla

Let’s start

  1. Open Flash > Create a new Flash ActionScript 3.0 document
  2. Insert > New Symbol
  3. Name : Btn
  4. Type > Button
  5. Click OK

Capture d’écran 2013-09-28 à 16.10.09

  1. Draw a button in the Up state (when the button is released)
  2. Draw a different button in the Over  state (when the mouse cursor is over the button)
  3. Daw a different button in the Down state (when the button is pressed)
  4. Draw a simple shape in the Hit state (The Hit area of the button)
  5. It’s done. Back to the stage now.

Capture d’écran 2013-09-28 à 16.18.25

  1. Then select the MovieClip on the stage
  2. Set an instance name “mc_btn” in the Properties pannel like this

simple_button_02

  1. Create a new Layer with this name: Actions
  2. Select this new layer
  3. Open the Actions Pannel: Windows > Actions or hit F9

simple_button_03

Copy and paste this code:

10:47 AM 10:47 AM10:47 AM
 

For all developers who love Flash Develop like me, you probably NEED to colorize all ActionScript 3.0 keywords.

Here a screenshot of the syntax coloring:

flash_develop

You can download Flash Develop 4 here.

Download my AS3.xml file and replace the AS3.xml in the Languages folder.

C:\Program Files (x86)\FlashDevelop\Settings\Languages

or

C:\Users\XXXX\AppData\Local\FlashDevelop\Settings\Languages

The xml file is compatible with Flash Develop 4.X.X.

10:54 AM 10:54 AM10:54 AM
 

Today a simple sample of code to create an inertia effect in ActionScript 3.0.

The character will start to move with smooth acceleration if you press an arrow key.

You can download the source code here : Flash_acceleration_benoifreslon.com.fla

10:04 AM 10:04 AM10:04 AM
 

Hello,

Today a tip for ActionScript developers.

It’s been a while I looking for an advanced trace output with more details in few line of code.

Just add this line of code instead the trace() function to get a trace message in your ouput with all details.

The output will show this :

Installation

  1. Download the Debug.as file
  2. Copy and paste de Debug.as at the root project, in the same folder of the .fla file
  3. Enable Debugging in Flash. Publish parameters > swf  > Advanced > Allow debugging
  4. Use the following code to display the advanced debugging message

Usage

Source code

Debug.as code:

Good programming :).

10:14 PM 10:14 PM10:14 PM
 

Part 4 – Create the pigs and the collision detection

Introduction

Here the 4th tutorial to learn how to create a physic based game like Angry Birds in Flash.

You can download the complete sources here: How_to_create_a_game_like_angry_birds_part4.zip

If you missed the first tutorial you can find it here: http://www.benoitfreslon.com/fr/tutorial-how-to-create-a-game-like-angry-birds-with-box2d-world-construction-kit-flash-part-1

In this tutorial we will create the the ennemies: the Pigs. We will detect the collision to destroy it.

Create the Pig character

Create the Pig MovieClip:

  1. Insert > New Symbol
  2. Name: Pig
  3. Type: MovieClip
  4. Check export for ActionScript
  5. Class: Pig
  6. OK

Capture d’écran 2013-04-28 à 22.25.04

Draw a beautiful green pig like this with this dimensions: 30×30

Capture d’écran 2013-04-28 à 22.25.21

Or get my sprite:

pig

The Pig class

Create the Pig class.

  1. New > File > ActionSript 3.0 class
  2. Class name: Pig

Copy and paste this code:

Finally add pigs in the World MovieClip like this:

Capture d’écran 2013-04-28 à 23.32.12

And test your level.

The tutorial is over. If you want more features and more tutorials about the Angry birds engine please post a comment :).

Have fun !