• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SpriteCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void create () {
	cam = new OrthographicCamera(480, 320);
	cam.position.set(WIDTH * 32 / 2, HEIGHT * 32 / 2, 0);
	camController = new OrthoCamController(cam);
	Gdx.input.setInputProcessor(camController);

	texture = new Texture(Gdx.files.internal("data/tiles.png"));

	Random rand = new Random();
	for (int i = 0; i < LAYERS; i++) {
		caches[i] = new SpriteCache();
		SpriteCache cache = caches[i];
		cache.beginCache();
		for (int y = 0; y < HEIGHT; y++) {
			for (int x = 0; x < WIDTH; x++) {
				int tileX = rand.nextInt(5);
				int tileY = rand.nextInt(5);
				cache.add(texture, x << 5, y << 5, 1 + tileX * 33, 1 + tileY * 33, 32, 32);
			}
		}
		layers[i] = cache.endCache();
	}

}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:TileTest.java


示例2: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render () {
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	cam.update();

	Gdx.gl.glEnable(GL20.GL_BLEND);
	Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
	for (int i = 0; i < LAYERS; i++) {
		SpriteCache cache = caches[i];
		cache.setProjectionMatrix(cam.combined);
		cache.begin();
		for (int j = 0; j < TILES_PER_LAYER; j += BLOCK_TILES) {
			cache.draw(layers[i], j, BLOCK_TILES);
		}
		cache.end();
	}

	if (TimeUtils.nanoTime() - startTime >= 1000000000) {
		Gdx.app.log("TileTest", "fps: " + Gdx.graphics.getFramesPerSecond());
		startTime = TimeUtils.nanoTime();
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:23,代码来源:TileTest.java


示例3: create

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public void create () {
	texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
	Sprite sprite = new Sprite(texture);
	sprite.setSize(tileSize, tileSize);

	cache = new SpriteCache(1000, false);
	for (int y = 0; y < tileMapHeight; y++) {
		cache.beginCache();
		for (int x = 0; x < tileMapWidth; x++) {
			sprite.setPosition(x * tileSize, y * tileSize);
			cache.add(sprite);
		}
		cache.endCache();
		sprite.rotate90(true);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:SpriteCacheOffsetTest.java


示例4: GameGridRenderer

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public GameGridRenderer(GameGrid gameGrid, OrthographicCamera camera) {
	this.gameGrid = gameGrid;
	this.camera = camera;

	renderTintColor = Color.WHITE;
	shouldRenderGridLines = false;
	shapeRenderer = new ShapeRenderer();

	transitLines = Lists.newArrayList();

	activeOverlay = null;

	makeOverlayFunctions();
	spriteCache = new SpriteCache();

	gameGrid.events().register(this);
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:18,代码来源:GameGridRenderer.java


示例5: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	if (animation != null) {
		if (isPlaying) {
			animationTime += Gdx.graphics.getDeltaTime();
			if (animationTime >= animation.animationDuration) {
				endPlayback();
			} else {
				Vector2 worldCenter = getWorldCenter();
				spriteBatch.draw(animation.getKeyFrame(animationTime, false), worldCenter.x - 53.5f * getGridScale(), worldCenter.y - 19 * getGridScale(),
						107 * getGridScale(), 44 * getGridScale());
			}
		}
	}

	if (!isPlaying && movie == null && getEmploymentLevel() > 0f) {
		long millis = System.currentTimeMillis();
		if (nextShowTime <= millis) {
			loadMovie();
		}
	}

	super.render(spriteBatch, spriteCache, renderTintColor);
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:25,代码来源:MovieTheater.java


示例6: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	Sprite sprite = getSprite();
	if (sprite != null) {
		sprite.setColor(renderColor);
		sprite.setPosition(worldPosition.x, worldPosition.y);
		sprite.setSize(worldSize.x, worldSize.y);

		if (shouldUseSpriteCache()) {
			spriteCache.beginCache();
			spriteCache.add(sprite);
			setSpriteCacheId(spriteCache.endCache());
		} else {
			sprite.draw(spriteBatch);
		}
	}
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:17,代码来源:GridObject.java


示例7: create

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void create () {
	cam = new OrthographicCamera(480, 320);
	camController = new OrthoCamController(cam);
	Gdx.input.setInputProcessor(camController);

	renderer = new ShapeRenderer();
	texture = new Texture(Gdx.files.internal("data/isotile.png"));

	Random rand = new Random();
	for (int i = 0; i < LAYERS; i++) {
		caches[i] = new SpriteCache();
		SpriteCache cache = caches[i];
		cache.beginCache();

		int colX = HEIGHT * TILE_WIDTH / 2 - TILE_WIDTH / 2;
		int colY = BOUND_Y - TILE_HEIGHT_DIAMOND;
		for (int x = 0; x < WIDTH; x++) {
			for (int y = 0; y < HEIGHT; y++) {
				int tileX = colX - y * TILE_WIDTH / 2;
				int tileY = colY - y * TILE_HEIGHT_DIAMOND / 2;
				cache.add(texture, tileX, tileY, rand.nextInt(2) * 54, 0, TILE_WIDTH, TILE_HEIGHT);
			}
			colX += TILE_WIDTH / 2;
			colY -= TILE_HEIGHT_DIAMOND / 2;
		}

		layers[i] = cache.endCache();
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:31,代码来源:IsometricTileTest.java


示例8: dispose

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void dispose () {
	renderer.dispose();
	texture.dispose();
	for (SpriteCache cache : caches)
		cache.dispose();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:IsometricTileTest.java


示例9: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render () {
	Gdx.gl.glClearColor(0.7f, 0.7f, 0.7f, 1);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	cam.update();

	Gdx.gl.glEnable(GL20.GL_BLEND);
	Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
	for (int i = 0; i < LAYERS; i++) {
		SpriteCache cache = caches[i];
		cache.setProjectionMatrix(cam.combined);
		cache.begin();
		cache.draw(layers[i]);
		cache.end();
	}

	renderer.setProjectionMatrix(cam.combined);
	renderer.begin(ShapeType.Line);
	renderer.setColor(1, 0, 0, 1);
	renderer.line(0, 0, 500, 0);
	renderer.line(0, 0, 0, 500);

	renderer.setColor(0, 0, 1, 1);
	renderer.line(0, BOUND_Y, BOUND_X, BOUND_Y);

	renderer.setColor(0, 0, 1, 1);
	renderer.line(BOUND_X, 0, BOUND_X, BOUND_Y);

	renderer.end();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:31,代码来源:IsometricTileTest.java


示例10: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	super.render(spriteBatch, spriteCache, renderTintColor);

	if (activeVehicleTexture != null) {
		spriteBatch.setColor(Color.WHITE);
		spriteBatch.draw(activeVehicleTexture, getWorldCenter().x - activeVehicleTexture.getRegionWidth() / 2,
				getWorldCenter().y - activeVehicleTexture.getRegionHeight() / 2);

	}
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:12,代码来源:ParkingGarageSpace.java


示例11: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	// stairs need to support overflowing into adjacent cells.
	if (sprite != null) {
		sprite.setColor(renderColor);
		sprite.setPosition(position.getWorldX(), position.getWorldY());
		sprite.draw(spriteBatch);
	}
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:10,代码来源:Stair.java


示例12: OrthogonalTileLayerRenderer

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public OrthogonalTileLayerRenderer(TiledMap tiledMap, boolean cacheLayers) {
	super();
	this.cacheLayers = cacheLayers;
	this.tiledMap = tiledMap;

	if (cacheLayers) {
		layerCache = new SpriteCache(5000, true);
		layerCacheIds = new HashMap<Integer, Integer>();
	}
	mapClip = new TiledMapRenderArea();
	tmpClip = new TiledMapRenderArea();
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:13,代码来源:OrthogonalTileLayerRenderer.java


示例13: drawSpriteCache

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void drawSpriteCache(SpriteCache spriteCache, int cacheId) {
	beginRendering();
	spriteCache.getProjectionMatrix().set(spriteBatch.getProjectionMatrix().cpy());
	spriteCache.getTransformMatrix().set(spriteBatch.getTransformMatrix().cpy());
	Gdx.gl.glEnable(GL20.GL_BLEND);

	spriteCache.begin();
	spriteCache.draw(cacheId);
	spriteCache.end();
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:12,代码来源:LibGdxGraphics.java


示例14: OrthoCachedTiledMapRenderer

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
/** @param cacheSize The maximum number of tiles that can be cached. */
public OrthoCachedTiledMapRenderer (TiledMap map, float unitScale, int cacheSize) {
	this.map = map;
	this.unitScale = unitScale;
	spriteCache = new SpriteCache(cacheSize, true);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:OrthoCachedTiledMapRenderer.java


示例15: getSpriteCache

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public SpriteCache getSpriteCache () {
	return spriteCache;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:4,代码来源:OrthoCachedTiledMapRenderer.java


示例16: create

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void create () {
	spriteCache = new SpriteCache(1000, true);

	texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
	texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

	Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
	pixmap.setColor(1, 1, 0, 0.5f);
	pixmap.fill();
	texture2 = new Texture(pixmap);
	pixmap.dispose();

	sprites = new float[SPRITES * 6];
	sprites2 = new float[SPRITES * 6];
	Sprite[] sprites3 = new Sprite[SPRITES * 2];

	for (int i = 0; i < sprites.length; i += 6) {
		sprites[i] = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
		sprites[i + 1] = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));
		sprites[i + 2] = 0;
		sprites[i + 3] = 0;
		sprites[i + 4] = 32;
		sprites[i + 5] = 32;
		sprites2[i] = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
		sprites2[i + 1] = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));
		sprites2[i + 2] = 0;
		sprites2[i + 3] = 0;
		sprites2[i + 4] = 32;
		sprites2[i + 5] = 32;
	}

	for (int i = 0; i < SPRITES * 2; i++) {
		int x = (int)(Math.random() * (Gdx.graphics.getWidth() - 32));
		int y = (int)(Math.random() * (Gdx.graphics.getHeight() - 32));

		if (i >= SPRITES)
			sprites3[i] = new Sprite(texture2, 32, 32);
		else
			sprites3[i] = new Sprite(texture, 32, 32);
		sprites3[i].setPosition(x, y);
		sprites3[i].setOrigin(16, 16);
	}

	float scale = 1;
	float angle = 15;

	spriteCache.beginCache();
	for (int i = 0; i < sprites2.length; i += 6)
		spriteCache.add(texture2, sprites2[i], sprites2[i + 1], 16, 16, 32, 32, scale, scale, angle, 0, 0, 32, 32, false, false);
	for (int i = 0; i < sprites.length; i += 6)
		spriteCache.add(texture, sprites[i], sprites[i + 1], 16, 16, 32, 32, scale, scale, angle, 0, 0, 32, 32, false, false);
	normalCacheID = spriteCache.endCache();

	angle = -15;

	spriteCache.beginCache();
	for (int i = SPRITES; i < SPRITES << 1; i++) {
		sprites3[i].setRotation(angle);
		sprites3[i].setScale(scale);
		spriteCache.add(sprites3[i]);
	}
	for (int i = 0; i < SPRITES; i++) {
		sprites3[i].setRotation(angle);
		sprites3[i].setScale(scale);
		spriteCache.add(sprites3[i]);
	}
	spriteCacheID = spriteCache.endCache();

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


示例17: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	tmpVector.set(worldPosition);

	if (selectedResizeHandle == ResizeHandle.BOTTOM) {
		bottomSprite.setColor(Color.CYAN);
	} else {
		bottomSprite.setColor(renderColor);
	}
	bottomSprite.setPosition(tmpVector.x, tmpVector.y);
	bottomSprite.draw(spriteBatch);

	Sprite shaftToRender;
	if (drawShaft && !(InputSystem.instance().getCurrentTool() instanceof PlacementTool)) {
		shaftToRender = shaftSprite;
	} else {
		shaftToRender = emptyShaftSprite;
	}

	tmpVector.add(0, scaledGridUnit());
	shaftToRender.setColor(renderColor);
	shaftToRender.setPosition(tmpVector.x, tmpVector.y);
	shaftToRender.setSize(worldSize.x, worldSize.y - scaledGridUnit());
	setWrap(shaftToRender);
	shaftToRender.draw(spriteBatch);

	floorLabelCache.setColor(1, 1, 1, 0.5f);
	floorLabelCache.draw(spriteBatch, renderColor.a);

	if (isPlaced() && selectedResizeHandle == null && !(InputSystem.instance().getCurrentTool() instanceof PlacementTool)) {
		for (ElevatorCar elevatorCar : elevatorCars) {
			elevatorCar.setColor(renderColor);
			elevatorCar.draw(spriteBatch);
		}
	}

	if (selectedResizeHandle == TOP) {
		topSprite.setColor(Color.CYAN);
	} else {
		topSprite.setColor(renderColor);
	}
	topSprite.setPosition(getWorldPosition().x, getWorldTop().y - scaledGridUnit());
	topSprite.draw(spriteBatch);
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:45,代码来源:Elevator.java


示例18: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	super.render(spriteBatch, spriteCache, renderTintColor);

	// drawEndCaps(spriteBatch);
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:7,代码来源:Lobby.java


示例19: render

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
@Override
public void render(SpriteBatch spriteBatch, SpriteCache spriteCache, Color renderTintColor) {
	super.render(spriteBatch, spriteCache, renderTintColor);
	renderDecals(spriteBatch);
}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:6,代码来源:Room.java


示例20: fillSpriteCache

import com.badlogic.gdx.graphics.g2d.SpriteCache; //导入依赖的package包/类
public void fillSpriteCache(SpriteCache spriteCache, Texture ...textures) {
	for(Texture texture : textures){
		spriteCache.add(texture, 0, 0);
	}
	
}
 
开发者ID:moriline,项目名称:AChocolate,代码行数:7,代码来源:Ace.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PKIMessage类代码示例发布时间:2022-05-23
下一篇:
Java PlayN类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap