cobblestone library

Classes

Aabb2
Defines a 2-dimensional axis-aligned bounding box between a min and a max position.
Aabb3
Defines a 3-dimensional axis-aligned bounding box between a min and a max position.
AnimatedTile
A tile that plays an animation in a loop.
AssetManager
A manager that loads assets in the background while the main loop continues.
AudioPlayer
Generic audio element, implemented by Sound and Music
AudioWrapper
A wrapper around the WebAudio context, will have extra features later
BaseGame
A base class for programming games. [...]
BasicTile
A static tile, with a single image.
BitmapFont
A set of data and a texture used for rendering text.
Camera2D
An orhographic camera, [...]
Colors
Contains functions for converting between different color models and manipulating colors. In addition to that, some known colors can be accessed for fast prototyping.
DebugBatch
A batch of bounding boxes, drawn in wireframe.
Ease
A set of easing functions for use with Tween. [...]
Framebuffer
An offscreen texture that can be rendered to.
Frustum
Defines a frustum constructed out of six Planes.
GLWrapper
A wrapper containing several useful WebGL functions.
HttpRequest
A client-side XHR request for getting data from a URL, formally known as XMLHttpRequest. [...]
IntersectionResult
Defines a result of an intersection test.
Keyboard
A container that tracks the current state of inputs on the keyboard.
KeyCode
Defines the keycode values for keys that are returned by KeyboardEvent.keyCode. [...]
MapEllipse
A map object consisting of an ellipse.
MapObject
An object in a tilemap.
MapPoint
A map object consisting of a single point.
MapPolygon
A map object consisting of a polygon.
MapProperties
A set of custom properties available on various components of Tiled maps. [...]
MapRect
A map object consisting of a rectangle.
MapText
A map object consisting of a string of text.
Matrix2
2D Matrix. Values are stored in column major order.
Matrix3
3D Matrix. Values are stored in column major order.
Matrix4
4D Matrix. Values are stored in column major order.
Mouse
A container that tracks current state of a user's mouse
Music
A longer sound, streamed from an AudioElement.
MutableRectangle<T extends num>
A class for representing two-dimensional axis-aligned rectangles with mutable properties.
Obb3
Defines a 3-dimensional oriented bounding box defined with a center, halfExtents and axes.
ObjectGroup
A group of objects in the map.
Particle
A single particle. [...]
ParticleEffect
All the information needed to emit particles. Use with ParticleEmitter.
ParticleEmitter
An emitter for particles, with behavior controlled by a ParticleEffect.
Plane
Point<T extends num>
A utility class for representing two-dimensional positions.
PointBatch
A batch of single points.
Quad
Defines a quad by four points.
Quaternion
Defines a Quaternion (a four-dimensional vector) for efficient rotation calculations. [...]
Random
A generator of random bool, int, or double values. [...]
Ray
Defines a Ray by an origin and a direction.
Rectangle<T extends num>
A class for representing two-dimensional rectangles whose properties are immutable.
ShaderProgram
A compiled WebGL shader
SimplexNoise
Sound
A playable sound using WebAudio. [...]
Sphere
Defines a sphere with a center and a radius.
SpriteBatch
A batch of textured sprites.
State
A state/screen of a game. [...]
Texture
A region of a WebGL texture used for drawing images. [...]
Tile
A tile on the map.
TileLayer
A tilemap layer filed with tiles.
Tilemap
A 2D orthographic tilemap.
Tileset
A set of tiles used in rendering a map.
Transform
A set of independently tracked transformations, grouped together into a Matrix4.
Triangle
Defines a triangle by three points.
Tween
An animation between two values
TweenManager
A set of tweens that updates each one. [...]
Vector
Base class for vectors
Vector2
2D column vector.
Vector3
3D column vector.
Vector4
4D column vector.
VertexBatch
A generic batch, used as a base for others like SpriteBatch.

Constants

colorAttrib → const String
Name of attribute for individual sprite color used in vertex shader
'aColor'
colorUni → const String
Name of uniform for color multiplication used in fragment shader
'uColor'
degrees2Radians → const double
Constant factor to convert and angle from degrees to radians.
math.pi / 180.0
e → const double
Base of the natural logarithms. [...]
2.718281828459045
ln2 → const double
Natural logarithm of 2. [...]
0.6931471805599453
ln10 → const double
Natural logarithm of 10. [...]
2.302585092994046
log2e → const double
Base-2 logarithm of e.
1.4426950408889634
log10e → const double
Base-10 logarithm of e.
0.4342944819032518
pi → const double
The PI constant.
3.1415926535897932
projMatUni → const String
Name of uniform for projection matrix used in vertex shader
'uPMatrix'
radians2Degrees → const double
Constant factor to convert and angle from radians to degrees.
180.0 / math.pi
samplerUni → const String
Name of uniform for texture used in fragment shader
'uSampler'
sqrt1_2 → const double
Square root of 1/2.
0.7071067811865476
sqrt2 → const double
Square root of 2.
1.4142135623730951
textureCoordAttrib → const String
Name of attribute for texture coordinates used in vertex shader
'aTextureCoord'
vertPosAttrib → const String
Name of attribute for vertex position used in vertex shader
'aVertexPosition'

Functions

absoluteError(dynamic calculated, dynamic correct) double
Returns absolute error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
acos(num x) double
Converts x to a double and returns its arc cosine in radians. [...]
asin(num x) double
Converts x to a double and returns its arc sine in radians. [...]
atan(num x) double
Converts x to a double and returns its arc tangent in radians. [...]
atan2(num a, num b) double
A variant of atan. [...]
buildPlaneVectors(Vector3 planeNormal, Vector3 u, Vector3 v) → void
Sets u and v to be two vectors orthogonal to each other and planeNormal.
catmullRom(double edge0, double edge1, double edge2, double edge3, double amount) double
Do a catmull rom spline interpolation with edge0, edge1, edge2 and edge3 by amount.
cos(num radians) double
Converts radians to a double and returns the cosine of the value. [...]
cross2(Vector2 x, Vector2 y) double
2D cross product. vec2 x vec2.
cross2A(double x, Vector2 y, Vector2 out) → void
2D cross product. double x vec2.
cross2B(Vector2 x, double y, Vector2 out) → void
2D cross product. vec2 x double.
cross3(Vector3 x, Vector3 y, Vector3 out) → void
3D Cross product.
degrees(double radians) double
Convert radians to degrees.
dot2(Vector2 x, Vector2 y) double
2D dot product.
dot3(Vector3 x, Vector3 y) double
3D dot product.
effectiveDimension(ScaleMode mode, int requested, int canvas) int
The dimension that can be assumed by users.
exp(num x) double
Converts x to a double and returns the natural exponent, e, to the power x. [...]
linear(GLWrapper wrapper, ImageElement element) Texture
Converts an ImageElement to a texture with linear scaling.
loadAtlas(String atlasUrl, FutureOr<Texture> texture) Future<Map<String, Texture>>
Loads a JSON texture atlas, in the format generated by the LibGDX texture packer.
loadEffect(String effectUrl, Future<Texture> texture) Future<ParticleEffect>
Loads a particle effect exported by https://pixijs.io/pixi-particles-editor/.
loadFont(String fontUrl, Future<Texture> texture) Future<BitmapFont>
Loads a font from a .fnt file and a texture
loadMusic(AudioWrapper audio, String url) Future<Music>
Loads a sound using an AudioElement.
loadProgram(GLWrapper wrapper, String vertex, String fragment) Future<ShaderProgram>
Compiles a new shader form code at the vertex and fragment URLS.
loadSound(AudioWrapper audio, String url) Future<Sound>
Loads a sound from a url.
loadTexture(GLWrapper wrapper, String url, [TextureHandler handle = nearest]) Future<Texture>
Loads a texture from a url. [...]
loadTilemap(String url, {FutureOr<Tileset> tileset, FutureOr atlas, int extraSpacing = 0, int extraMargin = 0}) Future<Tilemap>
Loads a TMX tilemap from a URL. [...]
loadTileset(String url, FutureOr atlas, [int extraSpacing = 0, int extraMargin = 0]) Future<Tileset>
Loads a TSX tileset from a url. [...]
log(num x) double
Converts x to a double and returns the natural logarithm of the value. [...]
makeFrustumMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL perspective projection matrix. [...]
makeInfiniteMatrix(double fovYRadians, double aspectRatio, double zNear) Matrix4
Constructs a new OpenGL infinite projection matrix. [...]
makeOrthographicMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL orthographic projection matrix. [...]
makePerspectiveMatrix(double fovYRadians, double aspectRatio, double zNear, double zFar) Matrix4
Constructs a new OpenGL perspective projection matrix. [...]
makePlaneProjection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points onto the plane specified with planeNormal and planePoint.
makePlaneReflection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points by reflecting them through the plane specified with planeNormal and planePoint.
makeViewMatrix(Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) Matrix4
Constructs a new OpenGL view matrix. [...]
max<T extends num>(T a, T b) → T
Returns the larger of two numbers. [...]
min<T extends num>(T a, T b) → T
Returns the lesser of two numbers. [...]
mipMap(GLWrapper wrapper, ImageElement image) Texture
Converts an ImageElement to a mip-mapped texture.
mix(double min, double max, double a) double
Interpolate between min and max with the amount of a using a linear interpolation. The computation is equivalent to the GLSL function mix.
nearest(GLWrapper wrapper, ImageElement element) Texture
Converts an ImageElement to texture with nearest neighbor scaling.
packColor(Vector4 color) double
Packs a color vector into a double, to be used in a float list
pickRay(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, Vector3 rayNear, Vector3 rayFar) bool
On success, rayNear and rayFar are the points where the screen space pickX, pickY intersect with the near and far planes respectively. [...]
pow(num x, num exponent) num
Returns x to the power of exponent. [...]
radians(double degrees) double
Convert degrees to radians.
relativeError(dynamic calculated, dynamic correct) double
Returns relative error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
scaleCanvas(CanvasElement element, ScaleMode mode, int requestWidth, int requestHeight, int parentWidth, int parentHeight, bool handleHDPI) → void
Scales element based on mode.
setFrustumMatrix(Matrix4 perspectiveMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix. [...]
setInfiniteMatrix(Matrix4 infiniteMatrix, double fovYRadians, double aspectRatio, double zNear) → void
Constructs an OpenGL infinite projection matrix in infiniteMatrix. fovYRadians specifies the field of view angle, in radians, in the y direction. aspectRatio specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio of x (width) to y (height). zNear specifies the distance from the viewer to the near plane (always positive).
setModelMatrix(Matrix4 modelMatrix, Vector3 forwardDirection, Vector3 upDirection, double tx, double ty, double tz) → void
Constructs an OpenGL model matrix in modelMatrix. Model transformation is the inverse of the view transformation. Model transformation is also known as "camera" transformation. Model matrix is commonly used to compute a object location/orientation into the full model-view stack. [...]
setOrthographicMatrix(Matrix4 orthographicMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL orthographic projection matrix in orthographicMatrix. [...]
setPerspectiveMatrix(Matrix4 perspectiveMatrix, double fovYRadians, double aspectRatio, double zNear, double zFar) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix. [...]
setRotationMatrix(Matrix4 rotationMatrix, Vector3 forwardDirection, Vector3 upDirection) → void
Constructs a rotation matrix in rotationMatrix. [...]
setViewMatrix(Matrix4 viewMatrix, Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) → void
Constructs an OpenGL view matrix in viewMatrix. View transformation is the inverse of the model transformation. View matrix is commonly used to compute the camera location/orientation into the full model-view stack. [...]
sin(num radians) double
Converts radians to a double and returns the sine of the value. [...]
smoothStep(double edge0, double edge1, double amount) double
Do a smooth step (hermite interpolation) interpolation with edge0 and edge1 by amount. The computation is equivalent to the GLSL function smoothstep.
sqrt(num x) double
Converts x to a double and returns the positive square root of the value. [...]
tan(num radians) double
Converts radians to a double and returns the tangent of the value. [...]
textureBind(int id) int
Returns the texture constant for the given id. E.g. when id is 0, this returns WebGL.TEXTURE0
unproject(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, num pickZ, Vector3 pickWorld) bool
On success, Sets pickWorld to be the world space position of the screen space pickX, pickY, and pickZ. [...]

Enums

ScaleMode
A method of scaling the game canvas
SpawnType
The type of spawn pattern particles are created in.
TextAlign
Enum representing the alignment of text for BitmapFont.

Typedefs

Easing = double Function(double, double, double, double)
TextureHandler = Texture Function(GLWrapper, ImageElement)
A function type used to convert an ImageElement into a WebGL texture