Jump to content

How to create a class extending sprite and create its objects in other class


madhurhtml5
 Share

Recommended Posts

Hello,

 

I am making a game consisting of a 2D array.

The game concept is same as that of candy crush, (2 swap between 2 items from the group).

For this i have to make a 2D array of sprites and so i have made a class and want to extend it with sprite so that i can create its objects to bring those sprites in 2D array on the screen.

using

 

object_name = new Class_name() is giving error.

 

 

Please do suggest.

 

 

Thanks in advance.

Link to comment
Share on other sites

Have you thought of using a Tilemap to represent the 2D array? Tilemap already has methods for swaping tiles etc. If you want to extend do something like

var MySuperTilemap = function(game, key, tileWidth, tileHeight, width, height) {    Phaser.Tilemap.call(this, game, key, tileWidth, tileHeight, width, height);    // @todo my construction stuff};MySuperTilemap.prototype = Object.create(Phaser.Tilemap.prototype);MySuperTilemap.prototype.constructor = MySuperTilemap;MySuperTilemap.prototype.coolMethod = function(something) {    //@todo more stuff};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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