Skip to main content

Migration guide for ct.js v4.0.

November 26, 2023

Migration guide for ct.js v4.0.

Ct.js lost its ct.! ๐Ÿ™€

All the ct.something lines are now just something, with few exceptions:

Example. Old code:

// A snippet from the catsteroids demo
this.targetx = ct.random.range(75, ct.camera.width - 75);
this.targety = ct.random.range(75, 300);
ct.tween.add({
    obj: this,
    fields: {
        x: this.targetx,
        y: this.targety
    },
    duration: 1500
});

New code:

// A snippet from the catsteroids demo
this.targetx = random.range(75, camera.width - 75);
this.targety = random.range(75, 300);
tween.add({
    obj: this,
    fields: {
        x: this.targetx,
        y: this.targety
    },
    duration: 1500
});

camera is not writable now

You can't assign a new camera to the camera variable.

New values for tracking time and changes in this.move() and backgrounds

Aside from u.delta and u.deltaUi, ct.js now also has u.time and u.timeUi, which are computed in secods and show the time passed between the last frame and the current one. It is recommended that you use these values for velocity and other time-dependent variables instead of u.delta and u.deltaUi, as the latter two won't provide smooth movement if you change the framerate cap in-game.

FitToScreen catmod is now a part of ct.js core library

Viewport settings are moved to project's render settings. Moreover, you can change viewport settings on the fly in the game with the new settings API!

Skeletal animations are no longer supported

Ct.js updated its underlying graphics library pixi.js, and though it brought various benefits for development and rendering performance, the DragonBones runtime is no longer supported by it, thus the skeletal animations are no longer supported in ct.js. Ct.js will probably add support for another runtime if its license is MIT-compatible.

Pixi.js was updated from v5.3 to v7.1

This includes some breaking changes and deprecations from the underlying graphics library. Unless you are using pixi.js API directly, this should not affect your projects.

Catmods

The option useUiDelta in tween.add was renamed to be isUi to match how other ct.js code names similar options.

The /*!%start%*/ injection was removed. Instead, write code in the index.js file.

Catmods mouse and touch were removed. Use pointer module instead, or the built-in pointer events you can add to event lists of your templates.

ct.u.ext (aka ct.u.extend) were removed

Use Object.assign(target, valuesObject) instead โ€” it works the same.