I have two questions.
1, I saw the sprite move around in the red frame. This is not a problem. But, sprites moving at high speed can pass through walls. Is this a bug?
2, I want to add a body to a dented shape. But I can not make a Physicsbody at once by PhysicsWorld rule.
So I divided it into three. This code is wrong, but what I want to do is here.
I would like to put the Physicsbody divided into three in one figure.
Please tell me the correct code. Thanks
//sprite
auto sprite = Sprite::create(“aaaa.png”);
if (sprite == nullptr)
{
problemLoading("‘aaaa.png’");
}
else
{
sprite->setPosition(Vec2((visibleSize.width/2 + origin.x) +0, (visibleSize.height/2 + origin.y) -400));
}Point spritePoints1[4] = { Point(-68, 43), Point(-55, 43), Point(-55, -8), Point(-68, -8) };
Point spritePoints2[4] =
{
Point(68, 43), Point(55, 43), Point(55, -8), Point(68, -8)
};
Point spritePoints3[4] =
{
Point(-68, -8), Point(68, -8), Point(68, -43), Point(-68, -43)
};auto sprBody = PhysicsBody::createPolygon(spritePoints1, spritePoints2, spritePoints3, 4, PhysicsMaterial(0.0f, 0.0f, 0.5f)); sprBody->setDynamic(false); sprite->setPhysicsBody(sprBody); this->addChild(sprite, 1);