当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getY方法代码示例

本文整理汇总了Java中com.badlogic.gdx.math.Rectangle.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getY方法的具体用法?Java Rectangle.getY怎么用?Java Rectangle.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.math.Rectangle的用法示例。


在下文中一共展示了Rectangle.getY方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makePlatform

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
/**
 * Creates a pivoted platform from the given object, at the given world.
 *
 * @param world  The world were the platform will be.
 * @param object The object used to initialize the platform.
 * @return The Platform Model of the created platform.
 */
static PlatformModel makePlatform(World world, RectangleMapObject object) {
    PlatformModel platform = new PlatformModel(world, object);

    Boolean pivoted = object.getProperties().get("pivoted", boolean.class);
    if (pivoted != null && pivoted == true) {
        Rectangle rect = object.getRectangle();
        RectangleMapObject anchorRect = new RectangleMapObject(
                rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2, 1, 1
        );
        Body anchor = makeRectGround(world, anchorRect);

        RevoluteJointDef jointDef = new RevoluteJointDef();
        jointDef.initialize(anchor, platform.getBody(), platform.getBody().getWorldCenter());
        world.createJoint(jointDef);
    }

    return platform;
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:26,代码来源:B2DFactory.java

示例2: onInit

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
/**
 * Inititalisiert den NPC.
 * Lädt alle Grafiken und Animationen.
 */
@Override
public void onInit()
{
    super.onInit();

    stoneAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/stone.atlas"));
    bigStone = stoneAtlas.findRegion("stone_big");

    if (rawObject instanceof RectangleMapObject)
    {
        RectangleMapObject rectObject = (RectangleMapObject) rawObject;
        Rectangle rect = rectObject.getRectangle();

        position = new Vector2(rect.getX() + rect.getWidth() / 2f, rect.getY());
        startPosition = new Vector2(rect.getX(), rect.getY());
        rectShape = Physics.createRectangle(rect.getWidth(), rect.getHeight(), new Vector2(rect.getWidth() / 2f, rect.getHeight() / 2f));

        if (activate)
            body = createEntityBody(startPosition, rectShape, BodyDef.BodyType.KinematicBody);

    } else {
        Gdx.app.log("WARNING", "Stone Barrier " + objectId + " must have an RectangleMapObject!");
        worldObjectManager.removeObject(this);
    }
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:30,代码来源:StoneBarrier.java

示例3: drawRect

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
public static void drawRect(SpriteBatch batch, Rectangle hitbox, float thickness, Color color) {
    // draw line
    /*
     * SpriteBatcherUtils.drawLine(batch, hitbox.getX(), hitbox.getY(),
     * hitbox.getX() + hitbox.getWidth(), hitbox.getY(), color);
     * 
     * //draw line SpriteBatcherUtils.drawLine(batch, hitbox.getX(),
     * hitbox.getY(), hitbox.getX(), hitbox.getY() + hitbox.getHeight(),
     * color);
     * 
     * //draw line SpriteBatcherUtils.drawLine(batch, hitbox.getX(),
     * hitbox.getY() + hitbox.getHeight(), hitbox.getX() +
     * hitbox.getWidth(), hitbox.getY() + hitbox.getHeight(), color);
     * 
     * //draw line SpriteBatcherUtils.drawLine(batch, hitbox.getX() +
     * hitbox.getWidth(), hitbox.getY(), hitbox.getX() + hitbox.getWidth(),
     * hitbox.getY() + hitbox.getHeight(), color);
     */

    float x = hitbox.getX();
    float y = hitbox.getY();
    float width = hitbox.getWidth();
    float height = hitbox.getHeight();

    // draw border of rectangle
    fillRectangle(batch, x, y, width, thickness, color);
    fillRectangle(batch, x, y, thickness, height, color);
    fillRectangle(batch, x + width - thickness, y, thickness, height, color);
    fillRectangle(batch, x, y + height - thickness, width, thickness, color);
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:31,代码来源:SpriteBatcherUtils.java

示例4: Meteorite

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
public Meteorite(Sprite[] textures, Sprite[] warning, Sound sound) {
    super(0, 0);
    this.sound = sound;
    Random r = new Random();
    int direction = r.nextInt(360 + 1);
    health = r.nextInt(2) + 3;

    float tempVelY = (float) (10 * Math.cos(Math.toRadians(direction)));
    float tempVelX = (float) (10 * Math.sin(Math.toRadians(direction)));

    if (r.nextInt(2) == 0)
        tempVelX *= -1;
    if (r.nextInt(2) == 0)
        tempVelY *= -1;
    Rectangle collision = new Rectangle((int) GameScreen.earth.getXCenter(),
            (int) GameScreen.earth.getYCenter(), radius * 2, radius * 2);
    Rectangle screen = new Rectangle(0, 0, Game.WIDTH, Game.HEIGHT);
    while (collision.overlaps(screen)) {
        collision.setPosition(collision.x + tempVelX, collision.y + tempVelY);
    }
    warningRect = new Rectangle(collision.x, collision.y, 50, 50);
    while (!warningRect.overlaps(screen)) {
        warningRect.setPosition(collision.x - tempVelX * 15, collision.y - tempVelY * 15);
    }
    x = (float) collision.getX();
    y = (float) collision.getY();
    float xSpeed = (Game.WIDTH / 2 - x) / 1.0f;
    float ySpeed = (Game.HEIGHT / 2 - y) / 1.0f;
    float factor = (float) (speed / Math.sqrt(xSpeed * xSpeed + ySpeed * ySpeed));
    xSpeed *= factor;
    ySpeed *= factor;

    velX = xSpeed;
    velY = ySpeed;
    this.collision = new Circle(x - radius, y - radius, radius);
    this.img = textures;
    this.warning = warning;
    warningTime = System.currentTimeMillis() + 3000;
}
 
开发者ID:MrGussio,项目名称:EarthInvadersGDX,代码行数:40,代码来源:Meteorite.java

示例5: assertThereIsPlacedObject

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
private void assertThereIsPlacedObject(CollisionMap<PixelCollisionMapTestObject> collisionMap, Rectangle bounds,
		PixelCollisionMapTestObject object)
{
	for (int i = (int) bounds.getX(); i < bounds.getWidth() + bounds.getX(); i++)
		for (int j = (int) bounds.getY(); j < bounds.getY() + bounds.getHeight(); j++)
			assertThat(collisionMap.getObject(i, j)).isEqualTo(object);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:8,代码来源:PixelCollisionMapTests.java

示例6: assertNullAroundObject

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
private void assertNullAroundObject(CollisionMap<PixelCollisionMapTestObject> collisionMap, Rectangle bounds)
{
	for (int i = (int) bounds.getX() - 1; i <= bounds.getX() + bounds.getWidth(); i++)
	{
		assertThat(collisionMap.getObject(i, (int) bounds.getY() - 1)).isNull();
		assertThat(collisionMap.getObject(i, (int) (bounds.getY() + bounds.getHeight()))).isNull();
	}
	for (int i = (int) bounds.getY(); i <= bounds.getY() + bounds.getHeight(); i++)
	{
		assertThat(collisionMap.getObject((int) bounds.getX() - 1, i)).isNull();
		assertThat(collisionMap.getObject((int) (bounds.getX() + bounds.getWidth()), i)).isNull();
	}
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:14,代码来源:PixelCollisionMapTests.java

示例7: makeBall

import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
/**
 * Creates a ball from the given object, at the given world.
 *
 * @param world   The world were the ball will be.
 * @param rectObj The object used to initialize the ball.
 * @return The BallModel of the created ball.
 */
static BallModel makeBall(World world, RectangleMapObject rectObj) {
    Rectangle rect = rectObj.getRectangle();
    return new BallModel(world, new Vector2(rect.getX() * PIXEL_TO_METER, rect.getY() * PIXEL_TO_METER));
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:12,代码来源:B2DFactory.java


注:本文中的com.badlogic.gdx.math.Rectangle.getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。