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


Java ShapeRenderer类代码示例

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


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

示例1: drawMenu

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
private void drawMenu()
{

	shapeRenderer.begin();
	shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
	shapeRenderer.rect(Gdx.graphics.getWidth() - 80, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
			Color.valueOf("#42f498"), Color.valueOf("#42f498"), Color.valueOf("#42f498"), Color.valueOf("#42f498"));
	shapeRenderer.set(ShapeRenderer.ShapeType.Line);
	shapeRenderer.line(Gdx.graphics.getWidth() - 80, 0, Gdx.graphics.getWidth() - 80, Gdx.graphics.getHeight(), Color.BLACK, Color.BLACK);

	shapeRenderer.end();

	batch.begin();
	for(int i = 0; i < menuTextures.size(); i++)
	{
		batch.draw(menuTextures.get(i),
				Gdx.graphics.getWidth() - 40 - menuTextures.get(i).getWidth()/2, Gdx.graphics.getHeight() - (menuTextures.get(i).getHeight() + MENU_PADDING_Y + i * 75),
				menuTextures.get(i).getWidth(), menuTextures.get(i).getHeight());
	}
	batch.end();
}
 
开发者ID:MartensCedric,项目名称:LD38-Compo,代码行数:22,代码来源:LudumDare38.java

示例2: drawBg

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public void drawBg(Batch batch, float parentAlpha) {
    batch.end();
    Gdx.gl.glLineWidth(1.0f);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
    Matrix4 matrix = batch.getTransformMatrix();
    shapeRenderer.setTransformMatrix(matrix);

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    BG.a = parentAlpha;
    shapeRenderer.setColor(BG);
    shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
    shapeRenderer.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
    batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
 
开发者ID:whitecostume,项目名称:libgdx_ui_editor,代码行数:21,代码来源:EditingZone.java

示例3: GameObjectMap

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的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

示例4: draw

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void draw (Batch batch, float parentAlpha) {
    batch.end();

    Gdx.gl.glLineWidth(10);

    for (PolygonRegion region : polygonRegions) {

        this.batch.begin();
        this.batch.draw(region, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        this.batch.end();

        Polyline line = new Polyline(region.getVertices());
        line.setScale(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
        shapeRenderer.setColor(Color.BROWN);
        shapeRenderer.polyline(line.getTransformedVertices());
        shapeRenderer.end();
    }

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

示例5: draw

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public void draw(ShapeRenderer renderer) {
    if (rect.width < 25 * cam.zoom || rect.height < 25 * cam.zoom) return;

    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    renderer.setProjectionMatrix(cam.combined);
    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(new Color(0x228b2255));
    renderer.rect(rect.x, rect.y, rect.width, rect.height);

    renderer.set(ShapeRenderer.ShapeType.Line);
    renderer.setColor(Color.BLACK);
    renderer.rect(rect.x, rect.y, rect.width, rect.height);
    renderer.end();
}
 
开发者ID:conquest,项目名称:conquest,代码行数:17,代码来源:Grabber.java

示例6: onInit

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
protected void onInit(ScreenBasedGame game, AssetManager assetManager) {
    // generate fonts
    this.font1 = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.WHITE, Color.BLUE,
            3);
    this.font2 = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.RED, Color.WHITE, 3);

    // load & get assets
    assetManager.load(TORPEDO_IMAGE_PATH, Texture.class);
    assetManager.finishLoadingAsset(TORPEDO_IMAGE_PATH);
    this.torpedoTexture = assetManager.get(TORPEDO_IMAGE_PATH, Texture.class);

    // create new Head-Up-Display
    this.hud = new HUD();
    this.filledBar = new FilledBar(this.font1);
    this.filledBar.setPosition(game.getViewportWidth() - 400, game.getViewportHeight() - 85);
    this.filledBar.setDimension(155, 35);
    this.hud.addWidget(this.filledBar);

    this.shapeRenderer = new ShapeRenderer();
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:22,代码来源:HUDOverlayScreen.java

示例7: Crafting

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public Crafting(int x, int y, int wid, int hei) {
	this.x = x;
	this.y = y;
	this.wid = wid;
	this.hei = hei;
	shapes = new ShapeRenderer();
	this.active = true;
	fontHandler = new FontHandler();

	layoutSave = new GlyphLayout(fontHandler.font32, "SAVE");
	widthSave = layoutSave.width;
	heightSave = layoutSave.height;

	layoutExit = new GlyphLayout(fontHandler.font32, "X");
	widthExit = layoutExit.width;
	heightExit = layoutExit.height;

}
 
开发者ID:MusicDev33,项目名称:JGame,代码行数:19,代码来源:Crafting.java

示例8: MainMenu

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public MainMenu(JGame game) {
	this.game = game;
	this.batch = game.batch;
	playY = (game.screenY / 2) + 200;
	loadY = (game.screenY / 2) + 100;
	exitY = (game.screenY / 2);
	shapes = new ShapeRenderer();

	fontHandler = new FontHandler();

	layoutPlay = new GlyphLayout(fontHandler.font90, "PLAY");
	widthPlay = layoutPlay.width;
	heightPlay = layoutPlay.height;

	layoutLoad = new GlyphLayout(fontHandler.font90, "LOAD");
	widthLoad = layoutLoad.width;
	heightLoad = layoutLoad.height;

	layoutExit = new GlyphLayout(fontHandler.font90, "EXIT");
	widthExit = layoutExit.width;
	heightExit = layoutExit.height;

}
 
开发者ID:MusicDev33,项目名称:JGame,代码行数:24,代码来源:MainMenu.java

示例9: drawCollisionBoxes

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public void drawCollisionBoxes(GameTime time, CameraWrapper camera, ShapeRenderer shapeRenderer, Color baseColor,
        Color inCollisionColor) {
    Color color = null;

    if (alreadyInCollision) {
        color = inCollisionColor;
    } else {
        color = baseColor;
    }

    // first, draw hull
    if (this.hullShape != null) {
        this.hullShape.drawShape(time, camera, shapeRenderer, color);
    }

    // draw inner shapes
    for (CShape shape : this.collisionShapes) {
        shape.drawShape(time, camera, shapeRenderer, color);
    }
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:21,代码来源:CollisionComponent.java

示例10: drawLayer1

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void drawLayer1(GameTime time, ShapeRenderer shapeRenderer) {
    // draw background
    shapeRenderer.setColor(this.backgroundColor);
    shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());

    float maxWidth = getWidth() - (paddingLeft + paddingRight);
    float maxHeight = getHeight() - (paddingTop + paddingBottom);

    float barWidth = maxWidth * percent;
    float barHeight = maxHeight;

    // draw foreground
    shapeRenderer.setColor(this.foregroundColor);
    shapeRenderer.rect(getX() + paddingBottom, getY() + paddingLeft, barWidth, barHeight);
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:17,代码来源:FilledBar.java

示例11: create

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void create() {
    saveFile = Gdx.files.local("bin/saves.dat");
    if (saveFile.exists()) {
        load();
    } else {
        currentDescriptor = newSaveFileDescriptor();
        save();
    }
    aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth();
    batch = new SpriteBatch();
    sr = new ShapeRenderer();
    setCurrentScreen(new SplashScreen());
    Gdx.graphics.requestRendering();
    Gdx.input.setInputProcessor(this);
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); //fixes red screen bug on startup
    Gdx.input.setCatchBackKey(true);
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:19,代码来源:Game.java

示例12: render

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void render(SpriteBatch sb, ShapeRenderer sr) {
    sb.setProjectionMatrix(camera.combined);
    sr.setAutoShapeType(true);
    sr.setProjectionMatrix(camera.combined);
    //SHAPERENDERER
    sr.begin();
    sr.set(ShapeRenderer.ShapeType.Filled);
    sr.setColor(new Color(23 / 255f, 23 / 255f, 23 / 255f, 1f));
    sr.rect(0, 0, Game.WIDTH, Game.HEIGHT);
    for (int i = 0; i < background.length; i++) {
        background[i].renderSR(sr);
    }
    play.renderSR(sr);
    music.renderSR(sr);
    sr.end();

    //SPRITEBATCH
    sb.begin();
    sb.draw(logo, Game.WIDTH / 2 - (logo.getTexture().getWidth() * 10) / 2, Game.HEIGHT - 50 - logo.getHeight() * 10, logo.getWidth() * 10, logo.getHeight() * 10);
    play.renderSB(sb);
    music.renderSB(sb);
    betaText.draw(sb, "Beta Release - Copyright 2017 Gussio. All rights reserved. Visit https://gussio.nl/ for more info.", 10, 25);
    sb.end();
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:26,代码来源:MenuScreen.java

示例13: render

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void render(SpriteBatch sb, ShapeRenderer sr) {
    sb.setProjectionMatrix(camera.combined);
    sr.setAutoShapeType(true);
    sr.setProjectionMatrix(camera.combined);

    //BACKGROUND
    sr.begin();
    sr.set(ShapeRenderer.ShapeType.Filled);
    sr.setColor(Color.WHITE);
    sr.rect(0, 0, Game.WIDTH, Game.HEIGHT);
    sr.end();

    //LOGO
    sb.begin();
    sb.draw(logo, Game.WIDTH / 2 - logo.getWidth() * 20 / 2, Game.HEIGHT / 2 - logo.getHeight() * 20 / 2, logo.getWidth() * 20, logo.getHeight() * 20);
    sb.end();
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:19,代码来源:SplashScreen.java

示例14: HudScene

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
public HudScene(SpriteBatch batch, ShapeRenderer shapeRenderer, ArcRenderer arcRenderer) {
    this.batch = batch;
    stage = new Stage();

    VisUI.load();

    Table table = new Table();
    table.top();
    table.setFillParent(true);

    scoreLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setScore(score);
    balanceLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setBalance(balance);

    table.add(scoreLabel).align(Align.left).expandX();
    table.add(balanceLabel).align(Align.right).expandX();

    stage.addActor(table);


    ringButton = new RingButton(shapeRenderer, arcRenderer);
    ringButton.setBounds(10, 10, 100, 100);
    stage.addActor(ringButton);
}
 
开发者ID:MiniDigger,项目名称:projecttd,代码行数:26,代码来源:HudScene.java

示例15: create

import com.badlogic.gdx.graphics.glutils.ShapeRenderer; //导入依赖的package包/类
@Override
public void create() {
	if (androidInterface != null)
		androidInterface.tryToStopMusicApp();

	batch = new SpriteBatch();
	sr = new ShapeRenderer();

	camera = new OrthographicCamera();
	viewport = new FitViewport(Configuration.WINDOW_WIDTH, Configuration.WINDOW_HEIGHT, camera);
	camera.position.set(viewport.getWorldWidth() / 2 - (viewport.getWorldWidth() - 500) / 2, viewport.getWorldHeight() / 2 - (viewport.getWorldHeight() - 220) / 2, 0);
	camera.update();

	fade = new Sprite(new Texture("sprites/fade.png"));
	fade.setBounds(0, -100, viewport.getWorldWidth(), viewport.getWorldHeight() - 40);

	font = new BitmapFont(Gdx.files.internal("fonts/amiga4everpro2.fnt"));

	showModernTimesCutscene(); // start the game
}
 
开发者ID:cdetamble,项目名称:nomoore,代码行数:21,代码来源:MyGdxGame.java


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