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


Java PolygonSpriteBatch类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch的典型用法代码示例。如果您正苦于以下问题:Java PolygonSpriteBatch类的具体用法?Java PolygonSpriteBatch怎么用?Java PolygonSpriteBatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PolygonSpriteBatch类属于com.badlogic.gdx.graphics.g2d包,在下文中一共展示了PolygonSpriteBatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCommand

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void onCommand(PolygonSpriteBatch batch) {
   	if(_shaderProgram == null) {
   		ShaderProgram p = GLProgramCache.getInstance().getSpriteBatchDefaultProgram();
   		if(batch.getShader() != p) {
   			batch.setShader(null);
   		}
   	} else {
   		if(batch.getShader() != _shaderProgram) {
   			batch.setShader(_shaderProgram);
   		}
   	}
   	if(_sprite.getTexture() != null) {
   		_sprite.draw(batch);
   	}
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:17,代码来源:Sprite.java

示例2: GameObjectMap

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
GameObjectMap(AssetMap assetMap) {

        this.assetMap = assetMap;
        batch = new PolygonSpriteBatch();
        shapeRenderer = new ShapeRenderer();

        Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
        pix.setColor(Color.WHITE);
        pix.fill();
        texture = new Texture(pix);

        regionMap = new HashMap<>();
        regionNameMap = new HashMap<>();

        initPolygonRegions();
    }
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:17,代码来源:GameObjectMap.java

示例3: Water

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
/**
 * Constructor that allows to specify if there is an effect of waves and splash particles.
 * @param waves Specifies whether the object will have waves
 * @param splashParticles Specifies whether the object will have splash particles
 */
public Water(boolean waves, boolean splashParticles) {

	this.waves = waves;
	this.splashParticles = splashParticles;
	this.fixturePairs = new HashSet<Pair<Fixture, Fixture>>();
	this.setDebugMode(false);

	if (waves) {
		textureWater = new TextureRegion(new Texture(Gdx.files.internal("water.png")));
		polyBatch = new PolygonSpriteBatch();
	}

	if (splashParticles) {
		textureDrop = new Texture(Gdx.files.internal("drop.png"));
		spriteBatch = new SpriteBatch();
		particles = new ArrayList<Particle>();
	}

	shapeBatch = new ShapeRenderer();
	shapeBatch.setColor(0, 0.5f, 1, 1);
}
 
开发者ID:jocasolo,项目名称:water2d-libgdx,代码行数:27,代码来源:Water.java

示例4: draw

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void draw(GameMapRenderer renderer, float deltaTime) {
	super.draw(renderer, deltaTime);
	if (!hasSprite()) {
		PlayerCharacterController controller = gameState.getPlayerCharacterController();
		Tool activeTool = controller.getActiveTool();
		
		PolygonSpriteBatch spriteBatch = renderer.getSpriteBatch();
		int src = spriteBatch.getBlendSrcFunc();
		int dst = spriteBatch.getBlendDstFunc();
		if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
			spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
		}
		spriteBatch.setColor(isHovered() && activeTool == Tool.DISARM ? ColorUtil.GREEN_SEVENFIVE : ColorUtil.RED_SEVENFIVE);
		polygonRenderer.render(spriteBatch);
		if (src != GL20.GL_SRC_ALPHA || dst != GL20.GL_ONE) {
			spriteBatch.setBlendFunction(src, dst);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:21,代码来源:UsableGameObject.java

示例5: show

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void show () {
	font = new BitmapFont(Gdx.files.internal("fonts/font.fnt"));
	cache = font.getCache();

	if (Gdx.app.getType() == ApplicationType.Android)
		font.getData().setScale(2);
	polygonBatch = new PolygonSpriteBatch();
	camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

	Pixmap pixMap = new Pixmap(1, 1, Format.RGB565);
	pixMap.setColor(Color.WHITE);
	pixMap.fill();
	emptyTexture = new Texture(pixMap);
	pixMap.dispose();
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:17,代码来源:RemoteEditLoadingScreen.java

示例6: create

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
	texture = new Texture(Gdx.files.internal("data/tree.png"));

	PolygonRegionLoader loader = new PolygonRegionLoader();
	region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));

	// create a region from an arbitrary set of vertices (a triangle in this case)
	region2 = new PolygonRegion(new TextureRegion(texture), new float[] {0, 0, 100, 100, 0, 100}, new short[] {0, 1, 2});

	camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	camera.position.x = 0;
	camera.position.y = 0;

	batch = new PolygonSpriteBatch();
	debugRenderer = new PolygonRegionDebugRenderer();

	Gdx.input.setInputProcessor(this);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:PolygonRegionTest.java

示例7: create

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
	texture = new Texture(Gdx.files.internal("data/tree.png"));

	PolygonRegionLoader loader = new PolygonRegionLoader();
	region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh"));

	renderer = new ShapeRenderer();

	camera = new OrthographicCamera(480, 320);
	camera.position.x = 240;
	camera.position.y = 160;
	camera.update();

	batch = new PolygonSpriteBatch();

	for (int i = 0; i < 50; i++) {
		PolygonSprite sprite = new PolygonSprite(region);
		sprite.setPosition(MathUtils.random(-30, 440), MathUtils.random(-30, 290));
		sprite.setColor(MathUtils.random(), MathUtils.random(), MathUtils.random(), 1.0f);
		sprite.setScale(MathUtils.random(0.5f, 1.5f), MathUtils.random(0.5f, 1.5f));
		sprites.add(sprite);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:PolygonSpriteTest.java

示例8: createStage

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
protected Stage createStage() {
	batch = new PolygonSpriteBatch(2500) {
		final int MAX = 2500 * 5;

		@Override
		public void draw(Texture texture, float[] spriteVertices,
				int offset, int count) {
			while (count > MAX) {
				super.draw(texture, spriteVertices, offset, MAX);
				offset += MAX;
				count -= MAX;
			}
			super.draw(texture, spriteVertices, offset, count);
		}
	};
	return new Stage(new ScreenViewport(), batch);
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:18,代码来源:EditorApplicationListener.java

示例9: setup

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Before
public void setup() {
	mockery = new Mockery();
	mockery.setImposteriser(ClassImposteriser.INSTANCE);
	gameWrapper = mockery.mock(GameWrapper.class);
	spriteBatch = mockery.mock(SpriteBatch.class);
	polygonSpriteBatch = mockery.mock(PolygonSpriteBatch.class);
	shapeRenderer = mockery.mock(ShapeRenderer.class);
	gdxGraphics = mockery.mock(com.badlogic.gdx.Graphics.class);
	Gdx.graphics = gdxGraphics;
	
	mockery.checking(new Expectations() {
		{
			one(gdxGraphics).getWidth();
			will(returnValue(800));
			one(gdxGraphics).getHeight();
			will(returnValue(600));
			one(spriteBatch).getColor();
			will(returnValue(null));
		}
	});
	
	graphics = new LibGdxGraphics(gameWrapper, spriteBatch, polygonSpriteBatch, shapeRenderer);
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:25,代码来源:LibGdxGraphicsTest.java

示例10: execute

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void execute(Renderer render) {
	PolygonSpriteBatch batch = render.batch;
	if(!batch.isDrawing()) {
		batch.begin();
	}
	this._callback.onCommand(render.batch);
}
 
开发者ID:mingwuyun,项目名称:cocos2d-java,代码行数:9,代码来源:RenderCommand.java

示例11: GameMapRenderer

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public GameMapRenderer(GameState gameState, GameMap map,
		PlayerCharacterController controller) {
	this.gameState = gameState;
	this.pcc = gameState.getPlayerCharacterController();
	this.pcg = GameState.getPlayerCharacterGroup();
	/*amplitudeWave = 0.5f;
	angleWave = 0;
	angleWaveSpeed = 1f;*/
	waterShader = WaterShader.createWaterShader();
	unitScaleX = map.getScaleX();
	unitScaleY = map.getScaleY();
	this.map = map;
	this.viewBounds = new Rectangle();
	this.spriteBatch = new PolygonSpriteBatch();
	this.controller = controller;
	textBatch = new SpriteBatch();
	textBatch.getProjectionMatrix().setToOrtho2D(0, 0,
			Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	combatPathRenderer = new CombatPathRenderer(controller);
	effectTargetRenderer = new EffectTargetRenderer(controller);
	shapeRenderer = new ShapeRenderer(100);
	cullingRectangle = new Rectangle();
	highlightedDrawables = new ObjectMap<Drawable, Color>();
	trapsToDraw = new ObjectMap<TrapLocation, FilledPolygonRenderer>(); 
	trapTiles = new Array<int[]>();
	normalColor = Color.toFloatBits(1f, 1f, 1f, 1f);
	fogColor = Color.toFloatBits(Configuration.getFogColor().r,
			Configuration.getFogColor().g, Configuration.getFogColor().b,
			1);
	frameBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
	frameBufferTextureRegion = new TextureRegion();
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:33,代码来源:GameMapRenderer.java

示例12: render

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public void render(PolygonSpriteBatch batch) {
	// lazy init of the polyReg to make sure the map is fully loaded
	if (polyReg == null) {
		setPolygon(polygon, map);
	}
	batch.draw(polyReg, 0, 0);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:8,代码来源:FilledPolygonRenderer.java

示例13: WorldRenderer

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public WorldRenderer(World world) {
    this.world = world;
    this.cam = new OrthographicCamera(CAMERA_WIDTH, CAMERA_HEIGHT);
    this.cam.position.set(0f, 0f, 0f);
    this.cam.update();
    spriteBatch = new PolygonSpriteBatch();
    renderer = new ShapeRenderer();
    layout = new GlyphLayout();
    loadTextures();
}
 
开发者ID:kbz,项目名称:SSTrain,代码行数:11,代码来源:WorldRenderer.java

示例14: Terrain

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
public Terrain(){
    random = new Random();
    shapeRenderer = new ShapeRenderer();
    speed = new Vector2(Commons.getInstance().backgroundSpeed);
    setPoints(new ArrayList<Vector2>());
    setTopPoints(new ArrayList<Vector2>());
    setPoints2(new ArrayList<Vector2>());
    setTopPoints2(new ArrayList<Vector2>());

    getPoints().add(new Vector2(0, Commons.getInstance().initialY));
    getPoints().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY));
    getTopPoints().add(new Vector2(0, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
    getTopPoints().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));

    getPoints2().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY));
    getPoints2().add(new Vector2(Commons.getInstance().deviceWidth * 2, Commons.getInstance().initialY));
    getTopPoints2().add(new Vector2(Commons.getInstance().deviceWidth, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));
    getTopPoints2().add(new Vector2(Commons.getInstance().deviceWidth * 2, Commons.getInstance().initialY + Commons.getInstance().wallsDifference));

    generateTerrain(1);
    generateTerrain(2);

    atlas = new TextureAtlas("terrain/textures/textures.pack.atlas");
    region = atlas.findRegion("terrain");
    batch = new PolygonSpriteBatch();

    updatePolygons();
}
 
开发者ID:AdoriaStudios,项目名称:SpaceRescueAndroid,代码行数:29,代码来源:Terrain.java

示例15: create

import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; //导入依赖的package包/类
@Override
public void create () {
	instance = this;

	Log.debug("Starting loading");

	try {
		GLFWIconSetter.newInstance().setIcon(Gdx.files.absolute(App.APP_FOLDER_PATH).child("cache/iconCache"),
				Gdx.files.internal("icon.ico"), Gdx.files.internal("icon.png"));
	} catch (IllegalStateException e) {
		Log.exception(e);
	}

	Assets.load();

	VisUI.load();
	VisUI.setDefaultTitleAlign(Align.center);
	Log.debug("VisUI " + VisUI.VERSION + " loaded");

	polygonSpriteBatch = new PolygonSpriteBatch();
	stage = createStage();
	Gdx.input.setInputProcessor(stage);

	uiRoot = new VisTable();
	uiRoot.setFillParent(true);

	stage.addActor(uiRoot);

	createUI();
	createModuleContainers();
	createModulesUI();

	Log.debug("Loading completed");

	if (experimentalSettings.isUIScale() || launchConfig.scaleUIEnabled) {
		stageViewport.setUnitsPerPixel(0.5f);
	}
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:39,代码来源:Editor.java


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