Thursday, January 27, 2011

Build a Physics-Based Platformer in Under an Hour

Build a Physics-Based Platformer in Under an Hour:

In this tutorial, you will learn to make a physics-based platform game in the quickest way possible with the World Construction Kit.


Final Result Preview

Let’s take a look at the final result we will be working towards:

It’s a little wonky, but that can be fixed — and wait until you see how quick and easy it was to make!


Step 1: Download

Download the Box2D Alchemy Port and WCK libraries. Get the source from github and for more information, see www.sideroller.com.


Step 2: New FlashDevelop Project

Click on ‘Project’ and select ‘New Project’ from the list. Select AS3 Project as your project template, name your project, point it to an empty directory and click OK.

Locate the Box2D/WCK libraries that you downloaded in Step 1 and place the following folders in your new project’s ‘lib’ folder: Box2D, Box2DAS, extras, gravity, misc, shapes, and wck.

Click on ‘Project’ again and select Properties. Click on the ‘Classpaths’ tab and add your lib folder.

Open Main.as in the source file and add the highlighted code. FlashDevelop should have auto-generated the rest.

public class Main extends WCK
{
 public function Main():void
 {
  if (stage) init();
  else addEventListener(Event.ADDED_TO_STAGE, init);
 }

 private function init(e:Event = null):void
 {
  removeEventListener(Event.ADDED_TO_STAGE, init);
  // entry point
 }
}

Step 3: Set Up the Flash IDE

Open Flash Professional. Press Ctrl+Shift+F12 to open Publish Settings. Click the Flash tab. Select the option ‘Export SWC’

Flash physics platformer WCK Box2D

….and then click the Settings button next to the ActionScript 3.0 combobox.

Flash physics platformer WCK Box2D

In the Source Path tab, click on the ‘browse to path’ icon and select your lib folder. Then click on the Library Path tab and select the ‘browse to SWC’ icon. Select the file lib/Box2DAS/Box2D.swc.

Click OK in Advanced Actionscript 3 Settings and again on the Publish Settings window. Save your FLA in the \src\ folder of your FlashDevelop project (the same folder with Main.as).

Finally, press Ctrl+F3 to open the document properties and set the Document Class to Main.


Step 4: Your First World Object

[...]

No comments:

Post a Comment