Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics


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

How to access property/variable of a "Copy" from another Copy.

A topic by white_dreams47 created 83 days ago Views: 60 Replies: 2
Viewing posts 1 to 3
(1 edit)

Its as the title says. Do you guys know how I can access the property/variables of a copy from a different copy?

For example, I want to get the this.x and this.y values of "Player" Copy from "Asteroid" copy.


The solution depends on your exact use case. Considering you are not working with homing asteroids, you probably want to get info about collisions:

var collided =, this.x, this.y, 'Player');
if (collided) {
    console.log(collided.x, collided.y);

But if you do need to get info about "Player" anytime, anywhere, then use ct.types.list:

var player = ct.types.list["Player"][0]; // assuming you have just one player pawn
if (player) {
    console.log(player.x, player.y);

And for multiple copies:

var players = ct.types.list["Player"]; // assuming you have numerous pawns
for (const player of players) {     console.log(player.x, player.y); }

Wow. Thank you very much mister Creator. Your reply was really helpful. And thank you for making this game engine, I really like it!