I'm in process of developing simple android puzzle game. I decided to choose andEngine as an engine for my game.

In my game I have a gameField [][] array, which represents a game field, where each element is a cell of game level and consists of a type of the cell (for ex. FLOOR of WALL). During the game, state of cell can be changed (for ex. DOOR_CLOSED changed to DOOR_OPENED), but it happens rarely, almost all the elements of gameField don't change.

I tried to implement that by adding repaint method to updateHandler, which would paint sprites for each cell every tick. But I wonder wouldn't be that approach a wasting of memory and processor time? What is the best practise for doing that?


How about having that multidimensional array of yours filled with, say, an extension of TiledSprites. Something like the following:

public class Door extends TiledSprite {

    private boolean isOpen = false;
    private static final int DOOR_CLOSED = 0;
    private static final int DOOR_OPEN = 1;

    public Door() {
        this(0, 0, doorTextureRegion, vertexBufferObjectManager);

    public open() {
        this.isOpen = true;

    public close() {
        this.isOpen = false;


In your scene, you attach all the TiledSprites as children of the scene. Iterate over the array in an initialization method, say. You shouldn't have to constantly poll and redraw--AndEngine takes care of that for you.

| improve this answer | |
  • \$\begingroup\$ I just saw your answer :) Thanks for reply, I've already implement similar approach in my game :) \$\endgroup\$ – mol Jun 20 '13 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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