Hi, there is a scene where it works Ray Cast,
void GameScena::RayCast_tick(float dt)
{
Vec2 point1 = Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y);
Vec2 d(visibleSize.height / 2.1 * cosf(_angle), visibleSize.height / 2.1 * sinf(_angle));
Vec2 point2 = point1 + d;
if (_drawNode)
{
removeChild(_drawNode);
}
_drawNode = DrawNode::create();
Vec2 point3 = point2;
auto func = CC_CALLBACK_3(GameScena::anyRay, this);
_world->rayCast(func, point1, point2, &point3);
_drawNode->drawSegment(point1, point3, 1, Color4F::RED);
if (point2 != point3)
{
_drawNode->drawDot(point3, 2, Color4F(1.0f, 1.0f, 1.0f, 1.0f));
}
addChild(_drawNode);
_angle += dt;
}
bool GameScena::anyRay(PhysicsWorld&_world, const PhysicsRayCastInfo& info, void* data)
{
*((Vec2*)data) = info.contact;
return false;
}
After that, when you change the scene and go back on stage with Ray Cast is an error
Vector
bool empty() const _NOEXCEPT
{ // test if sequence is empty
return (this->_Myfirst == this->_Mylast);
}
If you disable
// _world->rayCast(func, point1, point2, &point3);
There is no error and everything is working fine
How can I fix this error?