[**SOLVED**]errer occurred CCRect::CCRectContainsPoint in cocos2d-2.0-x-2.0.2

i’m using this code cocos2d-x1.0.1

//make touch area
for (int i=0; i<14; i++)
{
touchRect[i] = CCRectMake(15+(TileWidth*i), 0, 31, 43);
}

//touch detect
if(CCRect::CCRectContainsPoint(touchRect[i], location))
{
CCLOG (“rect%d area”,i);
}

in cocos2d-2.0-x-2.0.2 touche is disable
plz help

You should enable touches in the layer where you put that on first.

this -> setTouchEnabled( true );
CCDirector::sharedDirector() -> getTouchDispatcher() -> addTargetedDelegate( this, 0, true );

Lance Gray wrote:

You should enable touches in the layer where you put that on first.
>
[…]

already setTouchEnabled

if(CCRect::CCRectContainsPoint(touchRect[i], location))

have warning
‘CCRectContainsPoint’ is deprecated

It’s just a warning. Your app should run fine. It’s just giving you a warning because CCRectContainsPoint( CCRect, CCPoint ) will be removed in future versions but your app will only be affected by it when you upgrade to the new version and you used that new version for your app.

thanks to Lance Gray
CCRectContainsPoint is not problem

How to use touch, right?

void P3Scene::registerWithTouchDispatcher()
{
CCDirector::sharedDirector()->getTouchDispatcher()>addStandardDelegate;
}
bool P3Scene::ccTouchBegan
{
return true;
}
void P3Scene::ccTouchEnded
{
if == false)
{
CCPoint location = touch
>getLocation();
location = CCDirector::sharedDirector()>convertToGL;
CCRect touchRect[14];
for
{
touchRect[i] = CCRectMake, 0, 31, 43);
}
for
{
if)//it means
if(touchRect[i].containsPoint(location))
{
CCLOG (“rect%d area”,i);
if (p1tile[i].c_str()!=nullis)
{
P3Scene::tileOut(i);
}
}
}
}
}

why touch is disable………

You should either register your class as TargetedDelegate or use ccTouches… functions.

it’s my mistake

CCPoint location = touch->getLocation();
location = CCDirector::sharedDirector()>convertToGL;
change this
CCPoint location = touch
>getLocation();
//location = CCDirector::sharedDirector()->convertToGL(location);

Instead of

CCPoint location = touch->getLocation();    
location = CCDirector::sharedDirector()->convertToGL(location);

use

CCPoint location = this -> converTouchToNodeSpace( touch );