当前位置: 首页>>代码示例>>Java>>正文


Java Image.getSubImage方法代码示例

本文整理汇总了Java中org.newdawn.slick.Image.getSubImage方法的典型用法代码示例。如果您正苦于以下问题:Java Image.getSubImage方法的具体用法?Java Image.getSubImage怎么用?Java Image.getSubImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.Image的用法示例。


在下文中一共展示了Image.getSubImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.newdawn.slick.Image; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	image = new Image("testdata/logo.png");
	
	width = image.getWidth() / 3;
	height = image.getHeight() / 3;
	
	images = new Image[] {
			image.getSubImage(0, 0, width, height), image.getSubImage(width,0,width,height), image.getSubImage(width*2,0,width,height),
			image.getSubImage(0, height, width, height), image.getSubImage(width,height,width,height), image.getSubImage(width*2,height,width,height),
			image.getSubImage(0, height*2, width, height), image.getSubImage(width,height*2,width,height), image.getSubImage(width*2,height*2,width,height),
	};
	
	images[0].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[2].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[3].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[3].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	
	images[4].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[4].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[5].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[5].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	
	images[6].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[8].setColor(Image.TOP_LEFT, 0,1,1,1);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:35,代码来源:ImageCornerTest.java

示例2: init

import org.newdawn.slick.Image; //导入方法依赖的package包/类
@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    player = new Player();
    buildings = new ArrayList<>();
    goons = new ArrayList<>();
    bullets = new ArrayList<>();
    playerImage = new Image("res/player.png");
    playerImage.setFilter(Image.FILTER_NEAREST);
    playerJump = new Image("res/playerjump.png");
    playerJump.setFilter(Image.FILTER_NEAREST);
    cannonImage = new Image("res/cannon.png");
    cannonImage.setFilter(Image.FILTER_LINEAR);
    cannonImage.setCenterOfRotation(Player.CANNON_CENTER_X, Player.CANNON_CENTER_Y);
    SpriteSheet playerSS = new SpriteSheet("res/player_run.png", 60, 75);
    playerRunRight = new Animation(playerSS, RUN_ANIMATION_SPEED);
    playerRunLeft  = new Animation();
    int ssw = playerSS.getHorizontalCount(), ssh = playerSS.getVerticalCount();
    for (int y = 0; y < ssh; y++) {
        for (int x = 0; x < ssw; x++) {
            playerRunLeft.addFrame(playerSS.getSprite(x, y).getFlippedCopy(true, false), RUN_ANIMATION_SPEED);
        }
    }
    bulletAnim = new Animation(new SpriteSheet("res/bullet.png", 30, 30), BULLET_ANIMATION_SPEED);
    buildingTexture = new Image("res/building.png");
    buildingLastRow = buildingTexture.getSubImage(0, buildingTexture.getHeight() - 1, buildingTexture.getWidth(), 1);
    buildingTexture.setFilter(Image.FILTER_NEAREST);
    buildingLastRow.setFilter(Image.FILTER_NEAREST);
    graffitiImages = new Image[NUM_GRAFFITI * 2];
    for (int i = 0; i < NUM_GRAFFITI; i++) {
        graffitiImages[i] = new Image("res/graffiti" + i + ".png");
        graffitiImages[i + NUM_GRAFFITI] = graffitiImages[i].getFlippedCopy(true, false);
    }
    graffiti = new ArrayList<>();
    mainTheme = new Music("res/main.ogg");
    try {
        partsys = ParticleIO.loadConfiguredSystem("res/particle.xml");
    } catch (IOException e) {
        e.printStackTrace();
    }
    fireExplosion = (ConfigurableEmitter)partsys.getEmitter(0);
    blueExplosion = (ConfigurableEmitter)partsys.getEmitter(1);
    fireExplosion.setEnabled(false);
    blueExplosion.setEnabled(false);
    fireCannon = new Sound("res/firecannon.ogg");
    highExplosion = new Sound("res/highexplosion.ogg");
    softExplosion = new Sound("res/softexplosion.ogg");
    hurtSound = new Sound("res/hurt.ogg");
    basicGoon = new Image("res/plasticbag.png");
    strongGoon = new Image("res/trashbag.png");
    flyingGoon = new Animation(new SpriteSheet("res/tshirt.png", 50, 50), 200);
    background = new Image("res/sunset.png");
    background.setFilter(Image.FILTER_NEAREST);
    camx = 0;
    camy = 0;
    camvx = 0;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:57,代码来源:Game.java


注:本文中的org.newdawn.slick.Image.getSubImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。