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


Java TextRenderer类代码示例

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


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

示例1: display

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void display(@Nonnull final Element element, final ServerEntry serverEntry) {
    final Element text = element.findElementById("#server-name");
    final TextRenderer textRenderer = text.getRenderer(TextRenderer.class);
    final Element ip = element.findElementById("#server-ip");
    final TextRenderer ipRenderer = ip.getRenderer(TextRenderer.class);

    if (serverEntry != null) {
        textRenderer.setText(serverEntry.getName());
        ipRenderer.setColor(Color.WHITE);
        ipRenderer.setText(serverEntry.getIp());
    } else {
        textRenderer.setText("");
        ipRenderer.setText("");
    }
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:17,代码来源:ServerEntryConverter.java

示例2: update

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void update(float tpf) {       
    // Update a timer within the hud with time from start of screen and hanle
    // 5 minute time limit
    if(nifty.getCurrentScreen().getScreenId().equals("hud")) {
        // End the round or game at 5 minutes
        if(timer.getTimeInSeconds() - startMark > 300f) { //5 minute limit
            if(stateManager.getState(PlayAppState.class).getCurrentRound() == 
                    stateManager.getState(PlayAppState.class).getTotalRounds()) {
                stateManager.getState(PlayAppState.class).gameOver();
            } else {
                stateManager.getState(PlayAppState.class).roundOver();
                startMark = timer.getTimeInSeconds(); //reset the start timer
            }       
        }
        
        // Update the hud with current information
        nifty.getCurrentScreen().findElementByName(
                "timer").getRenderer(TextRenderer.class).setText("Time: " +
                    getTime(timer.getTimeInSeconds() - startMark));
        if(timer.getTimeInSeconds() - hitMark > 2) {
            nifty.getCurrentScreen().findElementByName("hitObject").getRenderer(
                TextRenderer.class).setText("");
        }
    }
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:27,代码来源:GuiAppState.java

示例3: showHitObject

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
public void showHitObject(String name, int points) {
    Integer totalPoints;
    
    // Reset the show time marker
    hitMark = timer.getTimeInSeconds();
    
    // Show the user what they hit
    nifty.getCurrentScreen().findElementByName("hitObject").getRenderer(
            TextRenderer.class).setText("You hit a " + name + ". + " + points);
    
    // Add the new points to the total
    stateManager.getState(PlayAppState.class).addPoints(points);
    
    // Get the current total score
    totalPoints = stateManager.getState(PlayAppState.class).getTotalPoints();
    
    // Show it
    nifty.getCurrentScreen().findElementByName("totalPoints").getRenderer(
            TextRenderer.class).setText("Total Score: " + totalPoints.toString());
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:21,代码来源:GuiAppState.java

示例4: update

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void update() {
	if(!nifty.isActive("interface/screen.xml", "hud")) {
		return;
	}
	String n = System.getProperty("line.separator");

	// update info
	if (CommandManager.selection.size() == 1) {
		Unit u = CommandManager.selection.get(0);
		getElement("unitName").getRenderer(TextRenderer.class).setText(Reporter.getName(u));
		getElement("unitHealth").getRenderer(TextRenderer.class).setText(Reporter.getHealth(u));
		getElement("unitState").getRenderer(TextRenderer.class).setText(Reporter.getState(u));
		getElement("unitOrder").getRenderer(TextRenderer.class).setText(Reporter.getOrder(u));
		getElement("unitHolding").getRenderer(TextRenderer.class).setText(Reporter.getHolding(u));
		getElement("info").show();
	} else {
		getElement("info").hide();
	}


}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:23,代码来源:BattlefieldGUIController.java

示例5: startGame

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
public void startGame() {
	//TODO: without a player one cannot start
	String mapName = screen.findElementById("mapNameLabel").getRenderer(TextRenderer.class).getOriginalText();
	List<Element> children = playerScrollPanelPanel.getChildren();
	ArrayList<Player> players = new ArrayList<Player>();
	for (int i = 0; i < children.size(); i++) {
		Element child = children.get(i);
		String name = child.findNiftyControl("player" + i + "TextField", TextField.class).getDisplayedText();
		if (child.findElementById("player" + i + "Label").getRenderer(TextRenderer.class).getOriginalText().equals("AI:")) {
			System.err.println("AI not implemented yet. " + name + " excluded from Players.");
			continue;
		}
		Color colorNifty = screen.findElementById("color" + i).getRenderer(PanelRenderer.class).getBackgroundColor();
		org.newdawn.slick.Color colorSlick = new org.newdawn.slick.Color(colorNifty.getRed(), colorNifty.getGreen(), colorNifty.getBlue(), colorNifty.getAlpha());
		int team = Integer.parseInt(screen.findNiftyControl("team" + i, Button.class).getText().substring(5))-1;
		players.add(new Player(name, colorSlick, team));
	}

	Player[] player = new Player[players.size()];
	player = players.toArray(player);
	NiftyMenu.startGame(new Controller(MapList.getInstance().getMap(mapName), player, "Conquest"));
}
 
开发者ID:oberien,项目名称:Oberien,代码行数:23,代码来源:GameSetupScreenController.java

示例6: sliderUpdate

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@NiftyEventSubscriber(pattern = ".*Volume")
public void sliderUpdate(String id, SliderChangedEvent e) {
	if ("masterVolume".equals(id)) {
		masterLabel.getRenderer(TextRenderer.class)
				.setText(Integer.toString((int) masterControl.getValue()));
		Options.setMasterVolume((int) masterControl.getValue());
	} else if ("musicVolume".equals(id)) {
		musicLabel.getRenderer(TextRenderer.class)
				.setText(Integer.toString((int) musicControl.getValue()));
		Options.setMusicVolume((int) musicControl.getValue());
	} else {
		soundLabel.getRenderer(TextRenderer.class)
				.setText(Integer.toString((int) soundControl.getValue()));
		Options.setMasterVolume((int) soundControl.getValue());
	}
}
 
开发者ID:oberien,项目名称:Oberien,代码行数:17,代码来源:SettingsScreenController.java

示例7: addMessage

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
public void addMessage(final String newMessage, Color color) {        
    Globals.app.enqueue(() -> {
        messages.add(newMessage);
        int index = messages.size() - 1;
        for (int i = rows.size() - 1; i >= 0;) {
            TextRenderer text = rows.get(i)
                    .getRenderer(TextRenderer.class);
            
            if (index < 0) {
                break;
            }

            String message = messages.get(index--);
            text.setText(message);
            String[] split = text.getWrappedText().split("\n");
            
            for (int l = split.length - 1; l >= 0 && i >= 0; --l) {
                rows.get(i--).getRenderer(TextRenderer.class)
                        .setText(split[l]);
            }
        }
        return null;
    });
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:25,代码来源:GameMessageHandler.java

示例8: end

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
public void end() {
    nifty.gotoScreen("end");

    try {
        Screen screen = nifty.getCurrentScreen();
        Element element = screen.findElementByName("money_end");
        element.getRenderer(TextRenderer.class).setText("Ruby " + account.getMoney());

        System.out.println("adasdasdassadsaadadasdasdd " + account.getMoney());
        System.out.println("adasdasdassadsaadadasdasdd " + account.getScore());


        element = screen.findElementByName("score_end");
        element.getRenderer(TextRenderer.class).setText("Score " + account.getScore());
    } catch (Exception e) {
        System.out.println("Catched Exception: " + e.toString());
    }
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:19,代码来源:Game.java

示例9: updateStore

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
private void updateStore() {
    Screen screen = nifty.getCurrentScreen();
    store.init();

    Element element = screen.findElementByName("power_price");
    element.getRenderer(TextRenderer.class).setText(store.getPowerPrice());

    element = screen.findElementByName("shield_price");
    element.getRenderer(TextRenderer.class).setText(store.getShieldPrice());

    element = screen.findElementByName("multi_price");
    element.getRenderer(TextRenderer.class).setText(store.getBombPrice());

    element = screen.findElementByName("money");
    element.getRenderer(TextRenderer.class).setText(account.getMoney() + "");

    element = screen.findElementByName("shield");
    element.getRenderer(TextRenderer.class).setText("Dangered");

    element = screen.findElementByName("power");
    element.getRenderer(TextRenderer.class).setText(account.getPower() + "/4 - " + account.getFruitString());

    element = screen.findElementByName("multi");
    element.getRenderer(TextRenderer.class).setText(account.getCapacity() + "/5");
}
 
开发者ID:damhonglinh,项目名称:Fruity-Bang,代码行数:26,代码来源:Home.java

示例10: updateTexts

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
private static void updateTexts(){
	Element e = HUD.nifty.getCurrentScreen().findElementByName("fps");
	TextRenderer txt = e.getRenderer(TextRenderer.class);
	String s = Timer.getFPSDisplay();
	txt.setText(s);
		
	e = HUD.nifty.getCurrentScreen().findElementByName("time");
	txt = e.getRenderer(TextRenderer.class);
	s = Timer.getChrono();
	txt.setText(s);
	
	e = HUD.nifty.getCurrentScreen().findElementByName("energy");
	txt = e.getRenderer(TextRenderer.class);
	s = "" + player.getEnergy();
	txt.setText(s);
			
	e = HUD.nifty.getCurrentScreen().findElementByName("battery");
	txt = e.getRenderer(TextRenderer.class);
	s = "" + player.getBatteriesNb();
	txt.setText(s);
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:22,代码来源:HUD.java

示例11: onStartScreen

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void onStartScreen() {
    mission = menuState.currentMission();
    mission.speedoMeterUI(screen.findElementById("speedDisplay").getRenderer(TextRenderer.class));
    mission.altimeterUI(screen.findElementById("altimeter").getRenderer(TextRenderer.class));
    mission.aoaUI(screen.findElementById("aoa").getRenderer(TextRenderer.class));
    inputManager.setCursorVisible(false);
    popupVisible = false;
    Element exitMenu = screen.findElementById("exitMenuPanel");
    exitMenu.setVisible(false);
}
 
开发者ID:ZoltanTheHun,项目名称:SkyHussars,代码行数:12,代码来源:MissionMenu.java

示例12: bind

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void bind(
        @Nonnull final Nifty niftyParam,
        @Nonnull final Screen screenParam,
        @Nonnull final Element newElement,
        @Nonnull final Parameters parameter) {
    super.bind(newElement);
    nifty = niftyParam;

    final Element text = newElement.findElementById("#text");
    if (text == null) {
        log.severe("ProgressBar element misses the text content element.");
        return;
    }
    buttonTextElement = text;

    if (newElement.getId() == null) {
        log.warning("ProgressBar element has no ID and can't publish any events properly.");
    }

    final TextRenderer renderer = buttonTextElement.getRenderer(TextRenderer.class);
    if (renderer == null) {
        throw new RuntimeException("ProgressBarControl is corrupted, #text element found, but missing TextRenderer");
    }
    buttonTextRenderer = renderer;

    final Element indicator = newElement.findElementById("#indicator");
    if(indicator == null) {
        log.severe("ProgressBar element misses the progress content element.");
        return;
    }
    progressIndicatorElement = indicator;
}
 
开发者ID:SkidRunner,项目名称:jME3-Examples,代码行数:34,代码来源:ProgressBarControl.java

示例13: getWidth

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public int getWidth(@Nonnull final Element element, final ServerEntry serverEntry) {
    final Element text = element.findElementById("#server-name");
    final TextRenderer textRenderer = text.getRenderer(TextRenderer.class);
    final Element ip = element.findElementById("#server-ip");
    final TextRenderer ipRenderer = ip.getRenderer(TextRenderer.class);

    return textRenderer.getFont().getWidth(serverEntry.getName()) + ipRenderer.getFont().getWidth(serverEntry.getIp());
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:10,代码来源:ServerEntryConverter.java

示例14: update

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
@Override
public void update(float tpf) {
    if (nifty != null) {
        Element niftyElement = nifty.getCurrentScreen().findElementByName("playername");
        niftyElement.getRenderer(TextRenderer.class).setText("name: " + getPlayerName());

        niftyElement = nifty.getCurrentScreen().findElementByName("playerhealth");
        niftyElement.getRenderer(TextRenderer.class).setText("health: " + getPlayerHealth());
    }
}
 
开发者ID:duodecimo,项目名称:magicallyous,代码行数:11,代码来源:PlayerNiftyController.java

示例15: onStartScreen

import de.lessvoid.nifty.elements.render.TextRenderer; //导入依赖的package包/类
public void onStartScreen() {
    Integer totalPoints;
    
    if(nifty.getCurrentScreen().getScreenId().equals("hud")) {
        // Set the current player in top corner
        nifty.getCurrentScreen().findElementByName(
                "currentRound").getRenderer(TextRenderer.class).setText("Round " +
                    stateManager.getState(PlayAppState.class).getCurrentRound());
        
        // Clear the object hit line if not already cleared.
        nifty.getCurrentScreen().findElementByName(
                "hitObject").getRenderer(TextRenderer.class).setText("");
        
        // Get the current total score
        totalPoints = stateManager.getState(PlayAppState.class).getTotalPoints();
        
        // Set the total points
        nifty.getCurrentScreen().findElementByName("totalPoints").getRenderer(
                TextRenderer.class).setText("Total Score: " + totalPoints);
    }
    
    if(nifty.getCurrentScreen().getScreenId().equals("end")) {
        // Set the end points
        nifty.getCurrentScreen().findElementByName("totalPointsEnd").getRenderer(
                TextRenderer.class).setText("Total Score: " + totalPointsEnd);
    }
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:28,代码来源:GuiAppState.java


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