LeichtgewichtLeichtgewicht

2009/03/25 – 14:21

Libspark: CharacterWalker

During the last weeks I studied the Spark project a lot. It fascinates me as a project. Of course there are drawbacks, but in general, all-in-all the sub-projects are charming me with a lot of creativity, well crafted code or just by being fresh.

I want to support the open-source community around flash, especially Libspark, and because of that I’ve decided to give it a try:  this is the first article in a new series “I am proud to introduce to you”:

Libspark: CharacterWalker

The CharacterWalker is one of the poor documented parts of Libspark. In fact its even kind of hidden, but I saw it and it immediately triggered my old love for rpg’s. I was eager to finally see myself in 32px wandering around the screen.

The few 5 classes available don’t do a lot, in essence they take a BitmapData instance in 3 common formats and create a figure with it that animates. The available formats are:

To try it out I chose to use the VX format. I could have used a predefined character of the program but I really wanted to see my work on the screen.

As in most RPG’s the character has to be shown from front, back, left and right side. To animate the character its necessary to have at least 3 frames that show the movement.

The painting was quite some work for me, who never did serious pixelart. Luckily the next part was a lot easier: just import the CharacterWalkerVX and pass-in the PNG as BitmapData and you get a walking me:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)


Okay: a complete iso-engine was be a bit oversized but I could do at least a small example. For that I’ve created a wrapper class called CharacterMover, it allows to just pass-in your CharacterWalker and you’ll get the handy method walkSteps( leftSteps: int = 0, topSteps: int = 0 ). With this the character started to move on the screen.

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)


That wasn’t enough! I just had to make it controllable by keyboard. So I went on to create a KeyboardCharacterMover which wraps the CharacterMover and listens to the stage’s key press. Because stage was still default gray, I’ve decided to add a little color background and some small features as well as another character. Here is the full example:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Download Sources

I know its a very playful first entry. I hope you enjoyed this first trip to japanese open-source anyway. If you have got special interests about other parts of libspark or other open-source libraries, let me know and I will if I can write about it in my next entry.

Thanks Tarotaro! Thanks Spark team!

Factsheet

author: tarotaro
category: game
used revision: trunk [r2369]
documentation: japanese (currently with dead links)

Tags: , , ,

Comments

  1. Davy

    This is a very nice example!
    I also like some other articles on your blog.

    I want to play with the Spark Project CharacterWalker myself, and indeed there is very little information available.

    So I might be better of asking my question to you: Is there collision detection, for object or tiles for example, already inside the class? (The Japanese comments are quite hard to read!)

  2. Martin Heidegger

    As far as I read: no. The important work that it does is to abstract the format and kind of “standardize” it. The object you retrieve is a normal sprite, which can be used further. In my sources you will find a “LoveInfo” class which does a primitive kind of distance checking. But maybe you’d better write one yourself.

  3. Davy

    Thanks for the reply, now I can get to work!

  4. Andelia

    Hi.I like reading your post , keep doing it.

Leave a Reply

Twitter Users!
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.

Site informations

Martin Heidegger – Web Developerskype:mastakanedaxing:martin.heideggertwitter:leichtgewicht