Sprite:setLayoutConstraints

From GiderosMobile
Revision as of 09:57, 3 September 2018 by Hgy29 (talk | contribs)


Available since: Gideros 2018.9
Class: Sprite

Description



This function specify the child placement rules within the grid defined on its parent by Sprite:setLayoutParameters.
Gideros layout system is heavily based on Java GridBagLayout principle. See here for more explanation: https://www.math.uni-hamburg.de/doc/java/tutorial/uiswing/layout/gridbag.html

The constraint table can contain the following fields:

  • gridx: The 0-based index of the column the child must be placed into
  • gridy: The 0-based index of the row the child must be placed into
  • gridwidth: The number of column this child will take
  • gridheight: The number of row this child will take
  • weightx: The horizontal weight of the child. Used to distribute extra space among children
  • weighty: The vertical weight of the child. Used to distribute extra space among children
  • anchor: Defines where the child should be placed inside its grid space.

Can be Sprite.LAYOUT_ANCHOR_NORTHWEST, Sprite.LAYOUT_ANCHOR_NORTH, Sprite.LAYOUT_ANCHOR_NORTHEAST, Sprite.LAYOUT_ANCHOR_WEST, Sprite.LAYOUT_ANCHOR_CENTER, Sprite.LAYOUT_ANCHOR_EAST, Sprite.LAYOUT_ANCHOR_SOUTHWEST, Sprite.LAYOUT_ANCHOR_SOUTH or Sprite.LAYOUT_ANCHOR_SOUTHEAST

Specifying a nil table will clear layout constraints. When a Sprite is resized by the layout system, a Event.LAYOUT_RESIZDE is triggered.

 Sprite:setLayoutConstraints(constraints)

Parameters

constraints: (table) Table of layout constraints.