当前位置: 首页>>代码示例>>Java>>正文


Java DebugRenderer类代码示例

本文整理汇总了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;
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:56,代码来源:WorldController.java

示例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);
	}
}
 
开发者ID:delight-im,项目名称:NationSoccer,代码行数:57,代码来源:GameScene.java


注:本文中的org.andengine.extension.debugdraw.DebugRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。