Prototype of a Flash game like Meeblings

You should all known Meeblings and the sequel, Meeblings 2.

Meeblings

You have to help the Meeblings (cute creatures I’d love to burn alive) reaching the exit using some special abilities.

One of such abilities attracts Meeblings when you click and hold the mouse on a special Meebling.

In the prototype you are about to see, derived from the basic HelloWorld Box2D example, there are 10 randomly placed balls with different masses.

When you click and hold anywhere on the stage, every ball in a 4 meters radius (read this post and this post too if you don’t know how to convert meters to pixels) will be attracted towards the mouse pointer.

The more the distance, the stronger the attraction. Read more

How to embed a text file in Flash

Reading some comments about the “Word Play” Flash Game Contest on this blog and on some forum threads, I noticed people can’t import a big list of words into Flash.

So here I am with a complete example :)

First, put your txt file in the same folder of your Flash project.

Then, the main file can be something like this one:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package {
	import flash.display.Sprite;
	import flash.text.TextField;
	public class wordz extends Sprite {
		var text_field:TextField = new TextField();
		var words:embedded_text = new embedded_text();
		public function wordz() {
			addChild(text_field);
			text_field.height=400;
			text_field.width=500;
			text_field.text=words.toString();
		}
	}
}

Really nothing new except the words variable at line 6 that belongs to a class called embedded_text, that is the key class of this example.

Let me show it:

1
2
3
4
5
6
7
8
package {
	import flash.utils.ByteArray;
	[Embed(source="words.txt",mimeType="application/octet-stream")]
	public class embedded_text extends ByteArray {
		public function embedded_text() {
		}
	}
}

What? That easy?

Yes… the magic is at line 3 where I specify the path and the mime type of the file to embed. And I’ll have it ready to use into my Flash project

I can’t show you the final result because displaying thousands of words would crash the browser, but if you download the example, you can click on it and scroll the mousewheel to see all words I am using in the game I am developing to enter the contest.

Download the source code and enjoy.

Upgrade your Flash CS4 to 10.0.2

I was playing with some thousands of words in an array to enter the “Word Play” Flash Game Contest when I got this strange error:

Obviously there was nothing wrong in my line 1, but it’s a CS4 issue related to compiling large projects.

So I recommend you to check for the Adobe Flash CS4 Professional Update (10.0.2) released to fix some important issues.

This update for Flash CS4 Professional (10.0.2) addresses issues related to compiling large projects. Specifically, it addresses stability and performance issues related to large animation files, such as timeline scrubbing and looping and nested movie clips, as well as text handling.

This may be the reason you couldn’t compile the Flash file with all words in it.

With my 10.0.2 version everything is going right and I am heading for the 1st prize :)

Play Mazeroll, my latest Box2D game

After SamePhysics, I made another Box2D game called Mazeroll.

Mazeroll

You have to drag a maze to made two circles touch, collecting as much red orbs as you can, before time reaches zero.

You can find some clues about the making of this game reading The magic of compound objects with Box2D and Perfect maze generation – tile based version.

I simply put together these two concept and added some gameplay.

As you can see there are some in-game banners, and there is room for two more banners in the rotation, so starting from June 29, when the game is supposed to have been widely published, I will insert two (and only two) more ** LIFETIME ** banners for as low as $100 per banner.

Drop me an email at info[at]emanueleferonato.com if you want to be one of the lucky two people that will get these banners.

Papervision3D: understanding Plane object – part 6

In part 5 we created a playing card.

Now it’s time to make it a bit more realistic. You know when you play again and again with playing cards, they bend.

We’ll learn how to bend our planes.

To bend objects in Papervision3D we need a 3rd party library called AS3Dmod.

AS3Dmod is a framework for creating static and animated modifier stacks, so you can modify the same object with more than one modifier.

So the steps to add a modifier to an object are:

1) Create a modifier stack and apply it to the object

2) Add a modifier to the stack

3) Configure the modifier

4) Repeat from step 2 if you want to add more than one modifier

5) Apply the queue

Now it’s time to download the library from the official Google Code page and copy the com folder in the same path you copied the org Papervision3D folder. Don’t worry if you can’t find it, at the end of the page I included the full source code with all needed libraries in the proper positions.

Now, the script we already saw at part 5 with the new lines commented.

Plese notice at lines 42 and 43 I added more segments to the planes, to have a smoother blend.

To understand what segments represent, read part 1 Read more

Papervision3D: understanding Plane object – part 5

This is the time to add textures to our plane from a movieclip.

Since I am making a card game, I want to store all cards in a single movieclip and assign each frame to a different plane.

At the moment I have only two frames, one with the front and one with the back of the card, because the creation of the “perfect card” is not over yet…

I am attaching the commented code, and please notice I NEVER add the card clip on the stage using addChild

All the uncommented code has been explained from part 1 to 4 Read more

Papervision3D: understanding Plane object – part 4

Understanding planes has never been so much fun, so here we go with the 4th part.

This is full of new features, such as:

* Making interactive objects

* Giving objects a name

* Changing object colors on the fly

This is the same old script as seen in Papervision3D: understanding Plane object – part 3 and previous tutorials, with some modifications. Read more

Understanding AS3 custom events

Every AS3 programmer uses event listeners to allow objects to become active and listen for specific instructions, such as a mouse click or the beginning of a new frame.

Now it’s time to see how can you create new events, but before entering into this script, let me say it’s not a “do it or die” feature.

You can always perform some if... then... else and achieve the same result, but from a PROgrammer point of view, a code with listeners is more readable than a complex list of conditions to check for events.

In this script, we are counting the time passed like in Understanding AS3 Timer Class, but we want to create a custom event to be triggered every 5 seconds.

Obviously in this case it’s quite pointless to create a custom event, but I am showing you the way you can do it.

This is the script: Read more

Papervision3D: understanding Plane object – part 3

In this 3rd part we’ll discover two interesting features:

1) How to add a bitmap texture to a plane

2) How to set the camera to make Papervision3D units match pixels

Let’s start… the “units Vs pixels” issue can be a problem when we want a plane (or whatever) to have a precise size in pixels.

Settings the camera properly can solve the problem… this is the same script used in Papervision3D: understanding Plane object – part 2 with a couple of modifications: Read more

Papervision3D: understanding Plane object – part 2

Here I am to continue the tutorial about Papervision3D and planes. I suggest to take a look at the first part if you are a new reader.

This time I am going to explain the basic color material and a trick to make a plane have two materials, one per side.

Before you continue reading, let me say you can’t have a plane with two materials, one per side. So if you are planning to have a double sided plane, such as a gambling card, you’ll have to make a trick…

let me show you this code: Read more

Next Page →

Posts