Class cocos.tiles.RectMapLayer

   layer.Layer --+            
                 |            
   ScrollableLayer --+        
                     |        
              MapLayer --+    
                         |    
RegularTesselationMapLayer --+
                             |
                            RectMapLayer

Rectangular map.

Cells are stored in column-major order with y increasing up, allowing [i][j] addressing: +---+---+---+ | d | e | f | +---+---+---+ | a | b | c | +---+---+---+ Thus cells = [['a', 'd'], ['b', 'e'], ['c', 'f']] and cells[0][1] = 'd'

Methods

  __init__(self, id, tw, th, cells, origin=None)
  get_in_region(self, x1, y1, x2, y2)
Return cells (in [column][row]) that are within the map-space pixel bounds specified by the bottom-left (x1, y1) and top-right (x2, y2) corners.
  get_at_pixel(self, x, y)
Return Cell at pixel px=(x,y) on the map.
  get_neighbor(self, cell, direction)
Get the neighbor Cell in the given direction (dx, dy) which is one of self.UP, self.DOWN, self.LEFT or self.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 = 0, 1
  DOWN = 0,-1
  LEFT = -1, 0
  RIGHT = 1, 0

Method Details

__init__

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

get_in_region

get_in_region(self, x1, y1, x2, y2)

Return cells (in [column][row]) that are within the map-space pixel bounds specified by the bottom-left (x1, y1) and top-right (x2, y2) corners.

Return a list of Cell instances.

get_at_pixel

get_at_pixel(self, x, y)

Return Cell at pixel px=(x,y) on the map.

The pixel coordinate passed in is in the map's coordinate space, unmodified by screen, layer or view transformations.

Return None if out of bounds.

get_neighbor

get_neighbor(self, cell, direction)

Get the neighbor Cell in the given direction (dx, dy) which is one of self.UP, self.DOWN, self.LEFT or self.RIGHT.

Returns None if out of bounds.