Performclick in Andengine

78 Views Asked by At

I am developing a game with Andengine and I have a problem. I want to use PerformClick() function on sprites that have touch areas but sprites have no methods like PerformClick(). How can I simulate a click action in Andengine?

Any help would be appreciated thanks

1

There are 1 best solutions below

0
On

you can define a sprite like a button like this:

mySprite = new Sprite(posX, posYy, mySpriteTextureRegion,
                vertexBufferObjectManager) {
            public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY) {
                if (pEvent.isActionDown()) {
                    //Do something
                    return true;
                } else {
                    return false;
                }
            }
        };

Hope it can help you!