Hello,
In the scene update function, I am generating a random objects to appear, like boxes, then decided to improve the behavior by checking if there’s any other object in the random point I generated to avoid placing the boxes on top of any other objects.
here’s what I did :
cocos2d::Size visibleSize = Director::getInstance()->getVisibleSize();
cocos2d::Vec2 startPos(random(0, (int)visibleSize.width), random(0, (int)visibleSize.height)); //place of the box
if (!this->getPhysicsWorld()->getShapes(startPos).size() > 0) //this line crashes
//logic to generate
stepping into the getShapes function :
Vector<PhysicsShape*> PhysicsWorld::getShapes(const Vec2& point) const
{
Vector<PhysicsShape*> arr;
cpSpaceNearestPointQuery(_cpSpace,
PhysicsHelper::point2cpv(point),
0,
CP_ALL_LAYERS,
CP_NO_GROUP,
(cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::getShapesAtPointFunc,
&arr);
return arr;
}
The cpSpaceNearestPointQuery function is the one that crashes with the following exception :
Unhandled exception at 0x10069350 (libcocos2d_v3.4_Windows_8.1.dll) in Game.Windows.exe: 0xC0000005: Access violation reading location 0x00000020.
Could you tell me if I am doing something wrong ?
Thanks.