How to scale physics?

When I scale CCSprite with a physical application, the physical body does not scale (I have debugDraw on). How to scale physics?

I found this code to change the radius of a circular physical body, but it does not work on cocos2d v3 ..

    for(ChipmunkCircleShape* newShape in self.chipmunkObjects)
    {
        if([newShape isKindOfClass:[ChipmunkCircleShape class]]) {
            cpCircleShapeSetRadius([newShape shape],[newShape radius]*scale); // Unsafe Resize
            cpCircleShapeSetOffset([newShape shape],ccpMult([newShape offset],scale));
        }
    }
+4
source share
1 answer

Do you include "chipmunk_unsafe.h"? The functions cpCircleShapeSetRadius and cpCircleShapeSetOffset are defined here. Also read the comment here . Hope this helps :)

+1
source

Source: https://habr.com/ru/post/1538458/


All Articles