managing multiple gravities with box2d

managing multiple gravities with box2d

ID:22371485

大小:89.50 KB

页数:14页

时间:2018-10-28

managing multiple gravities with box2d_第1页
managing multiple gravities with box2d_第2页
managing multiple gravities with box2d_第3页
managing multiple gravities with box2d_第4页
managing multiple gravities with box2d_第5页
资源描述:

《managing multiple gravities with box2d》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、ManagingmultiplegravitieswithBox2D  OneoftheapparentlyhardestthingstodoayaypleIamtalkingabout.  Thereisoneulatedifferentgravityandoneainscript,directlyfromtheHelloath.*; public class HelloE, Update, false, 0, true);   var __sprite=dbgSprite;   dbgDra_dra_fillAlpha=0.5;   dbgDra_lineThickness=1.0

2、;   dbgDra_dra__Shapes();   bodyDef = ne_Shapes();   for (var i:int = 1; i < 10; i++) {    bodyDef = ne()*12+2;    bodyDef.position.y=Math.random()+5;    var rX:Number=Math.random()+0.2;    var rY:Number=Math.random()+0.2;    if (Math.random()<0.5) {     boxDef = new b2PolygonDef();     bo

3、xDef.SetAsBox(r12345下一页[感谢阅读这篇文章,..,]X, rY);     boxDef.density=1.0;     boxDef.friction=0.5;     boxDef.restitution=0.2;     bodyDef.userData = nee="box";     body=m_e="circle";     body=m_Shapes();    addChild(bodyDef.userData);   }  }  public function Update(e:Event):void {   m__timeStep, m_i

4、terations);  } }}  Theonlyinterestinglinesareline17estotheobjectsboxforboxesandcircleforcircles  Andthisistheresult:  Noethod,called(bymyself).  Theantagonistforcesmethod  Asthenamemeans,theprincipleisapplyinganantagonistforcetocirclesinordertosimulateareversegravity.Sincethedefaultgravityis(0,1

5、0),Iamgoingtoapplya(0,-20)forcetoallcircles.  ThisistheupdatedUpdatefunction:public function Update(e:Event):void { var ant_gravity = b2Vec2; m__timeStep, m_iterations); for (var bb:b2Body = m__bodyList; bb; bb = bb.m_next) {  if (bb.GetUserData()!=null) {   if (bb.GetUserData().name=="circle") 

6、{    ant_gravity = nename="src"value="2009_10/1360672.saysaytocreateobjectsthatarentaffectedbygravityyoujusthavetochangeline88name="src"value="2009_10/1360673.swf"/>上一页12345下一页[感谢阅读这篇文章,..,]  circlesaresloethod,called  Theislandmethod  Thismethodisnamedafterthefilenameofthelibraryyouhavetoeditit

7、sb2Island.asinsideDynamicsfolder.  First,theonlylineinsideUpdatefunctionmustbeonceagainm__timeStep, m_iterations);  asinthefirstexample.  Then,thisisthemodifiedversionofSolvefunctioninsideb2Island.asfile:public function Solv

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。