Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8869899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:26+00:00 2026-06-14T17:35:26+00:00

I am new to andengine and even android game development. i have created sprite

  • 0

I am new to andengine and even android game development. i have created sprite as a box. this box is now draggable by using this coding. it works fine.

but i want multitouch on this which i want to rotate a sprite with 2 finger in that box and even it should be draggable. …. plz help someone…

i am trying this many days but no idea.

   final float centerX = (CAMERA_WIDTH - this.mBox.getWidth()) / 2;

   final float centerY = (CAMERA_HEIGHT - this.mBox.getHeight()) / 2;
     Box= new Sprite(centerX, centerY, this.mBox,
            this.getVertexBufferObjectManager()) {

     public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
                float pTouchAreaLocalX, float pTouchAreaLocalY) {
           this.setPosition(pSceneTouchEvent.getX() - this.getWidth()/ 2,
                           pSceneTouchEvent.getY() - this.getHeight() / 2);

             float pValueX = pSceneTouchEvent.getX();
            float pValueY = CAMERA_HEIGHT-pSceneTouchEvent.getY();

            float  dx = pValueX -  gun.getX();
            float  dy = pValueY -  gun.getY();

             double  Radius = Math.atan2(dy,dx);
             double Angle = Radius * 360 ;

                Box.setRotation((float)Math.toDegrees(Angle));
                 return true;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:35:27+00:00Added an answer on June 14, 2026 at 5:35 pm

    Make sure you enabled multi touch in your game. You can use the same code used in the MultiTouchExample in the onLoadEngine method.

    The algorithm is quite simple, similar to what you’ve posted here.

    1. Keep track of up to 2 pointer IDs you get in onAreaTouched method. (You can get the pointer ID by calling pSceneTouchEvent.getPointerID()).
    2. Keep track of the pointers’ state (Currently touching/not touching) and location (pTouchAreaLocalX and pTouchAreaLocalY).
    3. Whenever 2 pointers are touching (You received ACTION_DOWN for both), save the initial angle. (Math.tan2(pointer1Y - pointer2Y, pointer1X - pointer2X)).
    4. As long as ACTION_UP is not called for the pointers, update the new angle in every ACTION_MOVE event of the pointers, and get the angle delta (delta = currentAngle - initialAngle). Then call setRotation(Math.toDegrees(delta)).

    To make the sprite dragable with 2 pointers, you need to move your sprite the lesser of the distance each pointer has moved. For example, if:

    pointer1.dX = 50;
    pointer1.dY = -20;
    pointer2.dX = 40;
    pointer2.dY = -10;
    

    the sprite should move +40 units in the X axis, and -10 units in the Y axis.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Android game development and I'm using AndEngine GLES 2 Java.
I am new to android game development and I'm using AndEngine GLES 2 Java.
I am new to Android development and facing a problem while using AndEngine. I
new to android dev and andengine in general. trying to animate a sprite using
hi am new in Android game development i use AndEngine i need to ploat
Oky i am supplying this variable to animate a sprite sheet in andengine. player.animate(new
I want to develop a game using Andengine and i am new to game
I have a problem with AndEngine GLES2. I have this code: Sprite black =
I am using andengine to develop a game in android. I placed an object
I'm new to AndEngine and I'm trying to implement hanoi game following this tutorial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.