games crashes on boundingBox();

Hi,

My game crashes on CCRect rct = pimple[i]->boundingBox();

there is a “Continue” button when i touch exactly on it works fine but if i touch in surrounding area of continue button app gives crash

Pls help

Thanks in advance

Most likely you create your buttons in init() method, put them into std::vector or array and then refer to them in ccTouchEnded. If it’s so, the problem is that your container does not retain objects automatically, so pimple[i] in your case points to who-knows-where. Use CCArray instead or manually retain your button sprites.

Hi,

thanks for the reply. but app gives same problem everywhere i am using boundingBox();
it worls fine on “CONTINUE” button, it gives crash when touched outside the button

Can you please provide a bigger piece of code?

Does the CCRect rct = pimple[i]->boundingBox() line of code get executed when touching the Continue button or do you handle that first and not test the other objects?

What is pimple and pimple[i]?
If it is a CCArray then do you need to convert to something else like a CCSprite?

My eyes bleed

I think some people need to start using the pre tag!

It’s still not obvious what causes a crash - try debugging and looking where pimple[i] points to, I think you problem is caused by not retained objects

Victor Komarov wrote:

My eyes bleed

:slight_smile: kushhal k you got lots of code in this ccTouchesBegan method but I can’t see any declaration of pimple so still this does not say much about the problem. Beside that please use pre tag (preformated text) when posting code insted of code tag.

edit: It probably could show more about the problem if you could post code with declaration of pimple object and code that adds something to this pimple object.

Hmm so it looks like objects are retained by addChild. Are you sure that the code with pimple[i] = CCSprite::create(“pimpul.png”); is exectuded correctly before ccTouchesBegan is called? Maybe “pimpul.png” is not a correct file name or you have this file in wrong directory and sprite is not created correctly or this for loop is not called at all.

Hi,

Thanks, i got the issue i commented the code “return” on cctouches, ccmoved, now i uncommented and it worked fine

Though thanks :slight_smile: