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

Recommended Posts



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.



object_name = new Class_name() is giving error.



Please do suggest.



Thanks in advance.

Share this post

Link to post
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) {, 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};

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.

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.