Unable to use intersectsRect


#1

hello every1.

i have written the following code but am unable to utilize intersects Rect

if somebody can tell me what am i doing wrong…. The sprites get delted by the commented lines in selector method but same is not working in intersectsRect

//
// TestLayer.cpp
// cocos2d-xBox-2d
//
// Created by Er.Umesh on 16/05/13.
//
//

#include “TestLayer.h”
//TestLayer::TestLayer(){
//
//}
bool TestLayer::init() {
int returnLayer = false;
if (!(CCLayer::init()) ){
return returnLayer;
} else {
returnLayer = true;
s = cocos2d::CCDirector::sharedDirector()->getWinSize();

cocos2d::CCLabelTTF label = cocos2d::CCLabelTTF::create;
addChild;
label~~>setColor);
label~~>setPosition);
float anchorPoint1 = 0;
float anchorPoint2 = 0;
jumpTestSprite = CCSprite::create;
// jumpTestSprite~~>setAnchorPoint);
jumpTestSprite~~>setPosition.height/2, jumpTestSprite~~>getContentSize.width/2));
addChild;
jumpTestSprite2 = CCSprite::create;
// jumpTestSprite2~~>setAnchorPoint);
jumpTestSprite2~~>setPosition.height/2+jumpTestSprite2~~>getContentSize.width, jumpTestSprite2~~>getContentSize.width/2));
addChild;
rectTestSprite = CCSprite::create;
// rectTestSprite~~>setAnchorPoint);
rectTestSprite~~>setPosition.width, rectTestSprite~~>getContentSize.height/2));
addChild;
// Not working
rect1 = CCRectMake.x - .width/2),
jumpTestSprite~~>getPosition.y~~ .height/2),
jumpTestSprite~~>getContentSize.width,
jumpTestSprite~~>getContentSize.height);
rect2 = CCRectMake.x - .width/2),
jumpTestSprite2~~>getPosition.y~~ .height/2),
jumpTestSprite2~~>getContentSize.width,
jumpTestSprite2~~>getContentSize.height);
rect3 = CCRectMake.x - .width/2),
rectTestSprite~~>getPosition.y~~ .height/2),
rectTestSprite~~>getContentSize.width,
rectTestSprite~~>getContentSize.height);
this->schedule);
CCDirector::sharedDirector->getTouchDispatcher->addTargetedDelegate;
printf;
return returnLayer;
}
}
bool TestLayer::ccTouchBegan{
printf;
return true;
}
/

rect1.getMaxX() < rect2.getMinX() ||
rect2.getMaxX() < rect1.getMinX() ||
rect1.getMaxY() < rect2.getMinY() ||
rect2.getMaxY() < rect1. getMinY()
/
void TestLayer::schedularTestMethod{
if {
if .x > rectTestSprite~~>getPosition.x~~ rectTestSprite~~>getContentSize.width && jumpTestSprite~~>getPosition.x < rectTestSprite~~>getPosition.x + rectTestSprite~~>getContentSize.width && jumpTestSprite~~>getPosition.y > rectTestSprite~~>getPosition.y - rectTestSprite~~>getContentSize.height && jumpTestSprite~~>getPosition.y < rectTestSprite~~>getPosition.y + rectTestSprite~~>getContentSize.height) {
// this~~>removeChild;
// CC_SAFE_RELEASE_NULL;
}
if ) {
this~~>removeChild;
CC_SAFE_RELEASE_NULL;
}
}
if {
if .x > rectTestSprite~~>getPosition.x~~ rectTestSprite~~>getContentSize.width && jumpTestSprite2~~>getPosition.x < rectTestSprite~~>getPosition.x + rectTestSprite~~>getContentSize.width && jumpTestSprite2~~>getPosition.y > rectTestSprite~~>getPosition.y - rectTestSprite~~>getContentSize.height && jumpTestSprite2~~>getPosition.y < rectTestSprite~~>getPosition.y + rectTestSprite~~>getContentSize.height) {
// this~~>removeChild;
// CC_SAFE_RELEASE_NULL;
}
if ) {
this~~>removeChild;
CC_SAFE_RELEASE_NULL;
}
}
}
void TestLayer::ccTouchEnded {
float jumpTime = 1;
if {
jumpTestSprite~~>runAction, s.height/3, 1));
}
if {
jumpTestSprite2~~>runAction, s.height/3, 1));
}
}
TestLayer
TestLayer::create()
{
TestLayer * pRet = new TestLayer();
// CCDirector::sharedDirector()>setTouchDispatcher;
if )
{
pRet
>autorelease();
}
else
{
CC_SAFE_DELETE(pRet);
}
return pRet;
}