Jump to content

Issue with camera.follow: Will not let character move after a certain point.


dchhetri
 Share

Recommended Posts

Without seeing the source (because you linked to a local network IP) I am taking a guess:

 

If you set the camera to follow a sprite, the sprite itself will only move if it's near the edges of the game world.

If it reaches half the view-port of the camera, it will stop to move and now the camera will move instead.

 

For example: if you run to the very left in a mario level, the mario sprite will be able to reach the left of the screen.

Now you run to the right, the mario sprite will move, until it's in the center of the screen. It will then be stuck there and now the camera will move instead (so the level under the sprite moves on screen.)

 

In the game world, the x position of mario changes, but not on screen, because the camera ist following him.

 

Hope that helps - if not, please publish your game somewhere online, so we can check it out.

(Since phaser does not require serverside code you can use basically any free webhoster to do that.)

Link to comment
Share on other sites

Sorry about that. I've got port 80 forwarding on. So you guys should be able to hit it outside my network. I just have my computer off right now so you won't be able to check it out. I'll update this in a few hour when I get home so you guys can check it out. Thanks

Link to comment
Share on other sites

Just confirming, that your port forwared did work, and that the bug (suck after moving to the right for a while) does happen. (I used chrome)

 

I did not have the time to debug anything, since I had to leave for work.

 

Right now it seems to be offline.

Link to comment
Share on other sites

hi dchhetri,

 

The Link (updated public ip) is not working.

It's possible that you are offline again, it's also possible, that you have a dynamic ip adress (this would mean it changes everytime you go online and/or every 24h hours at the daily disconnect).

 

It would be easier if you upload your game in it's current state to your github and link it here.

Link to comment
Share on other sites

Hi dchetri,

 

I did the following to get it to work correctly:

 

All in file app.js:

 

Around Line 475:

 

Your lines (remove them):

      //this.nonWalkableLayer.fixedToCamera = false;
      //this.walkableLayer.fixedToCamera = false;
 
 
My lines (add this in their place):
      this.walkableLayer.resizeWorld();
      this.nonWalkableLayer.fixedToCamera = true;
      this.walkableLayer.fixedToCamera = true;
 

 

Around Line 493:

 

Your lines (remove them):

    if(keyboard.isDown(Phaser.Keyboard.W)){this.game.camera.y -= speed;}
      else if(keyboard.isDown(Phaser.Keyboard.S)){this.game.camera.y += speed;}
      else if(keyboard.isDown(Phaser.Keyboard.A)){this.game.camera.x -= speed;}
      else if(keyboard.isDown(Phaser.Keyboard.D)){this.game.camera.x += speed;}
 
My lines: none, just remove your four lines
 
 
Result: You can now walk around the whole map freely.
 
Hope that helped.. if you don't mind, click 'like this' on the posts that helped, thanks :)
Link to comment
Share on other sites

"this.walkableLayer.resizeWorld();" might be the really important change here.

I think Your World was too small for the layer, so you everything got stuck at the world border.

 

But I must admit that this is only a guess, since I just looked at the code and compared it to my working tileset code - tried this as a first change to your code, and when it worked I did not look into it further :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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