I took a look on those 2 project that I found in here: AndEngineJb2dJson AndEngineRubeLoaderExtension
As some of you know I'm developing a rolling scene based game I'm loading all the entities from a XML file and create them in the Loading Scene recently I increase the game width , and by doing so , in the whole level I have about 500 entities (instead of 250+-) But this cause a performance problems , the game is "Lagging" \ "jumping" and everything move slow.
My question is , if those Rube Loaders support performance issues , do some improvement or its just like the normal andengine loader , that I need to manually load each entity in the XML \ JSON
Does anyone develop a rolling scene based game with the same amount +- of entities and tell me what it the correct way to implement it?
Thanks
As you don't really provide much detail about your specific implementation I will just provide you with a generic way of handling a game of this type.
First, you need to define an "active" area for your game world - this would be the area of the world that needs to be simulated (i.e. the entities in this area will move and interact with the world).
Your world layout might look something like this:
In this example your world is the grey block and extends beyond the screen boundaries (which is the black frame). The red frame indicates the active area - notice that it extends beyond the size of the display, but does not cover the entire world. The size of this area will depend on your specific implementation/needs.
The active area will generally move along with your player and hence can easily be represented as distance from player (in two directions).
The basic idea is that the entities (in blue) are only simulated while they are inside the active area. All entities to the right of the active area should be inactive until they enter it, at which point their simulation can start - for this reason, the active area should extend some amount to the right of the display area so that entities have some initial time to run their simulation before being displayed. Once the entities leave the active area (to the left) they can stop their simulation - and be removed if needed.
So in the example image:
As for how to handle the entities, that depends on the size of the world, the number of entities, etc.
One way is to create/load the entities once they enter the active area - in which case it should extend far enough to the right of the display so that they have enough time to be created/loaded before entering the display area. This is the best approach for large worlds where there may be thousands of entities. In this case you may also need some kind of subdivision for your world so that you can exclude large amounts of entities from processing without checking each one - a array of fixed sized "blocks", each containing the entities that are within it, would work fine in most cases for a simple 2D side-scroller.
Another approach is to load all objects at the start and only perform simulation updates (such as physics, movement, collision detection) for them once they enter the active area. This approach works great for smaller worlds and provides an easier implementation.