Hi,
I’m using cocos2dx 3.3 ver. working on android project.
I draw a line like this -
rectNode = DrawNode::create();
Vec2 rectangle[2];
rectangle[0] = Vec2(0, -50);
rectangle[1] = Vec2(0, 50);
Color4F white(1, 1, 1, 1);
rectNode->drawLine(rectangle[0],rectangle[1],white);
rectNode->setPosition(Vec2(650,200));
this->addChild(rectNode,5);
And code for detecting collision with this line is as follows-
if(rectNode->getBoundingBox().intersectsRect(SpritePlayer->getBoundingBox()))
{
lable->setString(“Collide”);
}else
lable->setString(“No Collide”);
The above code shows collision only from middle point of the line.
Not from complete line.
Why ?
please tell me how can I detect collision of player with any part of line ?