How do I get the position of a node made from the DrawNode function?

How do I get the position of a node made from the DrawNode function?
0.0 0

#1

I have drawn a circle using the DrawNode function.
Then I am checking to see if the user is clicking the circle or not

Here I am creating the circle

DrawNode *drawnode = DrawNode::create();
drawnode->drawDot(ccp(10, Director::sharedDirector()->getVisibleSize().height / 5 ), 10, Color4F(2, 99, 2, 2));
drawnode->setPosition(Point(winSize.width / 2.1 + origin.x, winSize.height / 5 + origin.y));
this->addChild(drawnode);

Here is where I am checking to if the user is clicking the Circle

  if(Level::drawnode->getPosition() == touch->getLocation())

{
CCLOG(“Circle has been clicked”);
}
else
{
CCLOG(“Circle has not been clicked”);
}

The problem is this if statement keeps going to the else statement.

How do I get the circles position on the screen so that when the circle is clicked correctly


#2

I’d say this isn’t a good way to check if something has been touched.

use containspoint() and rect.


#3

DrawNode provides no way to tell where you have drawn on it. If you wish to detect when you touch the circle, you will need to remember where the circle was drawn and how large it is, and then check if the touch location is less than the radius from the centre. E.g. if ((circlePos - touch->getLocation()).length <= circleRadius)

circlePos in that example is the world space location of the circle, so you will need to take moving the DrawNode into account.