com.theoworlds.builder.MapObject |
base class for all map objects classes on the map : Tile, Furniture, Character
| com. | base class for all map objects classes on the map : Tile, Furniture, Character |
| Variables | |
| _ID | MapObject id:Number |
| __world | reference to a the World object |
| tileX | position on the map (column:Number) |
| tileY | position on the map (row:{Number}) |
| libID | id:Number of a Library for a map |
| libItemID | id:Number for an object from this library |
| libFrame | frame/phase:Number (if there are multiple possible directions), by default == 1 |
| _actions | name{name:String, [attributes:*]} |
| _currentActionName | character animation name:String (curent) |
| _elevation | the height:Number of the object |
| _stackable | stacks on top of other tiles, taking elevation in consideration |
| _walkable | flag(:Boolean) that tells if characters(Character) can walk on top of this object |
| _targetMC | MovieClip that contains the MapObject._spriteMC |
| _spriteMC | MovieClip in which MapObject is located |
| _addedMovieClip | used for loading symbols from Library |
| _spriteMCName | sets the World when activating the movieclip (if it’s present) |
| _spriteMCZOrder | Z--order of the MovieClip, if it’s present |
| MARKER_DEPTH | the depth(:Number) of the debug layer |
| GRID_DEPTH | the depth(:Number) of the grid layer |
| LOADED_DEPTH | the depth(:Number) of the loaded symbol |
| Functions | |
| MapObject | |
| init | if there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted |
| loadMovie | loads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect |
| onLoadInitLibrarySymbol | called by MovieClipLoader.onLoadInit |
| onLoadCompleteLibrarySymbol | called by MovieClipLoader.onLoadComplete to be implemented in the child classes |
| createSpriteMC | creates the base MovieClip into wich a Library symbol is loaded |
| removeSpriteMC | removes the MapObject._spriteMC |
| swapDepths | works like MovieClip.swapDepths |
| clear | cleans the assets |
| getActions | MapObject._actions |
| initActions | initializes the actions of a given object |
| isValidAction | checks if the action is valid |
| getActionName | |
| getAllowedActionDirections | |
| getAction | |
| attachAction | attach action to an object if action with such name exists -- it will be overwritten |
| detachAction | detach an action from an object |
| Properties | |
| currentActionName | sets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method |
| currentActionName | -- the name(:String) of the current action |
| world | used by CharacterLogic |
| ID | object id(:Number) |
| spriteMC | -- “base” MovieClip of MapObject |
| Functions | |
| setWorld | sets the reference to the World. |
private static var __world: World
reference to a the World object
var libID: Number
id:Number of a Library for a map
private var _actions: Object
name{name:String, [attributes:*]}
1 -- this is an object 2 -- the action name is stored and is called like this -- _actions[name] 3 -- parametters are set in this way: _actions[name].parameter1 _actions[name].parameter2 _actions[name].parameter3.... 4 -- one parametter is mandatory: а -- name:String -- _actions[name].name 5 -- the rest are optional: a -- frames -- the number of action animation frames (1 by default) b -- movable -- a flag that tells in this action is movable or now (walking vs dancing on the spot, for example) (0 by default) c -- nonStop -- a flag that shows if the animation is looping (repeating again and again) (0 by default) d -- snapToAction -- works only with movable=1, a flag that tells if the character starts the action right away or finishes his movement first (like sitting on a chair, instead of walking on it first) (0 by default) e -- usesLeftRightSteps -- a flag that tells if the movement action uses left/right step sequences. (1 by default) f -- allowedActionDirs -- the directions in which the action is available (“1,2,3,4,5,6,7,8” by default -- all the directions)
the parametters are stored as Strings. Later, the values are brought to the right type (ex: frames --> Number) New custom functions can be added, to make the access to the parametters easy example -- Character.getActionFrameNumber(action:String):Number { return Number( _actions[action].frames ); }
actionName+”_”+direction check the documentation for more details
private var _walkable: Boolean
flag(:Boolean) that tells if characters(Character) can walk on top of this object
private var _targetMC: MovieClip
MovieClip that contains the MapObject._spriteMC
private var _addedMovieClip: MovieClip
used for loading symbols from Library
private var _spriteMCName: String
sets the World when activating the movieclip (if it’s present)
public function MapObject( target: MovieClip, spriteMCName: String, spriteMCZOrder: Number, tileX: Number, tileY: Number, mos: MapObjectSettings, skipValidation: Boolean )
| target | MovieClip to wich MapObject is attached |
| spriteMCName | name(:String) of MovieClip if it’s created |
| spriteMCZOrder | z--order(:Number) of MovieClip, if it’s created |
| tileX | tile row(:Number) (to be removed since it’s in MapObjectSettings?) |
| tileY | tile column(:Number) |
| mos | (MapObjectSettings) |
private function init( mos: MapObjectSettings ):Void
if there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted
| mos | (MapObjectSettings) |
private function loadMovie( mos: MapObjectSettings ):Void
loads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect
| mos | (MapObjectSettings) -- it’s passed since more initiation actions may be needed after the loading MapObjectSettings is not saved in the class to save memory -- it can get heavy otherwise |
private function onLoadCompleteLibrarySymbol( mos: MapObjectSettings ) : Void
called by MovieClipLoader.onLoadComplete to be implemented in the child classes
| mos | (MapObjectSettings) |
private function createSpriteMC( x: Number, y: Number ):Void
creates the base MovieClip into wich a Library symbol is loaded
| x | -- integer that sets the x coordinate of a movie clip |
| y | -- integer that sets the y coordinate of a movie clip |
private function removeSpriteMC():Void
removes the MapObject._spriteMC
private function initActions( mos: MapObjectSettings ):Void
initializes the actions of a given object
| mos | (:MapObjectSettings) |
public function getAction( action: String ):Object
| action | (:String) -- action name |
the action (MapObject._actions) by name. Each action name has to be unique! a very heavy function since it makes the copy of the object it is recommended to write separate custom functions for accessing the parametters directly. Example: Character.getActionFrameNumber(action:String):Number { return Number( _actions[action].frames ); }
public function set currentActionName( action: String ):Void
sets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method
| action | (:String) -- action name |
public static function setWorld( w: World ):Void
sets the reference to the World. Called once on initialization
MapObject id:Number
private var _ID: Number
reference to a the World object
private static var __world: World
position on the map (column:Number)
public var tileX: Number
position on the map (row:{Number})
public var tileY: Number
id:Number of a Library for a map
var libID: Number
id:Number for an object from this library
var libItemID: Number
frame/phase:Number (if there are multiple possible directions), by default == 1
var libFrame: Number
name{name:String, [attributes:*]}
private var _actions: Object
character animation name:String (curent)
private var _currentActionName: String
the height:Number of the object
private var _elevation: Number
stacks on top of other tiles, taking elevation in consideration
private var _stackable: Boolean
flag(:Boolean) that tells if characters(Character) can walk on top of this object
private var _walkable: Boolean
MovieClip that contains the MapObject._spriteMC
private var _targetMC: MovieClip
MovieClip in which MapObject is located
private var _spriteMC: MovieClip
used for loading symbols from Library
private var _addedMovieClip: MovieClip
sets the World when activating the movieclip (if it’s present)
private var _spriteMCName: String
Z--order of the MovieClip, if it’s present
private var _spriteMCZOrder: Number
the depth(:Number) of the debug layer
private static var MARKER_DEPTH: Number
the depth(:Number) of the grid layer
private static var GRID_DEPTH: Number
the depth(:Number) of the loaded symbol
private static var LOADED_DEPTH: Number
public function MapObject( target: MovieClip, spriteMCName: String, spriteMCZOrder: Number, tileX: Number, tileY: Number, mos: MapObjectSettings, skipValidation: Boolean )
if there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted
private function init( mos: MapObjectSettings ):Void
loads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect
private function loadMovie( mos: MapObjectSettings ):Void
called by MovieClipLoader.onLoadInit
private function onLoadInitLibrarySymbol( mos: MapObjectSettings ):Void
called by MovieClipLoader.onLoadComplete to be implemented in the child classes
private function onLoadCompleteLibrarySymbol( mos: MapObjectSettings ) : Void
creates the base MovieClip into wich a Library symbol is loaded
private function createSpriteMC( x: Number, y: Number ):Void
removes the MapObject._spriteMC
private function removeSpriteMC():Void
works like MovieClip.swapDepths
public function swapDepths( depth: Number ):Void
cleans the assets
public function clear():Void
MapObject._actions
public function getActions():Object
initializes the actions of a given object
private function initActions( mos: MapObjectSettings ):Void
checks if the action is valid
private function isValidAction( action: String ):Boolean
private function getActionName( action: Object ):String
public function getAllowedActionDirections( action ):Array
public function getAction( action: String ):Object
attach action to an object if action with such name exists -- it will be overwritten
public function attachAction( action: Object ):Void
detach an action from an object
public function detachAction( action: String ):Void
sets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method
public function set currentActionName( action: String ):Void
used by CharacterLogic
public function get world (): World
object id(:Number)
public function get ID (): Number
-- “base” MovieClip of MapObject
public function get spriteMC():MovieClip
sets the reference to the World.
public static function setWorld( w: World ):Void