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


Java Gdx类代码示例

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


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

示例1: Addtogroup

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void Addtogroup(){
    grchatfaction = new VerticalGroup();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
    try {
        grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Welcome Chat!"));
        grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Faction!"));
        grchatfaction.addActor(labelTest1);
    } catch (ParseException e) {
        e.printStackTrace();
        Gdx.app.log("eroare","intra");
    }
    sp = new ScrollPane(grchatfaction);
    sp.layout();
    sp.setScrollingDisabled(true, false);
    sp.setFillParent(true);sp.setLayoutEnabled(true);
    ta = new Table();
    ta.setFillParent(false);
    ta.add(sp).fill().expand();
    ta.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
    ta.setVisible(false);
    groupbotttom.addActor(ta);
    sp.setScrollPercentY(200);
    sp.act(Gdx.graphics.getDeltaTime());
    sp.updateVisualScroll();
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:26,代码来源:ScreenChat.java

示例2: draw

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void draw(Batch batch) {
    vanishElapsed += Gdx.graphics.getDeltaTime();

    // vanishElapsed might be < 0 (delay), so clamp to 0
    float progress = Math.min(1f,
            Math.max(vanishElapsed, 0f) / vanishLifetime);

    // If one were to plot the elasticIn function, they would see that the slope increases
    // a lot towards the end- a linear interpolation between the last size + the desired
    // size at 20% seems to look a lot better.
    vanishSize = MathUtils.lerp(
            vanishSize,
            Interpolation.elasticIn.apply(cell.size, 0, progress),
            0.2f
    );

    float centerOffset = cell.size * 0.5f - vanishSize * 0.5f;
    Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize);
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:21,代码来源:VanishEffect.java

示例3: StageLoad

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
/**
 * Loading stage
 * @param doLoad should resources be loaded? It acts as a splash screen otherwise.
 */
public StageLoad(boolean doLoad) {
	this.doLoad = doLoad;
	// Create icon
	icon = new Image(new Texture("image/icon-512.png"));
	int size = Gdx.graphics.getHeight();
	if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth())
		size = Gdx.graphics.getWidth();
	icon.setSize(size, size);
	icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2,
			Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2);
	addActor(icon);
	// Loading Text
	Label.LabelStyle loadingStyle = new Label.LabelStyle();
	loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
	loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720);
	loading = new Label("DRC Sim", loadingStyle);
	loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f);
	loading.setAlignment(Align.center);
	addActor(loading);
}
 
开发者ID:rolandoislas,项目名称:drc-sim-client,代码行数:25,代码来源:StageLoad.java

示例4: addchatlocation

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void addchatlocation(){
    grchatlocation = new VerticalGroup();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
    try {
        grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.RED,"Welcome Chat!"));
        grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.GREEN,"Location!"));
        grchatlocation.addActor(labelTest);
    } catch (ParseException e) {
        e.printStackTrace();
        Gdx.app.log("eroare","intra");
    }
    scrollchatpublic = new ScrollPane(grchatlocation);
    scrollchatpublic.layout();
    scrollchatpublic.setScrollingDisabled(true, false);
    scrollchatpublic.setFillParent(true);
    scrollchatpublic.setLayoutEnabled(true);
    tablechatpublic = new Table();
    tablechatpublic.setFillParent(false);
    tablechatpublic.add(scrollchatpublic).fill().expand();
    tablechatpublic.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
    groupbotttom.addActor(tablechatpublic);
    scrollchatpublic.setScrollPercentY(100);
    scrollchatpublic.act(Gdx.graphics.getDeltaTime());
    scrollchatpublic.updateVisualScroll();
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:26,代码来源:ScreenChat.java

示例5: render

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void render(float delta) {
	Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g,
			backgroundColor.b, backgroundColor.a);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	game.getSpriteBatch().begin();

	if (backgroundTexture != null)
		game.getSpriteBatch().draw(this.backgroundTexture, 0, 0,
				game.getViewportWidth(), game.getViewportHeight());

	game.getSpriteBatch().setProjectionMatrix(game.getUICamera().combined);

	stage.act(delta);
	stage.draw();

	game.getSpriteBatch().end();
}
 
开发者ID:eskalon,项目名称:ProjektGG,代码行数:20,代码来源:BaseUIScreen.java

示例6: takeScreenshot

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public static void takeScreenshot() {
	byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0,
			Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), true);

	Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
			Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
	BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);

	SimpleDateFormat dateFormat = new SimpleDateFormat(
			"yyyy-MM-dd HH-mm-ss");

	PixmapIO.writePNG(
			Gdx.files.external(dateFormat.format(new Date()) + ".png"),
			pixmap);
	pixmap.dispose();
}
 
开发者ID:eskalon,项目名称:ProjektGG,代码行数:18,代码来源:ScreenshotUtils.java

示例7: draw

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void draw() {
    if (shown) {
        // Draw an overlay rectangle with not all the opacity
        // This is the only place where ShapeRenderer is OK because the batch hasn't started
        Gdx.gl.glEnable(GL20.GL_BLEND);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
        Color color = new Color(Klooni.theme.bandColor);
        color.a = 0.1f;
        shapeRenderer.setColor(color);
        shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        shapeRenderer.end();
    }

    super.draw();
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:17,代码来源:PauseMenuStage.java

示例8: loadSpawns

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public static List<Spawn> loadSpawns(BufferedReader data) {
    if (data == null)
        return null;
    List<Spawn> spawns = new ArrayList<com.logicmaster63.tdgalaxy.map.Spawn>();
    try {
        int spawnNum = Integer.parseInt(data.readLine());
        for (int i = 0; i < spawnNum; i++) {
            int repeatNum = Integer.parseInt(data.readLine());
            String name = data.readLine();
            int delay = Integer.parseInt(data.readLine());
            for (int j = 0; j < repeatNum; j++)
                spawns.add(new Spawn(name, delay));
            data.close();
        }
    } catch (IOException e) {
        Gdx.app.error("Error", e.toString());
    }
    return spawns;
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:20,代码来源:FileHandler.java

示例9: getSave

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
private static Save getSave(CubesCmdLineOptions.ServerCmdLineOptions options) {
	FileHandle worldFolder = Compatibility.get().getBaseFolder().child("world");
	if (options.worldFolder != null)
		worldFolder = Gdx.files.absolute(options.worldFolder);
	Save save = new Save("world", worldFolder);
	if (save.readSaveOptions() == null) {
		SaveOptions saveOptions = save.getSaveOptions();
		if (options.worldSeedString != null)
			saveOptions.setWorldSeed(options.worldSeedString);
		if (options.worldGenerator != null)
			saveOptions.worldType = options.worldGenerator;
		if (options.worldGamemode != null)
			saveOptions.worldGamemode = options.worldGamemode;
	}
	return save;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:17,代码来源:DedicatedServer.java

示例10: GameOver

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public GameOver(GameStateManager gsm, int score) {
    super(gsm);
    this.score = score;
    camera.setToOrtho(false, FlappyBaran.WIDTH / 2, FlappyBaran.HEIGHT / 2);
    background = new Texture("backgrnd.jpg");
    gameover = new Texture("gameover.png");
    font = new BitmapFont();
    prefs = Gdx.app.getPreferences("FlappyBaran");

    if (!prefs.contains("highScore")) {
        prefs.putInteger("highScore", 0);
    }

    prevHighScore = getHighScore();

    if (prevHighScore < this.score) {
        setHighScore(this.score);
        highscore = this.score;
    } else {
        highscore = prevHighScore;
    }

}
 
开发者ID:kirdmiv,项目名称:Flappy-Baranus,代码行数:24,代码来源:GameOver.java

示例11: initImageButtons

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
private void initImageButtons() {

        if (!sceneData.isGameHost()) {
            return; // player is not hosting - don't offer the player to start the game.
        }

        imageButtonStartGame = new ImageButtonSceneObject(sceneData.createImageButton(Assets.START_GAME_BUTTON_FILENAME), buttonPressedSound);
        imageButtonStartGame.setBounds((Gdx.graphics.getWidth() / 2.0f) - 137.5f, Gdx.graphics.getHeight() / 10.0f, 275f, 240f);
        imageButtonStartGame.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                sceneData.sendMessageFromGui(new StartGameClicked());
            }
        });
        addSceneObject(imageButtonStartGame);
        imageButtonStartGame.setDisabled();
    }
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:18,代码来源:LobbyScene.java

示例12: handleOutboundMessage

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void handleOutboundMessage(Message message) {

    if (message instanceof DisconnectClient) {
        handleDisconnect(((DisconnectClient)message).isTerminateClient());
        return;
    }

    try {
        byte[] data = new MessageSerializer(message).serialize();
        write(data);
    } catch (IOException | ProtocolException e) {
        Gdx.app.error(getClass().getSimpleName(), "Handling outbound message failed", e);
        handleDisconnect(true);
    }
}
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:17,代码来源:ClientConnectedState.java

示例13: downenergy

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void downenergy(int value){
    bar.act(Gdx.graphics.getDeltaTime());
    infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy() - value);
    FadeIn();
    new Timer().schedule(new Timer.Task() {
        @Override
        public void run() {
            bar.setAnimateDuration(3);
            bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mapsScreen.startTimer();
        }
    }, 1000);
}
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:19,代码来源:ProgressBarEnergy.java

示例14: handleMessage

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void handleMessage(String senderId, Message message) {
    if(message.getType().equals(NextPlayer.class)){
        setNextPlayer(((NextPlayer)message).getPlayername());
    } else if (message.getType().equals(IsAttacked.class)) {
        context.setState(new AttackState(context, false));
    } else if (message.getType().equals(AttackResult.class)) { // react on broadcast attack result as we have to update the regions
        updateRegions((AttackResult)message);
    } else if (message.getType().equals(SpawnTroop.class)) {
        doSpawnTroop((SpawnTroop) message);
    } else if (message.getType().equals(MoveTroop.class)) {
        doMoveTroop((MoveTroop) message);
    }
    else{
        Gdx.app.log("WaitingForNextTurnState","unknown messgae:"+message.getType().getSimpleName());
    }
}
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:18,代码来源:WaitingForNextTurnState.java

示例15: show

import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
    public void show() {
        if(drawone){
            addroomselect();
            addButtonBottom();
            addPuls();
            addimagebg();
            addbuildRoom();
            addtimerbuildroom();
            drawone = false;
        }
        cameraGroupStrategy = new CameraGroupStrategy(camera);
//        CameraInputController controller = new CameraInputController(camera);
        stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
        batchsprite = new SpriteBatch();
        addtostage();
        batch = new DecalBatch(this.cameraGroupStrategy);
        Gdx.input.setCatchBackKey(true);
        InputMultiplexer inputmulti = new InputMultiplexer();
        inputmulti.addProcessor(stage);
        Gdx.input.setInputProcessor(inputmulti);
    }
 
开发者ID:TudorRosca,项目名称:enklave,代码行数:23,代码来源:ScreenRooms.java


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