- List of Events
- Core
- Internal
- Events
- 2D
- Graphics
- Utilities
- Misc
- Stage
- Input
- Animation
- Scenes
- Audio
- Assets
Crafty Core
- NewEntityName [entity name: String]
- After setting new name for entity
- NewComponent [Component: String]
- when a new component is added to the entity
- RemoveComponent [Component: String]
- when a component is removed from the entity
- Remove
- when the entity is removed by calling .destroy()
.attr
- Change [Data: {key: value}]
- when properties change
Crafty.init
- EnterFrame [Data: { frame: Number }]
- on each frame
- Load
- Just after the viewport is initialised. Before the EnterFrame loops is started
Crafty.stop
- CraftyStop
- when the game is stopped
Crafty.pause
- Pause
- when the game is paused
- Unpause
- when the game is unpaused
Crafty.e
- NewEntity [Data: { id:Number }]
- When the entity is created and all components are added
2D
- Move [Old position: { _x:Number, _y:Number, _w:Number, _h:Number }]
- when the entity has moved
- Change [Old position: { _x:Number, _y:Number, _w:Number, _h:Number }]
- when the entity has moved
- Rotate [Data: { cos:Number, sin:Number, deg:Number, rad:Number, o: {x:Number, y:Number}, matrix: {M11, M12, M21, M22} }]
- when the entity is rotated
.flip
- Change
- when the entity has flipped
.unflip
- Change
- when the entity has unflipped
DOM
.DOM
- Draw [Data: { style:String, type:"DOM", co}]
- when the entity is ready to be drawn to the stage
FPS
- MessureFPS
- each second
Sprite
- Change
- when the sprites change
Canvas
- 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
Crafty.canvas
Crafty.canvas.init
- NoCanvas
- triggered if
Crafty.support.canvas
is false
KeyboardEvent
- KeyDown
- is triggered for each entity when the DOM 'keydown' event is triggered.
- KeyUp
- is triggered for each entity when the DOM 'keyup' event is triggered.
Mouse
- MouseOver [Data: MouseEvent]
- when the mouse enters the entity
- MouseOut [Data: MouseEvent]
- when the mouse leaves the entity
- MouseDown [Data: MouseEvent]
- when the mouse button is pressed on the entity
- MouseUp [Data: MouseEvent]
- when the mouse button is released on the entity
- Click [Data: MouseEvent]
- when the user clicks the entity. See documentation
- DoubleClick [Data: MouseEvent]
- when the user double clicks the entity
- MouseMove [Data: MouseEvent]
- when the mouse is over the entity and moves
Draggable
- 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
.stopDrag
- StopDrag
- Called right after the mouse listeners are removed
Multiway
- NewDirection [New direction: { x:Number, y:Number }]
- triggered when direction changes
- Moved [Old position: { x:Number, y:Number }]
- triggered on movement on either x or y axis. If the entity has moved on both axes for diagonal movement the event is triggered twice
SpriteAnimation
- AnimationEnd [Data: { reel }]
- When the animation finishes
- Change
- On each frame
Tween
- TweenEnd [property: String]
- when a tween finishes
Color
.color
- Change
- when the color changes
Tint
.tint
- Change
- when the tint is applied
Image
.image
- Change
- when the image is loaded
Crafty.scene
- SceneChange [Data: { oldScene:String, newScene:String }]
- when a scene is played
Text
- Change
- when the text is changed
Crafty.asset
- NewAsset [key and value of new added asset.: Object]
- After setting new asset