CCTouchesBegan CRASHES.....

Hi Again.
I got one more problem, when i start my simulator(ipad) and touches it crashes…
Here’s the code: initialize ccTouchesBegan: void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
And Defining the function in cpp:

void Game::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
    CCTouch* touch = (CCTouch*)(pTouches->anyObject());
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    
   
    CCSprite* sprite = CCSprite::create("HelloWorld.png");
    sprite->setPosition(location);
    this->addChild(sprite, 1);
}

I think it is something with the “location”, but not sure, SO PLZZZ HELP ME:)

Can you post a log error, or tell us exactly which line of code is crashing?

It might be happening for many reasons, HelloWorld.png might not be found, so sprite is NULL when you try to make setPosition, for example.
Or ‘this’ could be NULL for some reason!

:slight_smile:

Hi David.
I’m not on my pc right now, but i forgot to tell that it also crashes without the sprite thing.
It also crashes when it is only:
CCTouch touch = (CCTouch*)(pTouches->anyObject());
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);

And i when will sent the log as soon as I get to my pc, if u still want it:)

So do u have any idea??:slight_smile: :wink:
Please xD

mmm, sure try to send me the logs if you want :slight_smile:

Btw, try to remove lines one by one, to track down which line is causing the problem. The problem might be also somewhere else maybe!

Thanks, i did it.
My resultat was that, every time i initialize my location, it crashes…
Can u help:) :frowning:

Or…:wink:

mmm try send me the entire scene files :slight_smile:

And just so u know it, I Really appreciate your help!!!

THAAAAAAANKS, ok wait…:;ok

ok, the link is: http://www.4shared.com/zip/t-haAfWrba/nichlas2.html:)

ok…i have no idea why i didn’t just upload it here, fail…:;sick

and it is on iOS

Here’s the file, if u won’t download it from there…

Hello again!

I tested your code and I was able to run in on many emulators (both iPhone and iPad) with no problem. I attach a screen.

  • On which device is this crashing?
  • Which version of cocos2dx?
  • Which version of Xcode/OSX?
  • Can you provide logs/error messages?

Very stupid point: did you try to clean up the project?

Let me know :slight_smile:

Wooow Strange!!
It crashes on every emulator/simulator…
Cocos2d-x 2.2
I’ve updated Xcode last week, so it is probably the newest version
And it says: thread 1.1 breakpoint 1.2(I dont that matter)…
And i have tried to clean it, delete in organizer and reset in simulator, but still does’nt work…
ANNOYING!!!

What do u mean by attach a screen

what do you mean by “thread 1.1 breakpoint 1.2”? sounds like you set a breakpoint and xcode is catching it? could it be?

Wait, i’m not on my pc right now but in about 3 hours i am…i will check it then!:slight_smile:
But how can i attach a screen?

i don’t know what it is but…here’s an image if u can analyze that…:slight_smile: