本文整理汇总了Java中com.badlogic.gdx.math.Rectangle.set方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.set方法的具体用法?Java Rectangle.set怎么用?Java Rectangle.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Rectangle
的用法示例。
在下文中一共展示了Rectangle.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
public void init() {
// Bullet Upgrades
doubleBullets = false;
tripleBullets = false;
// GamePlay
damageValue = -100;
// Graphics || Might rewrite this later if it lags too much. Create a static method for this? Or have a permanent object
// with all the variables already.
allTexture = new Texture(Gdx.files.internal(pathname));
TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 2, allTexture.getHeight() / 1);
bulletTexture = new TextureRegion[1];
bulletTexture[0] = tmp[0][0];
// Rectangle
collisionBounds = new Rectangle();
collisionBounds.set(x, y, 4f, 9f);
}
示例2: getCollidingMapObject
import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
/**
* This method returns the properties of an object in a collision layer by checking the player rectangle and object rectangle for an intersection
* @param layerIndex the index of the layer in which to search for objects
* @return the collided object
*/
protected MapObject getCollidingMapObject(int layerIndex) {
MapObjects mapObjects = map.getLayers().get(layerIndex).getObjects();
for (MapObject mapObject : mapObjects) {
MapProperties mapProperties = mapObject.getProperties();
float width, height, x, y;
Rectangle objectRectangle = new Rectangle();
Rectangle playerRectangle = new Rectangle();
if (mapProperties.containsKey("width") && mapProperties.containsKey("height") && mapProperties.containsKey("x") && mapProperties.containsKey("y")) {
width = (float) mapProperties.get("width");
height = (float) mapProperties.get("height");
x = (float) mapProperties.get("x");
y = (float) mapProperties.get("y");
objectRectangle.set(x, y, width, height);
}
playerRectangle.set(
playScreen.getPlayer().getX() * MainGameClass.PPM,
playScreen.getPlayer().getY() * MainGameClass.PPM,
playScreen.getPlayer().getWidth() * MainGameClass.PPM,
playScreen.getPlayer().getHeight() * MainGameClass.PPM
);
// If the player rectangle and the object rectangle is colliding, return the object
if (Intersector.overlaps(objectRectangle, playerRectangle)) {
return mapObject;
}
}
// If no colliding object was found in that layer
return null;
}
示例3: setFrame
import com.badlogic.gdx.math.Rectangle; //导入方法依赖的package包/类
public void setFrame(float x, float y, float width, float height) {
Rectangle f = getFrame();
f.set(x, y, width, height);
layout();
}