Jump to content

How to use offset for sprite's body


EgorkZe
 Share

Recommended Posts

@rvizcaino Yes, of course   GameObject extends Phaser.Sprite

 

module BunnyRunner{

    export class Player extends BunnyRunner.GameObject {

 

        constructor(game: Phaser.Game, x: number, y: number,width:number = 50, height:number = 50) {

            super(game,x,y,width,height,"bunnyAtlas");

            this.body.fixedRotation = 1;

         

            

    this.animations.add('run', Phaser.Animation.generateFrameNames('bunny_run', 0, 12, '', 4), 25, true);

   this.animations.add('jump', Phaser.Animation.generateFrameNames('bunny_jump', 0, 12, '', 4), 25, true);

   this.animations.play('run');

 

     this.body.offset.setTo(-200, -30);  // it doesn't work

    this.body.onBeginContact.add(Player.prototype.checkCollision, this);

        }

Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

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