Jump to content

How use alignTo for tilemap?


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



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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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