Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

ct.js

Create cool 2D games with a free game editor! · By Cosmo Myzrail Gorynych

Direct Assignment using ct.camera.x/y doesn't work but ct.camera.teleportTo(x, y) do.

A topic by HardWomen created 19 days ago Views: 21 Replies: 2
Viewing posts 1 to 3

Direct Assignment using ct.camera.x/y doesn't work but ct.camera.teleportTo(x, y) do.

ct.camera.x = 0 doesn't work.
ct.camera.y = 0 doesn't work.

ct.camera.teleportTo(0, 0)
So the question now is...is ct.camera.x and ct.camera.y a read-only parameter ?

Developer (2 edits)

TL;DR: nope, but use ct.camera.targetX and ct.camera.targetY instead.

is ct.camera.x and ct.camera.y a read-only parameter ?

No, they are not, but they are supposed to be used with ct.camera.targetX and ct.camera.targetY (and that’s what ct.camera.teleportTo and ct.camera.moveTo use).

ct.camera.x and ct.camera.y are current coordinates, but each frame the camera tries to get to ct.camera.targetX and ct.camera.targetY. These four were crated for smooth transitions between coordinates. If ct.camera.drift equals to 0 (the default value), it may appear read-only as the camera jumps to targetX and targetY instantly. If it is different from 0, you will see that the camera does shift, yet flies towards ct.camera.targetX and ct.camera.targetY.

So should we use:

ct.camera.moveTo

or

ct.camera.drift = whatever and then
ct.camera.targetX = whatever ?