| Game Editor: Making Sprite Editors |
| Before the level editor can place a sprite, you need to give it a little information about the sprite.
Place a folder in the editor's "sprites" folder. Use DefaultSprite.exe to tell the editor what the sprite looks like. Create editor.swf, which the editor will use to edit the sprite's settings.
Sprite folder
| In the editor's "sprites" folder, create another folder and name it after the sprite's linkage name. This will allow the editor to place the sprite.
editor.swf
| The level editor will send a bunch of information to this editor, which will all be available when you get to frame 2. You'll mostly be interested in this object: editor.sprite.data This object stores all the settings for this sprite. They can be whatever you want. At first, it'll be empty. So you'll want to define your settings when this sprite is first created and this editor is loaded.
CODE data = editor.sprite.data; // reference to settings object if(data.myVar == undefined){ data.myVar = "default value"; }// if: myVar doesn't exist yet
| By defining the settings in this way, they'll be created when the editor is opened for the first time. But they won't get overwritten with default values afterwords. Now all you have to do is use some flash components to allow the user to change these variables, and your editor will be complete.
Available data
| The level editor makes lots of information available to sprite editors.
PASSED DATA: __ (editor) ____ (cursor) Cursor component ____ (menuBar_mc) MenuBar component ____ (status) Help text object ____ (clipboard) Clipboard object ____ (levelChanged) Tracks level changes ____ (data) current level's data ____ (sprite) selected sprite's data ______ (editSprite) sprite image settings ______ (position) location on the map ________ x Horizontal pixel location ________ y Vertical pixel location ______ [flags] array of flag strings ______ (data) this sprite's settings ______ type sprite's linkage name ______ name sprite's instance name ____ snapping Map snapping: true/false ____ (map_mc) Map component ____ (sprites_mc) Sprites component ____ (overlay_mc) empty movieClip ____ (fileBrowser_mc) file browser I won't go over all these right now since it would take a very long time to explain them all.
Video Tutorial
| Still confused? Click the link below to see a video demonstrating how it's all done! Video tutorial
| Last updated: April 27, 2010 |