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

ct.camera.scale = 2 doesn't work yet this.scale = 2 works.

A topic by HardWomen created 21 days ago Views: 31 Replies: 4
Viewing posts 1 to 4

ct.camera.scale.x = ct.camera.scale.y = 2 works.

you cannot:
ct.camera.scale = 2;

but yet you can:
this.scale = 2;
and you don't have to:
this.scale.x - this.scale.y = 2;

Developer

ct.camera.scale isn’t number, it is a point — an object with x and y parameters.

(this.scale = 2; was never supported or documented, how did you ever found this?)

That is not true, I am not a lier:      

Manipulating Copies' look

There are a number of parameters that can be changed:

  • animationSpeed — animation speed. Higher is faster, lower is slower;
  • depth — the drawing layer;
  • tex — the name of a texture to use;
  • rotation — the rotation of the copy in degrees;
  • scale — the scale factor of the object. You can either assign a simple value (this.scale = 0.5;) for uniform scaling or access its x and y compounds (this.scale.x = 0.5;).
  • tint — the tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect. The colors are the same as in CSS, e.g. 0xFF0000 is red, 0x00FFFF is cyan, ect;
  • alpha — the opacity of the copy. 0 makes a copy invisible, 1 is the default (fully opaque) mode. All in between will make a gradual transparency change;
  • visible — the visibility of the object (true or false).
Developer

O_o

(1 edit)

Straight from the documentation:    

https://docs.ctjs.rocks/ct.types.html#working-with-copies


ct.types

This object allows you to create new Copies and manipulate them. Each copy is an instance of Pixi's AnimatedSprite class, so you can find much more parameters


at their docs site.

# Working with Copies

# Moving Copies Around

Each Copy has these parameters for movement:

  • x, y — its location;
  • xprev, yprev — location of a Copy in a previous frame;
  • xstart, ystart — coordinates at which a copy was created;
  • speed — movement speed (or the length of vector [hspeed; vspeed]);
  • hspeed and vspeed — horizontal and vertical speed;
  • direction — movement direction (from 0 to 360);
  • gravity — gravity force;
  • gravityDir — gravity direction (from 0 to 360, default is 270).

You can also call this.addSpeed to add speed vector to a Copy in a given direction.

this.addSpeed(speed, dir);

To actually move a copy, you should call this.move(); in your copy's OnStep code (it is included in each Type by default). Default movement system already takes ct.delta into account, so it will move with the same speed at every frame rate.

# Manipulating Copies' look

There are a number of parameters that can be changed:

  • animationSpeed — animation speed. Higher is faster, lower is slower;
  • depth — the drawing layer;
  • tex — the name of a texture to use;
  • rotation — the rotation of the copy in degrees;
  • scale — the scale factor of the object. You can either assign a simple value (this.scale = 0.5;) for uniform scaling or access its x and y compounds (this.scale.x = 0.5;).
  • tint — the tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect. The colors are the same as in CSS, e.g. 0xFF0000 is red, 0x00FFFF is cyan, ect;
  • alpha — the opacity of the copy. 0 makes a copy invisible, 1 is the default (fully opaque) mode. All in between will make a gradual transparency change;
  • visible — the visibility of the object (true or false).

Read-only variables:

  • currentFrame — current drawing frame index. You should change it with gotoAndPlay, gotoAndStop methods;
  • totalFrames — the total number of frames in the Copy.