Jump to content

adding extended sprite to scene


Recommended Posts


For the record I am just a hobbyist so I don't know many of the ins and outs of programming.


I am trying to isolate? modulize? (not sure which is right word) my player to a class so I did below:

class Player extends Phaser.Physics.Arcade.Sprite{
    constructor(scene, x, y, texture){
        super(scene, x, y, texture);

        .....etc....//my own stuff



but i cant get it to render on screen or to update

the way i have been doing it before is

player = this.physics.add.sprite(x,y,texture);

I assume to use my class it would be

player = new Player(this, 0, 0, 'someloadedimageinpreload');


Based on some readings i think I may have to add it to displayList and updateList?

But I don't get how to do that...


Can someone help me please?



Link to comment
Share on other sites

  • 2 months later...

Thanks for the help on this one. This stumped me as well as I'd like to split up my code in several files and extending sprites seems to be a good way to make it more modular.

Why havent they added a generic .add( x ) function to game that just looks at the type and knows that its a sprite? the this.add.existing( x ) looks rather cryptic?

Link to comment
Share on other sites

  • 4 months later...

  • Recently Browsing   0 members

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