Jump to content

How to use offset for sprite's body


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) {


            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.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...

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...