Jump to content

First experience with Phaser+P2 physics: problem :(


samifruit514
 Share

Recommended Posts

Hello,

 

Im trying the Phaser framework and I found it very interesting. There are a LOT of features that are not present in the other frameworks I used. Altough, right at the start, I have an issue. my "game" seems to set a +x velocity to my sprite so right at the start (when I enable the body for P2), it goes to the right. Additionally, the sprite pos is affected by the enablebody and its moved few pixels left and few pixels up. Here's the complete code.

<!doctype html> <html lang="en"> <head> 	<meta charset="UTF-8" />        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />	<title>Phaser - Making your first game, part 1</title>	<script type="text/javascript" src="js/phaser.min.js"></script>    <style type="text/css">        body {            margin: 0;        }    </style></head><body><script type="text/javascript">var game = new Phaser.Game(768, 1024, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });game.objects = {}function preload() {    game.load.image('d_left', 'assets/d_left.png');}function create() {    game.physics.startSystem(Phaser.Physics.P2JS);    game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; //resize your window to see the stage resize too    game.scale.setExactFit();    game.scale.refresh();    game.objects.dummy = {}    game.objects.dummy.left = game.add.sprite(100,330,'d_left');    game.physics.p2.enable(game.objects.dummy.left, false)    game.input.addPointer();}function render() {    game.debug.pointer(game.input.mousePointer);}function update() {}</script></body></html>

 Im using phaser 2.0.2 and I tried with 2.0.0 and 2.0.1 as well. Any clue why its doing this? Is it because I'm using chrome?

 

Thank you

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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