Home | About | Forum | Manual | Download | Screenshots

Layer

Layers are manager objects to which sprites or other layers can be attached as children nodes. Each layer has its own center position, scale and rotation. All children nodes of a layer have positions relative to the origin or center of the parent layer. Therefore, changing the position of a layer implicitly moves all of its descendents. The center of every layer is the origin point (0, 0) where the positive x-axis points right and the positive y-axis points up.

Adding a child node to a layer increases the child's reference count by one. The child's reference count will be decremented only when the parent layer is destroyed or when explicitly removed via the "remove_child" method. Child nodes can only have a single parent, so the same sprite cannot be parented by two different layers. Each time you call "add_child", the supplied child node is automatically removed from its previous parent layer.

    Properties

  • number alpha
    Alpha modifier value
  • Color color
    Color tint modifier
  • number rotation
    Rotation of the layer in degrees
  • number scalex
    Horizontal scale of the layer
  • number scaley
    Vertical scale of the layer
  • number x
    X-location of the layer in parent coordinates
  • number y
    Y-location of the layer in parent coordinates

    Constructors

  • Layer ( )
  • Layer ( Point pt )
    Layer ( number x, number y )
    Creates a new layer object at a specified position in world coordinates

    Constant Methods

    Non-Constant Methods

  • add_child ( Sprite child )
    add_child ( Layer child )
    Adds a child node to the layer
  • change_position ( Point pt )
    change_position ( number x, number y )
    Translates the layer by a given amount
  • change_rotation ( number degres )
    Rotates the layer around its origin by a given amount in degrees
  • change_rotation_r ( number radians )
    Rotates the layer around its origin by a given amount in radians
  • change_scale ( number x, number y )
    Scales the layer by a given amount
  • change_scalex ( number x )
    Scales the layer horizontally by a given amount
  • change_scaley ( number y )
    Scales the layer vertically by a given amount
  • remove_child ( Sprite child )
    remove_child ( Layer child )
    Removes an existing child node from the layer
  • set_position ( Point pt )
    set_position ( number x, number y )
    Translates the layer to an explicit location
  • set_scale ( number x, number y )
    Scales the layer to explicit proportions