本文整理汇总了Java中com.badlogic.gdx.math.Polygon.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.setPosition方法的具体用法?Java Polygon.setPosition怎么用?Java Polygon.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Polygon
的用法示例。
在下文中一共展示了Polygon.setPosition方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Horse
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public Horse(TextureRegion horse, int width, int height, float weight,
float posX, float posY) {
super(horse, width, height, weight, posX, posY, AssetLoader.polyHorse);
this.polyMap = new HashMap<TextureRegion, Polygon>();
this.polyMap.put(AssetLoader.horse, AssetLoader.polyHorse);
this.polyMap.put(AssetLoader.horse2, AssetLoader.polyHorse2);
this.polyMap.put(AssetLoader.horse3, AssetLoader.polyHorse3);
this.polyMap.put(AssetLoader.horseJump, AssetLoader.polyHorseJump);
this.polyMap.put(AssetLoader.horseSlide, AssetLoader.polyHorseSlide);
for (Polygon polygon : this.polyMap.values()) {
polygon.setScale(0.15f, 0.16f);
polygon.setPosition(posX, posY + 50);
}
this.polyMap.get(AssetLoader.horseSlide).setScale(0.15f, 0.12f);
}
示例2: read
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
@Override
public Polygon read (Kryo kryo, Input input, Class<Polygon> type) {
int length = input.readInt();
float[] vertices = input.readFloats(length);
Polygon polygon = new Polygon(vertices);
polygon.setPosition(input.readFloat(), input.readFloat());
polygon.setOrigin(input.readFloat(), input.readFloat());
polygon.setRotation(input.readFloat());
polygon.setScale(input.readFloat(), input.readFloat());
return polygon;
}
示例3: Enemy
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public Enemy(final Application APP, TextureAtlas.AtlasRegion normalTexture, TextureAtlas.AtlasRegion hitTexture, Sprite redBar, Sprite greenBar, int BOUNDING_X, int BOUNDING_Y, int BOUNDING_WIDTH, int BOUNDING_HEIGHT)
{
this.normalTexture = normalTexture;
this.hitTexture = hitTexture;
this.sprite = new Sprite(normalTexture);
squishSFX = APP.assets.get("sounds/squish.wav", Sound.class);
velocity = new Vector2();
position = new Vector2();
forwardVelocity = new Vector2();
bounds = new Polygon();
healthBar = new HealthBar(redBar, greenBar);
this.BOUNDING_X = BOUNDING_X;
this.BOUNDING_Y = BOUNDING_Y;
this.BOUNDING_WIDTH = BOUNDING_WIDTH;
this.BOUNDING_HEIGHT = BOUNDING_HEIGHT;
vertices = new float[]{
0, 0,
0, BOUNDING_HEIGHT,
BOUNDING_WIDTH, BOUNDING_HEIGHT,
BOUNDING_WIDTH, 0};
bounds.setVertices(vertices);
bounds.setPosition(sprite.getX(), sprite.getY());
position.set(this.sprite.getX(), this.sprite.getY());
bounds.setOrigin(BOUNDING_WIDTH / 2, BOUNDING_HEIGHT / 2);
}
示例4: determineEscapeZone
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
private void determineEscapeZone() {
GameLocation escapeZone = findLocation(LOCATION_ESCAPE_ZONE);
Polygon polygon = new Polygon(new float[] {0, 0, escapeZone.getWidth(), 0, escapeZone.getWidth(), escapeZone.getHeight(), 0, escapeZone.getHeight()});
polygon.setPosition(escapeZone.getX(), escapeZone.getY());
Transition victoryTransition = new Transition(this, fromMap, fromX, fromY, polygon);
escapeTransition = new Transition(this, fromMap, escapeX, escapeY, polygon);
for (int x = (int)escapeZone.getX(); x < escapeZone.getX()+escapeZone.getWidth(); ++x) {
for (int y = (int)escapeZone.getY(); y < escapeZone.getY()+escapeZone.getHeight(); ++y) {
transitionTiles.put(new Vector2(x, y), victoryTransition);
}
}
}
示例5: write
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
@Override
public void write(Json json) {
PolygonUtils.ensureClockWise(walkZone.getVertices(), 0, walkZone.getVertices().length);
walkZone.dirty();
Polygon p = new Polygon(walkZone.getVertices());
p.setPosition(walkZone.getX() / walkZone.getScaleX(), walkZone.getY() / walkZone.getScaleY());
json.writeValue("walkZone", p);
}
示例6: rectangleToPolygon
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public static Polygon rectangleToPolygon(Rectangle rectangle) {
Polygon polygon = new Polygon();
polygon.setOrigin(0, 0);
polygon.setPosition(rectangle.x, rectangle.y);
polygon.setVertices(new float[] { 0, 0, 0 + rectangle.width, 0,
0 + rectangle.width, 0 + rectangle.height, 0,
0 + rectangle.height });
return polygon;
}
示例7: getCollider
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
@Override
public Array<Polygon> getCollider() {
Array<Polygon> collider = new Array<Polygon>();
Polygon newPolygon = new Polygon();
newPolygon.setPosition(value, value);
collider.add(newPolygon);
return collider;
}
示例8: GameObject
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public GameObject(String textureName, int x, int y) {
texture = AssetsManager.loadTexture(textureName);
center = new Vector2();
initialXScale =1f;
initialYScale =1f;
scaleX = 1f;
scaleY = 1f;
float[] vertices = SpaceGame.loadShape(textureName);
if(vertices == null && texture != null){
vertices = new float[8];
vertices[0] = 0;
vertices[1] = 0;
vertices[2] = 0;
vertices[3] = texture.getHeight();
vertices[4] = texture.getWidth();
vertices[5] = texture.getHeight();
vertices[6] = texture.getWidth();
vertices[7] = 0;
}else if(texture == null){
vertices = new float[6];
vertices[0] = 0;
vertices[1] = 0;
vertices[2] = 0;
vertices[3] = 0;
vertices[4] = 0;
vertices[5] = 0;
}
this.loadWidthAndHeight(vertices);
this.loadScaleFactors(textureName);
this.applyScaleToVertices(vertices);
logicShape = new Polygon(vertices);
logicShape.setPosition(x,y);
this.relocateCenter();
this.calculateRadio();
//Recolocamos el origen del logic shape para cuando se realice un giro con setRotation
this.getLogicShape().setOrigin(getWidth()/2, getHeight()/2);
}
示例9: generateSpokes
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
/** Generates spokes emanating from the center */
private void generateSpokes () {
worldSpokes = new Array<Polygon>();
// Initial reference angle to offset the spokes from
float referencenAngle = rng.nextFloat() * 360.0f;
float spokeOffset = (MathUtils.PI2 / param.spokeCount) * MathUtils.radDeg;
// Determine the length of the spokes
float halfWidth = (width * 0.5f);
float halfHeight = (height * 0.5f);
float length = (float)Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight);
// Create the spokes using polygon shapes
for (int i = 0; i < param.spokeCount; i++) {
// Calculate the angle the spoke will be set to
float angle = referencenAngle + (spokeOffset * i);
angle += randomSign() * (rng.nextFloat() * param.spokeScattering);
// Set the vertices of the polygon as a rectangle with a height of spokeWidth and a width of the length
float[] verticies = new float[8];
verticies[0] = 0;
verticies[1] = -param.spokeWidth * 0.5f;
verticies[2] = length;
verticies[3] = -param.spokeWidth * 0.5f;
verticies[4] = length;
verticies[5] = param.spokeWidth * 0.5f;
verticies[6] = 0;
verticies[7] = param.spokeWidth * 0.5f;
// Create the polygon shape
Polygon polygon = new Polygon();
polygon.setVertices(verticies);
polygon.setPosition(halfWidth, halfHeight);
polygon.setRotation(angle);
// Create a spawn point at the end of the spoke
Vector2 spawnPoint = new Vector2(length, 0);
spawnPoint.setAngle(angle);
spawnPoint.add(halfWidth, halfHeight);
WaveSystem.addSpawnPoint(spawnPoint);
worldSpokes.add(polygon);
}
}
示例10: parsePolygon
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
public static void parsePolygon(Polygon p, String v, String pos) {
parsePolygon(p, v);
Vector2 v2 = parseVector2(pos);
p.setPosition(v2.x, v2.y);
}
示例11: getPolygon
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
/**
* WARNING: EXPENSIVE OPERATION USE ONLY IN INITIALISATION STEPS
* This method is used to create a new rectangular polygon
*
* @param x the x coordinate of the polygon
* @param y the y coordinate of the polygon
* @param width the width of the polygon
* @param height the height of the polygon
* @return the created polygon
*/
public static Polygon getPolygon(float x, float y, float width, float height) {
float vals[] = {0, 0, width, 0, width, height, 0, height};
Polygon p = new Polygon();
p.setOrigin(width / 2, height / 2);
p.setScale(1, 1);
p.setVertices(vals);
p.setPosition(x, y);
return p;
}
示例12: setX
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
/**
* Used to set the x co-ordinate of polygon
*
* @param p polygon whose x co-ordinate is to be set
* @param x new value for x co-ordinate of polygon
*/
public static void setX(Polygon p, float x) {
p.setPosition(x, p.getY());
}
示例13: setY
import com.badlogic.gdx.math.Polygon; //导入方法依赖的package包/类
/**
* Used to set the y co-ordinate of polygon
*
* @param p polygon whose y co-ordinate is to be set
* @param y new value for y co-ordinate of polygon
*/
public static void setY(Polygon p, float y) {
p.setPosition(p.getX(), y);
}