當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle.set方法代碼示例

本文整理匯總了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);
	
}
 
開發者ID:ja-brouil,項目名稱:StarshipFighters,代碼行數:22,代碼來源:PlayerBullets.java

示例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;
}
 
開發者ID:johannesmols,項目名稱:GangsterSquirrel,代碼行數:40,代碼來源:InteractiveMapTileObject.java

示例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();
}
 
開發者ID:mcgeer,項目名稱:Climatar,代碼行數:7,代碼來源:View.java


注:本文中的com.badlogic.gdx.math.Rectangle.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。