Jump to content

Frame rate when using camera.follow and tilemapLayer


Recommended Posts

Hello everybody


This is my first post and I'm not english speaker, so excuse me if the english is not ok or if this topic has just been create.


I'm developing a game, it has a normal frame rate of 50-60 fps.


If I use camera.follow or if I create tilemapLayer the frame rate is correct, but if I use both of them the frame rate decreases to 5 fps.


I don't have a clue about what is hapenning here, so any help is ok.


I've commented all mi update function and the frame rate is still 5 fps, so I'm sure the problem is with tilemaps.


This is the code: 



game.load.tilemap('level1', 'assets/levelfinal1.json', null, Phaser.Tilemap.TILED_JSON);game.load.tilemap('level1m', 'assets/levelfinal2.json', null, Phaser.Tilemap.TILED_JSON);game.load.tileset('tiles', 'assets/Tileado_1.png', 32, 32);


this.map2 = game.add.tilemap('level1m');this.tileset = game.add.tileset('tiles');this.items = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 0);this.fondo = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 1);this.fondo.resizeWorld();this.arcos = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 2);this.plataformas = game.add.tilemapLayer(0, 0, 800, 600, this.tileset, this.map2, 3);this.plataformas.resizeWorld();this.tileset.setCollisionRange(0, this.tileset.total - 1, true, true, true, true);this.items.fixedToCamera = false;this.fondo.fixedToCamera = false;this.plataformas.fixedToCamera = false;this.arcos.fixedToCamera = false;	

I 've tried using the canvas size instead of 8192 and 806, that fix the frame rate problem, but the layers doesn't render ok.

Link to comment
Share on other sites

I've created a new project with the following index.html file: 


I'm starting thinking Phraser tilemapLayer functionallity is broken.

<html>	<head>		<script src="js/phaser.min.js" type="text/javascript"></script>	</head><body><script type="text/javascript">var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload(){	sprite =  game.load.spritesheet('pill', 'assets/PNGs/Escenario/Pildoras.png', 28, 28);	game.load.tilemap('level1', 'assets/levelfinal1.json', null, Phaser.Tilemap.TILED_JSON);	game.load.tilemap('level1m', 'assets/levelfinal2.json', null, Phaser.Tilemap.TILED_JSON);	game.load.tileset('tiles', 'assets/Tileado_1.png', 32, 32);}function create(){	//this.map = game.add.tilemap('level1');	this.map2 = game.add.tilemap('level1m');	this.tileset = game.add.tileset('tiles');	this.fondo = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 1);	this.fondo.resizeWorld();	this.arcos = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 2);	this.arcos.resizeWorld();	this.plataformas = game.add.tilemapLayer(0, 0, 8192, 608, this.tileset, this.map2, 3);	this.plataformas.resizeWorld();	this.tileset.setCollisionRange(0, this.tileset.total - 1, true, true, true, true);	this.fondo.fixedToCamera = false;	this.plataformas.fixedToCamera = false;	this.arcos.fixedToCamera = false;	sprite = game.add.sprite(32, game.world.height - 150, 'pill');	this.game.camera.follow(sprite);	sprite.body.velocity.x = 150;}function update(){	console.log(game.time.fps);	}</script>		</body></html> 
Link to comment
Share on other sites

what type of computer & browser is this in?


best guess without more information is that 5 fps is the best that you can do with that size world & viewport. when you start moving around the world the entire background is redrawn each frame. but 5 fps is pretty slow, so perhaps there's something else going on. unless hardware acceleration isn't being supported in your browser/os/hardware combination, in which case I wouldn't be surprised at all.


my (newish) laptop can manage several layers and a larger world area (but smaller viewport) and stay between 40 and 60 fps, but on a friend's older machine (and mobile devices - nexus 4, 5 & 7, iphone 4, ipad mini) it drops to mostly unplayable levels...

Link to comment
Share on other sites

My computer is a laptop (Phenom 2.1Ghz X3 cores & 4Gb ram), I've tried chromium, opera and firefox.

I've tried  safari on my friend's mac book air computer too.


If I stay whithout moving, 5fps is still the frame rate of the game.


If you need more info, please ask me again.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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