本文整理匯總了Java中com.badlogic.gdx.utils.ObjectMap.get方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMap.get方法的具體用法?Java ObjectMap.get怎麽用?Java ObjectMap.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.ObjectMap
的用法示例。
在下文中一共展示了ObjectMap.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadSpriteSheets
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* Loads spritesheets found within the given root
* directory and its subfolders into this
* {@link SpriteSheetManager}.
*
* @param rootDirectory the root directory to search in
*/
public void loadSpriteSheets(File rootDirectory) {
log.info("Loading spritesheet assets from directory " + rootDirectory.getAbsolutePath());
ObjectMap<String, File> files = FileUtil.loadWithIdentifiers(rootDirectory, file -> {
return file.getName().endsWith(".spritesheet");
});
for (String key : files.keys()) {
File targetFile = files.get(key);
try {
this.sheets.put(key,
new PackagedSpriteSheetFactory(key, renderer, new ZipFile(targetFile)));
log.info(
"Loaded packaged spritesheet " + targetFile.getName() + " under key " + key);
} catch (Exception e) {
String message = "Could not load spritesheet at spritesheet file "
+ targetFile.getAbsolutePath();
if (e instanceof ZipException)
message += " (bad spritesheet file/format)";
log.error(message, e);
}
}
log.info(this.sheets.size + " spritesheet(s) loaded.");
}
示例2: recalculateFormation
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
private void recalculateFormation(ObjectMap<Integer, Tile> formationToRecalculate, int rotationDegrees) {
for (Integer i : formation.keys()) {
Tile formationPosition = formationToRecalculate.get(i);
if (formationPosition == null) {
formationPosition = new Tile();
formationToRecalculate.put(i, formationPosition);
}
formationPosition.set(formation.get(i));
// we only rotate in multiplies of 45
// first we do as many 90 degrees rotations as needed
// and then do the final 45 rotation if required
int rotAmount = rotationDegrees / 90;
for (int j = 0; j < rotAmount; ++j) {
formationPosition.rotate90CW();
}
if (rotationDegrees % 90 == 45) {
rotateTile45CW(formationPosition);
}
}
}
示例3: load
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
private void load(TextureAtlasData data) {
ObjectMap<TextureAtlasData.Page, Texture> pageToTexture = new ObjectMap<TextureAtlasData.Page, Texture>();
for (TextureAtlasData.Page page : data.getPages()) {
Texture texture = TextureDecryptor.loadTexture(crypto, page.textureFile, page.format, page.useMipMaps);
texture.setFilter(page.minFilter, page.magFilter);
texture.setWrap(page.uWrap, page.vWrap);
getTextures().add(texture);
pageToTexture.put(page, texture);
}
// Same as libGDX source
for (TextureAtlasData.Region region : data.getRegions()) {
int width = region.width;
int height = region.height;
AtlasRegion atlasRegion = new AtlasRegion(pageToTexture.get(region.page), region.left, region.top,
region.rotate ? height : width, region.rotate ? width : height);
atlasRegion.index = region.index;
atlasRegion.name = region.name;
atlasRegion.offsetX = region.offsetX;
atlasRegion.offsetY = region.offsetY;
atlasRegion.originalHeight = region.originalHeight;
atlasRegion.originalWidth = region.originalWidth;
atlasRegion.rotate = region.rotate;
atlasRegion.splits = region.splits;
atlasRegion.pads = region.pads;
if (region.flip) atlasRegion.flip(false, true);
getRegions().add(atlasRegion);
}
}
示例4: loadFonts
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* Loads fonts found within the given root directory and
* its subfolders into this {@link FontManager}.
*
* @param rootDirectory the root directory to search in
*/
public void loadFonts(File rootDirectory) {
log.info("Loading fonts from directory " + rootDirectory.getAbsolutePath());
ObjectMap<String, File> files = FileUtil.loadWithIdentifiers(rootDirectory, file -> {
return file.getName().endsWith(".font");
});
for (String key : files.keys()) {
File fontFile = files.get(key);
if (key.startsWith("styles.")) {
continue;
}
try {
Font font = new Font(key, this.renderer, new ZipFile(fontFile));
this.fonts.put(key, font);
log.info("Loaded font " + fontFile.getName() + " under key " + key);
} catch (Exception e) {
String message = "Could not load font at font file " + fontFile.getAbsolutePath();
if (e instanceof IOException)
message += " (load error)";
if (e instanceof BadAssetException)
message += " (bad asset: " + e.getMessage() + ")";
if (e instanceof ZipException)
message += " (bad file)";
log.error(message, e);
}
}
log.info(fonts.size + " font(s) loaded.");
}
示例5: getDependencies
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) {
FileHandle imgDir = file.parent();
map = LyU.createDictionaryWithContentsOfFile(file);
ObjectMap<String, Object> metadata = (ObjectMap<String, Object>) map.get("metadata");
String dependFile = (String) metadata.get("textureFileName");
Array<AssetDescriptor> res = new Array<AssetDescriptor>();
TextureLoader.TextureParameter params = new TextureLoader.TextureParameter();
params.magFilter = Texture.TextureFilter.Linear;
params.minFilter = Texture.TextureFilter.Linear;
params.format = Pixmap.Format.RGBA8888;
texture = new Texture(imgDir.child(dependFile));
res.add(new AssetDescriptor(imgDir.child(dependFile), Texture.class, params));
return res;
}
示例6: isFontInUse
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* Is font is already in use somewhere else?
*/
public boolean isFontInUse(BitmapFont font) {
try {
// Check if it is already in use somewhere!
for (String widget : SkinEditorGame.widgets) {
String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
Class<?> style = Class.forName(widgetStyle);
ObjectMap<String, ?> styles = game.skinProject.getAll(style);
Iterator<String> it = styles.keys().iterator();
while (it.hasNext()) {
Object item = styles.get((String) it.next());
Field[] fields = ClassReflection.getFields(item.getClass());
for (Field field : fields) {
if (field.getType() == BitmapFont.class) {
BitmapFont f = (BitmapFont) field.get(item);
if (font.equals(f)) {
return true;
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例7: localize
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
public String localize(String key, ObjectMap<String, String> params) {
if (params == null)
params = EMPTY;
ThesaurusData thesaurusData = data.get(key);
String localized = getLocalized(thesaurusData);
if (localized == null) {
if (!key.contains(" ") && key.contains(".") && !key.contains("{")) {
String fallback = key.split("\\.")[0];
return localize(fallback);
}
localized = key;
}
while (localized.contains("{")) {
int end = localized.indexOf('}');
if (end == -1)
return localized;
int start = localized.indexOf('{');
String replaceKey = localized.substring(start + 1, end);
String replaceValue = params.get(replaceKey);
if (replaceValue == null) {
replaceValue = localize(replaceKey, params);
} else {
replaceValue = localize(replaceValue, params);
}
localized = localized.substring(0, start) + replaceValue + localized.substring(end + 1);
}
return localized;
}
示例8: toDistribution
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T extends Distribution> T toDistribution (String value, Class<T> clazz) {
StringTokenizer st = new StringTokenizer(value, ", \t\f");
if (!st.hasMoreTokens()) throw new DistributionFormatException("Missing ditribution type");
String type = st.nextToken();
ObjectMap<String, Adapter<?>> categories = typeMap.get(clazz);
Adapter<T> converter = (Adapter<T>)categories.get(type);
if (converter == null)
throw new DistributionFormatException("Cannot create a '" + clazz.getSimpleName() + "' of type '" + type + "'");
String[] args = new String[st.countTokens()];
for (int i = 0; i < args.length; i++)
args[i] = st.nextToken();
return converter.toDistribution(args);
}
示例9: addAsset
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
@Override
protected <T> void addAsset(String fileName, Class<T> type, T asset) {
super.addAsset(fileName, type, asset);
// this is VERY ugly, but a bit more future proof in case of changes in the parent
// than just copying the parent method
ObjectMap<String, RefCountedContainer> typeToAssets = assets.get(type);
if (!(typeToAssets instanceof OrderedMap)) {
RefCountedContainer value = typeToAssets.get(fileName);
typeToAssets = new OrderedMap<String, RefCountedContainer>();
typeToAssets.put(fileName, value);
assets.put(type, typeToAssets);
}
}
示例10: readAnimation
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
private void readAnimation(JsonValue line, ObjectMap<Integer, Array<AnimationDescription>> animationInfoMap) {
int animationLineNumber = line.getInt("line");
AnimationDescription ad = readAnimationDescription(line);
Array<AnimationDescription> lineAnimations = animationInfoMap.get(animationLineNumber);
if (lineAnimations == null) {
lineAnimations = new Array<AnimationDescription>();
animationInfoMap.put(animationLineNumber, lineAnimations);
}
lineAnimations.add(ad);
}
示例11: getCheckFrequency
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* Returns how many seconds must pass before the system checks again if a
* chatter should be displayed.
*
* @param type
* @param locations
* @return
*/
public float getCheckFrequency(ChatterType type, ObjectSet<GameLocation> locations) {
ObjectMap<String, Float> locationFrequencies = s_checkFrequency.get(type);
if (locations != null && locationFrequencies.size > 1) {
for (GameLocation location : locations) {
Float returnValue = locationFrequencies.get(location.getId());
if (returnValue != null) {
return returnValue;
}
}
}
return locationFrequencies.get(NO_LOCATION_ID);
}
示例12: getChanceToSay
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
public int getChanceToSay(ChatterType type, ObjectSet<GameLocation> locations) {
ObjectMap<String, Integer> locationChances = s_chanceToSay.get(type);
if (locations != null && locationChances.size > 1) {
for (GameLocation location : locations) {
Integer returnValue = locationChances.get(location.getId());
if (returnValue != null) {
return returnValue;
}
}
}
return locationChances.get(NO_LOCATION_ID);
}
示例13: getTexts
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
public Array<String> getTexts(ChatterType type, ObjectSet<GameLocation> locations) {
ObjectMap<String, Array<String>> locationTexts = texts.get(type);
if (locations != null && locationTexts.size > 1) {
for (GameLocation location : locations) {
Array<String> returnValue = locationTexts.get(location.getId());
if (returnValue != null) {
return returnValue;
}
}
}
return locationTexts.get(NO_LOCATION_ID);
}
示例14: loadFromXMLNoInit
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
XMLUtil.handleImports(this, file, root);
for (ChatterType type : ChatterType.values()) {
Array<Element> typeElements = root.getChildrenByName(type.getXmlName());
for (Element typeElement : typeElements) {
ObjectMap<String, Array<String>> locationTexts = texts.get(type);
ObjectMap<String, Integer> locationChances = s_chanceToSay.get(type);
ObjectMap<String, Float> locationFrequencies = s_checkFrequency.get(type);
String location = typeElement.get(XML_LOCATION, NO_LOCATION_ID).toLowerCase(Locale.ENGLISH);
locationChances.put(location, typeElement.getInt(XML_CHANCE_TO_SAY, 0));
locationFrequencies.put(location, typeElement.getFloat(XML_CHECK_FREQUENCY, 0f));
Array<String> textArray = locationTexts.get(location);
if (textArray == null) {
textArray = new Array<String>();
locationTexts.put(location, textArray);
}
Array<Element> textElements = typeElement.getChildrenByName(XML_TEXT);
for (Element textElement : textElements) {
textArray.add(textElement.getText());
}
}
}
}
示例15: readTracks
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
private <T extends AudioTrack<?>> void readTracks(Element tracksElement, ObjectMap<PrecipitationAmount, Array<AudioTrack<?>>> trackMap, PrecipitationAmount amount, Class<T> trackType) {
if (tracksElement == null) {
return;
}
Array<AudioTrack<?>> array = trackMap.get(amount);
if (array == null) {
array = new Array<AudioTrack<?>>();
trackMap.put(amount, array);
}
Array<AudioTrack<?>> tracks = XMLUtil.readTracks(tracksElement, trackType);
for (AudioTrack<?> track : tracks) {
array.add(track);
}
}