本文整理汇总了Java中org.andengine.entity.primitive.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Java Rectangle类的具体用法?Java Rectangle怎么用?Java Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于org.andengine.entity.primitive包,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Scrollable
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* New Scrollable with with the desired width and height.
* The width and height must be specified because a Scrollable will be smaller than the size
* needed for all of it's children
* @param x the X coordinate of the scene to place this Scrollable
* @param y the Y coordinate of the scene to place this Scrollable
* @param w the width for this Scrollable
* @param h the height for this Scrollable
* @param scroll_lock what directions can be scrolled (default Scrollable.SCROLL_BOTH)
*/
public Scrollable(float x, float y, float w, float h, int scroll_lock) {
super(x, y, w, h);
this.scroll_lock = scroll_lock;
this.scrollDetector = new SurfaceScrollDetector(this);
this.contents = new Entity(w/2, h/2, 0, 0);
this.childRect.set(0, 0, 0, 0);
this.touchAreas = new ArrayList<ITouchArea>();
super.attachChild(this.contents);
this.scrollbar_color = new Color(0.0f, 0.0f, 0.0f, 0.25f);
this.vertical_scrollbar = new Rectangle(this.getWidth()-(this.scrollbar_size /2)-2, this.getHeight()/2, scrollbar_size, this.getHeight(), PhoeniciaContext.vboManager);
this.vertical_scrollbar.setColor(this.scrollbar_color);
if (this.scroll_lock == SCROLL_HORIZONTAL) this.vertical_scrollbar.setVisible(false);
this.scroll_y = 0;
super.attachChild(this.vertical_scrollbar);
this.horizontal_scrollbar = new Rectangle(this.getWidth()/2, (scrollbar_size/2)+2, this.getWidth(), scrollbar_size, PhoeniciaContext.vboManager);
this.horizontal_scrollbar.setColor(this.scrollbar_color);
if (this.scroll_lock == SCROLL_VERTICAL) this.horizontal_scrollbar.setVisible(false);
this.scroll_x = 0;
super.attachChild(this.horizontal_scrollbar);
}
示例2: onUpdateVertices
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
final float[] bufferData = this.mBufferData;
final float width = pRectangle.getWidth(); // TODO Optimize with field access?
final float height = pRectangle.getHeight(); // TODO Optimize with field access?
bufferData[(0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = 0;
bufferData[(0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = 0;
bufferData[(1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = 0;
bufferData[(1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = height;
bufferData[(2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = width;
bufferData[(2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = 0;
bufferData[(3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X] = width;
bufferData[(3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y] = height;
this.setDirtyOnHardware();
}
示例3: onUpdateVertices
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float width = pRectangle.getWidth(); // TODO Optimize with field access?
final float height = pRectangle.getHeight(); // TODO Optimize with field access?
bufferData.put((0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X, 0);
bufferData.put((0 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y, 0);
bufferData.put((1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X, 0);
bufferData.put((1 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y, height);
bufferData.put((2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X, width);
bufferData.put((2 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y, 0);
bufferData.put((3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_X, width);
bufferData.put((3 * Rectangle.VERTEX_SIZE) + Rectangle.VERTEX_INDEX_Y, height);
this.setDirtyOnHardware();
}
示例4: HealthBar
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
public HealthBar(Enemy parent, VertexBufferObjectManager pVertexBufferObjectManager) {
super(parent.mCenterX - (WIDTH + BORDER_THICKNESS * 2) / 2, parent.mCenterY - YOFFSET - BORDER_THICKNESS, WIDTH + BORDER_THICKNESS * 2, HEIGHT + BORDER_THICKNESS * 2, pVertexBufferObjectManager);
// set variables
mParent = parent;
setColor(0.3f, 0.3f, 0.3f);
setZIndex(800);
TowerDefense.mSceneManager.getCurrentLevel().attachChild(this);
// set background
mHealthBackground = new Rectangle(mParent.mCenterX - WIDTH / 2, mParent.mCenterY - YOFFSET, WIDTH, HEIGHT, getVertexBufferObjectManager());
mHealthBackground.setColor(220f/255, 25f/255, 25f/255);
mHealthBackground.setZIndex(801);
TowerDefense.mSceneManager.getCurrentLevel().attachChild(mHealthBackground);
// set foreground
mHealthForeground = new Rectangle(mParent.mCenterX - WIDTH / 2, mParent.mCenterY - YOFFSET, WIDTH, HEIGHT, getVertexBufferObjectManager());
mHealthForeground.setColor(100f/255, 220f/255, 20f/255);
mHealthForeground.setZIndex(802);
TowerDefense.mSceneManager.getCurrentLevel().attachChild(mHealthForeground);
}
示例5: onUpdateVertices
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
final float[] bufferData = this.mBufferData;
final float x = 0;
final float y = 0;
final float x2 = pRectangle.getWidth(); // TODO Optimize with field access?
final float y2 = pRectangle.getHeight(); // TODO Optimize with field access?
bufferData[0 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X] = x;
bufferData[0 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y] = y;
bufferData[1 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X] = x;
bufferData[1 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y] = y2;
bufferData[2 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X] = x2;
bufferData[2 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y] = y;
bufferData[3 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X] = x2;
bufferData[3 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y] = y2;
this.setDirtyOnHardware();
}
示例6: onUpdateVertices
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Rectangle pRectangle) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float x = 0;
final float y = 0;
final float x2 = pRectangle.getWidth();
final float y2 = pRectangle.getHeight();
bufferData.put(0 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X, x);
bufferData.put(0 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y, y);
bufferData.put(1 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X, x);
bufferData.put(1 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y, y2);
bufferData.put(2 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X, x2);
bufferData.put(2 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y, y);
bufferData.put(3 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_X, x2);
bufferData.put(3 * Rectangle.VERTEX_SIZE + Rectangle.VERTEX_INDEX_Y, y2);
this.setDirtyOnHardware();
}
示例7: generateDiamond
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* Generate a diamond centered on the desired position.
* @param x the x position
* @param y the y position
* @return The entity corresponding to the created diamond.
*/
public Entity generateDiamond(float x, float y, float frequency) {
Sprite sDiamond = new Sprite(x , y, this.spriteLoader.getDiamondTextureRegion(), this.vertextBufferObjectManager);
sDiamond.setX(sDiamond.getX() - sDiamond.getWidth()/2);
sDiamond.setY(sDiamond.getY() - sDiamond.getHeight()/2);
Entity diamond = this.em.createEntity();
this.em.addComponentToEntity(new SpriteComponent(sDiamond, true), diamond);
Rectangle currLifeRect = new Rectangle(26, 242, 370, 80, this.vertextBufferObjectManager);
currLifeRect.setColor(0.8f, 0.2f, 0.2f);
Rectangle maxLifeRect = new Rectangle(26, 242, 370, 80, this.vertextBufferObjectManager);
maxLifeRect.setColor(0.79f, 0.79f, 0.79f);
this.em.addComponentToEntity(new DiamondComponent(frequency, 20, currLifeRect, maxLifeRect), diamond);
return diamond;
}
示例8: AbstractSkillComponent
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* Constructor.
* @param sprite the animation sprite
* @param cooldown the cooldown of the attack
*/
public AbstractSkillComponent(Sprite sprite, Sprite frame, float cooldown, VertexBufferObjectManager vb) {
this.iconSprite = sprite;
this.iconSprite.setZIndex(10);
this.iconFrame = frame;
this.iconFrame.setZIndex(12);
this.cooldown = cooldown;
this.ready = true;
Rectangle cooldownRect = new Rectangle(sprite.getX() + 3, sprite.getY() + 3, sprite.getWidth() -6 , sprite.getHeight() - 6, vb);
cooldownRect.setColor(0, 0, 0, 0.5f);
this.cooldownRectangle = cooldownRect;
this.cooldownRectangle.setZIndex(11);
this.cooldownRectangle.setVisible(false);
this.cooldownRectangeMaxHeight = cooldownRect.getHeight();
}
示例9: defineRectangularHitbox
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* Set the hitbox relatively to the Sprite
*
* @param xmin left distance to the sprite
* @param ymin top distance to the sprite
* @param width width of the hitbox
* @param height height of the hitbox
* @return this so this call can be inline
*/
public SpriteComponent defineRectangularHitbox(float xmin, float ymin, float width, float height) {
//sprite.setColor(Color.RED);
hitbox = new Rectangle(xmin, ymin, width, height, sprite.getVertexBufferObjectManager());
if (GameActivity.DEBUG_MODE) {
hitbox.setVisible(true); // to set to false
hitbox.setAlpha(10); // DON'T WORK
hitbox.setColor(Color.BLUE);
} else {
hitbox.setVisible(false);
}
sprite.attachChild(hitbox);
return this;
}
示例10: addRectangles
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
private void addRectangles() {
Rectangle rectangleScore = new Rectangle(0, (float) (camera.getHeight() * 0.45), camera.getWidth(),
textFieldHeight, vbom);
rectangleScore.setColor(0, 102 / 255f, 255 / 255f);
attachChild(rectangleScore);
Rectangle rectangleLevel = new Rectangle(0, rectangleScore.getY() + textFieldHeight, camera.getWidth(),
rectangleScore.getHeight(), vbom);
rectangleLevel.setColor(YELLOW);
attachChild(rectangleLevel);
if (justPlayScoreService.getHighscore() != null) {
Rectangle rectangleHighscore = new Rectangle(0, rectangleLevel.getY() + textFieldHeight, camera.getWidth(),
textFieldHeight, vbom);
rectangleHighscore.setColor(153 / 255f, 102 / 255f, 0);
attachChild(rectangleHighscore);
}
}
示例11: Pillar
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
public Pillar(float x, float y, TextureRegion reg, VertexBufferObjectManager vbom, PhysicsWorld physics) {
super(x, y);
pillarUp = new Sprite(0, shift, 96, 384, reg, vbom);
pillarUp.setFlippedVertical(true);
pillarUp.setAnchorCenterY(0);
attachChild(pillarUp);
pillarUpBody = PhysicsFactory.createBoxBody(physics, pillarUp, BodyType.StaticBody, Constants.WALL_FIXTURE);
pillarUpBody.setUserData(Constants.BODY_WALL);
pillarDown = new Sprite(0, -shift, 96, 384, reg, vbom);
pillarDown.setAnchorCenterY(1);
attachChild(pillarDown);
pillarDownBody = PhysicsFactory.createBoxBody(physics, pillarDown, BodyType.StaticBody, Constants.WALL_FIXTURE);
pillarDownBody.setUserData(Constants.BODY_WALL);
Rectangle r = new Rectangle(0, 0, 1, 9999, vbom); // just to make sure it's big
r.setColor(Color.GREEN);
r.setAlpha(0f);
attachChild(r);
scoreSensor = PhysicsFactory.createBoxBody(physics, r, BodyType.StaticBody, Constants.SENSOR_FIXTURE);
scoreSensor.setUserData(Constants.BODY_SENSOR);
}
示例12: initInfoMessageText
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* 戦闘ログテキスト初期化
*/
private void initInfoMessageText(IEntity entity) {
float width = getBaseScene().getWindowWidth() - (getBaseScene().getWindowWidth() / 10);
float height = 40;
Rectangle rectangle = getBaseScene().createRectangle(0, 0, width, height);
rectangle.setColor(Color.BLACK);
rectangle.setAlpha(0.5f);
rectangle.setZIndex(LayerZIndexType.TEXT_LAYER.getValue());
rectangle.setTag(INFO_MESSAGE_TEXT_TAG);
Text text = new Text(10, 10, getBaseScene().createFont(Typeface.DEFAULT, 20, Color.WHITE),
"000000000000000000000000000000000000000000000000000000000000000",
getBaseScene().getBaseActivity().getVertexBufferObjectManager());
rectangle.attachChild(text);
getBaseScene().placeToCenterX(rectangle, 10);
rectangle.setVisible(false);
entity.attachChild(rectangle);
}
示例13: touchedCusorRectangle
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
/**
* カーソル選択.
*/
private void touchedCusorRectangle(final MapPoint mapPoint) {
final PointF pointF = MapGridUtil.indexToDisp(new Point(mapPoint.getMapPointX(), mapPoint.getMapPointY()));
getBaseScene().getBaseActivity().runOnUpdateThread(new Runnable() {
@Override
public void run() {
Rectangle baseMap = getBaseMap();
int count = baseMap.getChildCount();
for (int i = 0; i < count; i++) {
if (baseMap.getChildByIndex(i) instanceof Sprite &&
baseMap.getChildByIndex(i).getZIndex() == LayerZIndexType.SELECTCURSOR_LAYER.getValue().intValue()) {
Sprite cursor = (Sprite) baseMap.getChildByIndex(i);
cursor.setPosition(pointF.x, pointF.y);
cursor.setVisible(true);
}
}
baseMap.sortChildren();
}
});
}
示例14: mapMove
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
private void mapMove(PointF movePointF) {
Rectangle mapBaseRect = getBaseMap();
// 表示可能領域で補正
if (getStartDispX() > movePointF.x) {
movePointF.x = getStartDispX();
}
if (getEndDispX(mapBaseRect) < (movePointF.x + mapBaseRect.getWidth())) {
movePointF.x = getEndDispX(mapBaseRect) - mapBaseRect.getWidth();
}
if (getStartDispY() > movePointF.y) {
movePointF.y = getStartDispY();
}
if (getEndDispY(mapBaseRect) < (movePointF.y + mapBaseRect.getHeight())) {
movePointF.y = getEndDispY(mapBaseRect) - mapBaseRect.getHeight();
}
mapBaseRect.registerEntityModifier(new MoveModifier(0.2f,
mapBaseRect.getX(), movePointF.x,
mapBaseRect.getY(), movePointF.y));
}
示例15: createTextRectangle
import org.andengine.entity.primitive.Rectangle; //导入依赖的package包/类
public Rectangle createTextRectangle(String titleStr, Font titleFont, String detatilStr, Font detailFont,
VertexBufferObjectManager pVertexBufferObjectManager) {
Text titleText = new Text(0, 0, titleFont, titleStr,
pVertexBufferObjectManager);
Text detatilText = new Text(0, 0, detailFont, detatilStr,
pVertexBufferObjectManager);
titleText.setPosition(0, 0);
detatilText.setPosition(titleText.getX() + titleText.getWidth(), titleText.getY());
float textWidth = titleText.getWidth() + detatilText.getWidth();
float textHeight = titleText.getHeight();
Rectangle resultRectangle = new Rectangle(0, 0, textWidth, textHeight,
pVertexBufferObjectManager);
resultRectangle.setColor(Color.TRANSPARENT);
resultRectangle.setAlpha(0.0f);
resultRectangle.attachChild(titleText);
resultRectangle.attachChild(detatilText);
return resultRectangle;
}