本文整理匯總了Java中org.andengine.extension.debugdraw.DebugRenderer類的典型用法代碼示例。如果您正苦於以下問題:Java DebugRenderer類的具體用法?Java DebugRenderer怎麽用?Java DebugRenderer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DebugRenderer類屬於org.andengine.extension.debugdraw包,在下文中一共展示了DebugRenderer類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createLevel
import org.andengine.extension.debugdraw.DebugRenderer; //導入依賴的package包/類
/**
* Create a new level
*
* @param levelClass class which will show the UI
* @param controllerClass class which will control the level
* @param isTutorial if true, the level is a tutorial level
* @return the created game level
*/
private GameLevel createLevel(Class levelClass, Class controllerClass, boolean isTutorial) {
_physicsWorld = new PhysicsWorld(_gravity, false);
if (isTutorial) {
_backgroundColor = LevelColorUtil.fromLevelColor(LevelColor.PURPLE);
}
GameLevel level;
try {
level = (GameLevel) levelClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
return null;
}
level.init(_width, _height, _scale, _density);
level.createLevel(_physicsWorld, OBSTACLE_FIX_DEF);
createBackground(level.getBackground(), null);
if (_doDebugDraw) {
DebugRenderer debugRenderer = new DebugRenderer(_physicsWorld, _engine.getVertexBufferObjectManager());
_engine.getScene().attachChild(debugRenderer);
}
createSinkHole(level.getSinkholeLocation());
createSpawnHole(level.getBallSpawnLocation());
createBall(level.getBallSpawnLocation());
initTimer(level.getLevelDuration());
createEdgeSensors();
if (controllerClass != null) {
createLevelController(controllerClass, level);
} else {
_levelController = null;
}
_gameLevel = level;
_orientationProvider.start();
_flash = createFlash(_nextBackgroundColor);
_timesUpFlash = createFlash(LevelColorUtil.fromLevelColor(LevelColor.YELLOW));
return level;
}
示例2: createSprites
import org.andengine.extension.debugdraw.DebugRenderer; //導入依賴的package包/類
private void createSprites() {
// attach field marks that have been created in createBackground()
attachChild(mFieldLeft_Sprite);
attachChild(mFieldRight_Sprite);
attachChild(mFieldCenter_Sprite);
float[] startingPosition;
// CREATE PLAYER 1 BEGIN
startingPosition = getKickoffPosition(SPRITE_PLAYER_1);
mPlayer1_Sprite = new TiledSprite(startingPosition[0], startingPosition[1], mResourcesManager.mPlayer1_TextureRegion, mVertexManager);
mPlayer1_Body = createPlayerBody(mPhysicsWorld, mPlayer1_Sprite, BodyType.DynamicBody, ObjectFixtures.getPlayer()); // physics world - object shape - body type - fixture definition
mPlayer1_Body.setFixedRotation(true); // this body may not rotate
mPlayer1_Body.setUserData(BODY_TYPE_PLAYER_1);
mPlayer1_Body.setBullet(true);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(mPlayer1_Sprite, mPlayer1_Body, true, false)); // object shape - body - updates of position - updates of rotation
mPlayer1_Sprite.setUserData(mPlayer1_Body);
mPlayer1_Sprite.setCurrentTileIndex(0);
mPlayer1_Sprite.setCullingEnabled(true); // don't render this sprite if it is not visible on the screen
PlayerData.mPlayer1_isLookingLeft = false;
// CREATE PLAYER 1 END
// CREATE PLAYER 2 BEGIN
startingPosition = getKickoffPosition(SPRITE_PLAYER_2);
mPlayer2_Sprite = new TiledSprite(startingPosition[0], startingPosition[1], mResourcesManager.mPlayer2_TextureRegion, mVertexManager);
mPlayer2_Body = createPlayerBody(mPhysicsWorld, mPlayer2_Sprite, BodyType.DynamicBody, ObjectFixtures.getPlayer()); // physics world - object shape - body type - fixture definition
mPlayer2_Body.setFixedRotation(true); // this body may not rotate
mPlayer2_Body.setUserData(BODY_TYPE_PLAYER_2);
mPlayer2_Body.setBullet(true);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(mPlayer2_Sprite, mPlayer2_Body, true, false)); // object shape - body - updates of position - updates of rotation
mPlayer2_Sprite.setUserData(mPlayer2_Body);
mPlayer2_Sprite.setCurrentTileIndex(1);
mPlayer2_Sprite.setCullingEnabled(true); // don't render this sprite if it is not visible on the screen
PlayerData.mPlayer2_isLookingLeft = true;
// CREATE PLAYER 2 END
// CREATE THE BALL BEGIN
startingPosition = getKickoffPosition(SPRITE_BALL);
mBall_Sprite = new Sprite(startingPosition[0], startingPosition[1], mResourcesManager.mBall_TextureRegion, mVertexManager);
mBall_Body = PhysicsFactory.createCircleBody(mPhysicsWorld, mBall_Sprite, BodyType.DynamicBody, ObjectFixtures.getBall()); // physics world - object shape - body type - fixture definition
mBall_Body.setUserData(BODY_TYPE_BALL);
mBall_Body.setLinearDamping(0.35f); // slows the ball down gradually
mBall_Body.setBullet(true);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(mBall_Sprite, mBall_Body, true, true)); // object shape - body - updates of position - updates of rotation
mBall_Sprite.setUserData(mBall_Body);
// CREATE THE BALL END
attachChild(mPlayer1_Sprite);
attachChild(mPlayer2_Sprite);
attachChild(mBall_Sprite);
if (getDebug() == DEBUG_RENDER) {
DebugRenderer debugger = new DebugRenderer(mPhysicsWorld, mVertexManager);
attachChild(debugger);
}
}