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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:07:18+00:00 2026-06-03T21:07:18+00:00

I have implemented a way to find pixel perfect collision in cocos2d. However, if

  • 0

I have implemented a way to find pixel perfect collision in cocos2d. However, if I have to scale the object pixel perfect collision not working.

     //sprite declaration
    fruit1=[CCSprite spriteWithSpriteFrameName:@"Burger-Cut1.png"]; 
    fruit1.position=ccp(200,100);
    [self addChild:fruit1];

    fruit.scale=0.5;


    //find the collision

   -(bool) isTransparentWithSprite: (CCSprite *)sprite pointInNodeSpace: (CGPoint) point {
NSLog(@"in function");
bool isTransparent = YES;

unsigned int w = 1;
unsigned int h = 1;
unsigned int wh = w * h;
//ccColor4B *buffer = ccColor4B[4];
Byte buffer[4];
// Draw into the RenderTexture
[rt beginWithClear:0 g:0 b:0 a:0];

CGPoint oldPos = sprite.position;
CGPoint oldAnchor = sprite.anchorPoint;
sprite.anchorPoint = ccp(0, 0);
sprite.position = ccp(-point.x, -point.y);

[sprite visit];
sprite.anchorPoint = oldAnchor;
sprite.position = oldPos;

// read the pixels
float x = 0;//local.x;
float y = 0;//local.y;
glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
//NSLog(@"%d: (%f, %f)", sprite.tag, x, y);
[rt end];
// Read buffer
ccColor4B color;
for(unsigned int i=0; i<wh; i++) {
    //color = buffer[i];
    // if untouched, point will be (0, 0, 0, 0). if the sprite was drawn into this pixel (ie not transparent), one of those values will be altered
    if ( buffer[0] || buffer[1] || buffer[2] || buffer[3]) {
        NSLog(@" ");
        NSLog(@"%d %d %d %d=== > ",buffer[0],buffer[1],buffer[2],buffer[3]);
        NSLog(@" ");
        isTransparent = NO;
    }
}
//delete buffer;
return isTransparent;
}
  • 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-03T21:07:20+00:00Added an answer on June 3, 2026 at 9:07 pm

    Your code looks ok, just try to debug it:

    • make special color border in your image (e.g. pink)
    • try to touch into it with scale 1 (or simulate location = ccp(0,0)), if color is pink, then try to touch with scale 0.5

    And one more thing, you could have problem with texture size 1×1 on device. I have such issue once, and should set texture size to 32×32: [[CCRenderTexture alloc] initWithWidth:32 height:32 pixelFormat:kCCTexture2DPixelFormat_RGBA8888];

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

Sidebar

Related Questions

I have implemented HorizontalScrollView to show image. but i cant find way to implement
I have been trying to understand the way ActionScript's events are implemented, but I'm
I have implemented Facebook into my app but now I find that whenever I
I have implemented spring security's remember me feature in our app, the way i
I have implemented an openCV applicationWhere I use SURF descriptor. It is working fine
I have implemented my custom ThreadManager which has been working flawlessly during my tests.
I have implemented a DataGrid that way: <DataGrid x:Name=MyDataGridFilter ItemsSource={Binding} IsSynchronizedWithCurrentItem=True AutoGenerateColumns=False> <DataGrid.Columns> <DataGridTemplateColumn
I have implement a scenario which involves two way communication between child and parent
I'm wondering why I have never seen the following way to implement templates in
I have a class that implements properties in a specific way, to handle some

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.