本文整理匯總了Java中com.badlogic.gdx.tools.texturepacker.TexturePacker類的典型用法代碼示例。如果您正苦於以下問題:Java TexturePacker類的具體用法?Java TexturePacker怎麽用?Java TexturePacker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TexturePacker類屬於com.badlogic.gdx.tools.texturepacker包,在下文中一共展示了TexturePacker類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
public static void main(String[] args) {
Settings settings = new Settings();
settings.maxWidth = 2048;
settings.maxHeight = 2048;
// We will assume that this code runs from
// [art]
// Raw assets live in
// [art]/assets/[sheetname]
// Thus, all asset source paths should be prefixed with
// assets
// and all asset destination paths should be prefixed with
// package
TexturePacker.process(settings, "assets/images", "package/assets", "main");
TexturePacker.process(settings, "assets/characters", "package/assets", "characters");
TexturePacker.process(settings, "assets/titleScreen", "package/assets", "titlescreen");
TexturePacker.process(settings, "assets/menuControls", "package/assets", "menu");
TexturePacker.process(settings, "assets/creditslogos", "package/assets", "credits");
}
示例2: onSettingsCbChecked
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@LmlAction("onSettingsCbChecked") void onSettingsCbChecked(VisCheckBox checkBox) {
PackModel pack = getSelectedPack();
if (pack == null) return;
TexturePacker.Settings settings = pack.getSettings();
switch (checkBox.getName()) {
case "cbUseFastAlgorithm": settings.fast = checkBox.isChecked(); break;
case "cbEdgePadding": settings.edgePadding = checkBox.isChecked(); break;
case "cbStripWhitespaceX": settings.stripWhitespaceX = checkBox.isChecked(); break;
case "cbStripWhitespaceY": settings.stripWhitespaceY = checkBox.isChecked(); break;
case "cbAllowRotation": settings.rotation = checkBox.isChecked(); break;
case "cbBleeding": settings.bleed = checkBox.isChecked(); break;
case "cbDuplicatePadding": settings.duplicatePadding = checkBox.isChecked(); break;
case "cbForcePot": settings.pot = checkBox.isChecked(); break;
case "cbUseAliases": settings.alias = checkBox.isChecked(); break;
case "cbIgnoreBlankImages": settings.ignoreBlankImages = checkBox.isChecked(); break;
case "cbDebug": settings.debug = checkBox.isChecked(); break;
case "cbUseIndices": settings.useIndexes = checkBox.isChecked(); break;
case "cbPremultiplyAlpha": settings.premultiplyAlpha = checkBox.isChecked(); break;
case "cbGrid": settings.grid = checkBox.isChecked(); break;
case "cbSquare": settings.square = checkBox.isChecked(); break;
case "cbLimitMemory": settings.limitMemory = checkBox.isChecked(); break;
}
}
示例3: onSettingsIntSpinnerChanged
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@LmlAction("onSettingsIntSpinnerChanged") void onSettingsIntSpinnerChanged(Spinner spinner) {
PackModel pack = getSelectedPack();
if (pack == null) return;
TexturePacker.Settings settings = pack.getSettings();
IntSpinnerModel model = (IntSpinnerModel) spinner.getModel();
switch (spinner.getName()) {
case "spnMinPageWidth": settings.minWidth = model.getValue(); break;
case "spnMinPageHeight": settings.minHeight = model.getValue(); break;
case "spnMaxPageWidth": settings.maxWidth = model.getValue(); break;
case "spnMaxPageHeight": settings.maxHeight = model.getValue(); break;
case "spnAlphaThreshold": settings.alphaThreshold = model.getValue(); break;
case "spnPaddingX": settings.paddingX = model.getValue(); break;
case "spnPaddingY": settings.paddingY = model.getValue(); break;
}
}
示例4: onSettingsCboChanged
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@LmlAction("onSettingsCboChanged") void onSettingsCboChanged(VisSelectBox selectBox) {
if (!initialized) return;
PackModel pack = getSelectedPack();
if (pack == null) return;
TexturePacker.Settings settings = pack.getSettings();
Object value = selectBox.getSelected();
switch (selectBox.getName()) {
case "cboEncodingFormat": settings.format = (Pixmap.Format) value; break;
case "cboMinFilter": settings.filterMin = (Texture.TextureFilter) value; break;
case "cboMagFilter": settings.filterMag = (Texture.TextureFilter) value; break;
case "cboWrapX": settings.wrapX = (Texture.TextureWrap) value; break;
case "cboWrapY": settings.wrapY = (Texture.TextureWrap) value; break;
// case "cboOutputFormat": settings.outputFormat = (String) value; break;
}
}
示例5: performPacking
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
private void performPacking(PackModel packModel, PageFileWriter pageFileWriter) throws Exception {
Array<ImageEntry> imageEntries = collectImageFiles(packModel);
if (imageEntries.size == 0) {
throw new IllegalStateException("No images to pack");
}
deleteOldFiles(packModel);
String filename = obtainFilename(packModel);
TexturePacker packer = new TexturePacker(packModel.getSettings(), pageFileWriter);
for (ImageEntry image : imageEntries) {
if (image.ninePatch) {
packer.addImage(image.fileHandle.file(), image.name, image.splits, image.pads);
} else {
packer.addImage(image.fileHandle.file(), image.name);
}
}
packer.pack(new File(packModel.getOutputDir()), filename);
}
示例6: deleteOldFiles
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
private static void deleteOldFiles(PackModel packModel) throws Exception {
String filename = obtainFilename(packModel);
TexturePacker.Settings settings = packModel.getSettings();
String atlasExtension = settings.atlasExtension == null ? "" : settings.atlasExtension;
atlasExtension = Pattern.quote(atlasExtension);
for (int i = 0, n = settings.scale.length; i < n; i++) {
FileProcessor deleteProcessor = new FileProcessor() {
protected void processFile (Entry inputFile) throws Exception {
Files.delete(inputFile.inputFile.toPath());
}
};
deleteProcessor.setRecursive(false);
String scaledPackFileName = settings.getScaledPackFileName(filename, i);
File packFile = new File(scaledPackFileName);
String prefix = filename;
int dotIndex = prefix.lastIndexOf('.');
if (dotIndex != -1) prefix = prefix.substring(0, dotIndex);
deleteProcessor.addInputRegex("(?i)" + prefix + "\\d*\\.(png|jpg|jpeg|ktx|zktx)");
deleteProcessor.addInputRegex("(?i)" + prefix + atlasExtension);
File outputRoot = new File(packModel.getOutputDir());
String dir = packFile.getParent();
if (dir == null)
deleteProcessor.process(outputRoot, null);
else if (new File(outputRoot + "/" + dir).exists()) //
deleteProcessor.process(outputRoot + "/" + dir, null);
}
}
示例7: prepareProcessingNodes
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
private Array<PackProcessingNode> prepareProcessingNodes(ProjectModel project, Array<PackModel> packs) {
Array<PackProcessingNode> result = new Array<>();
for (PackModel pack : packs) {
for (ScaleFactorModel scaleFactor : pack.getScaleFactors()) {
PackModel newPack = new PackModel(pack);
newPack.setScaleFactors(Array.with(scaleFactor));
TexturePacker.Settings settings = newPack.getSettings();
settings.scaleSuffix[0] = "";
settings.scale[0] = scaleFactor.getFactor();
PackProcessingNode processingNode = new PackProcessingNode(project, newPack);
processingNode.setOrigPack(pack);
result.add(processingNode);
}
}
return result;
}
示例8: copySettingsToAllPacks
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@LmlAction("copySettingsToAllPacks") public void copySettingsToAllPacks() {
PackModel selectedPack = getSelectedPack();
if (selectedPack == null) return;
TexturePacker.Settings generalSettings = selectedPack.getSettings();
Array<PackModel> packs = getProject().getPacks();
for (PackModel pack : packs) {
if (pack == selectedPack) continue;
pack.setSettings(generalSettings);
}
eventDispatcher.postEvent(new ShowToastEvent()
.message(getString("toastCopyAllSettings"))
.duration(ShowToastEvent.DURATION_SHORT));
}
示例9: processFolder
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
private static final void processFolder(Settings settings, String path)
{
File folderToProcess = new File(path);
boolean folderRequiresProcess = false;
for(File childFile : folderToProcess.listFiles())
{
if(childFile.isDirectory())
{
processFolder(settings, childFile.getAbsolutePath());
}
else
{
// It is a file, we need to pack!!
folderRequiresProcess = true;
}
}
// Perform actual pack now that we know that it's required
if(folderRequiresProcess)
{
TexturePacker.process(settings, path, path, folderToProcess.getName());
}
}
示例10: main
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
public static void main(String...args) throws Exception{
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.stripWhitespaceX = false;
settings.stripWhitespaceY = false;
TexturePacker.process(settings, "Assets Folder/items/images", "core/assets/items", "item-icons");
TexturePacker.process(settings, "Assets Folder/UI/images", "core/assets/UI", "UI");
TexturePacker.process(settings, "Assets Folder/res/images", "core/assets/res", "res");
}
示例11: main
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
public static void main(String[] arg) {
if (Assets.rebuildAtlas) {
Settings settings = new Settings();
settings.maxWidth = 2048;
settings.maxHeight = 2048;
settings.debug = Assets.drawDebugOutline;
try {
TexturePacker.process(settings, "assets-raw",
"../android/assets", "assets");
} catch (Exception e) {
e.printStackTrace();
}
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 1280;
config.height = 720;
config.addIcon("icon128.png", FileType.Internal);
config.addIcon("icon32.png", FileType.Internal);
config.addIcon("icon16.png", FileType.Internal);
new LwjglApplication(new Main(), config);
}
示例12: main
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
public static void main(String[] arg) throws FileNotFoundException, IOException {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = GameConstants.WINDOW_TITLE;
config.addIcon("gameicon.png", FileType.Internal);
config.width = GameConstants.GAME_WIDTH;
config.height = GameConstants.GAME_HEIGHT;
config.fullscreen = false;
readConfigFromPreference(config);
config.vSyncEnabled = config.fullscreen;
// check debug/run configuration ENVIRONMENT tab
// if the "DEVEOPMENT" flag is true, then the graphics will be packed together
// set the flag to false before exporting the jar
String getenv = System.getenv("DEVELOPMENT");
if (getenv != null && "true".equals(getenv)) {
Settings settings = new Settings();
settings.combineSubdirectories = true;
TexturePacker.process(settings, "../core/assets/graphics/hud", "../core/assets/packedGraphics", "hud");
TexturePacker.process(settings, "../core/assets/graphics/game", "../core/assets/packedGraphics", "gameGraphics");
TexturePacker.process(settings, "../core/assets/graphics/menu", "../core/assets/packedGraphics", "menuGraphics");
}
new LwjglApplication(new GDXGame(), config);
}
示例13: perform
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@Override
public Boolean perform() {
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.grid = true;
settings.square = true;
settings.paddingX = 2;
settings.paddingY = 2;
TexturePacker.process(settings, Gdx.files.internal("raw/blocks").path(), Gdx.files.internal("graphics/textures/").path(), "tilemap.atlas");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ForgE.blocks.reload();
return true;
}
示例14: perform
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
@Override
public Boolean perform() {
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.grid = true;
settings.square = true;
settings.paddingX = 2;
settings.paddingY = 2;
TexturePacker.process(settings, Gdx.files.internal(RAW_UI_IMAGES_PATH).path(), Gdx.files.internal(UIManager.STORE_PATH).path(), "ui.atlas");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
}
示例15: main
import com.badlogic.gdx.tools.texturepacker.TexturePacker; //導入依賴的package包/類
public static void main(String args[]){
if(resolver == null){
resolver = new Main();
}
boolean hacer_packer = false;
if(hacer_packer){
Settings settings = new Settings();
settings.pot = false;
settings.maxHeight = 1024;
settings.maxWidth = 1024;
settings.paddingX = 1;
settings.paddingY = 1;
settings.filterMin = TextureFilter.Linear;
settings.filterMag = TextureFilter.Linear;
TexturePacker.process(settings, "dataPC/screens/play/", "data/screens/play/", "play");
TexturePacker.process(settings, "dataPC/screens/background/", "data/screens/background", "bg");
}
new LwjglApplication(new Bar(resolver), "Bar", 480, 854, true);
}