/** * Ajoute un timer à l'interface. * * @param aTimer Le Timer à utiliser */ public void addTimer(final Timer aTimer) { LabelStyle timerStyle = new LabelStyle(); timerStyle.font = skin.getFont("timer"); timerStyle.background = skin.getDrawable("frame_left"); skin.add("timer", timerStyle); aTimer.addObserver(this); timerColorAction = new ColorAction(); timerColorAction.setEndColor(Color.WHITE); timerColorAction.setDuration(0.5f); timerLabel = new Label(aTimer.toString(), skin, "timer"); timerContainer.setActor(timerLabel); timerContainer.height(48); }
public NewSave(OdysseeDesMaths game) { this.game = game; viewport = new StretchViewport(WIDTH, HEIGHT); stage = new Stage(viewport); Gdx.input.setInputProcessor(stage); table = new Table(); table.setFillParent(true); stage.addActor(table); skin = new Skin(); skin.addRegions(Assets.getManager().get(Assets.UI_MAIN, TextureAtlas.class)); skin.addRegions(Assets.getManager().get(Assets.UI_ORANGE, TextureAtlas.class)); skin.add("background", Assets.getManager().get(Assets.MAIN_MENU_BACKGROUND, Texture.class)); skin.add("title", new LabelStyle(TITLE, null)); skin.add("text", new LabelStyle(TEXT, null)); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = TEXT; textButtonStyle.up = skin.getDrawable("button"); textButtonStyle.down = skin.getDrawable("button_pressed"); skin.add("textButton", textButtonStyle); TextFieldStyle textFieldStyle = new TextFieldStyle(); textFieldStyle.font = TEXT; textFieldStyle.fontColor = Color.BLACK; textFieldStyle.background = skin.getDrawable("field"); textFieldStyle.focusedBackground = skin.getDrawable("field_focused"); skin.add("textField", textFieldStyle); ButtonStyle returnButtonStyle = new ButtonStyle(); returnButtonStyle.up = skin.getDrawable("return"); skin.add("returnButton", returnButtonStyle); gameTitle = new Label("L'Odyssée des Maths", skin, "title"); saveNameLabel = new Label("Nom:", skin, "text"); saveNameField = new TextField("", skin, "textField"); saveNameField.setMaxLength(7); submit = new TextButton("C'est parti !", skin, "textButton"); audioButtons = new AudioButtons(); returnButton = new Button(skin, "returnButton"); table.setBackground(skin.getDrawable("background")); table.padTop(HEIGHT / 13); table.add(gameTitle).top().colspan(2).padBottom(HEIGHT / 9).expandX(); table.row().padBottom(HEIGHT / 10); table.add(saveNameLabel).right().padRight(10); table.add(saveNameField).size(200, 48).left(); table.row(); table.add(submit).size(350, 64).top().colspan(2).expandY(); table.row(); table.add(audioButtons).left(); table.add(returnButton).right(); NewSaveListener listener = new NewSaveListener(); submit.addListener(listener); returnButton.addListener(listener); noNameSubmitAction = new ColorAction(); noNameSubmitAction.setEndColor(Color.WHITE); noNameSubmitAction.setDuration(0.5f); }