Jump to content

Problem with an extended Phaser.Physics.Arcade.Sprite


Recommended Posts

Hello I'm a beginner with Phaser and I want to extended a physcis sprite.

So this is my code.

class Player extends Phaser.Physics.Arcade.Sprite {

    constructor (scene, x, y,texture)
        super(scene, x, y,texture);
var player1;
var MyScene = new Phaser.Class({

    Extends: Phaser.Scene,


    function MyScene (config)
        Phaser.Scene.call(this, config)

    preload: function ()
      this.load.image('back', 'img/background.jpg');
	  this.load.image('dude', 'img/player.png');

    create: function ()
    this.add.image(540,360, 'back');
	player1 = new Player(this, 400, 100, 'dude');


				 var config = {
	type: Phaser.AUTO,
	width: 1080,
	height: 720,
	physics: {
		default: 'arcade',
		arcade: {
			gravity: { y: 1000 },
			debug: false
	scene: MyScene	
var game = new Phaser.Game(config);

The object display the sprite but the object don't fall and I can not set something in my class.

I search a long time a long time on internet and I didn't found. 

Do someone know where is my mistake  ?

Link to comment
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.
  • Create New...