khleug35 Posted July 22, 2019 Share Posted July 22, 2019 Hello I using Panda2 + P2.js to develop my next project, When I add Camera function to Panda Editor Debug mode. the sprite bound is not displaying correctly ?? https://imgur.com/a/lUYxKd2 My full code: backgroundColor: '#272727', init: function() { this.world = new game.Physics(); this.world.on('beginContact', function(data) { }); this.world.on('impact', function(data) { }); this.world.on('postStep', function(data) { }); this.container = new game.Container(); this.container.addTo(this.stage); var ratio = this.world.ratio; var wallShape, wallBody; // Left wall wallShape = new p2.Box({ width: 2, height: game.height / ratio }); wallBody = new game.Body({ position: [-1, game.height / 2 / ratio] }); .......... //same width Panda2 P2.js "Main" Example this.mouseBody = new game.Body(); this.mouseBody.addTo(this.world); this.player2 = new game.Player(game.width / 2, game.height / 2); //Add Camera Function this.camera = new game.Camera(this.player2.sprite); this.camera.setPosition(this.player2.sprite); this.camera.addTo(this.container); }, addConstraint: function(x, y, player) { this.mousemove(x, y); .......... //same width Panda2 P2.js Player class Example }, mousemove: function(x, y) { this.mouseBody.position[0] = x / this.world.ratio; this.mouseBody.position[1] = y / this.world.ratio; }, mouseup: function() { .......... //same width Panda2 P2.js Player class Example } }); game.createClass('Player', { init: function(x, y) { .......... //same width Panda2 P2.js Player class Example } }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.