Sign in to follow this  
dhezyr

Purpose of extending Phaser.Tilemaps.Tile class

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

Share this post


Link to post
Share on other sites

Any opinions?

If its not clear I can explain a little bit in detail. Or if you can propose another approach it is also fine :) I have also some in my mind but this is the way I want to use.

Bests

Share this post


Link to post
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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.