In the rest of the documentation, you may have noticed references to cr.vector2 or cr.rect. These, and some other common functions, are declared in common_prelude.js. Like the rest of the runtime, they are in the cr namespace (for Construct Runtime). This section documents these classes and functions.
cr.vector2 is a simple x,y position (also usable as a size). Create with: new cr.vector2(x, y)
cr.rect is a simple 2D rectangle. It is implicitly axis-aligned. Create with: new cr.rect(left, top, right, bottom)
Creating many rect objects can result in garbage collector overhead causing poor performance. Re-use existing rect objects wherever possible.
A quad is simply four 2D points that form a four-sided shape. Unlike cr.rect, quads can represent rectangles at any angle (non-axis-aligned). Quads do not have to store a rectangle - each of the four points can have any position at all - but in the runtime, they are always used for the purpose of rotated rectangles.
Create a quad with: new cr.quad()
Create a new ObjectSet with: new cr.ObjectSet()
The following functions are not all related, but are often useful.