简体   繁体   English

如何扩展物理学?

[英]How to scale physicsBody?

When I scale a CCSprite with a physicsbody attached the physics body doesn't scale (I have debugDraw on). 当我使用物理体附加缩放CCSprite时,物理体不会缩放(我有debugDraw)。 How do I scale the physicsBody? 如何缩放物理体?

I found this code to change the radius of a circular physical body but it doesn't work on cocos2d v3.. 我发现这个代码改变了圆形物理体的半径,但它不适用于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));
        }
    }

Do you include "chipmunk_unsafe.h"? 你有“chipmunk_unsafe.h”吗? Functions cpCircleShapeSetRadius and cpCircleShapeSetOffset are defined there. 函数cpCircleShapeSetRadius和cpCircleShapeSetOffset在那里定义。 Read also the comment here . 另请阅读此处的评论。 Hope it helps :) 希望能帮助到你 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM