• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Ellipse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Ellipse类属于com.badlogic.gdx.math包,在下文中一共展示了Ellipse类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getPositionFromMapObject

import com.badlogic.gdx.math.Ellipse; //导入依赖的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


示例2: createEllipse

import com.badlogic.gdx.math.Ellipse; //导入依赖的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();
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:30,代码来源:BodyBuilder.java


示例3: write

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
@Override
public void write(Kryo kryo, Output output, Ellipse ellipse) {
    output.writeFloat(ellipse.x);
    output.writeFloat(ellipse.y);
    output.writeFloat(ellipse.width);
    output.writeFloat(ellipse.height);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:8,代码来源:EllipseSerializer.java


示例4: read

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
@Override
public Ellipse read(Kryo kryo, Input input, Class<Ellipse> type) {
    float x = input.readFloat();
    float y = input.readFloat();
    float width = input.readFloat();
    float height = input.readFloat();
    return new Ellipse(x, y, width, height);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:9,代码来源:EllipseSerializer.java


示例5: createCircle

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
/**
 * Erzeugt aus einem EllipseMapObject ein CircleShape.
 *
 * Ellipsen werden von Box2D nicht unterstützt, Tiled erzeugt aber auch bei Kreisen EllipseMapObjects.
 * Deshalb ermittelt diese Methode den kleineren Radius und benutzt diesen um einen Kreis zu erstellen.
 *
 * @param ellipseObject das MapObject
 * @return die entsprechende Form
 */
public static CircleShape createCircle(EllipseMapObject ellipseObject)
{
    Ellipse ellipse = ellipseObject.getEllipse();
    CircleShape circle = new CircleShape();

    circle.setPosition(new Vector2(ellipse.x + ellipse.width * 0.5f, ellipse.y + ellipse.height * 0.5f).scl(Physics.MPP));
    circle.setRadius(Math.min(ellipse.width, ellipse.height) * 0.5f * Physics.MPP);

    return circle;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:20,代码来源:PhysicsTileMapBuilder.java


示例6: createEllipseFixtureBodyDef

import com.badlogic.gdx.math.Ellipse; //导入依赖的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);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:13,代码来源:TiledUtils.java


示例7: getEllipseShape

import com.badlogic.gdx.math.Ellipse; //导入依赖的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;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:8,代码来源:TiledUtils.java


示例8: getStartCoordinates

import com.badlogic.gdx.math.Ellipse; //导入依赖的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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:20,代码来源:GameMap.java


示例9: spawnEnemies

import com.badlogic.gdx.math.Ellipse; //导入依赖的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);
	}
	
}
 
开发者ID:Portals,项目名称:DropTheCube-LD32,代码行数:31,代码来源:MapControllerSystem.java


示例10: getEllipse

import com.badlogic.gdx.math.Ellipse; //导入依赖的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;
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:9,代码来源:GeneradorNivel.java


示例11: copy

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
@Override
public Ellipse copy (Kryo kryo, Ellipse original) {
    return new Ellipse(original);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:5,代码来源:EllipseSerializer.java


示例12: onInit

import com.badlogic.gdx.math.Ellipse; //导入依赖的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);
    }
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:51,代码来源:TutorialDummy.java


示例13: onInit

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
/**
 * Initialisierung
 */
@Override
public void onInit()
{
    super.onInit();

    direction = new Vector2(MathUtils.random(-1f, 1f), MathUtils.random(-1f, 1f)).scl(4f);

    crabAtlas = new TextureAtlas(Gdx.files.internal("data/graphics/packed/krab.atlas"));
    crabAnimation = new Animation<TextureRegion>(1/7f, crabAtlas.findRegions("krab"), Animation.PlayMode.LOOP);

    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(Crab.this);
                } else {
                    hitTimer += 0.6f;
                }

                return true;
            }
        });

        handler.createAttackFixture(body, Physics.createRectangle(64, 64, new Vector2(0, 0)));

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


示例14: parseMapObjects

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
/**
 * Parst die Map: Sucht nach Objekten.
 *
 * Wird von {@link #parseMap()} ()} aufgerufen.
 */
private void parseMapObjects()
{
    MapLayer objectLayer = tileMap.getLayers().get(LevelConstants.TMX_OBJECT_LAYER);

    if (objectLayer == null)
    {
        Gdx.app.log("ERROR", "Missing object layer!");
        levelManager.exitToMenu();
        return;
    }

    for (MapObject tileObject : objectLayer.getObjects())
    {
        Gdx.app.log("LEVEL", "Found object '" + tileObject.getName() + "'");

        /*
        // Testcode um alle Eigenschaften auszugeben.
        Iterator<String> props = tileObject.getProperties().getKeys();
        while (props.hasNext())
        {
            String key = props.next();
            Gdx.app.log("LEVEL", "Property: " + key + " - " + tileObject.getProperties().get(key).toString());
        }
        */

        if (tileObject.getProperties().containsKey("type"))
        {
            String type = tileObject.getProperties().get(LevelConstants.TMX_TYPE, String.class);
            if (type.equals(LevelConstants.TMX_TYPE_START_POSITION) && tileObject instanceof EllipseMapObject)
            {
                EllipseMapObject start = (EllipseMapObject) tileObject;
                Ellipse startEllipse = start.getEllipse();
                player.setPosition(startEllipse.x + startEllipse.width / 2f, startEllipse.y + startEllipse.height / 2f);
            }
            else if (type.equals(LevelConstants.TMX_TYPE_WORLD_OBJECT)) {

                if (!tileObject.getName().isEmpty() &&
                    (tileObject instanceof EllipseMapObject || tileObject instanceof RectangleMapObject ||
                     tileObject instanceof PolygonMapObject || tileObject instanceof PolylineMapObject))
                {
                    worldObjectManager.initObject(tileObject.getName(), tileObject);
                } else {
                    Gdx.app.log("WARNING", "Missing object name or wrong class.");
                }
            } else {
                Gdx.app.log("LEVEL", "Object: " + tileObject.getName() + " -> Unkown type: " + type);
            }
        } else {
            Gdx.app.log("LEVEL", "Object: " + tileObject.getName() + " -> Missing type!");
        }
    }
    tileMap.getLayers().remove(objectLayer);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:59,代码来源:Level.java


示例15: ellipse

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
public Ellipse ellipse() {
    return ellipse(0, 0, 0, 0);
}
 
开发者ID:Murii,项目名称:Tilo-game-framework,代码行数:4,代码来源:math.java


示例16: getEllipse

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
/** @return ellipse shape */
public Ellipse getEllipse () {
	return ellipse;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:EllipseMapObject.java


示例17: EllipseMapObject

import com.badlogic.gdx.math.Ellipse; //导入依赖的package包/类
/** Creates an {@link Ellipse} object with the given X and Y coordinates along with a specified width and height.
 * 
 * @param x X coordinate
 * @param y Y coordinate
 * @param width Width in pixels
 * @param height Height in pixels */
public EllipseMapObject (float x, float y, float width, float height) {
	super();
	ellipse = new Ellipse(x, y, width, height);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:11,代码来源:EllipseMapObject.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IResourceForEditorInputFactory类代码示例发布时间:2022-05-22
下一篇:
Java StackPanel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap