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


Java RectangleMapObject.getRectangle方法代码示例

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


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

示例1: makePlatform

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的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: makeRectGround

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * Creates rectangular ground from the given object, at the given world.
 *
 * @param world  The world were the ground will be.
 * @param object The object used to initialize the ground.
 * @return The body of the created ground.
 */
static Body makeRectGround(World world, RectangleMapObject object) {
    Rectangle rect = object.getRectangle();

    // 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));

    Body body = world.createBody(bdef);

    shape.setAsBox((rect.getWidth() / 2) * PIXEL_TO_METER, (rect.getHeight() / 2) * PIXEL_TO_METER);
    fdef.shape = shape;
    fdef.filter.categoryBits = GROUND_BIT;
    body.createFixture(fdef);

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

示例3: onInit

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的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

示例4: createRectangle

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * 
 * @param world
 * @param rectangleObject
 * @param density
 * @param friction
 * @param restitution
 */
private void createRectangle(World world, RectangleMapObject rectangleObject, float density, float friction, float restitution){
	Rectangle rect = rectangleObject.getRectangle();
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(rect.width / SupaBox.PPM / 2f, rect.height / SupaBox.PPM / 2f);
	
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.StaticBody;
	bodyDef.position.set(new Vector2((rect.x + rect.width / 2f) / SupaBox.PPM, (rect.y + rect.height / 2f) / SupaBox.PPM));
	
	Body body = world.createBody(bodyDef);
	
	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = shape;
	fixtureDef.density = density;
	fixtureDef.friction = friction;
	fixtureDef.restitution = restitution;
	
	body.createFixture(fixtureDef);
	
	shape.dispose();
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:30,代码来源:BodyBuilder.java

示例5: loadEnemies

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * Carga los enemigos del nivel actual
 */
private static void loadEnemies() {
	
	Enemy enemy = null;
	
	// Carga los objetos m�viles del nivel actual
	for (MapObject object : LevelManager.map.getLayers().get("objects").getObjects()) {
		
		if (object instanceof RectangleMapObject) {
			RectangleMapObject rectangleObject = (RectangleMapObject) object;
			if (rectangleObject.getProperties().containsKey(TiledMapManager.ENEMY)) {
				Rectangle rect = rectangleObject.getRectangle();
				
				enemy = new Enemy();
				enemy.position.set(rect.x, rect.y);
				LevelManager.enemies.add(enemy);
			}
		}
	}
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:23,代码来源:LevelManager.java

示例6: loadPlatforms

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * Carga las plataformas m�viles de la pantalla actual
 */
public static void loadPlatforms() {
	
	Platform platform = null;
	
	// Carga los objetos m�viles del nivel actual
	for (MapObject object : LevelManager.map.getLayers().get("objects").getObjects()) {
		
		if (object instanceof RectangleMapObject) {
			RectangleMapObject rectangleObject = (RectangleMapObject) object;
			if (rectangleObject.getProperties().containsKey(TiledMapManager.MOBILE)) {
				Rectangle rect = rectangleObject.getRectangle();
				
				Direction direction = null;
				if (Boolean.valueOf((String) rectangleObject.getProperties().get("right_direction")))
					direction = Direction.RIGHT;
				else
					direction = Direction.LEFT;
				
				platform = new Platform(rect.x, rect.y, TiledMapManager.PLATFORM_WIDTH, TiledMapManager.PLATFORM_HEIGHT, 
									    Integer.valueOf((String) rectangleObject.getProperties().get("offset")), direction);
				LevelManager.platforms.add(platform);
			}
		}
	}
}
 
开发者ID:sfaci,项目名称:libgdx,代码行数:29,代码来源:LevelManager.java

示例7: Level

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
public Level() {
	super("Game");
	
	cam = new OrthographicCamera();
	// Setup camera viewport
	cam.setToOrtho(false, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
	cam.update();
	
	batch = new SpriteBatch();
	// Load map
	map =  new TmxMapLoader().load("maps/Lvl1.tmx");
	mapRenderer = new OrthogonalTiledMapRenderer(map);
	
	// Load walls as rectangles in an array
	MapObjects wallobjects = map.getLayers().get("Walls").getObjects();
	for(int i = 0; i < wallobjects.getCount(); i++) {
		RectangleMapObject obj = (RectangleMapObject) wallobjects.get(i);
		Rectangle rect = obj.getRectangle();
		walls.add(new Rectangle(rect.x, rect.y, 16, 16));
	}
	Texture[] tex = new Texture[]{new Texture("sprites/Player_Side_Left.png"),new  Texture("sprites/Player_Side_Right.png"), new Texture("sprites/Player_Behind_1.png"), new Texture("sprites/Player_Behind_2.png"),new Texture("sprites/Player_Forward1.png"),new Texture("sprites/Player.png")};
	player = new Player("sprites/Player.png", 120, 120, walls, tex);
	wall = new Texture("tiles/Wall.png");
}
 
开发者ID:stepansubbotin,项目名称:Elementorum,代码行数:25,代码来源:Level.java

示例8: PlatformModel

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * Platform Model's constructor.
 * Creates a platform model from the given object, into the given world.
 *
 * @param world  The world the platform model will be in.
 * @param object The object to create the platform model with.
 */
public PlatformModel(World world, RectangleMapObject object) {
    super(ModelType.PLATFORM, object.getRectangle());

    Rectangle rect = object.getRectangle();

    // Body and Fixture variables
    BodyDef bdef = new BodyDef();
    FixtureDef fdef = new FixtureDef();
    PolygonShape shape = new PolygonShape();

    bdef.type = BodyDef.BodyType.DynamicBody;
    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 = GROUND_BIT;
    fdef.isSensor = false;
    fdef.friction = 0.1f;
    fdef.restitution = 0f;

    // Fetch density from properties
    Float property = object.getProperties().get("density", float.class);
    if (property != null)
        fdef.density = property;
    else
        fdef.density = DEFAULT_DENSITY;

    body.createFixture(fdef);
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:39,代码来源:PlatformModel.java

示例9: addSpawner

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
private void addSpawner(RectangleMapObject spawnerElement)
{
	MapProperties properties = spawnerElement.getProperties();
	String monsterIdentifier = (String) properties.get("MonsterType");
	@SuppressWarnings("unchecked")
	Class<? extends Monster> monsterType = (Class<? extends Monster>) ObjectsIdentifier
			.getObjectType(monsterIdentifier);
	float spawnInterval = (float) properties.get("spawnInterval");
	int maximumMonsterAmount = (int) properties.get("MaximumMonsterAmount");
	IntegerRectangle spawnArea = new IntegerRectangle(spawnerElement.getRectangle());
	MonsterSpawnerUnit spawnerUnit = new MonsterSpawnerUnit(monsterType, spawnArea, maximumMonsterAmount,
			spawnInterval);
	monsterSpawner.addSpawner(spawnerUnit);
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:15,代码来源:PlayState.java

示例10: createRectangleFixtureBodyDef

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
public static FixtureBodyDefinition createRectangleFixtureBodyDef(RectangleMapObject object) {
    BodyDef bodyDef = new BodyDef();
    Rectangle rectangle = object.getRectangle();
    bodyDef.position.x = rectangle.x + (rectangle.width / 2);
    bodyDef.position.y = rectangle.y + (rectangle.height / 2);
    bodyDef.position.scl(MainCamera.getInstance().getTileMapScale());
    bodyDef.type = getBodyType(object);

    FixtureDef fixtureDef = getFixtureDefFromBodySkeleton(object);

    return new FixtureBodyDefinition(fixtureDef, bodyDef);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:13,代码来源:TiledUtils.java

示例11: getRectangle

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
private Shape getRectangle(RectangleMapObject rectangleObject) {
	Rectangle rectangle = rectangleObject.getRectangle();
	PolygonShape polygon = new PolygonShape();
	Vector2 size = new Vector2((rectangle.x + rectangle.width * 0.5f) / GameWorld.units,
	                           (rectangle.y + rectangle.height * 0.5f ) / GameWorld.units);
	polygon.setAsBox(rectangle.width * 0.5f / GameWorld.units,
	                 rectangle.height * 0.5f / GameWorld.units,
	                 size,
	                 0.0f);
	return polygon;
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:12,代码来源:GeneradorNivel.java

示例12: getRectangle

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
private Shape getRectangle(RectangleMapObject rectangleObject) {
	Rectangle rectangle = rectangleObject.getRectangle();
	PolygonShape polygon = new PolygonShape();
	Vector2 size = new Vector2((rectangle.x + rectangle.width * 0.5f) / units,
	                           (rectangle.y + rectangle.height * 0.5f ) / units);
	polygon.setAsBox(rectangle.width * 0.5f / units,
	                 rectangle.height * 0.5f / units,
	                 size,
	                 0.0f);
	return polygon;
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:12,代码来源:MapBodyManager.java

示例13: populatePhysicsWorld

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
public void populatePhysicsWorld(World physicsWorld) {
	for (MapObject collisionObject : collisionObjects) {
		if (collisionObject instanceof RectangleMapObject) {
			RectangleMapObject rectangleCollisionObject = (RectangleMapObject) collisionObject;
			Rectangle collisionRectangle = rectangleCollisionObject.getRectangle();

			CollisionBody collisionBody = new CollisionBody(collisionRectangle);
			collisionBody.addToPhysicsWorld(physicsWorld);
		}
	}
}
 
开发者ID:sftrabbit,项目名称:Interplanar,代码行数:12,代码来源:Level.java

示例14: getRectangle

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
private Shape getRectangle(RectangleMapObject rectangleObject) {
	Rectangle rectangle = rectangleObject.getRectangle();
	PolygonShape polygon = new PolygonShape();
	Vector2 size = new Vector2((rectangle.x + rectangle.width * 0.5f)
			* m_units, (rectangle.y + rectangle.height * 0.5f) * m_units);
	polygon.setAsBox(rectangle.width * 0.5f * m_units, rectangle.height
			* 0.5f * m_units, size, 0.0f);
	return polygon;
}
 
开发者ID:LostCodeStudios,项目名称:JavaLib,代码行数:10,代码来源:MapBodyManager.java

示例15: makeWater

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入方法依赖的package包/类
/**
 * Creates water from the given object, at the given world.
 *
 * @param world  The world were the water will be.
 * @param object The object used to initialize the water.
 * @return The Water Model of the created water.
 */
static WaterModel makeWater(World world, RectangleMapObject object) {
    return new WaterModel(world, object.getRectangle());
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:11,代码来源:B2DFactory.java


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