本文整理汇总了Java中com.badlogic.gdx.math.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Java Rectangle类的具体用法?Java Rectangle怎么用?Java Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Rectangle类属于com.badlogic.gdx.math包,在下文中一共展示了Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LevelScreen
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
LevelScreen(GftGame game) {
this.game = game;
this.guiCam = new OrthographicCamera(800, 480);
this.guiCam.position.set(800 / 2, 480 / 2, 0);
this.backBounds = new Rectangle(7, 432, 48, 48);
this.autoMoveToNextBounds = new Rectangle(0, 0, 800, 62);
this.levelBounds = new ArrayList<Rectangle>();
int line = 0;
int column = 0;
for(int i = 0; i < LEVELS; i++) {
this.levelBounds.add(i, new Rectangle(370 + 75 * column++, 240 - 70 * line, 57, 57));
if(column == 5) {
column = 0;
line++;
}
}
this.touchPoint = new Vector3();
}
示例2: GameButton
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public GameButton(float WIDTH, float HEIGHT, String drawable, boolean isCheckable) {
audioManager = AudioManager.getInstance();
skin = new Skin();
skin.addRegions(AssetsManager.getTextureAtlas());
Button.ButtonStyle buttonStyle = new Button.ButtonStyle();
buttonStyle.up = skin.getDrawable(drawable);
buttonStyle.down = skin.getDrawable(drawable + "_pressed");
if (isCheckable) {
buttonStyle.checked = skin.getDrawable(drawable + "_pressed");
}
setStyle(buttonStyle);
setSize(WIDTH, HEIGHT);
rectangle = new Rectangle(getX(),getY(),getWidth(),getHeight());
addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
audioManager.playSound(audioManager.getButtonSound());
}
});
}
示例3: addObject
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public void addObject(IQuadTreeObject obj) {
tempObjects.add(obj);
//update max aabb
final Rectangle rect = obj.getRectangle();
final float x0 = rect.x;
final float y0 = rect.y;
final float x1 = rect.x + rect.width;
final float y1 = rect.y + rect.height;
minX = minX > x0 ? x0 : minX;
minY = minY > y0 ? y0 : minY;
maxX = maxX < x1 ? x1 : maxX;
maxY = maxY < y1 ? y1 : maxY;
System.out.println("QuadTree : updateRootBounds [" +
minX +"," + minY + "," + maxX + "," + maxY + "]");
}
示例4: TrainingScreen
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
TrainingScreen(GftGame game) {
this.game = game;
this.guiCam = new OrthographicCamera(800, 480);
this.guiCam.position.set(800 / 2, 480 / 2, 0);
this.backBounds = new Rectangle(7, 432, 48, 48);
this.playPauseBounds = new Rectangle(7, 7, 48, 48);
this.restartBounds = new Rectangle(62, 7, 48, 48);
this.backFowardtBounds = new Rectangle(127, 7, 48, 48);
this.soundBounds = new Rectangle(192, 7, 48, 48);
this.minusBounds = new Rectangle(590, 7, 48, 48);
this.plusBounds = new Rectangle(699, 7, 48, 48);
this.touchPoint = new Vector3();
this.grid = new Grid(this.game);
this.grid.loadTraining();
this.bottomBar = new BottomBar(this.game);
this.firstRun = 3;
this.lastUpdateTime = TimeUtils.millis();
this.bpm = MINUTE_IN_MILLIS / SettingsUtil.bpm;
}
示例5: update
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
void update(BaseScorer scorer) {
float cupSize = Math.min(scoreHeight, scorer.cupTexture.getHeight());
final Rectangle area = new Rectangle(
marginWidth, pieceHolderHeight + boardHeight,
availableWidth, scoreHeight);
scorer.cupArea.set(
area.x + area.width * 0.5f - cupSize * 0.5f, area.y,
cupSize, cupSize);
scorer.currentScoreLabel.setBounds(
area.x, area.y,
area.width * 0.5f - cupSize * 0.5f, area.height);
scorer.highScoreLabel.setBounds(
area.x + area.width * 0.5f + cupSize * 0.5f, area.y,
area.width * 0.5f - cupSize * 0.5f, area.height);
}
示例6: Renderer
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public Renderer() {
Core.cameraScale = baseCameraScale;
Effects.setEffectProvider((name, color, x, y, rotation) -> {
if(Settings.getBool("effects")){
Rectangle view = Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight)
.setCenter(camera.position.x, camera.position.y);
Rectangle pos = Tmp.r2.setSize(name.size).setCenter(x, y);
if(view.overlaps(pos)){
new EffectEntity(name, color, rotation).set(x, y).add();
}
}
});
clearColor = Hue.lightness(0.4f);
clearColor.a = 1f;
}
示例7: draw
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
@Override
public void draw (Batch batch, float parentAlpha) {
Rectangle scissors = new Rectangle();
Rectangle clipBounds = new Rectangle(getX(),getY(),getWidth(),getHeight());
ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);
drawBg(batch, parentAlpha);
batch.draw(texture,
getX() + getWidth() / 2 - texture.getRegionWidth() / 2 + shift.x,
getY() + getHeight() / 2 - texture.getRegionHeight() / 2 + shift.y,
texture.getRegionWidth() / 2f,
texture.getRegionHeight() / 2f,
texture.getRegionWidth(), texture.getRegionHeight(),
currZoom, currZoom, 0);
drawSplits(batch, parentAlpha);
batch.flush();
ScissorStack.popScissors();
}
示例8: pickPiece
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public boolean pickPiece() {
Vector2 mouse = new Vector2(
Gdx.input.getX(),
Gdx.graphics.getHeight() - Gdx.input.getY()); // Y axis is inverted
final float perPieceWidth = area.width / count;
for (int i = 0; i < count; ++i) {
if (pieces[i] != null) {
Rectangle maxPieceArea = new Rectangle(
area.x + i * perPieceWidth, area.y, perPieceWidth, area.height);
if (maxPieceArea.contains(mouse)) {
heldPiece = i;
return true;
}
}
}
heldPiece = -1;
return false;
}
示例9: WaterModel
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
/**
* Water Model's constructor.
* Creates a water model from the given object, into the given world.
*
* @param world The world the water model will be in.
* @param rect The rectangle to create the water model with.
*/
public WaterModel(World world, Rectangle rect) {
// Body and Fixture variables
BodyDef bdef = new BodyDef();
FixtureDef fdef = new FixtureDef();
PolygonShape shape = new PolygonShape();
bdef.type = BodyDef.BodyType.StaticBody;
bdef.position.set(PIXEL_TO_METER * (rect.getX() + rect.getWidth() / 2), PIXEL_TO_METER * (rect.getY() + rect.getHeight() / 2));
this.body = world.createBody(bdef);
shape.setAsBox((rect.getWidth() / 2) * PIXEL_TO_METER, (rect.getHeight() / 2) * PIXEL_TO_METER);
fdef.shape = shape;
fdef.filter.categoryBits = FLUID_BIT;
fdef.isSensor = true;
fdef.density = 1f;
fdef.friction = 0.1f;
fdef.restitution = 0f;
body.createFixture(fdef);
body.setUserData(new BuoyancyController(world, body.getFixtureList().first()));
}
示例10: resize
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public void resize(int w, int h)
{
screenWidth.set(w);
screenHeight.set(h);
if (BlueIrisViewer.bivSettings != null)
{
double sqrt = Math.sqrt(numCams);
cols = (int) Math.ceil(sqrt);
rows = (int) sqrt;
if (cols * rows < numCams)
rows++;
HandleOverrideGridSize();
imageWidth = (float) w / cols;
imageHeight = (float) h / rows;
aImageWidth.set((int) Math.ceil(imageWidth));
aImageHeight.set((int) Math.ceil(imageHeight));
}
blueIrisLayoutModelRect = new Rectangle(0, h, mainImageWidth, mainImageHeight);
ScaleRectangleToFitScreenCentered(blueIrisLayoutModelRect);
PrecalculateBlueIrisLayoutRectangles();
}
示例11: addEnemy
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
/**
* Reads the enemy type and spawn position out of an enemy object on the map and then spawns it in the current level
* @param object the map object that has been read in the map file
* @param rectangle the rectangular shape of the object, contains position used for selecting the spawn position
*/
private void addEnemy(MapObject object, Rectangle rectangle) {
MapProperties properties = object.getProperties();
if (properties != null && properties.containsKey("enemy_type")) {
String enemyType = properties.get("enemy_type", String.class);
switch (enemyType) {
case "Frog":
playScreen.spawnEnemy(FrogEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
break;
case "Monkey":
playScreen.spawnEnemy(MonkeyEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
break;
case "Boss":
playScreen.spawnEnemy(BossEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
break;
default:
break;
}
}
}
示例12: Band
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public Band(final Klooni game, final GameLayout layout, final BaseScorer scorer) {
this.scorer = scorer;
bandTexture = Theme.getBlankTexture();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = game.skin.getFont("font");
scoreLabel = new Label("", labelStyle);
scoreLabel.setAlignment(Align.center);
infoLabel = new Label("pause menu", labelStyle);
infoLabel.setAlignment(Align.center);
scoreBounds = new Rectangle();
infoBounds = new Rectangle();
layout.update(this);
}
示例13: PlayAnimation
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public void PlayAnimation(Animation animation, Rectangle newRegionOnTexture)
{
if (animation == null && this.animation == null)
throw new GdxRuntimeException("No animation is currently playing.");
// If this animation is already running, do not restart it.
if (this.animation == animation)
return;
// Start the new animation.
this.animation = animation;
this.frameIndex = 0;
this.animationTimeline = 0.0f;
this.setRegionX((int) newRegionOnTexture.x);
this.setRegionY((int) newRegionOnTexture.y);
this.setRegionWidth((int) newRegionOnTexture.getWidth());
this.setRegionHeight((int) newRegionOnTexture.getHeight());
onAnimationChanged();
}
示例14: InteractiveTileObject
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public InteractiveTileObject(World world, TiledMap map, Rectangle bounds){
this.world = world;
this.map = map;
this.bounds = bounds;
BodyDef bdef = new BodyDef();
FixtureDef fdef = new FixtureDef();
PolygonShape shape = new PolygonShape();
bdef.type = BodyDef.BodyType.StaticBody;
bdef.position.set((bounds.getX() + bounds.getWidth() / 2) / NoObjectionGame.PPM, (bounds.getY() + bounds.getHeight() / 2 )/ NoObjectionGame.PPM);
body = world.createBody(bdef);
shape.setAsBox(bounds.getWidth() / 2 / NoObjectionGame.PPM, bounds.getHeight() / 2 / NoObjectionGame.PPM);
fdef.shape = shape;
fixture = body.createFixture(fdef);
}
示例15: GameService
import com.badlogic.gdx.math.Rectangle; //导入依赖的package包/类
public GameService(SpriteBatch batch, IGameAsset asset,
BaseGameSetting setting, OrthographicCamera camera,
ISceneManager sceneManager) {
this.batch = batch;
this.asset = asset;
this.setting = setting;
if (asset == null)
this.asset = new DefaultGameAsset();
if (setting == null)
this.setting = new DefaultGameSetting();
this.camera = camera;
this.setChangeScene(sceneManager);
Rectangle.tmp.set(0, 0, getWindowSize().x, getWindowSize().y);
services = new IService[MAX_SERVICES];
}