Pixeljs

A simple and flexible HTML5 and JavaScript powered game engine.

View Project on GitHub Download Pixel.js (v0.9b)

FPSCounter Class

Represents a drawable FPS counter.

Inheritance Hierarchy

Properties

Name Description
asset The Asset that is used to give a visual representation of the entity. (Inherited from Entity.)
canMoveDown A boolean value indicating whether the entity can be moved downards. (Inherited from Entity.)
canMoveLeft A boolean value indicating whether the entity can be moved to the left. (Inherited from Entity.)
canMoveRight A boolean value indicating whether the entity can be moved to the right. (Inherited from Entity.)
canMoveUp A boolean value indicating whether the entity can be moved upwards. (Inherited from Entity.)
fps The current FPS reading.
isCollidable A boolean value indicating whether the entity can collide with other collidable entities. (Inherited from Entity.)
layer The Layer that the entity is registered to. (Inherited from Entity.)
pos The position of the entity on screen relative to the top-left corner of the scene. (Inherited from Entity.)
size The size of the entity. (Inherited from Entity.)
velocity The velocity at which the entity moves. (Inherited from Entity.)
visible A boolean value indicating whether the entity is visible. (Inherited from Entity.)

Methods

Name Description
addToLayer Adds the entity to the collection of registered entities on a Layer. (Inherited from Entity.)
collidesWith Checks if the entity collides with another entity. (Inherited from Entity.)
draw Draws the current FPS reading to the game scene. (Overrides Entity.draw.)
moveDown Moves the entity down based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.)
moveLeft Moves the entity left based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.)
moveRight Moves the entity right based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.)
moveUp Moves the entity up based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.)
onCollide The function to be called when the entity has collided with another entity. (Inherited from Entity.)
update Recalculates the number of frames per second. (Overrides Entity.update.)

Remarks

An FPS counter can be automatically added to a game by setting the displayFPS property of the engine class to true.

Supported Platforms

Google Chrome, Mozilla FireFox, Internet Explorer 9+, Opera, Safari.