当前位置: 首页>>代码示例>>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;未经允许,请勿转载。