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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:02:39+00:00 2026-06-09T17:02:39+00:00

I’m trying to create a destroyable world with Cocos2D and I did some reading

  • 0

I’m trying to create a destroyable world with Cocos2D and I did some reading on the subject, but I can’t really figure out how to get it working properly.

I have a very simple test at the moment; the screen is black and a touch will draw a white circle on the touched location with CCRenderTexture.

This is my test:

// Get the black background

- (CCSprite *)sprite
{
    CGSize winSize = [CCDirector sharedDirector].winSize;
    self.renderTexture = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height];
    [self.renderTexture beginWithClear:0.0 g:0.0 b:0.0 a:1.0];
    [self.renderTexture end];
    return [CCSprite spriteWithTexture:self.renderTexture.sprite.texture];
}

- (void)generateBackground
{
    background = [self sprite];

    CGSize winSize = [CCDirector sharedDirector].winSize;
    background.position = ccp(winSize.width/2, winSize.height/2);

    [self addChild:background z:-1];
}

// Draw the white circle

- (void)generateExplosionWithTouch:(UITouch *)touch
{
    [self.renderTexture begin];

    CGPoint location = [touch locationInView:touch.view];
    location = [self convertToNodeSpace:location];

    ccDrawCircle(location, 30.0, 5.0, 360, NO);

    [self.renderTexture end];
}

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [touches anyObject];
    [self generateExplosionWithTouch:touch];
}

I add a sprite after adding the black background:

CGSize winSize = [CCDirector sharedDirector].winSize;
self.icon = [CCSprite spriteWithFile:@"Icon.png"];
self.icon.position = ccp(winSize.width / 2, winSize.height / 2);
[self addChild:self.icon];

Is there an easy method to check if the sprite is on a black/white area with some kind of pixel collision check?

I’ve seen this question before, but the answer always was something like: “Just check with a simple black/white image if it’s on the black or white area”, ok, but how? 😛

Thank you,

Rick

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

    If you want to do pixel collision check, here you can find a tutorial in 2 parts with code and references.

    One alternative approach could be this:

    1. you use a CCRenderTexture to do the rendering (as you are doing now);

    2. instead of adding the CCRenderTexture to your layer/parent node, you create a sprite from it:

          return [CCSprite spriteWithTexture:renderTexture.sprite.texture];
      

      and add this one to your layer/parent.

    By doing like this, you will have all of your explosions represented by a sprite, then you can do collision checking.

    By the way, in the approach I suggest, you create a new CCRenderTexture for each explosion.

    Another approach would be doing just like you are doing now, i.e., using one CCRenderTexture and draw everything inside of it, while at the same time also keeping a list of explosion CCNodes (i.e., you also add a CCNode to your layer/parent for each explosion). Then you would do collision detection on the CCNodes.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.