Class cocos.tiles.MapLayer

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

Base class for Maps.

Maps are comprised of tiles and can figure out which tiles are required to be rendered on screen.

Both rect and hex maps have the following attributes:

id -- identifies the map in XML and Resources (width, height) -- size of map in cells (px_width, px_height) -- size of map in pixels (tw, th) -- size of each cell in pixels (origin_x, origin_y, origin_z) -- offset of map top left from origin in pixels cells -- array [i][j] of Cell instances debug -- display debugging information on cells

The debug flag turns on textual display of data about each visible cell including its cell index, origin pixel and any properties set on the cell.

Methods

  __init__(self)
  set_dirty(self)
  set_view(self, x, y, w, h)
  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.
  set_debug(self, debug)
  draw(self) (Inherited from cocos.tiles.ScrollableLayer)

Class Variables

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

Method Details

__init__

(Constructor) __init__(self)
Overrides:
ScrollableLayer.__init__

set_view

set_view(self, x, y, w, h)
Overrides:
ScrollableLayer.set_view

get_visible_cells

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.

Pass to get_in_region to return a list of Cell instances.