當前位置: 首頁>>代碼示例>>Java>>正文


Java Camera類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.Camera的典型用法代碼示例。如果您正苦於以下問題:Java Camera類的具體用法?Java Camera怎麽用?Java Camera使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Camera類屬於com.badlogic.gdx.graphics包,在下文中一共展示了Camera類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: renderForCamera

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
public void renderForCamera(Camera camera) {
    spriteBatch.begin();
    spriteBatch.draw(background, 0, 0, viewport.getWorldWidth(), viewport.getWorldHeight(), (int)(scroll / (float)length * (background.getWidth() - viewport.getScreenWidth())), 0, viewport.getScreenWidth(), (int)viewport.getWorldHeight(), false, false);
    for(int i = 0; i < campaignWorlds.size(); i++)
        if(segmentWidth + i * segmentWidth - scroll > 0 && halfFreeWidth + i * segmentWidth - scroll < background.getWidth() - viewport.getWorldWidth())
            spriteBatch.draw(campaignWorlds.get(i).icon, halfFreeWidth + i * segmentWidth - scroll, viewport.getWorldHeight() / 2f - ICON_SIZE / 2);
    if(selection != -1) {
        layout.setText(game.getFonts().get("moonhouse64"), campaignWorlds.get(selection).name);
        spriteBatch.draw(textBack, viewport.getWorldWidth() / 2 - (layout.width + 40) / 2, viewport.getWorldHeight() - 72 - layout.height, layout.width + 40, layout.height + 40);
        game.getFonts().get("moonhouse64").draw(spriteBatch, campaignWorlds.get(selection).name, viewport.getWorldWidth() / 2 - layout.width / 2, viewport.getWorldHeight() - 10 - layout.height);
        layout.setText(game.getFonts().get("moonhouse64"), campaignWorlds.get(selection).desc);
        spriteBatch.draw(textBack, viewport.getWorldWidth() / 2 - (layout.width + 40) / 2, layout.height + 20, layout.width + 40, layout.height + 40);
        game.getFonts().get("moonhouse64").draw(spriteBatch, campaignWorlds.get(selection).desc, viewport.getWorldWidth() / 2 - layout.width / 2, layout.height + 83);
    }
    spriteBatch.end();
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:18,代碼來源:CampaignScreen.java

示例2: keepInBoundaries

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
private void keepInBoundaries(){
    final Camera camera = viewport.getCamera();
    final Vector3 position = camera.position;
    if(position.x < boundary.x){
        position.x = boundary.x;
    }
    if(position.x > boundary.x + boundary.width){
        position.x = boundary.x + boundary.width;
    }
    if(position.y < boundary.y){
        position.y = boundary.y;
    }
    if(position.y > boundary.y + boundary.height) {
        position.y = boundary.y + boundary.height;
    }
}
 
開發者ID:unlimitedggames,項目名稱:gdxjam-ugg,代碼行數:17,代碼來源:CameraController.java

示例3: update

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
   public void update(Entity entity, GameWorld world, Map map, Camera camera, float deltaTime) {
if (State.IMMOBILE != state) {
    stateTime -= deltaTime;
    if (stateTime <= 0) {
	// change state
	stateTime = MathUtils.random(2);
	State nextState = State.getRandom();
	if (State.WALKING == nextState) {
	    entity.sendMessage(MessageType.SET_STATE, State.WALKING, Direction.getRandom());
	} else {
	    entity.sendMessage(MessageType.SET_STATE, nextState);
	}
    }

}
   }
 
開發者ID:Quillraven,項目名稱:Quilly-s-Castle,代碼行數:18,代碼來源:NPCAIComponent.java

示例4: updateCamera

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
private void updateCamera()
{
    if (!GameEntityManager.getGameEntities().contains(this.level.getShip()))
    {
        return;
    }
    Camera camera = SpaceTravels3.gameViewport.getCamera();

    camera.position.set(
        this.level.getShip().physicsComponent.getPosition().x,
        this.level.getShip().physicsComponent.getPosition().y,
        0f);
    camera.update();

    SpaceTravels3.spriteBatch.setProjectionMatrix(camera.combined);
}
 
開發者ID:overengineering,項目名稱:space-travels-3,代碼行數:17,代碼來源:GameScreen.java

示例5: update

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
public void update(float deltaTime, Camera camera) {
	sun.update(!isWorldMap());
	updateLocalGameObjects(deltaTime);
	super.update(deltaTime, camera);
	for (GameLocation loc : locations) {
		loc.update(deltaTime, camera);
	}
	
	fogOfWarRayHandler.setCombinedMatrix(camera.combined);
	fogOfWarRayHandler.update();
	unpausableTweenManager.update(deltaTime);
	if (!GameState.isPaused()) {
		tweenManager.update(deltaTime);
		if (particleEffectManager != null) {
			particleEffectManager.update(deltaTime);
		}
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:20,代碼來源:GameMap.java

示例6: updateFastForward

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
private float updateFastForward(float deltaTime, Camera camera) {
	if (fastForwarding && fastForwarded >= fastForwardBy) {
		fastForwarding = false;
		UIManager.hideProgressDialog();
		if (fastForwardCallback != null) {
			fastForwardCallback.onFinished();
		}
		fastForwardCallback = null;
	}
	
	if (fastForwarding && !isPaused) {
		int currentTimeMultiplier = currentMap.getGameTimeMultiplier();
		deltaTime = Configuration.getFastForwardStep()
				* Math.max(Configuration.getWorldGameTimeMultiplier(),
						Configuration.getLocalGameTimeMultiplier())
				/ currentTimeMultiplier;
		fastForwarded += deltaTime;
		UIManager.updateProgressDialog((fastForwarded / 3600) * currentTimeMultiplier);
		if (fastForwardRandomEncounter != null && fastForwarded >= fastForwardRandomAfter) {
			handleFastForwardRandomEncounter();
		}
	}
	return deltaTime;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:25,代碼來源:GameState.java

示例7: render

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
public void render(ModelBatch batch, Environment environment) {
        if (drawShapes) {
            batch.render(hub.modelInstance, environment);
            batch.render(rim.modelInstance, environment);

            for (int i = 0; i < spokesToDraw; i++) {
                spokes.get(i).updateSpokeRender();
                batch.render(spokes.get(i).modelInstance, environment);
            }
//            spokes.forEach(s -> batch.render(s.modelInstance, environment));
//            bulletWorld.updateAabbs();
        }


        if (debugDrawer.getDebugMode() > 0) {
            Camera camera = batch.getCamera();
            batch.flush();
            debugDrawer.begin(camera);
            bulletWorld.debugDrawWorld();
            debugDrawer.end();
        }
    }
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:23,代碼來源:WheelWorld.java

示例8: render

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
public void render(ModelBatch batch, Environment environment) {
        if (drawShapes) {
            for (WorldEntity entity : entities) {
                batch.render(entity.instance, environment);
            }

            batch.render(instances);
        }

        if (getDebugMode() > 0) {
            Camera camera = batch.getCamera();
            batch.flush();
            debugDrawer.begin(camera);
            bulletWorld.debugDrawWorld();
            debugDrawer.end();
//            batch.begin(camera);
        }
    }
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:19,代碼來源:World.java

示例9: populate

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
public void populate(TiledMap tiledMap, State state, Camera camera, MapLayerRendererFactory rendererFactory,
      TiledMapConfig config) {
   MapLayers mapLayers = tiledMap.getLayers();
   handleMapProperties(tiledMap.getProperties(), state, config);
   List<String> layerIds = new ArrayList<String>();
   int lastTileLayerIndex = 0;
   for (int i = 0; i < mapLayers.getCount(); ++i) {
      MapLayer mapLayer = mapLayers.get(i);
      if (mapLayer instanceof TiledMapTileLayer) {
         if (i > 0) {
            lastTileLayerIndex++;
         }
         String layerId = handleTiledMapTileLayer((TiledMapTileLayer) mapLayer, i, tiledMap, camera, rendererFactory,
               config);
         layerIds.add(layerId);
         populateStaticMapData(lastTileLayerIndex, (TiledMapTileLayer) mapLayer, state, config);
      } else {
         // Not a tiledlayer so consider it as an object layer
         handleObjectLayer(lastTileLayerIndex, mapLayer, state, config);
      }
   }
   state.setLayerIds(layerIds);
}
 
開發者ID:bitbrain,項目名稱:braingdx,代碼行數:24,代碼來源:StatePopulator.java

示例10: draw

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
/**
 * Draws the view with all information depending on the subclass.
 * 
 * @param sp
 *            The sprite batch to draw on.
 * @param position
 *            The position of the view in pixel coordinates.
 */
public void draw(SpriteBatch sp, Point position)
{
	METRO.__spriteBatch.end();
	METRO.__spriteBatch.begin();
	
	// Create scissor to draw only in the area of the statistic view.
	com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
	com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(position.x + METRO.__getXOffset(), position.y + METRO.__getYOffset(), _size.x + 1, _size.y
	        + 1);
	ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
	ScissorStack.pushScissors(scissors);
	
	drawView(sp);
	
	ScissorStack.popScissors();
}
 
開發者ID:hauke96,項目名稱:METRO,代碼行數:25,代碼來源:AbstractTrainStatisticView.java

示例11: draw

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
protected void draw()
{
	METRO.__spriteBatch.end();
	METRO.__spriteBatch.begin();
	
	// Create scissor to draw only in the area of the list box.
	com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
	com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(_area.x + METRO.__getXOffset(), _area.y + METRO.__getYOffset(), _area.width
	        + 1, _area.height + 1);
	ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
	ScissorStack.pushScissors(scissors);
	
	if (_decorated) clearBackground();
	
	drawEntries();
	
	if (_decorated) drawBorders();
	
	drawScrollbar();
	
	ScissorStack.popScissors();
}
 
開發者ID:hauke96,項目名稱:METRO,代碼行數:24,代碼來源:List.java

示例12: draw

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
protected void draw()
{
	Contract.RequireNotNull(_painter);
	
	Draw.setOffset(_area.x, _area.y);
	Fill.setOffset(_area.x, _area.y);
	
	com.badlogic.gdx.math.Rectangle scissors = new com.badlogic.gdx.math.Rectangle();
	com.badlogic.gdx.math.Rectangle clipBounds = new com.badlogic.gdx.math.Rectangle(_area.x + METRO.__getXOffset(), _area.y + METRO.__getYOffset(), _area.width
	        + 1, _area.height + 1);
	
	ScissorStack.calculateScissors((Camera) METRO.__camera, METRO.__spriteBatch.getTransformMatrix(), clipBounds, scissors);
	ScissorStack.pushScissors(scissors);
	
	_painter.paint();
	
	ScissorStack.popScissors();
	
	Draw.setOffset(METRO.__getXOffset(), METRO.__getYOffset());
	Fill.setOffset(METRO.__getXOffset(), METRO.__getYOffset());
}
 
開發者ID:hauke96,項目名稱:METRO,代碼行數:23,代碼來源:Canvas.java

示例13: begin

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
@Override
public void begin(Camera camera, RenderContext context) {
	program.begin();
	viewProjTrans.set(camera.combined);

	program.setUniformf(u_cameraPosition, camera.position.x, camera.position.y, 
			camera.position.z, 1);
	program.setUniformf(u_worldLightDir, lightDirection.x, lightDirection.y, lightDirection.z, 0);

	context.setDepthTest(GL20.GL_LEQUAL);
	context.setCullFace(GL20.GL_BACK);
	context.setBlending(shouldFadeEnds ? true : false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

	texture.bind(0);
	program.setUniformi(u_texture, 0);

	specLUT.getTexture().bind(1);
	program.setUniformi(u_specularPowerLUTTexture, 1);

}
 
開發者ID:CypherCove,項目名稱:DoubleHelix,代碼行數:21,代碼來源:SubsurfaceScatteringShader.java

示例14: ParticleGroupStrategy

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
public ParticleGroupStrategy(final Camera camera) {
    this.camera = camera;

    cameraSorter = new Comparator<Decal>() {
        @Override
        public int compare (Decal o1, Decal o2) {
            return (int)Math.signum(((DecalPlus)o2).cameraDistance - ((DecalPlus)o1).cameraDistance);
        }
    };

    billboardCameraSorter = new Comparator<BillboardDecal>() {
        @Override
        public int compare (BillboardDecal o1, BillboardDecal o2) {
            return (int)Math.signum(o2.floatValue - o1.floatValue);
        }
    };

    loadShaders();
}
 
開發者ID:CypherCove,項目名稱:DoubleHelix,代碼行數:20,代碼來源:ParticleGroupStrategy.java

示例15: replaceCameraActuator

import com.badlogic.gdx.graphics.Camera; //導入依賴的package包/類
public ActuatorEntity replaceCameraActuator(Camera camera, short height,
		float damping, float minDistanceX, float minDistanceY,
		String followTagEntity) {
	CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
	if (component == null) {
		component = new CameraActuator(camera, height, damping,
				minDistanceX, minDistanceY, followTagEntity);
	} else {
		component.actuator = (indexOwner) -> {
			Set<GameEntity> followEntities = Indexed
					.getTagEntities(followTagEntity);
			for (GameEntity followEntity : followEntities) {
				RigidBody rc = followEntity.getRigidBody();
				Transform transform = rc.body.getTransform();
				Vector3 position = camera.position;
				position.x += (transform.getPosition().x + minDistanceX - position.x)
						* damping;
				position.y += (transform.getPosition().y + minDistanceY - position.y)
						* height;
			}
		};
	}
	replaceComponent(ActuatorComponentsLookup.CameraActuator, component);
	return this;
}
 
開發者ID:Rubentxu,項目名稱:Entitas-Java,代碼行數:26,代碼來源:ActuatorEntity.java


注:本文中的com.badlogic.gdx.graphics.Camera類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。