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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:42:19+00:00 2026-06-01T17:42:19+00:00

Thanks for reading. I’m working on a setup in Cocos2D 1.x where I have

  • 0

Thanks for reading.

I’m working on a setup in Cocos2D 1.x where I have a huge CCLayerPanZoom in a scene with free panning and zooming.
Every frame, I have to additionally draw a CCRenderTexture on top to create “darkness” (I’m cutting out the light). That works well.

Now I’ve added single sprites to the surface, and they are managed by Box2D. That works as well. I can translate to the RenderTexture where the light sources ought to be, and they render fine.

And then I wanted to add a HUD layer on top, by adding a CCLayer to the scene. That layer needs to contain several sprites stacked on top of each other, as user interface elements.

Only, all of these elements fail to draw where I need them to be: Exactly in the center of screen. The Sprites added onto the HUD layer are all off, and I have iterated through pretty much every variation “convertToWorldSpace”, “convertToNodeSpace”, etc.

It is as if the constant scaling by the CCPanZoomLayer in the background throws off anchor points in the layer above each frame, and resetting them doesn’t help. They all seem to default into one of the corners of the node bounding box they are attached to, as if their transform is blocked or set to zero when it comes to the drawing.

Has anyone run into this problem? Is this a known issue when using CCLayerPanZoom and drawing a custom CCRenderTexture on top each frame?

  • 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-01T17:42:20+00:00Added an answer on June 1, 2026 at 5:42 pm

    Ha! I found the culprit! There’s a bug in Cocos2D’ way of using Zwoptex data. (I’m using Cocos2D v 1.0.1).

    It seems that when loading in Zwoptex v3 data, sprite frames’ trim offset data is ignored when the actual sprite frame anchor point is computed. The effect is that no anchor point on a sprite with trim offset in its definition (eg in the plist) has its anchor point correctly set. Really strange… I wonder whether this has occurred to anybody else? It’s a glaring issue.

    Here’s how to reproduce:
    Create any data for a sprite frame in zwoptex v3 format (the one that uses the trim data). Make sure you actually have a trimmed sprite, i.e. offset must be larger than zero, and image size must be larger than source.
    Load in sprite, and try to position it at center of screen. You’ll see it’s off. Here’s how to compute your anchor point correctly:

            CCSprite *floor = [CCSprite spriteWithSpriteFrameName:@"Menu_OmeFloor.png"]; //create a sprite
            CCSpriteFrame *frame=[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"Menu_OmeFloor.png"]; //get its frame to access frame data
            [floor setTextureRectInPixels:frame.rect rotated:frame.rotated untrimmedSize:frame.originalSizeInPixels]; //re-set its texture rect
            //Ensure that the coordinates are right: Texture frame offset is not counted in when determining normal anchor point:
            xa = 0.5 + (frame.offsetInPixels.x / frame.originalSizeInPixels.width);
            ya = 0.5 + (frame.offsetInPixels.y / frame.originalSizeInPixels.height);
            [floor setAnchorPoint:ccp(xa,ya)];
            floor.position=(where you need it);
    

    Replace the 0.5 in the xa/ya formula with your required anchor point values.

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

Sidebar

Related Questions

Thanks for reading this. I have markup similar to what is below. Using the
Hello and thanks to everyone for reading my question. I've been working on a
Thanks for reading this. I have 2 MySQL databases - master for writes, slave
Hello, thanks for reading my question. I have a string that I need to
Thanks for reading. if we have: var letters = 'a b c h'; //
Thanks for reading this. I would have thought it would be as simple as
Thanks for reading. I've noticed that if I have a page that has one
thanks for reading this. I was wondering if I have some simple authentication system
Thanks for reading. I'm currently working on a database of about 10 entities for
Thanks for reading my question. I have a website that uses PHP for a

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.