Jump to content

Char movements seems to slow on reaching worldbounds


Dlost1
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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