EgorkZe Posted November 19, 2014 Share Posted November 19, 2014 Im trying do it like this:this.body.offset = new Phaser.Point(-20,-30);But it doesn't working( What am i doing wrong? Link to comment Share on other sites More sharing options...
rvizcaino Posted November 19, 2014 Share Posted November 19, 2014 Try this.body.offset.setTo(-20, -30); Link to comment Share on other sites More sharing options...
EgorkZe Posted November 19, 2014 Author Share Posted November 19, 2014 @rvizcaino no, it doesn't help( Link to comment Share on other sites More sharing options...
Sam Posted November 19, 2014 Share Posted November 19, 2014 hrm, what do you like to do (what is that for especially)? Link to comment Share on other sites More sharing options...
rvizcaino Posted November 20, 2014 Share Posted November 20, 2014 Can you show a bit of code? Link to comment Share on other sites More sharing options...
EgorkZe Posted November 20, 2014 Author Share Posted November 20, 2014 @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 More sharing options...
rvizcaino Posted November 20, 2014 Share Posted November 20, 2014 I am not an expert but i think you are missing the part where you enable the physic body, something like:game.physics.enable(sprite, 'arcade');Also don't forget to start the physics engine. Link to comment Share on other sites More sharing options...
EgorkZe Posted November 20, 2014 Author Share Posted November 20, 2014 @rvizcaino No, i enabled the physic engine like this:this.game.physics.startSystem(Phaser.Physics.P2JS); and enabled physic body :game.physics.p2.enable(this, true); Link to comment Share on other sites More sharing options...
rvizcaino Posted November 20, 2014 Share Posted November 20, 2014 Weird... Please make sure you're using Phaser with P2 bundled. Link to comment Share on other sites More sharing options...
EgorkZe Posted November 20, 2014 Author Share Posted November 20, 2014 @rvizcaino I sure that i am using p2, because physic are working and objects are falling and colliding, but i can't use offset for the sprite's body( Link to comment Share on other sites More sharing options...
valueerror Posted November 20, 2014 Share Posted November 20, 2014 i'm not sure if that has something to do with it but i used sprite.pivot to create a specific offset between the sprite and it's body and with the new version of phaser it stopped working.. rich said it's a pixi problem Link to comment Share on other sites More sharing options...
EgorkZe Posted November 21, 2014 Author Share Posted November 21, 2014 @valuererror And what can i do to apply sprite's body offset? Help me Link to comment Share on other sites More sharing options...
EgorkZe Posted November 21, 2014 Author Share Posted November 21, 2014 Hmmmm, pivot is working! Nice! Link to comment Share on other sites More sharing options...
tlark Posted January 18, 2015 Share Posted January 18, 2015 I can confirm this behavior, Pivot is a work around, but not a good one because it messes up the geometry of all dependant child sprites below the pivot sprite (their world pos is off) Link to comment Share on other sites More sharing options...
Recommended Posts