divillysausages.com

AS3 Game Object Editor

Current version: 1.3.1

A few days Photo Storm posted a game dev tip on his site: Configure your games in real time. It seemed like a pretty good tip, especially if you're making a physics enabled game and you spend your time tweaking weight, restitution, and bouncability and the like. The images over on his site give a good idea on what you can do with an in-game editor. The only problem I have with this is that each panel seems to be custom-built for each level/game. As Terry Pratchett would say: blow that for a game of soldiers.

So, with the anticipation no doubt keeping you on the edge of your seat, I present the AS3 Game Object Editor:

The AS3 Game Object Editor

Using the power of reflection and the ability to ignore my girlfriend for the weekend, the editor can make any class editable by adding a few lines of metadata. Once that's done and your class is registered, anytime an Object of that type is created and added to the Stage (non-DisplayObject objects, or blitted objects - if you're using something like Flixel - can be explicitly added by calling registerObject()), it's added into the list of Objects that we can edit. Make your adjustments, and when you're finished, save out an XML file containing all your changes.

I've created a project for it on Bitbucket (it's released under the MIT license), you can read more about it from the links on the left, check out the documentation, or play with the prototype just below.

Thanks go out to Photon Storm for the intial idea and to Keith Peters at Bit-101 for the excellent Minimal Comps lib that the game editor uses to create the UI.

Updates

v1.1 (03/04/11):
With the update comes some bug fixes, the ability to retrieve the current object that you're editing, and the ability to work with non-DisplayObject objects.

v1.2 (07/04/11):
With the update comes the ability to highlight and track the current object (to make it easier to see which object you're editing if there's a lot of them), and the ability to click to select as the current object (DisplayObjects only)

v1.3 (17/04/11):
With the update comes some bug fixes, some refactoring, and the ability for objects to be removed from the Editor when they're removed from the Stage, or to explicitly remove them. ComboBox static const edits are now sorted for convenience as well.

v1.3.1 (21/04/11):
Fixed bug where the available component array was getting repeatedly set which would throw the player into an infinite loop if using minimalcomps v0.9.10. There's still a bug in that lib that prevents me from using it though.

Comments

Richard Davey

Nice work! Great to see my article evolve into this :)

Anonymous

hmmmm where do i add the
-keep-as3-metadata+=Editable
in flashdevelop?

am feeling like an idiot now... :(
tried compiler option but does not seem
to work. log is working fine. but no class or objects.

Damian Connolly

See the answer to this comment. If you're still having trouble, you can download the source files at https://bitbucket.org/divillysausages/as3-game-object-editor/downloads, which contains a FlashDevelop project file with this working.

Anonymous

where should i add "-keep-as3-metadata+=Editable"
i flashdeveop? :D

Damian Connolly

You can find it in Project > Properties > Compiler Options > Additional Compiler Options. I've updated the How To section to mention this, with an image

Anonymous

Hi,

Maybe it is better to mention the editor started as visible = false?

btw is the function call a planned feature? Now we only have access to variables and properties. If we have function calls it would be perfect. :D

Anyway, thanx for the nice editor! :D

Damian Connolly

Showing and hiding the editor is mentioned in the How To, but I'll update it to make it clear that it's not visible by default.

I could add basic function calling in a future update, though it might have to exclude functions that pass non-primitive Objects (perhaps I could get around it with some metadata magic, but I'm not sure). I'll take a look.

Anonymous

yeah even with native data types, it will help a lot. :D

Anonymous

yeah because the visible = true is not in the code snippet. I just copied the code and nothing shows. Nothing too important just want to mention it as feedback.

Personally, I think has the editor ingame is way better than an external editor, coughhh De coughhhh Monster. :D

At least for the more frequently used features.

Anonymous

And ohhh, had problem registering a non DisplayObject object.

It turned out to be I need to call registerClass first AND THEN registerObject. :D

Damian Connolly

Yeah, I was considering making the call to registerClass() automatic if you call registerObject() and the class isn't registered, as it's easier for the end user. I guess I wanted to keep the workflow the same for DisplayObjects and non-DisplayObjects, but now it doesn't make as much sense to me :D

I'll stick it in the next update.

Anonymous

some more feedback, i am fine with how it is now, just in case u are interested.

int setter: when i set the int manually, and then clicked the plus button, the value before the manual change will be used.

string input setter: each time i write a character, the setter got called instead i input the whole word and press enter.

Damian Connolly
"when i set the int manually, and then clicked the plus button, the value before the manual change will be used"

Do you mean you load up the object, change the value through code, but it's not reflected in the edit component? By default, the only component the constantly updates it's value based on the current object is the watch component. If you want to update all components, set the updateOnlyWatchVars property on the Editor to false.

For the String input setter, I can work up something in the next update so that it only sets the property when the user hits Enter, though it'll probably have to be off by default to avoid breaking existing usage (or maybe it's better to break it if it's easier to use it this way...).

Thanks for the feedback!

Anonymous

why not just hide the registerClass method? And do a check in registerObj method. if its class is not registered, do it automatically.

Damian Connolly

Because the normal way to add objects for editing (DisplayObjects) is to register the class, and the objects get added automatically when an object of that type is added to the stage, then removed when it's removed from the stage. registerObject() is there more for non-DisplayObjects (like level objects or classes that just contain variables to control your game/program).

In the latest update (available if you check out the source code - I've not announced it yet), if you call registerObject(), it'll register the class if it's not already there.

johnny

your DA best because you can make deferent

Submit a comment

* indicates required