Container

Pixel~ Container

Container class.

Constructor

new Container(ctx)

Source:
Creates a container element.
Parameters:
Name Type Description
ctx CanvasRenderingContext2D The screen every object is rendered to.

Namespaces

keyboard

Members

container :boolean

Source:
I forgot what this is for but am to worried to get rid of it.
Type:
  • boolean

ctx :CanvasRenderingContext2D

Source:
Stores the canvas 2d context.
Type:
  • CanvasRenderingContext2D

regions :object

Source:
Stores all clickable regions on the screen.
Type:
  • object

stage :Array.<Pixel.Sprite>

Source:
Contains all sprites.
Type:

Methods

add(sprite)

Source:
Auto renders sprite.
Parameters:
Name Type Description
sprite Pixel.Sprite | Pixel.SpriteSheet | Pixel.AnimatedSprite | Pixel.Map | Pixel.Rectangle | Pixel.Circle | Pixel.Text Sprite to be rendered.

addChild(sprite)

Source:
Adds child to container.
Parameters:
Name Type Description
sprite Pixel.Sprite Sprite to add.

addHitRegion(opts, call)

Source:
Adds clickable region to the stage.
Parameters:
Name Type Description
opts object Options for hit region.
Properties
Name Type Description
name string Name of hit region.
start Pixel.Point Start point of hit region.
end Pixel.Point End point of hit region.
call function Function called when region clicked.

background(color)

Source:
Changes the background color.
Parameters:
Name Type Description
color string The color, in hexidecimal or rgb.

cloneChildren(base)

Source:
Moves all children into a Pixel.Stage element.
Parameters:
Name Type Description
base Pixel.Stage Stage contents are moved to.

on(name, func)

Source:
Defines a new event that can be called.
Parameters:
Name Type Description
name string
func function

on(name, call)

Source:
Event handler.
Parameters:
Name Type Description
name string Name of event.
call function Function called whenever event occurs.

removeChild(id)

Source:
Locates and deletes a sprite saved in the container.
Parameters:
Name Type Description
id number The ID of the sprite to be deleted.

render()

Source:
Renders all elements in container.