Jump to content

Problems with body


crouzilles
 Share

Recommended Posts

Hi,

 

I have been having problems with scaling my paddle (breakout game), and to try to figure out what could be wrong I cloned my game and removed everything except the paddle and added debug info on the paddle's body.

 

You can see this code below, and the paddle attached as an image if you want to try for yourselves.  post-13646-0-23870800-1426960682.png

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });var paddle;var cursors;function preload() {    // Load sprites    game.load.image('paddle', 'assets/sprites/paddle.png');}function create() {    //  We're going to be using physics, so enable the Arcade Physics system    game.physics.startSystem(Phaser.Physics.ARCADE);     //  We check bounds collisions against all walls other than the bottom one    game.physics.arcade.checkCollision.down = false;        paddle = game.add.sprite(game.world.centerX, game.world.height - 12, 'paddle');    game.physics.arcade.enable(paddle);    paddle.body.collideWorldBounds = true;        cursors = game.input.keyboard.createCursorKeys();        game.debug.bodyInfo(paddle, 32, 32);    game.debug.body(paddle);}function update() {        //  Reset the paddle's velocity (movement)    paddle.body.velocity.x = 0;        if (cursors.left.isDown)    {        //  Move to the left        paddle.body.velocity.x = -250;    }    else if (cursors.right.isDown)    {        //  Move to the right        paddle.body.velocity.x = 250;    }}

The problem I see when debugging, is that the green body debug does not follow my paddle when it moves left or right. maybe this is why I get scaling problems.

Is it normal that the green body debug stays at the same place?

 

post-13646-0-04081200-1426960909.png

post-13646-0-70893000-1426960922.png

 

As you can see, debug data doesn't seem to change either.

 

Regards

Crouz

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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