- List of Events
- Core
- 2D
- Animation
- Assets
- Audio
- Controls
- Debug
- Events
- Game Loop
- Graphics
- Input
- Misc
- Model
- Scenes
- Stage
- Utilities
Controls
- TriggerInputDown [Data = {name}]
- When a trigger group is activated
- TriggerInputUp [Data = {name, downFor}]
- When a trigger group is released
- DirectionalInput [Data = {name, x, y}]
- When a directional input changes
- ControlDefined [Data = {type, name}]
- When a control input is defined
- ControlDestroyed [Data = {type, name}]
- When a control input is destroyed
Jumper
- CheckJumping
- When entity is about to jump. This event is triggered with the object the entity is about to jump from (if it exists). Third parties can respond to this event and enable the entity to jump.
KeyboardState
- KeyDown [Data = {KeyboardEvent}]
- when a key is pressed
- KeyUp [Data = {KeyboardEvent}]
- when a key is released
MouseState
- MouseDown [Data = {MouseEvent}]
- when a mouse button is pressed
- MouseMove [Data = {MouseEvent}]
- when the mouse moves
- MouseUp [Data = {MouseEvent}]
- when a mouse button is released
TouchState
- TouchStart [Data = {TouchPointEvent}]
- when a finger is pressed
- TouchMove [Data = {TouchPointEvent}]
- when a pressed finger is moved
- TouchEnd [Data = {TouchPointEvent}]
- when a finger is raised
- TouchCancel [Data = {TouchPointEvent}]
- when a touch event has been disrupted in some way
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
.freeze
- Freeze
- Directly before the entity is frozen
Crafty.init
- Load
- Just after the viewport is initialised. Before the UpdateFrame loops is started
Crafty.stop
- CraftyStop [Data = {bool clearState}]
- when the game is stopped
Crafty.pause
- Pause
- when the game is paused
- Unpause
- when the game is unpaused
Crafty.timer.steptype
- NewSteptype [New steptype = { mode, maxTimeStep }]
- when the current steptype changes
Crafty.timer.step
- EnterFrame [Data = { frame: Number, dt:Number }]
- Triggered before each frame. Passes the frame number, and the amount of time since the last frame. If the time is greater than maxTimestep, that will be used instead. (The default value of maxTimestep is 50 ms.)
- UpdateFrame [Data = { frame: Number, dt:Number }]
- Triggered on each frame. Passes the frame number, and the amount of time since the last frame. If the time is greater than maxTimestep, that will be used instead. (The default value of maxTimestep is 50 ms.)
- ExitFrame [Data = { frame: Number, dt:Number }]
- Triggered after each frame. Passes the frame number, and the amount of time since the last frame. If the time is greater than maxTimestep, that will be used instead. (The default value of maxTimestep is 50 ms.)
- PreRender
- Triggered every time immediately before a scene should be rendered
- RenderScene
- Triggered every time a scene should be rendered
- PostRender
- Triggered every time immediately after a scene should be rendered
- MeasureWaitTime [Data = {Number}]
- Triggered at the beginning of each step after the first. Passes the time the game loop waited between steps.
- MeasureFrameTime [Data = {Number}]
- Triggered after each frame. Passes the time it took to advance one frame.
- MeasureRenderTime [Data = {Number}]
- Triggered after each render. Passes the time it took to render the scene
Crafty.timer.FPS
- FPSChange [new target FPS = {Number}]
- Triggered when the target FPS is changed by user
Crafty.e
- NewEntity [Data = { id:Number }]
- When the entity is created and all components are added
Crafty.asset
- NewAsset [key and value of new added asset. = {Object}]
- After setting new asset
Model
- Change
- When any data on the model has changed.
- Change[key]
- When the specific key on the model has changed.
- Change[key.key]
- The nested key value has changed.
Crafty.scene
- SceneChange [Data = { oldScene:String, newScene:String }]
- just before a new scene is initialized
- SceneDestroy [Data = { newScene:String }]
- just before the current scene is destroyed
Crafty.s
- SystemLoaded [system object = {obj}]
- When the system has initialized itself
- SystemDestroyed [system object = {obj}]
- Right before the system is destroyed
Tween
- TweenEnd [an object containing the properties that finished tweening = {Object}]
- when a tween finishes
DebugCanvas
- DebugDraw
- when the entity is ready to be drawn to the stage
- NoCanvas
- if the browser does not support canvas
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
.color
- Invalidate
- when the color changes
.DOM
- Draw [Data = { style:String, type:"DOM", co}]
- when the entity is ready to be drawn to the stage
.css
- SetStyle [propertyName = {string}]
- for each style that is set
.image
- Invalidate
- when the image is loaded
Particles
- ParticleStart
- when the particle animation has started
- ParticleEnd
- when the particle animation has finished
Renderable
- Invalidate
- when the entity needs to be redrawn
.flip
- Invalidate
- when the entity has flipped
.unflip
- Invalidate
- when the entity has unflipped
SpriteAnimation
- StartAnimation [Data = {Reel}]
- When an animation starts playing, or is resumed from the paused state
- AnimationEnd [Data = { Reel }]
- When the animation finishes
- FrameChange [Data = { Reel }]
- Each time the frame of the current reel changes
- ReelChange [Data = { Reel }]
- When the reel changes
Sprite
- Invalidate
- when the sprites change
Text
- Invalidate
- when the text is changed
Crafty.viewport
- ViewportScroll
- when the viewport's x or y coordinates change
- ViewportScale
- when the viewport's scale changes
- ViewportResize
- when the viewport's dimension's change
- InvalidateViewport
- when the viewport changes
- StopCamera
- when any camera animations should stop, such as at the start of a new animation.
- CameraAnimationDone
- when a camera animation reaches completion
Crafty.viewport.reset
- StopCamera
- called to cancel camera animations
WebGL
- 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
Keyboard
- KeyDown [Data = {KeyboardEvent}]
- when a key is pressed
- KeyUp [Data = {KeyboardEvent}]
- when a key is released
MouseWheel
- MouseWheelScroll [Data = {MouseWheelEvent}]
- when mouse is scrolled
MouseSystem
- MouseOver [Data = {MouseEvent}]
- when the mouse enters an entity
- MouseOut [Data = {MouseEvent}]
- when the mouse leaves an entity
- Click [Data = {MouseEvent}]
- when the user clicks
- DoubleClick [Data = {MouseEvent}]
- when the user double clicks
Mouse
- MouseOver [Data = {MouseEvent}]
- when the mouse enters the entity
- MouseMove [Data = {MouseEvent}]
- when the mouse is over the entity and moves
- MouseOut [Data = {MouseEvent}]
- when the mouse leaves the entity
- MouseDown [Data = {MouseEvent}]
- when a mouse button is pressed on the entity
- MouseUp [Data = {MouseEvent}]
- when a mouse button is released on the entity
- Click [Data = {MouseEvent}]
- when the user clicks on the entity
- DoubleClick [Data = {MouseEvent}]
- when the user double clicks on the entity
MouseDrag
- 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
.areaMap
- NewAreaMap [Data = {Crafty.polygon}]
- when a new areaMap is assigned
TouchSystem
- TouchOver [Data = {TouchPointEvent}]
- when a finger enters an entity
- TouchOut [Data = {TouchPointEvent}]
- when a finger leaves an entity
Touch
- TouchOver [Data = {TouchPointEvent}]
- when a finger enters the entity
- TouchMove [Data = {TouchPointEvent}]
- when a finger is over the entity and moves
- TouchOut [Data = {TouchPointEvent}]
- when a finger leaves the entity
- TouchStart [Data = {TouchPointEvent}]
- when a finger is pressed on the entity
- TouchEnd [Data = {TouchPointEvent}]
- when a finger is raised over the entity
- TouchCancel [Data = {TouchPointEvent}]
- when a touch event has been disrupted in some way whilst over the entity
Crafty.selected
- CraftyFocus
- is triggered when Crafty's stage gets selected
- CraftyBlur
- is triggered when Crafty's stage is no longer selected
2D
- Move [Old position = { _x:Number, _y:Number, _w:Number, _h:Number }]
- when the entity has moved
- Invalidate
- when the entity needs to be redrawn
- Rotate [Rotation in degrees = { rotation:Number}]
- when the entity is rotated
- Reorder
- when the entity's z index has changed
- Resize [Data = { axis: 'w' | 'h', amount: Number }]
- when the entity's dimensions have changed
.offsetBoundary
- BoundaryOffset
- when the MBR offset changes
.origin
- OriginChanged -- after the new origin is assigned
Collision
- HitOn [Data = { hitData }]
- Triggered when collisions occur. Will not trigger again until collisions of this type cease, or an event is requested once more (using `resetHitChecks(component)`).
- HitOff [componentName = {String}]
- Triggered when collision with a specific component type ceases
.collision
- NewHitbox [Data = {Crafty.polygon}]
- when a new hitbox is assigned
AngularMotion
- Rotated [Old rotation = {Number}]
- When entity has rotated due to angular velocity/acceleration a Rotated event is triggered.
- NewRotationDirection [New direction = {-1 | 0 | 1}]
- When entity has changed rotational direction due to rotational velocity a NewRotationDirection event is triggered. The event is triggered once, if direction is different from last frame.
- MotionChange [Motion property name and old value = { key: String, oldValue: Number }]
- When a motion property has changed a MotionChange event is triggered.
Motion
- NewDirection [New direction = { x: -1 | 0 | 1, y: -1 | 0 | 1 }]
- When entity has changed direction due to velocity on either x or y axis a NewDirection event is triggered. The event is triggered once, if direction is different from last frame.
- MotionChange [Motion property name and old value = { key: String, oldValue: Number }]
- When a motion property has changed a MotionChange event is triggered.
Supportable
- LandedOnGround
- When entity has landed. This event is triggered with the object the entity landed on.
- LiftedOffGround
- When entity has lifted off. This event is triggered with the object the entity stood on before lift-off.
- CheckLanding
- When entity is about to land. This event is triggered with the object the entity is about to land on. Third parties can respond to this event and prevent the entity from being able to land.