Jump to content

Purpose of extending Phaser.Tilemaps.Tile class


dhezyr
 Share

Recommended Posts

Hi everyone,

This is my first post in here but I generally read most of the topics in this forum. I couldn't find anything about this topic. So this is the question;

I'm trying to generate a random world with a tile map in phaser. I want to extend Tile class to use in my needs for example; clicking a tile or when you hovering mouse on a tile it will give the information depending on the tile type.

So I want to get those infos from extended class itself. Addtionally when you click on a tile maybe you I will trigger some actions and every different extended tile class has its own implementation for onclick function (you know the idea here...).

But when I do this and using the putTileAt() function, in the layer data I still see the tile object type as Phaser.Tilemaps.Tile, because in the source code it's just copying the attributes of the extended Tile class to Phaser Tile class.

This is done on purpose I believe but I want to use some polymorphism in my code and don't want to write custom code (by puting the extended tile object to its cordinatte with layer.data[j] = new XTile())  for this because I want to be depended on phaser 3 framework with tilemaps.

How I can achieve this?

Thanks in advance for your opinions

Bests

Deniz

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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