CanvasActor API Reference


A CanvasActor is a special kind of Actor that can scroll its content around as well as dock its content to its edges, CanvasActor’s are designed for creating user interfaces. CanvasActor is derived from Actor thus inherits all of its properties, methods and so on. Not that any actors that are docked and are added to a CanvasActor will be docked against the edges of the CanvasActor instead of the Scene.

Public properties

  • scroll_pos_x – Canvas scroll X position
  • scroll_pos_y – Canvas scroll Y position
  • scroll_vx – Canvas scroll X velocity
  • scroll_vy – Canvas scroll Y velocity
  • scroll_range – Scrollable range of canvas (left, top, width, height)

Internal properties

  • prev_scroll_pos_x – Previous canvas scroll X position
  • prev_scroll_pos_y – Previous canvas scroll Y position


CanvasActor() – Creates an instance of a CanvasActor

onTouchMoveBase(touch_pos) – Base touch movement handler (called by the system) which provides content scrolling functionality

  • The touched position

update(dt) – Updates the actor, this method can be overriden by derived actors. This is a customised update handler which provides content scrolling functionality

  • dt – The amount of time that has passed since this actor was last updated

scrollRangeCheck() – A utility method that is used to keep the content from scrolling out of range

updateLayout() – Called to update the layout of the content, should be called if any of the actors that make up the content are changed (for example if any of the content actors are undocked)


Example showing how to create a canvas actor that can scroll its content


331 total views, 1 views today