Answer the question
In order to leave comments, you need to log in
Different coordinate systems for events and rendering?
If you put a listener on a click and display the coordinates of the click
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->setSwallowTouches(false);
touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorldScene::onTouchBegan, this);
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);
DrawNode* circleInner = DrawNode::create();
circleInner->drawDot(
Vec2(0, 0),
55,
Color4F::BLUE
);
this->addChild(circleInner);
float distSquared = touch->getLocationInView().getDistance(circleInner->getPosition());
CCLOG(" distSquared %f", distSquared);
Answer the question
In order to leave comments, you need to log in
A clumsy solution a day later found here
auto height = Director::getInstance()->getOpenGLView()->getFrameSize().height;
location.y = height - location.y;
auto height = Director::getInstance()->getOpenGLView()->getFrameSize().height;
auto width = Director::getInstance()->getOpenGLView()->getFrameSize().width;
circleInner->getBoundingBox().containsPoint(
Vec2(
width - touch->getLocationInView().x,
height - touch->getLocationInView().y
)
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question