Qfo

Members
  • Content count

    1
  • Joined

  • Last visited

  1. I do not quite understand what you want, but why you use child? In your code problem here: class Player extends Phaser.Sprite { constructor(game, x, y) { // This is create the invisible sprite without x and y. If x, y not defined x = 0, y = 0; // super(game); - wrong; x = 0, y = 0; super(game, x, y); //correct, x = x, y = y; // Also, you need to specify the size of the invisible sprite. this.width = 300; this.height = 300; this.playerBody = this.addChild( game.add.sprite( // Child x and y relative parent x, y. x, // parent.x + x, if you don't want offset set 0 y, // parent.y + y, if you don't want offset set 0 'atlas1', 'dot' ) ); this.playerBody.anchor.set(0.5); // Child anchor relative parent anchor. // If you don't want offset set anchor parent this.anchor.set(0.5); game.add.existing(this); this.inputEnabled = true; this.input.enableDrag(); //this.enableBody = true; is a Group property, not Sprite's. Thx samme. this.game.physics.enable(this, Phaser.Physics.ARCADE); } } Also, you can to try use my Player class class Player extends Phaser.Sprite { constructor(x, y, key, frame) { super(game, x, y, key, frame); game.physics.arcade.enable(this); //this.enableBody = true; is a Group property, not Sprite's. Thx samme. this.body.gravity.y = 100; this.body.maxVelocity.setTo(100, 100); this.anchor.set(0.5); game.add.existing(this); } } this.player = new Player(100, 100, 'player', frame);