/** * Creates the screen of a level within the placement mode. This is the * screen which is presented to the user upon entering a recoloring or * termedit level. * * @param game * the backreference to the central game * @param controller * the game controller, which is responsible for the played level */ public PlacementModeScreen(AlligatorApp game, GameController controller) { super(game); gameController = controller; AssetManager assetManager = AssetManager.getInstance(); assetManager.load(getAssetDirPath() + "textures/pack.atlas", TextureAtlas.class); goalDialog = new Dialog("", StyleHelper.getInstance().getDialogStyle()); fillTable(); final int packageIndex = gameController.getLevel().getPackageIndex(); final LevelPackagesController packagesController = game .getLevelPackagesController(); final LevelPackage pack = packagesController.getLevelPackages().get( packageIndex); setBackground(pack.getDesign()); game.getSettingController().addSettingChangeListener(this); // load graphics for animation/tutorial if (gameController.getLevel().hasAnimation()) { List<String> animations = gameController.getLevel().getAnimation(); for (String animation : animations) { assetManager.load(animation, Texture.class); } } }
private void buildTutorialDialog(String animationPath) { AssetManager manager = AssetManager.getInstance(); StyleHelper helper = StyleHelper.getInstance(); final Dialog tutorial = new Dialog("", StyleHelper.getInstance() .getDialogStyle()); tutorial.clear(); tutorial.fadeDuration = 0f; Table buttonTable = new Table(); Drawable drawable = new TextureRegionDrawable(new TextureRegion( manager.get(animationPath, Texture.class))); // used image button here because it keeps the ratio of the texture ImageButton tutorialImage = new ImageButton(drawable); ImageButton okay = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-check")); okay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { tutorial.hide(); } }); buttonTable.add(okay).size(100).bottom().right().expand().pad(30); tutorial.stack(tutorialImage, buttonTable).height(500).width(800); tutorial.show(stage); }
public ColorButton(Color c) { this.c = c; AssetManager assets = AssetManager.getInstance(); Drawable up; if (colorBlindEnabled) { up = new TextureRegionDrawable(new TextureRegion(assets.getPatternTexture(c))); } else { up = new TextureRegionDrawable(new TextureRegion(assets.getColorTexture(c))); } this.setStyle(new Button.ButtonStyle(up, up, up)); }
/** * Is called by the application lifecycle on creation. Does all the initialization that hasn't * been done by the constructor. */ @Override public void create() { de.croggle.data.AssetManager.initialize(); StyleHelper.initialize(); SoundHelper.initialize(); if (!HEADLESS) { this.batch = new SpriteBatch(); } // catch android back key Gdx.input.setCatchBackKey(true); // initialize Controllers persistenceManager = new PersistenceManager(this); statisticController = new StatisticController(this); settingController = new SettingController(this); profileController = new ProfileController(this); soundController = new SoundController(); levelPackagesController = new LevelPackagesController(this); // Not sure how to initialize those. achievementController = new AchievementController(this); levelPackagesController = new LevelPackagesController(this); if (!HEADLESS) { // / initialize screens mainMenuScreen = new MainMenuScreen(this); levelPackagesScreen = new LevelPackagesScreen(this); // levelsOverviewScreen = new LevelsOverviewScreen(this, null); // placementModeScreen = new PlacementModeScreen(this, null); // simulationModeScreen = new SimulationModeScreen(this, null); achievementScreen = new AchievementScreen(this); settingsScreen = new SettingsScreen(this); statisticScreen = new StatisticScreen(this); selectProfileScreen = new SelectProfileScreen(this); profileSetNameScreen = new ProfileSetNameScreen(this); profileSetAvatarScreen = new ProfileSetAvatarScreen(this); creditsScreen = new CreditsScreen(this); // add onProfileChangeListener settingController.addSettingChangeListener(soundController); profileController.addProfileChangeListener(settingsScreen); profileController.addProfileChangeListener(selectProfileScreen); profileController.addProfileChangeListener(mainMenuScreen); profileController.addProfileChangeListener(statisticScreen); if (profileController.getAllProfiles().isEmpty()) { profileSetNameScreen.showBackButton(false); setScreen(new LoadingScreen(this, profileSetNameScreen)); } else { setScreen(new LoadingScreen(this, mainMenuScreen)); } } }
@Override public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float parentAlpha) { if (de.croggle.AlligatorApp.DEBUG) { batch.draw( de.croggle.data.AssetManager.getInstance() .getColorTexture(de.croggle.game.Color.uncolored()), getX(), getY(), getWidth() * getScaleX(), getHeight() * getScaleY()); } }
/** * Returns the asset manager which controls all kinds of game media, e.g. graphics. * * @return the asset manager */ public AssetManager getAssetManager() { return de.croggle.data.AssetManager.getInstance(); }