本文整理匯總了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();
}