List of usage examples for com.badlogic.gdx.graphics OrthographicCamera setToOrtho
public void setToOrtho(boolean yDown, float viewportWidth, float viewportHeight)
From source file:com.agateau.pixelwheels.tools.MapScreenshotGenerator.java
License:Apache License
private static Pixmap generateScreenshot(FileHandle tmxFile) { TiledMap map = new TmxMapLoader().load(tmxFile.path()); TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0); int mapWidth = (int) (layer.getWidth() * layer.getTileWidth()); int mapHeight = (int) (layer.getHeight() * layer.getTileHeight()); FrameBuffer fbo = new FrameBuffer(Pixmap.Format.RGB888, mapWidth, mapHeight, false /* hasDepth */); OrthogonalTiledMapRenderer renderer = new OrthogonalTiledMapRenderer(map); OrthographicCamera camera = new OrthographicCamera(); camera.setToOrtho(true /* yDown */, mapWidth, mapHeight); renderer.setView(camera);/*from w ww.j a v a 2 s .com*/ fbo.begin(); renderer.render(); return ScreenUtils.getFrameBufferPixmap(0, 0, mapWidth, mapHeight); }
From source file:com.bladecoder.engineeditor.ui.SceneList.java
License:Apache License
private TextureRegion createBgIcon(String atlas, String region) { TextureAtlas a = new TextureAtlas(Gdx.files .absolute(Ctx.project.getProjectPath() + "/" + Project.ATLASES_PATH + "/1/" + atlas + ".atlas")); AtlasRegion r = a.findRegion(region); if (r == null) { a.dispose();//from w w w . j av a 2s. com return null; } FrameBuffer fbo = new FrameBuffer(Format.RGBA8888, 200, (int) (r.getRegionHeight() * 200f / r.getRegionWidth()), false); SpriteBatch fboBatch = new SpriteBatch(); fboBatch.setColor(Color.WHITE); OrthographicCamera camera = new OrthographicCamera(); camera.setToOrtho(false, fbo.getWidth(), fbo.getHeight()); fboBatch.setProjectionMatrix(camera.combined); Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); fbo.begin(); fboBatch.begin(); fboBatch.draw(r, 0, 0, fbo.getWidth(), fbo.getHeight()); fboBatch.end(); TextureRegion tex = ScreenUtils.getFrameBufferTexture(0, 0, fbo.getWidth(), fbo.getHeight()); // tex.flip(false, true); fbo.end(); Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); fbo.dispose(); a.dispose(); fboBatch.dispose(); return tex; }
From source file:com.digitale.screens.CharCreator.java
License:Open Source License
public CharCreator(final Integer muser) { Stardust3d.currencharacteruid = "" + Stardust3d.charList[0].getUid(); // populate avatardropdown for (int i = 0; i < Stardust3d.avatarList.size(); i++) { listEntries[i] = Stardust3d.avatarList.get(i).getDescription(); // do avatar dropdown population from db here }//from ww w. j a v a 2s.c o m selectedAvatar = ("avatar00.jpg"); OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Button buttonSaveCharacter = new TextButton("Save Character", skin.getStyle(TextButtonStyle.class), "button-save-char"); final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "button-cancel"); final Button buttonRandName = new TextButton("Generate Random Name", skin.getStyle(TextButtonStyle.class), "button-random-name"); final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo"); final SelectBox dropdownsex = new SelectBox(listsexEntries, skin.getStyle(SelectBoxStyle.class), "combosex"); final SelectBox dropdownrace = new SelectBox(listraceEntries, skin.getStyle(SelectBoxStyle.class), "comborace"); final TextField textfieldFirstName = new TextField("", "Firstname", skin.getStyle(TextFieldStyle.class), "textfieldfirstname"); final TextField textfieldSurName = new TextField("", "Surname", skin.getStyle(TextFieldStyle.class), "textfieldsurname"); final Label lableracepicker = new Label("Race", skin.getStyle(LabelStyle.class), "label-race-picker"); final Label lablesexpicker = new Label("Sex", skin.getStyle(LabelStyle.class), "label-sex-picker"); final Label lableportraitpicker = new Label("Portrait", skin.getStyle(LabelStyle.class), "label-portrait-picker"); final Label lablefirstname = new Label("First name", skin.getStyle(LabelStyle.class), "label-firstname"); final Label lablesurname = new Label("Surname", skin.getStyle(LabelStyle.class), "label-surname"); imageActor = new Image(image0); final FlickScrollPane scrollPane = new FlickScrollPane(imageActor, "flickscroll"); final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list"); final ScrollPane scrollPane2 = new ScrollPane(list, skin.getStyle(ScrollPaneStyle.class), "scroll"); scrollPane2.setWidget(list); final SplitPane splitPane = new SplitPane(scrollPane, scrollPane, false, skin.getStyle("default-horizontal", SplitPaneStyle.class), "split"); final Label lablerace = new Label(racetext, skin.getStyle(LabelStyle.class), "label-race"); lablerace.setWrap(true); final ScrollPane scrollPanerace = new ScrollPane(lablerace, skin.getStyle(ScrollPaneStyle.class), "scroll"); // set defaults selectedAvatar = (Stardust3d.avatarList.get(0).getImagename()); racetext = "Humans small size compared to other races, nimble hands and excellent sight allows them to handle thier ships with more finesse than other races."; racetext = racetext + "\n\n Racial Bonus:- +1 to dexterity."; racetext = racetext + "\n Skilled with Human ships and weaponry."; PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 2 + "\nLeadership " + 1 + "\nRecuperation " + 1 + ""; final Label PrimaryStatLabel = new Label(PrimaryStat + Stardust3d.myCharacter.getIntelligence(), skin.getStyle(LabelStyle.class), "primary-stat"); Window window = new Window("Create Character", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5); window.defaults().spaceBottom(5).align("top"); window.row().fill().expandX(); window.add(buttonCancel).colspan(2); window.add().colspan(2).maxWidth(200); window.add(buttonSaveCharacter).colspan(2); window.row(); window.add(lableracepicker).align("middleleft"); window.add(dropdownrace).colspan(1).maxHeight(32); window.add(lableportraitpicker).align("middleleft"); window.add(dropdown).colspan(1).maxHeight(32); window.add(lablesexpicker).align("middleleft"); window.add(dropdownsex).colspan(1).maxHeight(32); window.row(); window.add(scrollPanerace).fill().expand().colspan(2).align("topleft"); window.add(PrimaryStatLabel).colspan(2); window.add().minHeight(256).colspan(2); window.row(); window.add(lablefirstname).align("middleleft"); window.add(textfieldFirstName); window.add(lablesurname).align("middleleft"); window.add(textfieldSurName); window.add(buttonRandName).colspan(2); window.pack(); stage.addActor(window); dropdown.setSelectionListener(new SelectionListener() { @Override public void selected(Actor actor, int index, String value) { SoundManager.playuiclick(); selectedAvatar = (Stardust3d.avatarList.get(index).getImagename()); } }); dropdownsex.setSelectionListener(new SelectionListener() { @Override public void selected(Actor actor, int index, String value) { SoundManager.playuiclick(); selectedSex = value; } }); dropdownrace.setSelectionListener(new SelectionListener() { @Override public void selected(Actor actor, int index, String value) { SoundManager.playuiclick(); switch (index) { case 0: racetext = "Humans small size compared to other races, nimble hands and excellent sight allows them to handle thier ships with more finesse than other races."; racetext = racetext + "\n\n Racial Bonus:- +1 to dexterity."; racetext = racetext + "\n Skilled with Human ships and weaponry."; selectedRace = "Human"; PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 2 + "\nLeadership " + 1 + "\nRecuperation " + 1; break; case 1: racetext = "Jelkek are a war-like race, for generations they have subjugated the Orinians to further their technological advancement. Fearless and bloodthirsty tendencies make their combat pilots unequalled."; racetext = racetext + "\n\n Racial Bonus:- +1 to recuperation."; racetext = racetext + "\n Skilled with Jelkek ships and weaponry."; selectedRace = "Jelkek"; PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 1 + "\nDexterity " + 1 + "\nLeadership " + 1 + "\nRecuperation " + 2; break; case 2: racetext = "Orinians are masters of biotechnology, their skills make them the foremost manufacturers in the universe."; racetext = racetext + "\n\n Racial Bonus:- +1 to intelligence."; racetext = racetext + "\n Skilled with Orinian ships and weaponry."; selectedRace = "Orinian"; PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 2 + "\nSocial " + 1 + "\nDexterity " + 1 + "\nLeadership " + 1 + "\nRecuperation " + 1; break; case 3: racetext = "Gulhurg colonies are unarguably the most complex systems known to science. Their hive-like social structure gives them an unrivalled empathy with others, making them excellent traders."; racetext = racetext + "\n\n Racial Bonus:- +1 to social."; racetext = racetext + "\n Skilled with Gulhurg ships and weaponry."; selectedRace = "Gulhurg"; PrimaryStat = "Stamina " + 1 + "\nIntelligence " + 1 + "\nSocial " + 2 + "\nDexterity " + 1 + "\nLeadership " + 1 + "\nRecuperation " + 1; break; } } }); buttonSaveCharacter.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("Charmaker Complete"); if (textfieldFirstName.getText().length() < 1) { SoundManager.playError(); stage.addActor(Actors.bottomToast("Character first name cannot be blank.", 4, skin)); } else { SoundManager.playuiclick(); // populate game from db, based on this char // Stardust3d.gameMode = 4; String result = Stardust3d.MyDataOp.makeAvatar(selectedAvatar, selectedRace, selectedSex, textfieldFirstName.getText(), textfieldSurName.getText(), muser); if (Stardust3d.DEBUG) System.out.println(LOG_TAG + "Everworld: char creation result: " + result); if (result.trim().equals("ok")) { Stardust3d.gameMode = 3; // repopulate players characters Stardust3d.populateCharacterlist(Stardust3d.muser); doneflag = true; } else { SoundManager.playError(); stage.addActor(Actors.bottomToast("This character name is taken, please choose another.", 4, skin)); } } } }); buttonCancel.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); stage.addActor(Actors.bottomToast("Cancelling character creation", 4, skin)); doneflag = true; Stardust3d.gameMode = 3; } }); buttonRandName.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); // generate human female name if (selectedSex.equals("Female") && selectedRace.equals("Human")) { Stardust3d.MyDataOp.getRandomHumanFemaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate human male name } else if (selectedSex.equals("Male") && selectedRace.equals("Human")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Jelkek female name } else if (selectedSex.equals("Female") && selectedRace.equals("Jelkek")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Jelkek male name } else if (selectedSex.equals("Male") && selectedRace.equals("Jelkek")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Orinian female name } else if (selectedSex.equals("Female") && selectedRace.equals("Orinian")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Orinain male name } else if (selectedSex.equals("Male") && selectedRace.equals("Orinain")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Gulhurg female name } else if (selectedSex.equals("Female") && selectedRace.equals("Gulhurg")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); // generate Gulhurg male name } else if (selectedSex.equals("Male") && selectedRace.equals("Gulhurg")) { Stardust3d.MyDataOp.getRandomHumanMaleName(); textfieldFirstName.setText(Stardust3d.generatedFirstName); textfieldSurName.setText(Stardust3d.generatedSurName); } } }); DialogListener dialogListener = (new DialogListener() { @Override public void optionSelected(int option) { if (Stardust3d.DEBUG) System.out.println("option " + option); if (option == 1) { if (Stardust3d.DEBUG) System.out.println("no"); stage.removeActor(dialog); } if (option == 0) { if (Stardust3d.DEBUG) System.out.println("yes"); stage.removeActor(dialog); } } }); }
From source file:com.digitale.screens.CharPicker.java
License:Open Source License
public CharPicker() { try {/*from w w w . j av a 2s. c om*/ Renderer.bindMeshes(3); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Stardust3d.currencharacteruid = "" + Stardust3d.charList[0].getUid(); int charListLength = 0; for (int i = 0; i < Stardust3d.charList.length; i++) { if (Stardust3d.charList[i].getFirstname() != null) { tempEntries[i] = new String(""); tempEntries[i] = (Stardust3d.charList[i].getFirstname() + " " + Stardust3d.charList[i].getSurname()); tempEntries[i] = tempEntries[i] + (" System " + Stardust3d.charList[i].getSystem()// + " Sta " //+ Stardust3d.charList[i].getStamina() + " Int " //+ Stardust3d.charList[i].getIntelligence() + " Soc " + Stardust3d.charList[i].getSocial() //+ " Dex " + Stardust3d.charList[i].getDexterity() + " Led " //+ Stardust3d.charList[i].getLeadership() + " Rec " //+ Stardust3d.charList[i].getRecuperation() + ". Flying: " + Util.asCapFirstChar(Stardust3d.charList[i].getShipname())); charListLength++; } else { tempEntries[i] = ""; } listEntries = new String[charListLength]; for (int j = 0; j < listEntries.length; j++) { listEntries[j] = tempEntries[j]; } } currentAvatar = Stardust3d.charList[0].getAvatar(); OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); final Button buttonEnterGame = new TextButton("Enter Game", skin.getStyle(TextButtonStyle.class), "button-enter-game"); final Button buttonNewCharacter = new TextButton("New Character", skin.getStyle(TextButtonStyle.class), "button-enter-game"); final Button buttonDeleteCharacter = new TextButton("Delete Character", skin.getStyle(TextButtonStyle.class), "button-enter-game"); final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo"); final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list"); setAvatarPicture(); if (Stardust3d.charList[0].getFirstname() == null) { selectedCharacter = " "; } else { selectedCharacter = (Stardust3d.charList[0].getFirstname() + " " + Stardust3d.charList[0].getSurname()); } final Label fpsLabel = new Label(selectedCharacter, skin.getStyle(LabelStyle.class), "label"); Window window = new Window("Choose Character", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.align(Align.TOP); window.defaults().pad(5); window.defaults().spaceBottom(5).align("top"); window.row().fill().expandX().maxHeight(28); window.add(buttonNewCharacter); window.add(buttonDeleteCharacter); window.add(buttonEnterGame); window.row(); window.add(dropdown).colspan(3); window.row(); window.add(imageActor).size(128, 128); window.add(fpsLabel).colspan(2).align("centre"); window.add(); window.pack(); stage.addActor(window); dropdown.setSelectionListener(new SelectionListener() { @Override public void selected(Actor actor, int index, String value) { SoundManager.playuiclick(); selectedCharacter = (Stardust3d.charList[index].getFirstname() + " " + Stardust3d.charList[index].getSurname()); Stardust3d.currencharacteruid = "" + Stardust3d.charList[index].getUid(); currentAvatar = Stardust3d.charList[index].getAvatar(); setAvatarPicture(); ((Label) stage.findActor("label")).setText(selectedCharacter); } }); buttonEnterGame.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("Charpicker Close"); SoundManager.playuiclick(); if (Stardust3d.DEBUG) System.out.println("character ID" + Stardust3d.currencharacteruid); if (Integer.valueOf(Stardust3d.currencharacteruid) != 0) { //populate game from db, based on this char Stardust3d.gameMode = 4; //init character Stardust3d.MyDataOp.get3dChar(Integer.valueOf(Stardust3d.currencharacteruid)); // if (!Stardust3d.DEBUG) { String passed = Stardust3d.MyDataOp.postChat(Stardust3d.myCharacter.getFirstname() + " " + Stardust3d.myCharacter.getSurname() + " has joined the game.", 1, 48); } Stardust3d.MyDataOp.getInventory(Integer.valueOf(Stardust3d.currencharacteruid), true); Stardust3d.MyDataOp.getSolarSystem(Stardust3d.myCharacter.getX(), Stardust3d.myCharacter.getX(), Stardust3d.myCharacter.getZ()); Stardust3d.MyDataOp.getLocalPlayers(Stardust3d.myCharacter.getX(), Stardust3d.myCharacter.getY(), Stardust3d.myCharacter.getZ(), true); Stardust3d.MyDataOp.start(); try { Renderer.bindMeshes(4); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } doneflag = true; } else { stage.addActor( Actors.bottomToast("Please select a character before entering the game.", 4, skin)); } } }); buttonNewCharacter.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); if (Stardust3d.numberOfCharacters >= 10) { SoundManager.playError(); stage.addActor(Actors.bottomToast( "You already have 10 characters, you must delete one first, before you can create a new one.", 4, skin)); } else { // startNewCharActivity(); Stardust3d.gameMode = 15; stage.addActor(Actors.bottomToast("Creating new character", 4, skin)); doneflag = true; } } }); DialogListener dialogListener = (new DialogListener() { @Override public void optionSelected(int option) { System.out.println("option " + option); if (option == 1) { System.out.println("no"); stage.removeActor(dialog); } if (option == 0) { System.out.println("yes"); System.out.println("DELETED" + selectedCharacter + " " + Stardust3d.currencharacteruid); stage.removeActor(dialog); } } }); dialogTexts = ("Are you sure you wish to delete " + selectedCharacter + ", and all the contents of thier inventory?"); dialog = (Actors.twoOptionsDialog(selectedCharacter, dialogListener, "Delete Character", "Yes", "No", skin)); buttonDeleteCharacter.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); stage.addActor(dialog); } }); }
From source file:com.digitale.screens.Help.java
License:Open Source License
public Help(String newslines) { OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn();/* w w w. j a va2 s. co m*/ stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Button buttonLogin = new TextButton("Close", skin.getStyle(TextButtonStyle.class), "buttonLogin"); final Label labelStories = new Label(newslines, skin); labelStories.setWrap(true); final ScrollPane scrollPane2 = new ScrollPane(labelStories, skin.getStyle(ScrollPaneStyle.class), "scroll"); // configures an example of a TextField in password mode. final Label lableNews = new Label("Basic Help: ", skin); Window window = new Window("Help Screen", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5); //build table window.row().fill().expandX(); window.add(); window.add(); window.add(); window.add(buttonLogin).colspan(1).align("right"); window.row(); window.add(lableNews).align("left"); window.row(); window.add(scrollPane2).fill().expand().colspan(4); window.row(); window.pack(); stage.addActor(window); buttonLogin.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { System.out.println("help Close pressed"); SoundManager.playuiclick(); if (Stardust3d.mloginOK) { Stardust3d.gameMode = 4; doneflag = true; } else { Stardust3d.gameMode = 2; doneflag = true; } } }); }
From source file:com.digitale.screens.Login.java
License:Open Source License
public Login(String newslines) { //all sounds loaded, now bind them try {//from w w w . j a v a 2s . c o m Renderer.bindMeshes(0); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn(); stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Button buttonLogin = new TextButton("Log in", skin.getStyle(TextButtonStyle.class), "buttonLogin"); final Button buttonHelp = new TextButton("Quick Help", skin.getStyle(TextButtonStyle.class), "buttonHelp"); final Button buttonNewAccount = new TextButton("New Account", skin.getStyle(TextButtonStyle.class), "buttonNewAccount"); final Button buttonOptions = new TextButton("Options", skin.getStyle(TextButtonStyle.class), "buttonOptions"); final CheckBox checkBox = new CheckBox("Remember account name and password.", skin.getStyle(CheckBoxStyle.class), "checkbox"); final TextField textfieldUserName = new TextField("", "Account Name", skin.getStyle(TextFieldStyle.class), "textfield"); // final List list = new List(listEntries, // skin.getStyle(ListStyle.class), "list"); final Label labelStories = new Label(newslines, skin); labelStories.setWrap(true); final ScrollPane scrollPane2 = new ScrollPane(labelStories, skin.getStyle(ScrollPaneStyle.class), "scroll"); // configures an example of a TextField in password mode. final Label lableNews = new Label("News: ", skin); final TextField passwordTextField = new TextField("", "password", skin); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); textfieldUserName.getOnscreenKeyboard().show(true); Boolean booltemp = prefs.getBoolean("nopoly", false); //is save account checked in prefs if (booltemp) { //if preferences account is too short to have been set to a valid account name checkBox.setChecked(true); String temp = prefs.getString("un", ""); ac = temp; textfieldUserName.setText(ac); temp = prefs.getString("cullingtree", ""); String pw = null; try { pw = new String(mcrypt.decrypt(temp.trim())); pw = pw.replace('~', ' ').trim(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } passwordTextField.setText(pw); } Window window = new Window("Login Screen", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5); //build table window.row().fill().expandX(); window.add(buttonNewAccount).colspan(1).align("Centre"); window.add(buttonOptions).colspan(1).align("center"); window.add(buttonHelp).colspan(1).align("center"); window.add(buttonLogin).colspan(1).align("right"); window.row(); window.add(textfieldUserName).minWidth(100).expandX().fillX().colspan(2); window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2); window.row(); window.add(lableNews).align("left"); window.row(); window.add(scrollPane2).fill().expand().colspan(4); window.row(); window.add(checkBox).colspan(4); window.row(); window.pack(); stage.addActor(window); SoundManager.init(); try { Renderer.bindMeshes(1); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } textfieldUserName.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); buttonLogin.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { try { Renderer.bindMeshes(2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (Stardust3d.DEBUG) System.out.println("login button pressed"); SoundManager.playuiclick(); ac = textfieldUserName.getText().toString(); String pw = passwordTextField.getText().toString(); if (checkpass(pw, pw) && checkuser(ac)) { String passed = Stardust3d.MyDataOp.login(ac, pw); if (Stardust3d.DEBUG) System.out.println("passed " + passed); if (passed.equals("true")) { SoundManager.playconfirm(); stage.addActor(Actors.bottomToast("Login sucessful", 4, skin)); Stardust3d.mloginOK = true; Stardust3d.gameMode = 3; //get players characters Stardust3d.populateCharacterlist(Stardust3d.muser); doneflag = true; isDone(); } else if (passed.equals("NOT_ACTIVE")) { SoundManager.playError(); stage.addActor(Actors.bottomToast( "Login failed, this account is not active, check your Email.", 4, skin)); } else if (passed.equals("false")) { SoundManager.playError(); stage.addActor(Actors.bottomToast( "Login failed, please check your account name and password.", 4, skin)); } } } }); buttonOptions.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("options button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 6; doneflag = true; } }); buttonNewAccount.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("New account button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 14; doneflag = true; } }); buttonHelp.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { if (Stardust3d.DEBUG) System.out.println("help button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 9; doneflag = true; } }); checkBox.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { SoundManager.playuiclick(); String encrypted = null; if (Stardust3d.DEBUG) System.out.println("remeber account name pressed"); Stardust3d.mremeberAccountname = checkBox.isChecked(); //if user wants to save login if (Stardust3d.mremeberAccountname) { String pw = passwordTextField.getText().toString(); String acc = textfieldUserName.getText().toString(); //check user has entered account details before saving if (pw.length() > 8 && acc.length() > 8) { /* Encrypt */ try { encrypted = (mcrypt.encrypt(pw)); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname); prefs.putString("un", acc); prefs.putString("cullingtree", encrypted); prefs.flush(); } else { stage.addActor(Actors.bottomToast( "You need to enter your account name and password before trying to save them.", 4, skin)); checkBox.setChecked(false); } } else { stage.addActor(Actors.bottomToast("Saved account details cleared.", 4, skin)); //clear saved account details prefs.putBoolean("nopoly", Stardust3d.mremeberAccountname); prefs.putString("un", ""); prefs.putString("cullingtree", ""); prefs.flush(); } } }); }
From source file:com.digitale.screens.NewAccount.java
License:Open Source License
public NewAccount() { OrthographicCamera camera; batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png")); xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true); xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear); background = new Texture(Gdx.files.internal("data/bgpland.jpg")); camera = new OrthographicCamera(); camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); fadeIn();// w ww .jav a 2 s . c o m stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(stage); // Group.debug = true; final Label labelEmail = new Label( "Valid email address (Stardust will send an activation mail to this address).", skin); final Label labelAccountName = new Label("Account Name (must contain at least 8 letters or numbers).", skin); final Label labelPassword1 = new Label( "Password (must be at least 8 letters and include a capital letter and a number).", skin); final Label labelPassword2 = new Label("Repeat Password", skin); final Button buttonCreateAccount = new TextButton("Create Account", skin.getStyle(TextButtonStyle.class), "buttonCreateAccount"); final Button buttonCancel = new TextButton("Cancel", skin.getStyle(TextButtonStyle.class), "buttonCancel"); final TextField textfieldEmail = new TextField("", "Email address", skin.getStyle(TextFieldStyle.class), "textfield"); final TextField textfieldUserName = new TextField("", "Account Name", skin.getStyle(TextFieldStyle.class), "textfield"); // configure TextField in password mode. final Label lableNews = new Label("News: ", skin); final TextField passwordTextField = new TextField("", "Password", skin); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); //password confirmation box final TextField password2TextField = new TextField("", "Repeat password", skin); password2TextField.setPasswordCharacter('*'); password2TextField.setPasswordMode(true); Window window = new Window("New Account Screen", skin.getStyle(WindowStyle.class), "window"); if (Stardust3d.DEBUG) window.debug(); window.x = window.y = 0; window.setFillParent(true); window.setMovable(false); window.defaults().pad(5).align("left"); //build table window.row().fill().expandX(); window.add(buttonCancel).colspan(1); window.add(); window.add(buttonCreateAccount).colspan(1); window.row(); window.add(labelEmail).colspan(3); window.row(); window.add(textfieldEmail).minWidth(400).colspan(3); window.row(); window.add(labelAccountName).colspan(3); window.row(); window.add(textfieldUserName).minWidth(400).colspan(3); window.row(); window.add(labelPassword1).minWidth(400).colspan(3); window.row(); window.add(passwordTextField).minWidth(400).colspan(3); window.row(); window.add(labelPassword2).minWidth(400).colspan(3); window.row(); window.add(password2TextField).minWidth(400).colspan(3); window.pack(); stage.addActor(window); textfieldUserName.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); buttonCreateAccount.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { System.out.println("create account button pressed"); SoundManager.playuiclick(); ac = textfieldUserName.getText().toString(); mpw1 = passwordTextField.getText().toString(); mpw2 = password2TextField.getText().toString(); memail = textfieldEmail.getText().toString(); if (checkEmail(memail.toLowerCase())) { if (checkuser(ac)) { if (checkpass(mpw1, mpw2)) { if (checkuserandpassaredifferent(ac, mpw1)) { Stardust3d.MyDataOp.getFreeUser(ac); if (Stardust3d.muserExists.equals("0")) { SoundManager.playconfirm(); if (Stardust3d.DEBUG) System.out.println(LOG_TAG + " " + mpw1); stage.addActor(Actors.bottomToast( "Your account has been created, please check your EMail.", 4, skin)); Stardust3d.MyDataOp.createUser(ac, mpw1, memail); //TODO need pause in here so toast can display Stardust3d.gameMode = 2; doneflag = true; } else { //user name is already in database SoundManager.playError(); stage.addActor(Actors.bottomToast( "Sorry, this account name is used, please try another.", 4, skin)); } } else { //the username and password are the same SoundManager.playError(); stage.addActor(Actors.bottomToast("Your username and password cannot be the same.", 4, skin)); } } else { //password is not good enough SoundManager.playError(); stage.addActor(Actors.bottomToast( "There is a problem with your password, please check it.", 4, skin)); } } else { //username is not good enough SoundManager.playError(); stage.addActor(Actors.bottomToast("There is a problem with your username, please check it.", 4, skin)); } } else { //email is not valid SoundManager.playError(); stage.addActor( Actors.bottomToast("This does not appear to be a valid Email address.", 4, skin)); } } }); buttonCancel.setClickListener(new ClickListener() { public void click(Actor actor, float x, float y) { System.out.println("new account cancel button pressed"); SoundManager.playuiclick(); Stardust3d.gameMode = 2; doneflag = true; } }); }
From source file:com.eightpuzzle.game.EightPuzzle.java
License:Apache License
@Override public void create() { gameFont = new BitmapFont(); solvedFont = new BitmapFont(); batch = new SpriteBatch(); aspectRatio = (float) Gdx.graphics.getHeight() / (float) Gdx.graphics.getWidth(); OrthographicCamera camera = new OrthographicCamera(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.position.set(GAME_WIDTH/2, GAME_HEIGHT/2, 0) camera.setToOrtho(false, GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio); //camera.setToOrtho(false,GAME_WIDTH,GAME_HEIGHT); stage = new Stage(new ExtendViewport(GAME_WIDTH * aspectRatio, GAME_HEIGHT * aspectRatio, camera));//Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), camera)); Gdx.input.setInputProcessor(stage);/* w w w . j av a2s . co m*/ // A skin can be loaded via JSON or defined programmatically, either is fine. Using a skin is optional but strongly // recommended solely for the convenience of getting a texture, region, etc as a drawable, tinted drawable, etc. skin = new Skin(); // Generate a 1x1 white texture and store it in the skin named "white". Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888); pixmap.setColor(Color.WHITE); pixmap.fill(); skin.add("white", new Texture(pixmap)); // Store the default libgdx font under the name "default". skin.add("default", new BitmapFont()); // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this doesn't overwrite the font. TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY); textButtonStyle.down = skin.newDrawable("white", Color.DARK_GRAY); //textButtonStyle.checked = skin.newDrawable("white", Color.BLUE); textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY); textButtonStyle.font = skin.getFont("default"); skin.add("default", textButtonStyle); Label.LabelStyle labelSty = new Label.LabelStyle(); labelSty.font = skin.getFont("default"); //labelSty.fontColor = Color.GREEN; skin.add("default", labelSty); WindowStyle ws = new Window.WindowStyle(); ws.titleFont = new BitmapFont(); ws.background = skin.newDrawable("white", Color.BLACK); skin.add("default", ws); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Zig.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); parameter.size = 25; gameFont = generator.generateFont(parameter); FreeTypeFontParameter parameter2 = new FreeTypeFontParameter(); parameter2.size = 100; parameter2.color = Color.GREEN; solvedFont = generator.generateFont(parameter2); generator.dispose(); FileHandle blue, n1, n2, n3, n4, n5, n6, n7, n8, solveUp, solveDown; if (Gdx.app.getType() == ApplicationType.Desktop) { blue = Gdx.files.internal("icons64px/blue-square.png"); n1 = Gdx.files.internal("icons64px/Number-1-icon.png"); n2 = Gdx.files.internal("icons64px/Number-2-icon.png"); n3 = Gdx.files.internal("icons64px/Number-3-icon.png"); n4 = Gdx.files.internal("icons64px/Number-4-icon.png"); n5 = Gdx.files.internal("icons64px/Number-5-icon.png"); n6 = Gdx.files.internal("icons64px/Number-6-icon.png"); n7 = Gdx.files.internal("icons64px/Number-7-icon.png"); n8 = Gdx.files.internal("icons64px/Number-8-icon.png"); solveUp = blue; solveDown = blue; } else { blue = Gdx.files.internal("icons256px/blue-circle.png"); n1 = Gdx.files.internal("icons256px/Number-1-icon.png"); n2 = Gdx.files.internal("icons256px/Number-2-icon.png"); n3 = Gdx.files.internal("icons256px/Number-3-icon.png"); n4 = Gdx.files.internal("icons256px/Number-4-icon.png"); n5 = Gdx.files.internal("icons256px/Number-5-icon.png"); n6 = Gdx.files.internal("icons256px/Number-6-icon.png"); n7 = Gdx.files.internal("icons256px/Number-7-icon.png"); n8 = Gdx.files.internal("icons256px/Number-8-icon.png"); solveUp = Gdx.files.internal("icons256px/Box_Green.png"); solveDown = Gdx.files.internal("icons256px/rectangle_green.png"); } Texture bSquare = new Texture(blue); Texture n1T = new Texture(n1); Texture n2T = new Texture(n2); Texture n3T = new Texture(n3); Texture n4T = new Texture(n4); Texture n5T = new Texture(n5); Texture n6T = new Texture(n6); Texture n7T = new Texture(n7); Texture n8T = new Texture(n8); TextureRegion bSquareReg = new TextureRegion(bSquare); TextureRegion n1Reg = new TextureRegion(n1T); TextureRegion n2Reg = new TextureRegion(n2T); TextureRegion n3Reg = new TextureRegion(n3T); TextureRegion n4Reg = new TextureRegion(n4T); TextureRegion n5Reg = new TextureRegion(n5T); TextureRegion n6Reg = new TextureRegion(n6T); TextureRegion n7Reg = new TextureRegion(n7T); TextureRegion n8Reg = new TextureRegion(n8T); TextureRegionDrawable solveDUp = new TextureRegionDrawable(new TextureRegion(new Texture(solveUp))); TextureRegionDrawable solveDDown = new TextureRegionDrawable(new TextureRegion(new Texture(solveDown))); ImageTextButton.ImageTextButtonStyle tbSty = new ImageTextButton.ImageTextButtonStyle(solveDUp, solveDDown, solveDUp, gameFont); skin.add("default", tbSty); ImageButtonStyle bSquareSty = new ImageButtonStyle(); bSquareSty.imageUp = new TextureRegionDrawable(bSquareReg); bSquareSty.imageDown = new TextureRegionDrawable(bSquareReg); ImageButtonStyle n1Sty = new ImageButtonStyle(); n1Sty.imageUp = new TextureRegionDrawable(n1Reg); n1Sty.imageDown = new TextureRegionDrawable(n1Reg); ImageButtonStyle n2Sty = new ImageButtonStyle(); n2Sty.imageUp = new TextureRegionDrawable(n2Reg); n2Sty.imageDown = new TextureRegionDrawable(n2Reg); ImageButtonStyle n3Sty = new ImageButtonStyle(); n3Sty.imageUp = new TextureRegionDrawable(n3Reg); n3Sty.imageDown = new TextureRegionDrawable(n3Reg); ImageButtonStyle n4Sty = new ImageButtonStyle(); n4Sty.imageUp = new TextureRegionDrawable(n4Reg); n4Sty.imageDown = new TextureRegionDrawable(n4Reg); ImageButtonStyle n5Sty = new ImageButtonStyle(); n5Sty.imageUp = new TextureRegionDrawable(n5Reg); n5Sty.imageDown = new TextureRegionDrawable(n5Reg); ImageButtonStyle n6Sty = new ImageButtonStyle(); n6Sty.imageUp = new TextureRegionDrawable(n6Reg); n6Sty.imageDown = new TextureRegionDrawable(n6Reg); ImageButtonStyle n7Sty = new ImageButtonStyle(); n7Sty.imageUp = new TextureRegionDrawable(n7Reg); n7Sty.imageDown = new TextureRegionDrawable(n7Reg); ImageButtonStyle n8Sty = new ImageButtonStyle(); n8Sty.imageUp = new TextureRegionDrawable(n8Reg); n8Sty.imageDown = new TextureRegionDrawable(n8Reg); ImageButton b1 = new ImageButton(n1Sty); b1.addListener(new MyChangeListener(1)); map.put(1, b1); ImageButton holeB = new ImageButton(bSquareSty); map.put(0, holeB); ImageButton ib = new ImageButton(n2Sty); ib.addListener(new MyChangeListener(2)); map.put(2, ib); ImageButton b4 = new ImageButton(n3Sty); b4.addListener(new MyChangeListener(3)); ImageButton b5 = new ImageButton(n4Sty); b5.addListener(new MyChangeListener(4)); ImageButton b6 = new ImageButton(n5Sty); b6.addListener(new MyChangeListener(5)); map.put(3, b4); map.put(4, b5); map.put(5, b6); ImageButton b7 = new ImageButton(n6Sty); b7.addListener(new MyChangeListener(6)); ImageButton b8 = new ImageButton(n7Sty); b8.addListener(new MyChangeListener(7)); ImageButton b9 = new ImageButton(n8Sty); b9.addListener(new MyChangeListener(8)); map.put(6, b7); map.put(7, b8); map.put(8, b9); newGameB = new ImageTextButton("New Game", skin); newGameB.addListener(new NewGameListener()); solveB = new ImageTextButton("Solve", skin); solveB.addListener(new MySolveListener()); newGameBoard(); //table.padTop(50); //table.padBottom(20); VerticalGroup vg = new VerticalGroup(); //vg.padTop(50); vg.setFillParent(true); vg.addActor(newGameB); vg.addActor(table); vg.addActor(solveB); stage.addActor(vg); }
From source file:com.gmail.emersonmx.tictactoe.BaseScreen.java
License:Open Source License
protected void setup() { Viewport viewport = new FitViewport(TicTacToe.WINDOW_WIDTH, TicTacToe.WINDOW_HEIGHT); OrthographicCamera camera = (OrthographicCamera) viewport.getCamera(); camera.setToOrtho(false, TicTacToe.WINDOW_WIDTH, TicTacToe.WINDOW_HEIGHT); Gdx.gl.glClearColor(0, 0, 0, 1);/*from w w w . ja v a2 s.c o m*/ stage = new Stage(viewport); Gdx.input.setInputProcessor(stage); }
From source file:com.mob.dao.objects.Map.java
License:Open Source License
/** * Renders a map layer to it's internal FrameBuffer Object * * @param layer//from w w w . ja va 2 s . co m * @return void */ public void renderLayerToBuffer(int layer) { int width = (int) (Map.MAX_MAP_SIZE_WIDTH * Map.TILE_PIXEL_WIDTH); int height = (int) (Map.MAX_MAP_SIZE_HEIGHT * Map.TILE_PIXEL_HEIGHT); OrthographicCamera camera = new OrthographicCamera(width, height); camera.setToOrtho(true, width, height); FrameBuffer fbo = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false); SpriteBatch sb = new SpriteBatch(); sb.setProjectionMatrix(camera.combined); fbo.begin(); sb.enableBlending(); Gdx.gl.glBlendFuncSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl.glViewport(0, 0, width, height); Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); sb.begin(); this.renderLayer(sb, layer); sb.end(); fbo.end(); this.bufferedLayer = fbo.getColorBufferTexture(); }