Migration guide for ct.js v2.0.
Changes to copies'
rotation property, or "My copies spin like propellers"
rotation was proxying pixi.js' same-named parameter, which was measured in radians. It was made to preserve compatibility with older projects, those which were created before v1 emerged. We dropped this proxy to better conform to pixi.js' behavior and remove unexpected inconsistencies when working both with ct.js and pixi.js entities.
Pixi.js has a built-in
angle property that is measured in degrees, so:
- Instead of
this.anglegoes clockwise compared to previous
this.rotation, that winded counter-clockwise, so
this.angle = 90;points to bottom, 180 — to the left, 270 — upwards, 360 and 0 — to the right.
Types are now called "Templates"
It is something that I, the creator of ct.js, wanted to change for a whopping five years or so. Most names in ct.js were made with poor knowledge of the English language, and contrary to the internal properties and niche things like "code injects" (which are to be named "code injections"), "types" are something that every ct.js user writes daily.
Templates are a better word for the entities from which ct.js' copies are created, especially when translating ct.js to other languages, and are also more language-neutral. After all, there are just six types in ct.js, and none of them is an old ct.js type.
"Templates" will also make more sense when ct.js supports templates based on classes different than simple animated sprites: the idea is to allow making buttons, panel templates, and utilize cool stuff like spline terrain. While all that will come later, it is better to make small transitions now — to ease future migrations.
How this affects you and your projects:
- You will now have to write
- Ct.IDE will replace
ct.templatesonce you open a project that was made in previous versions of ct.js, but there are still changes in
ct.templatesAPI listed below.
ct.templates.exists(copy)is renamed into
ct.templates.exists(typeName)now checks whether there are copies of a particular name in a room (or its appended/prepended rooms).
ct.templates.make was removed as no one really used it.
There are now two separate methods for spawning copies, though:
Note that arguments shifted a bit in
ct.templates.copyIntoRoom(type, x, y, container, exts) compared to the previous
ct.templates.copyIntoRoom will throw an error if
container is not set. The whole separation into two methods is to make copy creation more failsafe and to exclude situations like when you pass
ct.rooms.list['NonExistentRoomName'] as a container and then get a copy inside the main room without any warnings.
ct.u.gameToUiCoord now return
PIXI.Point instead of arrays
PIXI.Point are objects with
y properties plus a few handy methods for copying them.
ct.camera.gameToUiCoord, and all
ct.camera.get(XY)Corner do the same as well as they are dependant on these methods.
ct.place changed to be both more efficient and easy to use
ct.place.freenow work both for copies and tiles, so you need just them instead of adding an additional
ct.place.tilecheck. Additionally, all the tracing functions now work with tiles as well.
multipleargument was removed from
ct.place.occupied. Instead, there are now methods
ct.place.occupiedMultiple, to make code more readable. You may need to rewrite some code to make it work for multiple copies again.
ct.place.tileis renamed to
ct.place.tiles, and is accompanied with
ct.placenow supports and respects collision shapes of tiles. It is currently of little use with large tilesets, but you can now have individual tiles of circular and other shapes!
See the new docs for ct.place in your ct.js' side panel.
ct.sound is now a catmod
Usually it won't cause any issues, but in case you have errors from ct.res about no sound systems, turn one of the sound catmods on in your project's settings.
ct.touch are now deprecated in favor of
This causes no immediate issues, but consider using
ct.pointer module in your future projects. It covers functionality of both
ct.touch with familiar API, as well as supports additional features like pressure reading, pen position, and an abstraction over Pointer Lock API.