本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Body.applyForce方法的典型用法代码示例。如果您正苦于以下问题:Java Body.applyForce方法的具体用法?Java Body.applyForce怎么用?Java Body.applyForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.physics.box2d.Body
的用法示例。
在下文中一共展示了Body.applyForce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyForce
import com.badlogic.gdx.physics.box2d.Body; //导入方法依赖的package包/类
/**
* Apply a force to physics object with a force apply position
*
* @param data
* @param force
* @param applyPoint
*/
protected void applyForce(IPhysicsObject data, Vector2 force,
Vector2 applyPoint) {
Iterator<Body> bi = world.getBodies();
while (bi.hasNext()) {
Body b = bi.next();
IPhysicsObject e;
try {
e = (IPhysicsObject) b.getUserData(); // get the IPhysicsObject
} catch (Exception ex) {
e = null;
}
if (e != null) {
if (e == data) {
if (applyPoint == null)
b.applyForceToCenter(force);
else
b.applyForce(force, applyPoint);
}
}
}
}
示例2: applyForce
import com.badlogic.gdx.physics.box2d.Body; //导入方法依赖的package包/类
/**
* Apply a force to physics object with a force apply position
*
* @param data
* @param force
* @param applyPoint
*/
protected void applyForce(IPhysicsObject data, Vector2 force,
Vector2 applyPoint) {
Iterator<Body> bi = world.getBodies();
while (bi.hasNext()) {
Body b = bi.next();
IPhysicsObject e;
try {
e = (IPhysicsObject) b.getUserData(); // get the IPhysicsObject
} catch (Exception ex) {
e = null;
}
if (e != null) {
if (e == data) {
if (applyPoint == null)
b.applyForceToCenter(force);
else
b.applyForce(force, applyPoint);
}
}
}
}