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 6794391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:12:59+00:00 2026-05-26T18:12:59+00:00

in my app I have some sprites that i need to drag and drop

  • 0

in my app I have some sprites that i need to drag and drop over the display.
i defined the BitmapTextureAtlas and the corresponding TextureRegion, and then i’have created the draggable sprite from those data.

Some sprites must be set in the same position and they have to be stacked.

everything works fine except that the sprites seams to be stacked but when i touch an drag away one, instead of dragging the first on the top, it makes me drag away always the first on the bottom.

how can i fix it?

this function inizializes the sprite

public Vector<Sprite> initSprite(Vector<TextureRegion> tRegionV){
    Vector<Sprite> aux = new Vector<Sprite>();
    for(int i=0; i<dataV.size(); i++ ){
        final int gap = dataV.elementAt(i).gap;
        sprite = new Sprite(dataV.elementAt(i).x, dataV.elementAt(i).y, tRegionV.elementAt(i))

        // gestione del drag & drop
        {
            @Override
            public boolean onAreaTouched(final TouchEvent pSceneTouchEvent,
                    final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
                setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY()
                        - gap /*this.getHeight() / 2*/);
                //System.out.println("POSIZIONE X: "+(pSceneTouchEvent.getX()- this.getWidth() / 2) +" --- Y: " +(pSceneTouchEvent.getY() - this.getHeight() / 2));
                //System.out.println("ALTEZZA: "+this.getHeight());

                return true;
            }
        };

        if(sprite==null)   System.out.println("AAAAAA sprite" +i+" null");
        aux.addElement(sprite);
    }

    return aux;
}

and i set the sprites in the scene this way

    for(int x=0;x<spriteV.size();x++){
        scene.getLastChild().attachChild(spriteV.elementAt(x));
    }
  • 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-05-26T18:13:00+00:00Added an answer on May 26, 2026 at 6:13 pm

    See: MultiTouchExample.java

    You probably want to do:

    this.mScene.setOnAreaTouchTraversalFrontToBack();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some things in my app that I need to store, in order
I have some classes in my app that don't require an ID to be
I'm trying to make logging for my rails app and have some dilemmas over
I have in my app some sprites. When I touch a sprite (in TouchEvent.isActionDown()
in my app i have some NSOperation that update some core data element from
I have an iPhone app I have developed that I want to have some
In my android app I have some buttons, that should work with onTouch() method,
I have been doing some mobile web app testing and have noticed that the
in my app i have some NSOperation that update some core data element from
i have an app using cocos2d, Im moving some sprites and having animations when

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.