简体   繁体   English

如何移动与另一个b2body相连的我的一个b2body

[英]how to move my one b2body attached with another b2body

i am very new to cocos2d ,i have started working with rope physics.i am using vrope class for creating ropes.i have implemented one rope attached with one polygon shaped b2body ,now i have fixed one end of my rope on top of the screen and one end with my polygon shaped dynamic b2body , it looks like it's hanging in air.now what i want is by applying some force on my b2body(dynamic body) , i want it falling down from top to bottom means i want to move my this body1 which is attached with rope towards ground along with that rope , i am trying like this :applying force on my b2body : 我是cocos2d的新手,我已经开始从事绳索物理学的工作。我正在使用vrope类来创建绳索。我已经实现了一根绳索与一个多边形b2body的连接,现在我已经将绳索的一端固定在屏幕顶部一端是多边形的动态b2body,看起来好像悬挂在空中。现在我想要的是对b2body(动态物体)施加一些力,我希望它从上到下掉落,这意味着我想移动我的这个body1和那条绳索一起用绳子朝向地面连接,我正在这样尝试:在我的b2body上施加力:

in my update() method : 在我的update()方法中:

   body1->ApplyForce(b2Vec2(0.0 , 9.8 * body1->GetMass()*100 ), body1->GetWorldCenter());

but ,somehow this not working . 但是,这不起作用。

i searched a lot on this but still i don't find anything which can help me for this . 我对此进行了很多搜索,但仍然找不到任何可以帮助我解决这个问题的方法。 it would be appreciated if any kind of help. 如果有任何帮助,将不胜感激。

If you want to make the body fall along with the rope. 如果要使身体与绳索一起掉落。 Then before you apply some force to that body1, instead of attaching a static body at other end, attach the body with very small dynamic body. 然后,在对该物体施加一些力之前,不要在另一端附加静态物体,而应使用很小的动态物体附加该物体。 In this way the body1 will fall down along with the rope 这样,body1将与绳索一起掉落

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

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