當前位置: 首頁>>代碼示例>>Java>>正文


Java Align.top方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.Align.top方法的典型用法代碼示例。如果您正苦於以下問題:Java Align.top方法的具體用法?Java Align.top怎麽用?Java Align.top使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.scenes.scene2d.utils.Align的用法示例。


在下文中一共展示了Align.top方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: layout

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
public void layout () {
	if (drawable == null) return;

	float regionWidth = drawable.getMinWidth();
	float regionHeight = drawable.getMinHeight();
	float width = getWidth();
	float height = getHeight();

	Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
	imageWidth = size.x;
	imageHeight = size.y;

	if ((align & Align.left) != 0)
		imageX = 0;
	else if ((align & Align.right) != 0)
		imageX = (int)(width - imageWidth);
	else
		imageX = (int)(width / 2 - imageWidth / 2);

	if ((align & Align.top) != 0)
		imageY = (int)(height - imageHeight);
	else if ((align & Align.bottom) != 0)
		imageY = 0;
	else
		imageY = (int)(height / 2 - imageHeight / 2);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:27,代碼來源:Image.java

示例2: onTouchDown

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
@Override
public void onTouchDown(Actor actor) {
	if (Scene.mouseButton == 0) {
		edge = 0;
		float x = Scene.mouse.x;
		float y = Scene.mouse.y;
		if (x > actor.getX() + actor.getWidth() - 10) edge |= Align.right;
		if (y > actor.getY() + actor.getHeight() - 10) edge |= Align.top;
		//if (x < actor.getX() + 20 && y < actor.getY() + 20) edge = Align.left; no rotation
		dragging = edge != 0;
		startX = x;
		startY = y;
		lastX = x;
		lastY = y;
	}
}
 
開發者ID:pyros2097,項目名稱:GdxStudio,代碼行數:17,代碼來源:SceneEditor.java

示例3: drawBackground

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
protected void drawBackground (Batch batch, float parentAlpha, float x, float y) {
	float width = getWidth(), height = getHeight();
	float padTop = getPadTop();

	super.drawBackground(batch, parentAlpha, x, y);

	// Draw button table.
	buttonTable.getColor().a = getColor().a;
	buttonTable.pack();
	buttonTable.setPosition(width - buttonTable.getWidth(), Math.min(height - padTop, height - buttonTable.getHeight()));
	buttonTable.draw(batch, parentAlpha);

	// Draw the title without the batch transformed or clipping applied.
	y += height;
	TextBounds bounds = titleCache.getBounds();
	if ((titleAlignment & Align.left) != 0)
		x += getPadLeft();
	else if ((titleAlignment & Align.right) != 0)
		x += width - bounds.width - getPadRight();
	else
		x += (width - bounds.width) / 2;
	if ((titleAlignment & Align.top) == 0) {
		if ((titleAlignment & Align.bottom) != 0)
			y -= padTop - bounds.height;
		else
			y -= (padTop - bounds.height) / 2;
	}
	titleCache.tint(Color.tmp.set(getColor()).mul(style.titleFontColor));
	titleCache.setPosition((int)x, (int)y);
	titleCache.draw(batch, parentAlpha);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:32,代碼來源:Window.java

示例4: top

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Adds {@link Align#top} and clears {@link Align#bottom} for the alignment of the actor within the cell. */
public Cell<T> top () {
	if (align == null)
		align = topi;
	else
		align = (align | Align.top) & ~Align.bottom;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:9,代碼來源:Cell.java

示例5: bottom

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Adds {@link Align#bottom} and clears {@link Align#top} for the alignment of the actor within the cell. */
public Cell<T> bottom () {
	if (align == null)
		align = bottomi;
	else
		align = (align | Align.bottom) & ~Align.top;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:9,代碼來源:Cell.java

示例6: makeGameFileRow

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
private Table makeGameFileRow(final FileHandle gameSaveFile) {
	GameSave towerData;
	try {
		towerData = GameSaveFactory.readMetadata(gameSaveFile.read());
	} catch (Exception e) {
		Gdx.app.log(TAG, "Failed to parse file.", e);
		return null;
	}

	FileHandle imageFile = Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png");

	Actor imageActor = null;
	if (imageFile.exists()) {
		try {
			imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top);
		} catch (Exception ignored) {
			imageActor = null;
		}
	}

	if (imageActor == null) {
		imageActor = FontManager.Default.makeLabel("No image.");
	}

	Table fileRow = new Table();
	fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10));
	fileRow.row();
	fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center();
	fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top();
	fileRow.row().fillX();
	fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2);

	return fileRow;
}
 
開發者ID:frigidplanet,項目名稱:droidtowers,代碼行數:35,代碼來源:LoadTowerWindow.java

示例7: addBackground

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
protected void addBackground()
{
	this.bgTexture = new Texture(this.backgroundFileName);
	this.bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
	
	TextureRegion bgTextureRegion = new TextureRegion(bgTexture, 0, 0, 512, 512);
	
	TextureRegionDrawable drawableBg = new TextureRegionDrawable(bgTextureRegion);
	
	this.bgImage = new Image(drawableBg, Scaling.fillX, Align.top);
	this.bgImage.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	this.bgImage.setFillParent(true);
	
	this.stage.addActor(this.bgImage);
}
 
開發者ID:Xesenix,項目名稱:libgdx-template-project,代碼行數:16,代碼來源:AbstractMenuScreen.java

示例8: show

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
public void show()
{
	Gdx.app.log(XesEffects.LOG, "Showing SplashScreen");
	super.show();
	
	// preparing actors
	// - background:
	this.bgTexture = new Texture("data/splash_screen.png");
	this.bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
	
	TextureRegion bgTextureRegion = new TextureRegion(bgTexture, 0, 0, 512, 512);
	
	TextureRegionDrawable drawableBg = new TextureRegionDrawable(bgTextureRegion);
	
	this.bgImage = new Image(drawableBg, Scaling.fillX, Align.left | Align.top);
	this.bgImage.setFillParent(true);
	
	// building stage
	this.stage.clear();
	this.stage.addActor(this.bgImage);
	
	// show animation
	this.stage.addAction(
		sequence(
			fadeOut(0),
			moveTo(0, Gdx.graphics.getHeight() / 2),
			parallel(
				fadeIn(1.5f),
				moveTo(0, 0, 1.5f)
			)
		)
	);
}
 
開發者ID:Xesenix,項目名稱:libgdx-template-project,代碼行數:34,代碼來源:SplashScreen.java

示例9: layout

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
public void layout () {
	if (actor == null) return;

	float padLeft = this.padLeft.get(this), padBottom = this.padBottom.get(this);
	float containerWidth = getWidth() - padLeft - padRight.get(this);
	float containerHeight = getHeight() - padBottom - padTop.get(this);
	float minWidth = this.minWidth.get(actor), minHeight = this.minHeight.get(actor);
	float prefWidth = this.prefWidth.get(actor), prefHeight = this.prefHeight.get(actor);
	float maxWidth = this.maxWidth.get(actor), maxHeight = this.maxHeight.get(actor);

	float width;
	if (fillX > 0)
		width = containerWidth * fillX;
	else
		width = Math.min(prefWidth, containerWidth);
	if (width < minWidth) width = minWidth;
	if (maxWidth > 0 && width > maxWidth) width = maxWidth;

	float height;
	if (fillY > 0)
		height = containerHeight * fillY;
	else
		height = Math.min(prefHeight, containerHeight);
	if (height < minHeight) height = minHeight;
	if (maxHeight > 0 && height > maxHeight) height = maxHeight;

	float x = padLeft;
	if ((align & Align.right) != 0)
		x += containerWidth - width;
	else if ((align & Align.left) == 0) // center
		x += (containerWidth - width) / 2;

	float y = padBottom;
	if ((align & Align.top) != 0)
		y += containerHeight - height;
	else if ((align & Align.bottom) == 0) // center
		y += (containerHeight - height) / 2;

	if (round) {
		x = Math.round(x);
		y = Math.round(y);
		width = Math.round(width);
		height = Math.round(height);
	}

	actor.setBounds(x, y, width, height);
	if (actor instanceof Layout) ((Layout)actor).validate();
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:49,代碼來源:Container.java

示例10: top

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Sets {@link Align#top} and clears {@link Align#bottom} for the alignment of the actor within the container. */
public Container<T> top () {
	align |= Align.top;
	align &= ~Align.bottom;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:7,代碼來源:Container.java

示例11: bottom

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Sets {@link Align#bottom} and clears {@link Align#top} for the alignment of the actor within the container. */
public Container<T> bottom () {
	align |= Align.bottom;
	align &= ~Align.top;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:7,代碼來源:Container.java

示例12: top

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Adds {@link Align#top} and clears {@link Align#bottom} for the alignment of the logical table within the table actor. */
public Table top () {
	align |= Align.top;
	align &= ~Align.bottom;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:7,代碼來源:Table.java

示例13: bottom

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Adds {@link Align#bottom} and clears {@link Align#top} for the alignment of the logical table within the table actor. */
public Table bottom () {
	align |= Align.bottom;
	align &= ~Align.top;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:7,代碼來源:Table.java

示例14: layout

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
public void layout () {
	BitmapFont font = cache.getFont();
	float oldScaleX = font.getScaleX();
	float oldScaleY = font.getScaleY();
	if (fontScaleX != 1 || fontScaleY != 1) font.setScale(fontScaleX, fontScaleY);

	if (sizeInvalid) computeSize();

	if (wrap) {
		float prefHeight = getPrefHeight();
		if (prefHeight != lastPrefHeight) {
			lastPrefHeight = prefHeight;
			invalidateHierarchy();
		}
	}

	float width = getWidth(), height = getHeight();
	StringBuilder text;
	if (ellipsis && width < bounds.width) {
		float ellipseWidth = font.getBounds("...").width;
		text = tempText != null ? tempText : (tempText = new StringBuilder());
		text.setLength(0);
		if (width > ellipseWidth) {
			text.append(this.text, 0, font.computeVisibleGlyphs(this.text, 0, this.text.length, width - ellipseWidth));
			text.append("...");
		}
	} else
		text = this.text;

	Drawable background = style.background;
	float x = 0, y = 0;
	if (background != null) {
		x = background.getLeftWidth();
		y = background.getBottomHeight();
		width -= background.getLeftWidth() + background.getRightWidth();
		height -= background.getBottomHeight() + background.getTopHeight();
	}
	if ((labelAlign & Align.top) != 0) {
		y += cache.getFont().isFlipped() ? 0 : height - bounds.height;
		y += style.font.getDescent();
	} else if ((labelAlign & Align.bottom) != 0) {
		y += cache.getFont().isFlipped() ? height - bounds.height : 0;
		y -= style.font.getDescent();
	} else
		y += (int)((height - bounds.height) / 2);
	if (!cache.getFont().isFlipped()) y += bounds.height;

	if ((labelAlign & Align.left) == 0) {
		if ((labelAlign & Align.right) != 0)
			x += width - bounds.width;
		else
			x += (int)((width - bounds.width) / 2);
	}

	cache.setColor(Color.WHITE);
	if (wrap)
		cache.setWrappedText(text, x, y, bounds.width, lineAlign);
	else
		cache.setMultiLineText(text, x, y, bounds.width, lineAlign);

	if (fontScaleX != 1 || fontScaleY != 1) font.setScale(oldScaleX, oldScaleY);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:63,代碼來源:Label.java

示例15: top

import com.badlogic.gdx.scenes.scene2d.utils.Align; //導入方法依賴的package包/類
/** Sets {@link Align#top} and clears {@link Align#bottom} for the alignment of widgets within the horizontal group. */
public HorizontalGroup top () {
	align |= Align.top;
	align &= ~Align.bottom;
	return this;
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:7,代碼來源:HorizontalGroup.java


注:本文中的com.badlogic.gdx.scenes.scene2d.utils.Align.top方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。