本文整理汇总了Java中com.badlogic.gdx.maps.objects.EllipseMapObject类的典型用法代码示例。如果您正苦于以下问题:Java EllipseMapObject类的具体用法?Java EllipseMapObject怎么用?Java EllipseMapObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EllipseMapObject类属于com.badlogic.gdx.maps.objects包,在下文中一共展示了EllipseMapObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processFreeBodies
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的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);
}
}
示例2: getFixtureDefFromBodySkeleton
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的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;
}
示例3: getPositionFromMapObject
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的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!");
}
示例4: createEllipse
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
/**
*
* @param world
* @param ellipseObject
* @param density
* @param friction
* @param restitution
*/
private void createEllipse(World world, EllipseMapObject ellipseObject, float density, float friction, float restitution){
Ellipse circle = ellipseObject.getEllipse();
CircleShape shape = new CircleShape();
shape.setRadius(circle.width / 2f / SupaBox.PPM);
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(new Vector2((circle.x + circle.width / 2f) / SupaBox.PPM, (circle.y + circle.width / 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();
}
示例5: getPlayerPosition
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
public static Vector2 getPlayerPosition(Map map, MapLayer layer) {
Vector2 playerPos = new Vector2(0,0);
for(MapObject object : layer.getObjects()) {
if(object instanceof EllipseMapObject) {
EllipseMapObject mapObject = (EllipseMapObject)object;
Vector3 tempVec3 = new Vector3();
tempVec3.set(mapObject.getEllipse().x + mapObject.getEllipse().width / 2,
mapObject.getEllipse().y + mapObject.getEllipse().height / 2, 0);
tempVec3.mul(getTransformationMatrix(map));
playerPos.set(tempVec3.x, tempVec3.y);
}
}
return playerPos;
}
示例6: onInit
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
@Override
public void onInit()
{
crystalAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/crystal.atlas"));
crystal = crystalAtlas.findRegion("crystal");
if (rawObject instanceof EllipseMapObject)
{
EllipseMapObject ellipseMapObject = (EllipseMapObject) rawObject;
position = new Vector2(ellipseMapObject.getEllipse().x + ellipseMapObject.getEllipse().width / 2f, ellipseMapObject.getEllipse().y + ellipseMapObject.getEllipse().height / 2f);
} else {
Gdx.app.log("WARNING", "Crystal " + objectId + " must be an EllipseMapObject.");
worldObjectManager.removeObject(this);
}
}
示例7: onInit
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
@Override
public void onInit()
{
wolfAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/wolf.atlas"));
wolf = wolfAtlas.findRegion("wolf_side", 4);
if (rawObject instanceof EllipseMapObject)
{
EllipseMapObject ellipseMapObject = (EllipseMapObject) rawObject;
position = new Vector2(ellipseMapObject.getEllipse().x + ellipseMapObject.getEllipse().width / 2f, ellipseMapObject.getEllipse().y + ellipseMapObject.getEllipse().height / 2f);
} else {
Gdx.app.log("WARNING", "EndingWolf " + objectId + " must be an EllipseMapObject.");
worldObjectManager.removeObject(this);
}
}
示例8: createEllipseFixtureBodyDef
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
public static FixtureBodyDefinition createEllipseFixtureBodyDef(EllipseMapObject object) {
BodyDef bodyDef = new BodyDef();
Ellipse ellipse = object.getEllipse();
bodyDef.position.x = ellipse.x + (ellipse.width / 2);
bodyDef.position.y = ellipse.y + (ellipse.height / 2);
bodyDef.position.scl(MainCamera.getInstance().getTileMapScale());
bodyDef.type = getBodyType(object);
FixtureDef fixtureDef = getFixtureDefFromBodySkeleton(object);
return new FixtureBodyDefinition(fixtureDef, bodyDef);
}
示例9: getEllipseShape
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
private static Shape getEllipseShape(MapObject object) {
Ellipse circle = ((EllipseMapObject)object).getEllipse();
CircleShape shape = new CircleShape();
shape.setRadius(circle.width / 2 * MainCamera.getInstance().getTileMapScale());
return shape;
}
示例10: getStartCoordinates
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
/**
* Returns the coordinates where the PCs should
* appear when they enter this map.
*
* @return
*/
public Vector2 getStartCoordinates() {
if (startCoordinates == null) {
MapLayer npcLayer = tiledMap.getLayers().get(LAYER_SPECIAL);
if (npcLayer != null && npcLayer.getObjects().getCount() > 0) {
MapObject startLocation = npcLayer.getObjects().get(0);
if (startLocation instanceof EllipseMapObject) {
Ellipse center = ((EllipseMapObject)startLocation).getEllipse();
startCoordinates = new Vector2((int)(center.x/getTileSizeX()), (int)(center.y/getTileSizeY()));
}
}
}
return startCoordinates;
}
示例11: spawnEnemies
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
private void spawnEnemies(TiledMap tiledMap, int level) {
Array<Vector2> spawnpoints = new Array<Vector2>();
MapLayer layer = tiledMap.getLayers().get("EnemySpawnPoints");
Iterator<MapObject> it = layer.getObjects().iterator();
while(it.hasNext()){
MapObject object = it.next();
EllipseMapObject ellipseMapObject = (EllipseMapObject) object;
Ellipse ellipse = ellipseMapObject.getEllipse();
spawnpoints.add(new Vector2(ellipse.x + ellipse.width / 2, ellipse.y + ellipse.height / 2));
}
int numberOfEnemies = level / 6 + 1;
if(numberOfEnemies >= 8){
numberOfEnemies = 8;
}
float speed = (float) Math.pow(1.045, level);
for(int i = 0; i < numberOfEnemies; i++){
int random = MathUtils.random(0, spawnpoints.size - 1);
Vector2 vec = spawnpoints.get(random);
spawnpoints.removeIndex(random);
Entity enemy = EntityUtils.createEnemyAStar(vec.x, vec.y, speed);
enemies.add(enemy);
engine.addEntity(enemy);
}
}
示例12: createLights
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
private void createLights(TiledMap tiledMap, int map) {
MapLayer layer = tiledMap.getLayers().get("PointLights");
Iterator<MapObject> it = layer.getObjects().iterator();
while(it.hasNext()){
MapObject object = it.next();
//Always going to be a circle
EllipseMapObject ellipse = (EllipseMapObject) object;
Entity entity = new Entity();
PointLightComponent pointComponent = new PointLightComponent();
pointComponent.color = Values.LIGHT_COLORS[map];
pointComponent.maxDistance = (float)Math.sqrt((double)ellipse.getEllipse().area());
pointComponent.numRays = Values.POINT_LIGHT_DEFAULT_NUM_RAYS;
pointComponent.x = ellipse.getEllipse().x + ellipse.getEllipse().width / 2;
pointComponent.y = ellipse.getEllipse().y + ellipse.getEllipse().height / 2;
LightComponent lightComponent = new LightComponent();
lightComponent.lightType = LightType.PointLight;
entity.add(pointComponent);
entity.add(lightComponent);
engine.addEntity(entity);
pointLights.add(entity);
}
}
示例13: createBodies
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
/**
*
* @param world
* @param map
*/
public void createBodies(ArrayList<Entity> entities, World world, TiledMap map){
MapObjects objects;
objects = map.getLayers().get("ground").getObjects();
for(MapObject object : objects){
if(object instanceof RectangleMapObject){
createRectangle(world, (RectangleMapObject) object, 0.5f, 0.4f, 0.6f);
} else if(object instanceof PolygonMapObject){
createPolygon(world, (PolygonMapObject) object, 0.5f, 0.4f, 0.6f);
} else if(object instanceof PolylineMapObject){
createPolyline(world, (PolylineMapObject) object, 0.5f, 0.4f, 0.6f);
} else if(object instanceof EllipseMapObject){
createEllipse(world, (EllipseMapObject) object, 0.5f, 0.4f, 0.6f);
} else{
Gdx.app.error("Error", "Invalid map object");
}
}
/*
objects = map.getLayers().get("dynamic").getObjects();
for(MapObject object : objects){
RectangleMapObject entity = (RectangleMapObject) object;
Rectangle position = entity.getRectangle();
entities.add(new Box(world, new Vector2(position.x / SupaBox.PPM, position.y / SupaBox.PPM), new Vector2(0f, 0f), 1f, 1f));
}
*/
}
示例14: getEllipse
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
private Shape getEllipse(EllipseMapObject ellipseObject) {
Ellipse ellipse = ellipseObject.getEllipse();
CircleShape ellipseShape = new CircleShape();
ellipseShape.setRadius((ellipse.width/2) / GameWorld.units);
ellipseShape.setPosition(new Vector2(ellipse.x / GameWorld.units, ellipse.y / GameWorld.units));
return ellipseShape;
}
示例15: onInit
import com.badlogic.gdx.maps.objects.EllipseMapObject; //导入依赖的package包/类
/**
* Initialisierung
*/
@Override
public void onInit()
{
super.onInit();
dummyAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/chicken.atlas"));
dummy = dummyAtlas.findRegion("chicken");
dummy_hit = dummyAtlas.findRegion("chicken_hit");
if (rawObject instanceof EllipseMapObject)
{
EllipseMapObject ellipseObject = (EllipseMapObject) rawObject;
Ellipse ellipse = ellipseObject.getEllipse();
Vector2 startPos = new Vector2(ellipse.x + ellipse.width / 2f, ellipse.y + ellipse.height / 2f);
body = createCircleBody(startPos, 10);
handler = new AttackHandler(worldObjectManager);
handler.setAttackedCallback(new AttackHandler.AttackedCallback()
{
@Override
public boolean run(Player player, int damage)
{
health -= damage;
if (health <= 0)
{
if (deathCallback != null)
deathCallback.run();
worldObjectManager.removeObject(TutorialDummy.this);
} else {
hitTimer += 0.6f;
}
return true;
}
});
handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));
} else {
Gdx.app.log("WARNING", "Tutorial Dummy " + objectId + " must have an EllipseMapObject!");
worldObjectManager.removeObject(this);
}
}