I want to change default mouse pointer in Android emulator. I want to change it for my game to use different type of cursor.I am using AndEngine for my game development. Is there nay way to change default mouse cursor for my Application. Thanks in Advance

  • 1
    \$\begingroup\$ This doesn't really make sense. Android is a touch-based OS and as such doesn't have a mouse cursor or any kind of cursor for that matter. Your hand is the cursor. If your game draws something at the fingertip, that's up to you and not something I'd imagine would be built into the engine. \$\endgroup\$ Mar 1 '13 at 4:57

I don't think the emulator has such a feature. It's built to emulate Android environment and Android environment has no such thing as a mouse cursor.

  • \$\begingroup\$ Thanks for Reply.I want to change cursor for my game Application only for ex. when I move cursor on menu button it will change from default cursor to different shapes like hand shape. \$\endgroup\$
    – Maan
    Mar 1 '13 at 4:25
  • \$\begingroup\$ Mate, Android OS will never fire a Mouse Over event so it's impossible. \$\endgroup\$
    – JanithaR
    Mar 1 '13 at 4:59
  • \$\begingroup\$ but i want to use this kind of feature in my Application.Is there any way to do this type of task. \$\endgroup\$
    – Maan
    Mar 1 '13 at 5:14
  • \$\begingroup\$ @Cameron Fredman 's answer is as close as you could get to this, but still it won't achieve what you're expecting. You're expecting something like when we are browsing through a web page. \$\endgroup\$
    – JanithaR
    Mar 1 '13 at 5:39

"Faking" a Mouse-Like Interface Using AndEngine GLES2

As JanithaR mentioned, there's no "default mouse cursor" in Android. Newer versions of the Android operating system support a developer mode that shows touch events with a screen image and various apps exist that create a mouse effect for touch events.

For your own application, if you want to have something like a mouse, you should think of it as a sprite that gets re-positioned based on touch events. You'll have to decide if you want the "pointer" visible on the screen when the screen isn't being touched (i.e., whether to leave it in the last touched location or whether to remove it). You'll also have to decide whether you want multiple pointers appearing for multitouch.

Do render a sprite, you should take a look at the SpriteExample from the examples library. Basically you'll be doing something along these lines:

this.mTexture = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
    public InputStream open() throws IOException {
        return getAssets().open("gfx/pointer.png");

this.mPointerTextureRegion = TextureRegionFactory.extractFromTexture(this.mTexture);

final Sprite pointer= new Sprite(centerX, centerY, this.mPointerTextureRegion, this.getVertexBufferObjectManager());

You're going to want some kind of pointer image in your gfx directory. Something like these:


And you're going to want to override the onTouch() method of the sprite, so it gets relocated as you touch:

final Sprite pointer = new Sprite(centerX, centerY, this.mPointerTextureRegion, this.getVertexBufferObjectManager()) {
            public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
                this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
                return true;

Alternative Approach to Controlling the Pointer

As an alternative, you might consider using an analog or digital on screen control (from the libraries in AndEngine) to "steer" the pointer around the screen. One of these:

Analog control

Take a look at the examples library to see how to build them in and use them. If you do this you'll have to do some work to "bind" the sprite to the screen area. (Here's a discussion on that.)

What to Do for AndEngine GLES1

As you noted in the comments, the above sample code was for GLES2. I think you'll find yourself in increasingly a land of no support if you're determined to use the older version GLES1, so the real advice I'd give is to upgrade to GLES2. (It's free, after all.)

BUT, if you really don't want to upgrade, you can still accomplish everything I've described. The key is to break it down into steps. You'll just need to:

A Sidenote About User Experience

I know your question isn't directly getting at this, but I suspect the User Experience community would have aneurysms at the idea of implementing a mouse in this manner in Android. From a usability standpoint, it really is contrary to the "touch" experience people expect with Android and iOS. (Reminds me a bit of some early console ports of PC games.) That doesn't mean there isn't an appropriate time and place to do it, but I think it's worth giving thought to whether you really want to fake a "mouse" or if there might be an alternative, more android-friendly, approach to your problem.

  • \$\begingroup\$ Thanks for reply.But i am getting error on IInputStreamOpener()this.Is this used with AndEngine Gles 1.0. because i am using AndEngine Gles 1.0 with jar file may be not supported this method. \$\endgroup\$
    – Maan
    Mar 1 '13 at 5:11
  • \$\begingroup\$ I think this code is for AndEngine GLES 2.0 so this code is not used with my Application which is in AndEngine GLES 1.0 . \$\endgroup\$
    – Maan
    Mar 1 '13 at 5:35
  • \$\begingroup\$ @Maan made some revisions for GLES1 and some other thoughts. \$\endgroup\$ Mar 1 '13 at 17:08

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.