By
被删
更新日期:
本节主要介绍获取刚体的各属性。
获取刚体的各属性
Body.Get属性名()
在实际编程中,往往需要得到一些关于刚体的信息、数据等,以便下一步对刚体进行一系列操作。
下面代码中给出了获取某些数据的方法,还有一些设置刚体属性的语句。语法格式一般为Body.Get属性名()。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| function showAllFuc() { var OriginPosition = new b2Vec2(); OriginPosition = slectBody.GetOriginPosition(); alert(OriginPosition.x + "," + OriginPosition.y);
var mass; mass = slectBody.GetMass();
var inertia; inertia = slectBody.GetInertia(); alert(inertia);
var worldPoint; var localPoint = new b2Vec2(100, 100); worldPoint = slectBody.GetWorldPoint(localPoint); alert(slectBody.GetCenterPosition().x + "," + slectBody.GetCenterPosition().y); alert(localPoint.x + "," + localPoint.y); alert(worldPoint.x + "," + worldPoint.y);
var localVector; var worldVector = new b2Vec2(slectBody.GetCenterPosition().x, slectBody.GetCenterPosition().y); localVector = slectBody.GetLocalVector(worldVector); alert(worldVector.x + "," + worldVector.y); alert(localVector.x + "," + localVector.y);
var staticFlage; staticFlage = slectBody.IsStatic(); alert(staticFlage);
var frozenFlage; frozenFlage = slectBody.IsFrozen(); alert(frozenFlage);
var sleepingFlage; sleepingFlage = slectBody.IsSleeping(); alert(sleepingFlage);
var allowSleepingFlage = 1; slectBody.AllowSleeping(allowSleepingFlage); slectBody.WakeUp();
var shapeList = new Array(); shapeList = slectBody.GetShapeList(); slectBody.Destroy(); slectBody.GetNext();
var otherBody = Body4; var conectJuge; conectJuge = slectBody.IsConnected(otherBody); alert(conectJuge); }
|
查看Github有更多内容噢:https://github.com/godbasin
更欢迎来被删的前端游乐场边撸猫边学前端噢
如果你想要关注日常生活中的我,欢迎关注“牧羊的猪”公众号噢