# How get object of class Tile?

**URL:** <https://phaser.discourse.group/t/how-get-object-of-class-tile/3393>\
**Category:** Phaser 3\
**Created:** [August 8, 2019, 11:03am UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393 "2019-08-08T11:03:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrio](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Andrio](https://phaser.discourse.group/u/Andrio)\
**Post date:** [August 8, 2019, 11:03am UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393/1 "2019-08-08T11:03:02Z")

</div>

I can’t get and use object of class Tile. The programm is crushing.  
Please help!

I do this :

```
   var map = this.make.tilemap({ key: 'map'});   
   var tileset = map.addTilesetImage('pesok_frames', 'tiles'); 
   var pesok_layer = map.createDynamicLayer('my_layer', tileset);   

   pesok_layer.setCollisionByExclusion(-1, true); 

  const one_tile = pesok_layer.getTileAt({ tileX:60, tileY:10});

```

Than when I try to use any methods of class Tile , program crashes. For excample :

one\_tile.destroy();

or  
test\_text = this.add.text(50, 470, 'one\_tile.x: ’ + one\_tile.x + ', one\_tile.y: ’ + one\_tile.y);

---

<div class="post-metadata">

**Author:** ![oL-web](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/ol-web/32/1347_2.png) [@oL-web](https://phaser.discourse.group/u/oL-web)\
**Post date:** [August 8, 2019, 12:06pm UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393/2 "2019-08-08T12:06:30Z")

</div>

Show us the errors in your dev console. To me it looks like one\_tile returns undefined and you’re trying to get its properties which results in an error in JS.

---

<div class="post-metadata">

**Author:** ![Telinc1](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/telinc1/32/60_2.png) [@Telinc1](https://phaser.discourse.group/u/Telinc1)\
**Post date:** [August 8, 2019, 12:35pm UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393/3 "2019-08-08T12:35:47Z")

</div>

Check [the documentation for `getTileAt`](https://photonstorm.github.io/phaser3-docs/Phaser.Tilemaps.DynamicTilemapLayer.html#getTileAt). It takes the coordinates as two parameters, not as an object. Try `getTileAt(60, 10)` instead of your current code.

Even if this does turn out to be the only problem, keep in mind what oL-web said. The errors you’re getting are almost always required to figure out what’s wrong and it’s hard to help without them.

---

<div class="post-metadata">

**Author:** ![Andrio](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Andrio](https://phaser.discourse.group/u/Andrio)\
**Post date:** [August 9, 2019, 3:24am UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393/4 "2019-08-09T03:24:39Z")

</div>

Thanks, but it also don’t works :  
getTileAt(60, 10)

I am a nuber, can you help me please where can i debug my game ? I try to do it in Visual Studio Code, but the problem is I can’t in .js file add path phaser/dist/phaser.min.js .  
This doesn’t work: document.write(‘script type=“phaser/dist/phaser.min.js” \>’);  
I get error “document is not defined”

---

<div class="post-metadata">

**Author:** ![Andrio](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@Andrio](https://phaser.discourse.group/u/Andrio)\
**Post date:** [August 9, 2019, 4:12pm UTC](https://phaser.discourse.group/t/how-get-object-of-class-tile/3393/5 "2019-08-09T16:12:06Z")

</div>

So I resolved problem  
getTileAt(tileX, tileY ) tileX, tileY - in tile units, not pixels.  
It’s my neglection, I didn’t look in tutorial carefully.  
And also now I installed Debugger for Chrome in VSC and it works fine.  
Thanks everyone !
