Class cocos.tiles.ScrollingManager

layer.Layer --+
              |
             ScrollingManager

Manages scrolling of Layers in a Cocos Scene.

Each layer that is added to this manager (via standard list methods) may have pixel dimensions .px_width and .px_height. MapLayers have these attribtues. The manager will limit scrolling to stay within the pixel boundary of the most limiting layer.

If a layer has no dimensions it will scroll freely and without bound.

The manager is initialised with the viewport (usually a Window) which has the pixel dimensions .width and .height which are used during focusing.

A ScrollingManager knows how to convert pixel coordinates from its own pixel space to the screen space.

Methods

  __init__(self, viewport=None)
  set_scale(self, scale)
  add(self, child, z=0, name=None)
Add the child and then update the manager's focus / viewport.
  pixel_from_screen(self, x, y)
Look up the Layer-space pixel matching the screen-space pixel.
  pixel_to_screen(self, x, y)
Look up the screen-space pixel matching the Layer-space pixel.
  set_focus(self, fx, fy)
Determine the viewport based on a desired focus pixel in the Layer space (fx, fy) and honoring any bounding restrictions of child layers.
  force_focus(self, fx, fy)
Force the manager to focus on a point, regardless of any managed layer visible boundaries.

Class Variables

  scale = property(lambda s: s._scale, set_scale)

Method Details

pixel_from_screen

pixel_from_screen(self, x, y)

Look up the Layer-space pixel matching the screen-space pixel.

Account for viewport, layer and screen transformations.

pixel_to_screen

pixel_to_screen(self, x, y)

Look up the screen-space pixel matching the Layer-space pixel.

Account for viewport, layer and screen transformations.

set_focus

set_focus(self, fx, fy)

Determine the viewport based on a desired focus pixel in the Layer space (fx, fy) and honoring any bounding restrictions of child layers.

The focus will always be shifted to ensure no child layers display out-of-bounds data, as defined by their dimensions px_width and px_height.