crouzilles Posted March 21, 2015 Share Posted March 21, 2015 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. 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? As you can see, debug data doesn't seem to change either. RegardsCrouz Link to comment Share on other sites More sharing options...
Westinghouse Posted March 21, 2015 Share Posted March 21, 2015 Your problem here is that you didn't put the debug functions in render. So they will be created but not updated, that is the reason the body doesn't move. Link to comment Share on other sites More sharing options...
crouzilles Posted March 21, 2015 Author Share Posted March 21, 2015 Thanks for the answer. If anyone knows of a good tutorial on render as I never used it and have no idea what it does. RegardsCrouz Link to comment Share on other sites More sharing options...
Westinghouse Posted March 21, 2015 Share Posted March 21, 2015 Render is mostly use for debugging, as far as I know. Here are some examples how to debug with render correctly: http://phaser.io/examples/v2/category/debug and an explanation what render does: http://phaser.io/docs/Phaser.State.html#render Link to comment Share on other sites More sharing options...
Recommended Posts