Jump to content

Physics Body Radius Tween (p2js)


flowabuse
 Share

Recommended Posts

I'm having a bit of trouble trying to scale the body of my circle sprite using  circleSprite.body.data.shapes[0] which I found in this thread http://www.html5gamedevs.com/topic/10094-cant-scale-sprite-body-using-tween/#entry59444

 

The sprite starts moving in a weird pattern across the screen.

 

Here is a gif showing the movement: http://makeagif.com/i/SeqG8k

 

I'm sorry if it's something obvious, I'm new to Phaser.

class SimpleGame {    constructor() {        this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'content',            { create: this.create, update: this.update , render: this.render });    }    game: Phaser.Game;    circleSprite: Phaser.Sprite;    graphics: Phaser.Graphics;    circle: PIXI.Graphics;           create() {    this.circleSprite = this.game.add.sprite(200,300);    this.game.physics.startSystem(Phaser.Physics.P2JS);            this.graphics = this.game.add.graphics(0, 0);    this.graphics.lineStyle(4, 0xFF0000, 0.5);    this.circle = this.graphics.drawCircle(0, 0, 50);    this.graphics.endFill();    this.circleSprite.addChild(this.circle);    this.game.physics.enable(this.circleSprite, Phaser.Physics.P2JS,true);    this.circleSprite.body.setCircle(20);    this.game.add.tween(this.circleSprite.body.data.shapes[0]).to({ radius: 90 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);    update() {        }    render()     this.game.debug.inputInfo(50, 50)}window.onload = () => {    var game = new SimpleGame();}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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