1

I am making a game in javascript using Phaser that has a map that is 11800 x 11800 pixels. This comes to about 394.5 mb. This is too large to render with 8 gigs of ram, so I split it into 100 pieces (1180 x 1180 each being a 10x10 grid).

Does Phaser render images off screen, or should I write code to only render when in range of camera, and image.kill(); when not. Or is there a better way of handling this?

Thanks.

2 Answers 2

0

You can check a Phaser example to handle out of bounds elements here. Basically you have to handle the out of bounds event for each element.

About how to handle a huge map, it depends of what kind of game you are creating: usually the approach is using tiles from a spritesheet, which allows you to create huge maps without big files (example here):

0

Phaser does not automatically check for objects visibility before rendering them, that is something you have to handle yourself.

There is a function in Phaser.Component called inCamera which allows you to check if the game object is inside the camera bounds.

http://phaser.io/docs/2.6.2/Phaser.Component.InCamera.html

Running this on every game object can cause performance issues if you're constantly checking them, so depending on the logic of your game I would try to keep the checks as low as possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.