GithubHelp home page GithubHelp logo

andenginemultitouchextension's Introduction

๐Ÿ‘‹ Hi, Iโ€™m @nicolasgramlich

andenginemultitouchextension's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

andenginemultitouchextension's Issues

All TMXTiles in a TMXLayer need to be in the same TMXTileSet.

Hi,

I am writing a game that uses TMX maps and tilesets. There is a tileset for the land (desert, water, hill, etc) and there is another tileset for the environment(trees, bushes, buildings, etc). The map has two layers. When I implemented this part and tried out, I got this exception:
10-07 23:00:55.598: E/AndroidRuntime(26679): java.lang.NullPointerException
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXLayer.addTileByGlobalTileID(TMXLayer.java:277)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXLayer.initializeTMXTilesFromDataString(TMXLayer.java:247)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.andengine.extension.tmx.TMXParser.endElement(TMXParser.java:197)
10-07 23:00:55.598: E/AndroidRuntime(26679): at org.apache.harmony.xml.ExpatParser.endElement(ExpatParser.java:156)

if the pGlobalTileID is 0 this exception is always thrown.
With a small reordering this exception can be avoided:

private void addTileByGlobalTileID(final int pGlobalTileID,
            final ITMXTilePropertiesListener pTMXTilePropertyListener) {
        final TMXTiledMap tmxTiledMap = mTMXTiledMap;

        final int tilesHorizontal = mTileColumns;

        final int column = mTilesAdded % tilesHorizontal;
        final int row = mTilesAdded / tilesHorizontal;

        final TMXTile[][] tmxTiles = mTMXTiles;

        final ITextureRegion tmxTileTextureRegion;
        if (pGlobalTileID != 0) {
            tmxTileTextureRegion = tmxTiledMap
                    .getTextureRegionFromGlobalTileID(pGlobalTileID);

            final int tileHeight = mTMXTiledMap.getTileHeight();
            final int tileWidth = mTMXTiledMap.getTileWidth();

            if (mTexture == null) {
                mTexture = tmxTileTextureRegion.getTexture();
                super.initBlendFunction(mTexture);
            } else {
                if (mTexture != tmxTileTextureRegion.getTexture()) {
                    throw new AndEngineRuntimeException(
                            "All TMXTiles in a TMXLayer need to be in the same TMXTileSet.");
                }
            }
            final TMXTile tmxTile = new TMXTile(pGlobalTileID, column, row,
                    tileWidth, tileHeight, tmxTileTextureRegion);
            tmxTiles[row][column] = tmxTile;

            setIndex(getSpriteBatchIndex(column, row));
            this.drawWithoutChecks(tmxTileTextureRegion, tmxTile.getTileX(),
                    tmxTile.getTileY(), tileWidth, tileHeight,
                    Color.WHITE_ABGR_PACKED_FLOAT);
            submit(); // TODO Doesn't need to be called here, but should rather
                        // be called in a "init" step, when parsing the XML is
                        // complete.

            /* Notify the ITMXTilePropertiesListener if it exists. */
            if (pTMXTilePropertyListener != null) {
                final TMXProperties<TMXTileProperty> tmxTileProperties = tmxTiledMap
                        .getTMXTileProperties(pGlobalTileID);
                if (tmxTileProperties != null) {
                    pTMXTilePropertyListener.onTMXTileWithPropertiesCreated(
                            tmxTiledMap, this, tmxTile, tmxTileProperties);
                }
            }
        } else {
            tmxTileTextureRegion = null;
        }

        mTilesAdded++;
    }

what is your opinion?
Br

Szabolcs

Misleading

A lot of people that are new to Andegine get this extension and then complain that they get errors.
There should be a readme added so it's clearer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.