本文整理匯總了Java中com.badlogic.gdx.physics.box2d.Body.applyForceToCenter方法的典型用法代碼示例。如果您正苦於以下問題:Java Body.applyForceToCenter方法的具體用法?Java Body.applyForceToCenter怎麽用?Java Body.applyForceToCenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.physics.box2d.Body
的用法示例。
在下文中一共展示了Body.applyForceToCenter方法的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);
}
}
}
}