Java Code Examples for com.badlogic.gdx.math.Rectangle#getWidth()
The following examples show how to use
com.badlogic.gdx.math.Rectangle#getWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkinTextFont.java From beatoraja with GNU General Public License v3.0 | 6 votes |
private void setLayout(Color c, Rectangle r) { if (isWrapping()) { layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], true); } else { switch (getOverflow()) { case OVERFLOW_OVERFLOW: layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); break; case OVERFLOW_SHRINK: layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); float actualWidth = layout.width; if (actualWidth > r.getWidth()) { font.getData().setScale(font.getData().scaleX * r.getWidth() / actualWidth, font.getData().scaleY); layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); } break; case OVERFLOW_TRUNCATE: layout.setText(font, getText(), 0, getText().length(), c, r.getWidth(), ALIGN[getAlign()], false, ""); break; } } }
Example 2
Source File: SkinTextBitmap.java From beatoraja with GNU General Public License v3.0 | 6 votes |
private void setLayout(Color c, Rectangle r) { if (isWrapping()) { layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], true); } else { switch (getOverflow()) { case OVERFLOW_OVERFLOW: layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); break; case OVERFLOW_SHRINK: layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); float actualWidth = layout.width; if (actualWidth > r.getWidth()) { font.getData().setScale(font.getData().scaleX * r.getWidth() / actualWidth, font.getData().scaleY); layout.setText(font, getText(), c, r.getWidth(), ALIGN[getAlign()], false); } break; case OVERFLOW_TRUNCATE: layout.setText(font, getText(), 0, getText().length(), c, r.getWidth(), ALIGN[getAlign()], false, ""); break; } } }
Example 3
Source File: SayAction.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public boolean run(VerbRunner cb) { float x = TextManager.POS_SUBTITLE, y = TextManager.POS_SUBTITLE; Color color = null; if (text == null) return false; InteractiveActor a = (InteractiveActor) w.getCurrentScene().getActor(actor, false); if (type == Text.Type.TALK && a != null) { Rectangle boundingRectangle = a.getBBox().getBoundingRectangle(); x = boundingRectangle.getX() + boundingRectangle.getWidth() / 2; y = boundingRectangle.getY() + boundingRectangle.getHeight(); color = ((CharacterActor) a).getTextColor(); Vector2 talkingTextPos = ((CharacterActor) a).getTalkingTextPos(); if(talkingTextPos != null) { x += talkingTextPos.x; y += talkingTextPos.y; } } w.getCurrentScene().getTextManager().addText(text, x, y, queue, type, color, style, a != null ? a.getId() : actor, voiceId, animation, wait?cb:null); return wait; }
Example 4
Source File: CCTextureAtlasLoader.java From cocos-ui-libgdx with Apache License 2.0 | 4 votes |
@Override public TextureAtlas load(AssetManager assetManager, String fileName, FileHandle file, TextureAtlasLoader.TextureAtlasParameter parameter) { TextureAtlas atlas = new TextureAtlas(); atlas.getTextures().add(texture); ObjectMap<String, Object> frames = (ObjectMap<String, Object>) map.get("frames"); for (ObjectMap.Entry<String, Object> entry : frames.entries()) { String pageName = entry.key; ObjectMap<String, Object> params = (ObjectMap<String, Object>) entry.value; Rectangle frame = LyU.parseRect((String) params.get("frame")); GridPoint2 offset = LyU.parsePoint((String) params.get("offset")); boolean rotated = Boolean.parseBoolean((String) params.get("rotated")); GridPoint2 sourceSize = LyU.parsePoint((String) params.get("sourceSize")); Rectangle sourceColorRect = LyU.parseRect((String) params.get("sourceColorRect")); TextureAtlas.TextureAtlasData.Region region = new TextureAtlas.TextureAtlasData.Region(); region.name = pageName.substring(0, pageName.lastIndexOf('.')); region.rotate = rotated; region.offsetX = offset.x; region.offsetY = offset.y; region.originalWidth = sourceSize.x; region.originalHeight = sourceSize.y; region.left = (int) frame.x; region.top = (int) frame.y; region.width = (int) frame.getWidth(); region.height = (int) frame.getHeight(); int width = region.width; int height = region.height; TextureAtlas.AtlasRegion atlasRegion = new TextureAtlas.AtlasRegion(texture, 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); } atlas.getRegions().add(atlasRegion); } texture = null; map = null; return atlas; }