Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Weird Arcade Physics with 2.0.1


ltruelove
 Share

Recommended Posts

I just updated to 2.0.1 and I'm getting some really strange behavior. In the example I've posted below, the sprite that I'm adding goes flying off the screen the second it's loaded. If I take out the line that enables physics for the sprite it stays in place, but obviously that's not very useful. In another project I'm working on, if I use cursor keys to control my character to go left after pressing the left arrow key, they go flying left across the screen even if I set velocity.x = 0. That's an issue for a different post though because the code to show that project is too big to paste. Here's the simplified enough version:

<!DOCTYPE HTML><html><head>    <title>Test!!!</title>    <script src="pkg/phaser.js"></script></head><body >    <script type="text/javascript">        var game = new Phaser.Game(600,720, Phaser.CANVAS, 'test', { preload: preload,            create: create,            update: update,            render: render });        var arrowSprite = null;        function preload() {            game.stage.backgroundColor = '#0072bc';            game.stage.scale.maxWidth = 600;            game.stage.scale.maxHeight = 720;            game.load.atlasJSONHash('sprites', 'sprites.png', 'sprites.json');        }        function create() {            game.physics.startSystem(Phaser.Physics.ARCADE);            arrowSprite = game.add.sprite(game.world.centerX,585,'sprites','arrow');            game.physics.enable(arrowSprite, Phaser.Physics.ARCADE);            arrowSprite.pivot.x = 135;            arrowSprite.pivot.y = 15;            arrowSprite.rotation = 1.57;        }        function update(){            arrowSprite.body.velocity.x = 0;            arrowSprite.body.velocity.y = 0;        }        function render(){        }    </script>    </body></html>
Link to comment
Share on other sites

I have the same problem in this topic: http://www.html5gamedevs.com/topic/5071-why-does-a-sprite-move-down-once-physics-is-enabled/   , i have a ball rotating around a sprite, before enabling physics, i can set the pivot and it rotates nicely around the sprite and i can change this pivot which causes the ball to rotate in a larger circle around the sprite, after enabling physics, the balls flies completely off course in a wider circle, and changing the pivot makes it worse. It seems like pivot before and after physics are completely different methods, I've ended up using sprite's base method Overlap to check for some basic collisions until this gets fixed in a later version.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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