Jump to content

How use alignTo for tilemap?


tihoho
 Share

Recommended Posts

Hey guys!

I want align tilemap to bottom screen. But it not work:

// in create method
...
map = this.make.tilemap({ key: "map" });
map.alignTo(this.cameras.main, Phaser.BOTTOM_CENTER, 0, 0);
...

console said: Uncaught TypeError: map.alignTo is not a function

image.thumb.png.87bd61ec29a79d900aea645a0d5c6503.png

 

How I can do it?

Link to comment
Share on other sites

The map is not the graphical object. The layer is. (the result of createDynamicLayer or createStaticLayer) I'm not a hundred per cent sure the static or dynamic layer does have a alignTo method.
If not you could try: https://photonstorm.github.io/phaser3-docs/Phaser.Display.Align.To.html Where you would call it as a static method: Phaser.Display.Align.To.BottomRight(tileLayer, this.cameras.main, etc

I hope this helps. I haven't tried it out myself - but I do know that the tilemap is not a graphical object.

Link to comment
Share on other sites

Elleniaw, Thanks for the examples. I realized that I initially chose the alignment policy incorrectly. Now I align the elements relative to the center of the camera, it turned out to be easier :)

As I understood that the most difficult thing in game development is correct alignment and scaling of elements so that they look normal on all devices.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...