Class cocos.tiles.HexMapLayer

   layer.Layer --+            
                 |            
   ScrollableLayer --+        
                     |        
              MapLayer --+    
                         |    
RegularTesselationMapLayer --+
                             |
                            HexMapLayer
MapLayer with flat-top, regular hexagonal cells.

Additional attributes extending MapBase:

    edge_length -- length of an edge in pixels

Hexmaps store their cells in an offset array, column-major with y
increasing up, such that a map:
      /d\ /h        /b\_/f\_/
    \_/c\_/g        /a\_/e\_/
    \_/ \_/
has cells = [['a', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h']]

Methods

  __init__(self, id, th, cells, origin=None)
  get_in_region(self, x1, y1, x2, y2)
Return cells (in [column][row]) that are within the pixel bounds specified by the bottom-left (x1, y1) and top-right (x2, y2) corners.
  get_at_pixel(self, x, y)
Get the Cell at pixel px=(x,y).
  get_neighbor(self, cell, direction)
Get the neighbor HexCell in the given direction which is one of self.UP, self.DOWN, self.UP_LEFT, self.UP_RIGHT, self.DOWN_LEFT or self.DOWN_RIGHT.
  draw(self) (Inherited from cocos.tiles.ScrollableLayer)
  get_cell(self, i, j)
Return Cell at cell pos=(i, j).
(Inherited from cocos.tiles.RegularTesselationMapLayer)
  get_visible_cells(self)
Given the current view in map-space pixels, transform it based on the current screen-space transform and figure the region of map-space pixels currently visible.
(Inherited from cocos.tiles.MapLayer)
  set_debug(self, debug) (Inherited from cocos.tiles.MapLayer)
  set_dirty(self) (Inherited from cocos.tiles.MapLayer)
  set_view(self, x, y, w, h) (Inherited from cocos.tiles.MapLayer)

Class Variables

  debug = False (Inherited from cocos.tiles.MapLayer)
  origin_x = 0 (Inherited from cocos.tiles.ScrollableLayer)
  origin_y = 0 (Inherited from cocos.tiles.ScrollableLayer)
  origin_z = 0 (Inherited from cocos.tiles.ScrollableLayer)

Constants

  UP = 'up'
  DOWN = 'down'
  UP_LEFT = 'up left'
  UP_RIGHT = 'up right'
  DOWN_LEFT = 'down left'
  DOWN_RIGHT = 'down right'

Method Details

__init__

(Constructor) __init__(self, id, th, cells, origin=None)
Overrides:
MapLayer.__init__

get_at_pixel

get_at_pixel(self, x, y)
Get the Cell at pixel px=(x,y). Return None if out of bounds.

get_neighbor

get_neighbor(self, cell, direction)

Get the neighbor HexCell in the given direction which is one of self.UP, self.DOWN, self.UP_LEFT, self.UP_RIGHT, self.DOWN_LEFT or self.DOWN_RIGHT.

Return None if out of bounds.