Core Module Description

See also

Module crafty

Note

Aggregates factory, control and interface units in this single module

Crafty

Set of methods added to every single entity.

See also

Class crafty.core.BCrafty

Note

Main API Unit.

Base Module Description

See also

Module crafty

Note

Aggregates factory, control and interface units in this single module

Base

Set of methods added to Crafty class.

See also

Class crafty.base.Base

Note

Main Base API Unit.

ViewPort

Manages Camera at 2D games.

See also

Class crafty.base.ViewPort

Note

Aggregates viewport facilities to Crafty class.

Entity Module Description

See also

Module crafty.entity

Note

Aggregates entity and component in this single module

Entity

Creates an entity. Any arguments will be applied in the same way .addComponent() is applied as a quick way to add components.

Any component added will augment the functionality of the created entity by assigning the properties and methods from the component to the entity.

Example

myEntity = Crafty().e("2D, DOM, Color");

Events

NewEntity [Data: { id:Number }]
When the entity is created and all components are added

See Also

See also

Class crafty.entity.Entity

Note

Composite Element.

Graphics Module Description

See also

Module crafty.graphics

Note

Aggregates canvas and sprite in this single module

Canvas

When this component is added to an entity it will be drawn to the global canvas element. The canvas element (and hence all Canvas entities) is always rendered below any DOM entities.

Crafty.canvas.init() will be automatically called if it is not called already to initialize the canvas element.

Create a canvas entity like this

myEntity = Crafty().e("2D, Canvas, Color")\
     .color("green")\
     .attr(x= 13, y= 37, w= 42, h= 42);

Events

Draw [Data: {type: “canvas”, pos, co, ctx}]
when the entity is ready to be drawn to the stage
NoCanvas
if the browser does not support canvas

See also

Class crafty.graphics.Canvas

Note

DOm Element Unit.

Sprite

Component for using tiles in a sprite map.

Events

Invalidate
when the sprites change

See also

Class crafty.graphics.Sprite

Note

Composite Unit.

Draggable

Enable drag and drop of the entity.

Events

Dragging [Data: MouseEvent]
is triggered each frame the entity is being dragged
StartDrag [Data: MouseEvent]
is triggered when dragging begins
StopDrag [Data: MouseEvent]
is triggered when dragging ends

See also

Class crafty.graphics.Draggable

Note

Interface Unit.