Dlost1 Posted February 8, 2017 Share Posted February 8, 2017 Hello, I am building a small Phaser game. For fun;) I got one problem: I focus my camera on my character, but when I near the edge of the map the characters speed "seems" to increase greatly (and decrease as soon as the camera starts moving of the edge again). I think this has to do with the camera abruptly stopping when on the edge of the map (so the cam stops but char moves on) Is there a way to make the camere go "over the edge", like, half or so? Cause this looks a bit crappy;) Underneath I posteed the code (I took out the parts which have nothing to do with this issue:) Anyone got an idea or a sollution for me? (Btw: I am using Tiled to create a Json map which I imported into my program.) create: function () { game.world.setBounds(0, 0, 2560, 2560); game.physics.startSystem(Phaser.Physics.ARCADE); this.map = game.add.tilemap("GameWorld1616", 16, 16, 160, 160); this.map.addTilesetImage("Ground1","Ground1"); this.map.addTilesetImage("Market2", "Market2"); this.map.addTilesetImage("Tree1", "Tree1"); this.layer1 = this.map.createLayer("GroundLayer"); this.layer2 = this.map.createLayer("Roads"); this.layer3 = this.map.createLayer("TreesFront"); this.layer4 = this.map.createLayer("TreesBack"); this.layer5 = this.map.createLayer("Collision"); player = game.add.sprite(game.world.centerX, game.world.centerY, avatar); game.camera.follow(player); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; cursors = game.input.keyboard.createCursorKeys(); this.menuFactory('Return', function () { game.state.start("CharSelect"); }); }, update: function() { game.physics.arcade.collide(player); // Reset the players velocity (movement) player.body.velocity.x = 0; player.body.velocity.y = 0; if (cursors.left.isDown) { // Move to the left player.body.velocity.x = -500; player.animations.play('left'); } else if (cursors.right.isDown) { // Move to the right player.body.velocity.x = 500; player.animations.play('right'); Link to comment Share on other sites More sharing options...
Dlost1 Posted February 8, 2017 Author Share Posted February 8, 2017 Also: please let me know if my question is not clear enough;)) Link to comment Share on other sites More sharing options...
samme Posted February 8, 2017 Share Posted February 8, 2017 You can do, e.g., game.camera.bounds.inflate(256, 0) Dlost1 1 Link to comment Share on other sites More sharing options...
Dlost1 Posted February 8, 2017 Author Share Posted February 8, 2017 Well it does solve the speed problem indeed. I think I ll go with that unless anyone has a suggestion for a more beautiful solution form my problem?:) Thanks Samme:) Link to comment Share on other sites More sharing options...
Recommended Posts