/** * Attaches Statistics View to guiNode and displays it on the screen * above FPS statistics line. * */ public void loadStatsView() { statsView = new StatsView("Statistics View", app.getAssetManager(), app.getRenderer().getStatistics()); // move it up so it appears above fps text statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0); statsView.setEnabled(showStats); statsView.setCullHint(showStats ? CullHint.Never : CullHint.Always); guiNode.attachChild(statsView); }
public StatsView(String name, AssetManager manager, Statistics stats){ super(name); setQueueBucket(Bucket.Gui); setCullHint(CullHint.Never); statistics = stats; statistics.setEnabled(enabled); statLabels = statistics.getLabels(); statData = new int[statLabels.length]; BitmapFont font = manager.loadFont("Interface/Fonts/Console.fnt"); statText = new BitmapText(font); statText.setLocalTranslation(0, statText.getLineHeight() * statLabels.length, 0); attachChild(statText); addControl(this); }
public void update(float tpf) { if (!isEnabled()) return; statistics.getData(statData); stringBuilder.setLength(0); // Need to walk through it backwards, as the first label // should appear at the bottom, not the top. for (int i = statLabels.length - 1; i >= 0; i--) { stringBuilder.append(statLabels[i]).append(" = ").append(statData[i]).append('\n'); } statText.setText(stringBuilder); // Moved to ResetStatsState to make sure it is // done even if there is no StatsView or the StatsView // is disable. //statistics.clearFrame(); }
public void setDisplayStatView(boolean show) { showStats = show; if (statsView != null ) { statsView.setEnabled(show); statsView.setCullHint(show ? CullHint.Never : CullHint.Always); if (darkenStats != null) { darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); } } }
/** * Attaches Statistics View to guiNode and displays it on the screen * above FPS statistics line. * */ public void loadStatsView() { statsView = new StatsView("Statistics View", assetManager, renderer.getStatistics()); // move it up so it appears above fps text statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0); guiNode.attachChild(statsView); }
/** * Initializes game */ @Override public void simpleInitApp() { Logger.getLogger("com.jme3").setLevel(Level.WARNING); flyCam.setEnabled(false); statsView.setCullHint(CullHint.Always); Keys(); defaultFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); pressStart = new BitmapText(defaultFont, false); fpsScoreText = new BitmapText(defaultFont, false); loadText(fpsScoreText, "Current Score: 0", defaultFont, 0, 2, 0); loadText(pressStart, "PRESS ENTER", defaultFont, 0, 5, 0); player = createPlayer(); rootNode.attachChild(player); cubeField = new ArrayList<Geometry>(); obstacleColors = new ArrayList<ColorRGBA>(); gameReset(); } /**
public void loadDarken() { Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", new ColorRGBA(0,0,0,0.5f)); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); darkenFps = new Geometry("StatsDarken", new Quad(200, fpsText.getLineHeight())); darkenFps.setMaterial(mat); darkenFps.setLocalTranslation(0, 0, -1); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenFps); darkenStats = new Geometry("StatsDarken", new Quad(200, statsView.getHeight())); darkenStats.setMaterial(mat); darkenStats.setLocalTranslation(0, fpsText.getHeight(), -1); darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenStats); }
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (enabled) { fpsText.setCullHint(showFps ? CullHint.Never : CullHint.Always); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always); statsView.setEnabled(showStats); statsView.setCullHint(showStats ? CullHint.Never : CullHint.Always); darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); } else { fpsText.setCullHint(CullHint.Always); darkenFps.setCullHint(CullHint.Always); statsView.setEnabled(false); statsView.setCullHint(CullHint.Always); darkenStats.setCullHint(CullHint.Always); } }
public void loadDarken() { Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", new ColorRGBA(0,0,0,0.5f)); mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); darkenFps = new Geometry("StatsDarken", new Quad(200, fpsText.getLineHeight())); darkenFps.setMaterial(mat); darkenFps.setLocalTranslation(0, 0, -1); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenFps); darkenStats = new Geometry("StatsDarken", new Quad(200, statsView.getHeight())); darkenStats.setMaterial(mat); darkenStats.setLocalTranslation(0, fpsText.getHeight(), -1); darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); guiNode.attachChild(darkenStats); }
public StatsView(String name, AssetManager manager, Statistics stats){ super(name); setQueueBucket(Bucket.Gui); setCullHint(CullHint.Never); statistics = stats; statLabels = statistics.getLabels(); statData = new int[statLabels.length]; labels = new BitmapText[statLabels.length]; BitmapFont font = manager.loadFont("Interface/Fonts/Console.fnt"); for (int i = 0; i < labels.length; i++){ labels[i] = new BitmapText(font); labels[i].setLocalTranslation(0, labels[i].getLineHeight() * (i+1), 0); attachChild(labels[i]); } addControl(this); }
/** * Attaches Statistics View to guiNode and displays it on the screen * above FPS statistics line. * */ public void loadStatsView() { statsView = new StatsView("Statistics View", app.getAssetManager(), app.getRenderer().getStatistics()); // move it up so it appears above fps text statsView.setLocalTranslation(0, fpsText.getLineHeight(), 0); statsView.setEnabled(showStats); statsView.setCullHint(showStats ? CullHint.Never : CullHint.Always); guiNode.attachChild(statsView); }
public void setDisplayStatView(boolean show) { statsView.setEnabled(show); statsView.setCullHint(show ? CullHint.Never : CullHint.Always); }
public void update(float tpf) { if (!isEnabled()) return; statistics.getData(statData); stringBuilder.setLength(0); // Need to walk through it backwards, as the first label // should appear at the bottom, not the top. for (int i = statLabels.length - 1; i >= 0; i--) { stringBuilder.append(statLabels[i]).append(" = ").append(statData[i]).append('\n'); } statText.setText(stringBuilder); // Moved to ResetStatsState to make sure it is // done even if there is no StatsView or the StatsView // is disable. //statistics.clearFrame(); }
public StatsView(String name, AssetManager manager, Statistics stats){ super(name); setQueueBucket(Bucket.Gui); setCullHint(CullHint.Never); statistics = stats; statistics.setEnabled(enabled); statLabels = statistics.getLabels(); statData = new int[statLabels.length]; BitmapFont font = manager.loadFont("Interface/Fonts/Console.fnt"); statText = new BitmapText(font); statText.setLocalTranslation(0, statText.getLineHeight() * statLabels.length, 0); attachChild(statText); addControl(this); }
public void setDisplayStatView(boolean show) { showStats = show; if (statsView != null ) { statsView.setEnabled(show); statsView.setCullHint(show ? CullHint.Never : CullHint.Always); if (darkenStats != null) { darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); } } }
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (enabled) { fpsText.setCullHint(showFps ? CullHint.Never : CullHint.Always); darkenFps.setCullHint(showFps && darkenBehind ? CullHint.Never : CullHint.Always); statsView.setEnabled(showStats); statsView.setCullHint(showStats ? CullHint.Never : CullHint.Always); darkenStats.setCullHint(showStats && darkenBehind ? CullHint.Never : CullHint.Always); } else { fpsText.setCullHint(CullHint.Always); darkenFps.setCullHint(CullHint.Always); statsView.setEnabled(false); statsView.setCullHint(CullHint.Always); darkenStats.setCullHint(CullHint.Always); } }