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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:49:30+00:00 2026-06-11T03:49:30+00:00

I have three layers in my CCScene . MainLayer which contains GameLayer and HUDLayer

  • 0

I have three layers in my CCScene. MainLayer which contains GameLayer and HUDLayer. This is what it looks like now:

[ z-Order        ] | [ Layer ]
==============================
  3 ( Top Most )   | HUDLayer
  2 ( Middle )     | GameLayer
  1 ( Bottom )     | MainLayer 

I have added touch listeners (ccTouchBegan, ccTouchMoved, and ccTouchEnded) on my MainLayer which calls GameLayer‘s method getTouchedObject( CCPoint p_Loc ) which returns the touched object in that layer.

I am now able to successfully ‘touch’ a specific object in the MainLayer. Now, what I want to do is to drag the object touched and put it into the HUDLayer. When I was working with just one layer, I was able to drag and drop different objects with no problem but the need to implement CCLayers came so I divided the main layer into three different layers.

Answers doesn’t need to be cocos2d-x. I understand a bit of Obj-C and can translate Obj-C into C++ so cocos2d answers are welcome. Thanks in advance.

  • 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-11T03:49:31+00:00Added an answer on June 11, 2026 at 3:49 am

    The easiest way to do it, is probably:

    1. Add a new CCLayer on the very top called HoverLayer or something. This is for modularity.
    2. As soon as a sprite is touched on any layer, remove it from that layer, and add it as a child of HoverLayer at the same position. The user will not “see” anything changed.
    3. On touch up, after dragging the sprite, detect if the sprite is within the HUDLayer or not.
    4. Remove the sprite from the HoverLayer and add it to the appropriate layer.

    NOTES:

    • You can use the HUDLayer instead of the HoverLayer, but your class will be messy.
    • Of course, if you keep the touched sprite at the GameLayer while dragging, it will end up behind the HUDLayer at some point, so moving the sprite to a top layer is a must.
    • The code to implement the given solution is trivial. Nothing special to do, really.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three layers, two of which are hidden using CSS. I would like
I have three layers, the bottom layer is written in C++ and the other
I have an asp.net mvc application with three layers: - data layer with entities
This bothers me a bit: Suppose you have a matrix with three layers. Is
In a visual studio project I have three layers, Data Layer, Business Layer and
I have a three 'layers' deep model, that i's like to access through my
I have an app which consists of three layers of view controllers: UITabBarController =>
I have an application with three layers (Presentation, Business Logic, and Data Access). In
I have a three tier system, SQL Server backend, hand written data access layer,
I have an MSMQ-based system with three layers that communicate with each other. For

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.