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


Java RectangleMapObject类代码示例

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


RectangleMapObject类属于com.badlogic.gdx.maps.objects包,在下文中一共展示了RectangleMapObject类的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: makePowerUp

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
/**
 * Creates a PowerUp from the given object, at the given world.
 *
 * @param world  The world were the PowerUp will be.
 * @param object The object used to initialize the PowerUp.
 * @return The created PowerUp.
 */
static PowerUp makePowerUp(World world, RectangleMapObject object) {
    String classProperty = object.getProperties().get("class", String.class);
    if (classProperty == null) {
        System.err.println("PowerUp has no class set!");
        return null;
    }

    switch (classProperty) {
        case "gravity":
            return new GravityPowerUp(world, object);
        case "velocity":
            return new SpeedPowerUp(world, object);
        case "jump":
            return new JumpPowerUp(world, object);
        default:
            return new RandomPowerUp(world, object);
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:26,代码来源:B2DFactory.java

示例4: BoxModel

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
/**
 * Box's Constructor.
 * Creates a Box in the given with world, from the given object.
 *
 * @param world  Physics world where the box will be in.
 * @param object Object used to create the box.
 */
public BoxModel(World world, RectangleMapObject object) {
    super(world, object.getRectangle().getCenter(new Vector2()).scl(PIXEL_TO_METER), ModelType.BOX, ANGULAR_DAMP, LINEAR_DAMP);

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

    // Create Fixture's Shape
    Shape shape = createPolygonShape(new float[]{
            0, 0, 64, 0, 64, 64, 0, 64
    }, new Vector2(64, 64));

    createFixture(new FixtureProperties(shape, density, FRICTION, RESTITUTION, GROUND_BIT, (short) (BALL_BIT | GROUND_BIT | FLUID_BIT)));
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:23,代码来源:BoxModel.java

示例5: 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

示例6: Box

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
public Box(World world, MapObject object){
    super(Assets.getAtlas().findRegion("boxCrate_double"));
    Rectangle rect = ((RectangleMapObject) object).getRectangle();
    bdef.type = BodyDef.BodyType.DynamicBody;
    bdef.position.set((rect.getX()+rect.getWidth()/2)/ QuackHack.PPM, (rect.getY() + rect.getHeight()/2)/QuackHack.PPM); // I don't follow the math
    body = world.createBody(bdef);
            
    shape.setAsBox(rect.getWidth() / 2 / QuackHack.PPM, rect.getHeight() / 2 / QuackHack.PPM);
    fdef.shape = shape;
    fdef.friction = 0.4f;
    fdef.density = 0.1f;
    body.createFixture(fdef);

    boxRegion = new TextureRegion(getTexture(), 0, 0, 128, 128);
    setBounds(0,0, 128 / QuackHack.PPM, 128 / QuackHack.PPM);
    setRegion(boxRegion);
    setOrigin(getHeight()/2, getWidth()/2);
}
 
开发者ID:edwardszczepanski,项目名称:QuackHack,代码行数:19,代码来源:Box.java

示例7: processFreeBodies

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
private void processFreeBodies(Array<MapObject> bodies) {
    for (MapObject object : bodies) {
        FixtureBodyDefinition fixtureBodyDefinition;
        if (object instanceof RectangleMapObject) {
            fixtureBodyDefinition = TiledUtils.createRectangleFixtureBodyDef((RectangleMapObject)object);
        } else if (object instanceof CircleMapObject) {
            fixtureBodyDefinition = TiledUtils.createCircleFixtureBodyDef((CircleMapObject)object);
        } else if (object instanceof EllipseMapObject) {
            fixtureBodyDefinition = TiledUtils.createEllipseFixtureBodyDef((EllipseMapObject)object);
        } else if (object instanceof PolylineMapObject || object instanceof PolygonMapObject) {
            fixtureBodyDefinition = TiledUtils.createPolyFixtureBodyDef(object);
        } else {
            throw new InvalidConfigException(filename, "Unknown MapObject type");
        }

        freeBodyDefinitions.add(fixtureBodyDefinition);
    }
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:19,代码来源:TiledMapLevelLoadable.java

示例8: getFixtureDefFromBodySkeleton

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
public static FixtureDef getFixtureDefFromBodySkeleton(MapObject object) {
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 1;
    fixtureDef.friction = 0;
    fixtureDef.restitution = 0;

    Shape shape = null;
    if (object instanceof TextureMapObject) {
        shape = getTextureMapShape(object);
    } else if (object instanceof RectangleMapObject) {
        shape = getRectangleShape(object);
    } else if (object instanceof CircleMapObject) {
        shape = getCircleShape(object);
    } else if (object instanceof EllipseMapObject) {
        shape = getEllipseShape(object);
    } else if (object instanceof PolygonMapObject) {
        shape = getPolygonShape(object);
    } else if (object instanceof PolylineMapObject) {
        shape = getPolylineShape(object);
    }

    fixtureDef.shape = shape;

    return fixtureDef;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:26,代码来源:TiledUtils.java

示例9: parseCollisionLayer

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
private void parseCollisionLayer() {
if (collisionLayer == null) {
    Gdx.app.debug(TAG, "No collision layer!");
    return;
}

for (MapObject object : collisionLayer.getObjects()) {
    if (object instanceof RectangleMapObject) {
	Rectangle rect = ((RectangleMapObject) object).getRectangle();
	rect.set( // update Tiled editor real values with our game world values
		rect.x * GameWorld.UNIT_SCALE, // scale x
		rect.y * GameWorld.UNIT_SCALE, // scale y
		rect.width * GameWorld.UNIT_SCALE, // scale width
		rect.height * GameWorld.UNIT_SCALE // scale height
	);
    }
}
   }
 
开发者ID:Quillraven,项目名称:Quilly-s-Castle,代码行数:19,代码来源:Map.java

示例10: parseSpawnLayer

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
private void parseSpawnLayer() {
if (spawnsLayer == null) {
    Gdx.app.debug(TAG, "No spawn layer!");
    return;
}

for (MapObject object : spawnsLayer.getObjects()) {
    if (object instanceof RectangleMapObject) {
	entities.add(Entity.getEntity( // params
		EntityType.valueOf(object.getName()), // entity type
		((RectangleMapObject) object).getRectangle().x * GameWorld.UNIT_SCALE, // start x
		((RectangleMapObject) object).getRectangle().y * GameWorld.UNIT_SCALE // start y
	));
    }
}
   }
 
开发者ID:Quillraven,项目名称:Quilly-s-Castle,代码行数:17,代码来源:Map.java

示例11: getPositionFromMapObject

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
private Vector2 getPositionFromMapObject(MapObject mapObject) {
	if (mapObject instanceof PolygonMapObject) {
		Polygon polygon = ((PolygonMapObject) mapObject).getPolygon();
		return new Vector2(polygon.getX(), polygon.getY());
	} else if (mapObject instanceof RectangleMapObject) {
		Rectangle rectangle = ((RectangleMapObject) mapObject).getRectangle();
		return new Vector2(rectangle.getX(), rectangle.getY());
	} else if (mapObject instanceof EllipseMapObject) {
		Ellipse ellipse = ((EllipseMapObject) mapObject).getEllipse();
		return new Vector2(ellipse.x, ellipse.y);
	} else if (mapObject instanceof CircleMapObject) {
		Circle circle = ((CircleMapObject) mapObject).getCircle();
		return new Vector2(circle.x, circle.y);
	}
	throw new GdxRuntimeException("Only Polygons, Rectangles, Ellipses and Circles are supported!");
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:GameMapLoader.java

示例12: InteractiveTileObject

import com.badlogic.gdx.maps.objects.RectangleMapObject; //导入依赖的package包/类
public InteractiveTileObject(PlayScreen screen, MapObject object) {
    this.screen = screen;
    this.world = screen.getWorld();
    this.map = screen.getMap();
    this.object = object;
    this.bounds = ((RectangleMapObject) object).getRectangle();

    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) / MarioBros.PPM, (bounds.getY() + bounds.getHeight() / 2) / MarioBros.PPM);

    body = world.createBody(bdef);

    shape.setAsBox(bounds.getWidth() / 2 / MarioBros.PPM, bounds.getHeight() / 2 / MarioBros.PPM);
    fdef.shape = shape;
    fixture = body.createFixture(fdef);
}
 
开发者ID:lbalmaceda,项目名称:libgdx_mario,代码行数:21,代码来源:InteractiveTileObject.java

示例13: 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

示例14: 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

示例15: 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


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