API Docs for: 0.1.1
Show:

flatworld.objects.ObjectSprite Class

Extends PIXI.Sprite

The base class of all sprite objects

Constructor

flatworld.objects.ObjectSprite

(
  • coords
  • {}
)

Parameters:

  • coords PIXI.Point

    the coordinate where the object is located at, relative to it's parent

  • {} Object
    • data Object

      objects data, that will be used in the game. It will not actually be mainly used in graphical but rather things like unit-data and city-data presentations etc.

Methods

clone

(
  • renderer
  • options
)
Object

Clone object

Parameters:

  • renderer Object

    PIXI renderer

  • options Object

    position: Boolean, anchor: Boolean

Returns:

Object:

cloned object

drawNewFrame

(
  • x
  • y
  • newFrame
)

Draws new frame to animate or such

Parameters:

  • x Number

    coordinate x

  • y Number

    coordinate y

  • newFrame Number

    New frame number to animate to

Returns:

this object instance

getGraphicalArea

(
  • options
)
AreaSize

Get the area that is reserved for the graphical presenation of this object as a rectangle.

Parameters:

  • options Object

    toGlobal: Boolean. Should the method return global coordinates or local (movableLayer)

Returns:

AreaSize:

{ x: Number, y: Number, width: Number, height: Number}

innerDraw

(
  • x
  • y
)

Drawing the object

Parameters:

Returns:

this object instance

Attributes

areaHeight

Number

Object area height in pixels.

Fires event areaHeightChange

Fires when the value for the configuration attribute areaHeight is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

areaWidth

Number

Object area width in pixels.

Fires event areaWidthChange

Fires when the value for the configuration attribute areaWidth is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

data

Object

Objects custom data. Holds unit statistics and most data. Like unit movement speed etc.

Fires event dataChange

Fires when the value for the configuration attribute data is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

highlightable

Boolean

Is the object highligtable.

Fires event highlightableChange

Fires when the value for the configuration attribute highlightable is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

name

String

Name of the object. Used mostly for debugging

Fires event nameChange

Fires when the value for the configuration attribute name is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

static

Boolean

If this object is static. Meaning it's position won't be changed etc. This can be used e.g. in rendering the minimap. The static objects and then the dynamic separately.

Fires event staticChange

Fires when the value for the configuration attribute static is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

type

String

Type of the object. Can be used for filtering, ordering or finding correct objects.

Fires event typeChange

Fires when the value for the configuration attribute type is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:

  • e EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.