本文整理匯總了Java中org.newdawn.slick.Image類的典型用法代碼示例。如果您正苦於以下問題:Java Image類的具體用法?Java Image怎麽用?Java Image使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Image類屬於org.newdawn.slick包,在下文中一共展示了Image類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTileImage
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* Gets the Image used to draw the tile at the given x and y coordinates.
*
* @param x
* The x coordinate of the tile whose image should be retrieved
* @param y
* The y coordinate of the tile whose image should be retrieved
* @param layerIndex
* The index of the layer on which the tile whose image should be
* retrieve exists
* @return The image used to draw the specified tile or null if there is no
* image for the specified tile.
*/
public Image getTileImage(int x, int y, int layerIndex) {
Layer layer = (Layer) layers.get(layerIndex);
int tileSetIndex = layer.data[x][y][0];
if ((tileSetIndex >= 0) && (tileSetIndex < tileSets.size())) {
TileSet tileSet = (TileSet) tileSets.get(tileSetIndex);
int sheetX = tileSet.getTileX(layer.data[x][y][1]);
int sheetY = tileSet.getTileY(layer.data[x][y][1]);
return tileSet.tiles.getSprite(sheetX, sheetY);
}
return null;
}
示例2: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
image1 = new Image("testdata/grass.png");
image2 = new Image("testdata/rocks.png");
fill = new GradientFill(-64,0,new Color(1,1,1,1f),64,0,new Color(0,0,0,0));
shape = new Rectangle(336,236,128,128);
poly = new Polygon();
poly.addPoint(320,220);
poly.addPoint(350,200);
poly.addPoint(450,200);
poly.addPoint(480,220);
poly.addPoint(420,400);
poly.addPoint(400,390);
}
示例3: createGraphics
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* Create an underlying graphics context for the given image
*
* @param image The image we want to render to
* @return The graphics context created
* @throws SlickException
*/
private static Graphics createGraphics(Image image) throws SlickException {
init();
if (fbo) {
try {
return new FBOGraphics(image);
} catch (Exception e) {
fbo = false;
Log.warn("FBO failed in use, falling back to PBuffer");
}
}
if (pbuffer) {
if (pbufferRT) {
return new PBufferGraphics(image);
} else {
return new PBufferUniqueGraphics(image);
}
}
throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible");
}
示例4: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
try {
fire = ParticleIO.loadConfiguredSystem("testdata/system.xml");
} catch (IOException e) {
throw new SlickException("Failed to load particle systems", e);
}
copy = new Image(400,300);
String[] formats = ImageOut.getSupportedFormats();
message = "Formats supported: ";
for (int i=0;i<formats.length;i++) {
message += formats[i];
if (i < formats.length - 1) {
message += ",";
}
}
}
示例5: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
LoadingList.setDeferredLoading(true);
new Sound("testdata/cbrown01.wav");
new Sound("testdata/engine.wav");
sound = new Sound("testdata/restart.ogg");
new Music("testdata/testloop.ogg");
music = new Music("testdata/SMB-X.XM");
new Image("testdata/cursor.png");
new Image("testdata/cursor.tga");
new Image("testdata/cursor.png");
new Image("testdata/cursor.png");
new Image("testdata/dungeontiles.gif");
new Image("testdata/logo.gif");
image = new Image("testdata/logo.tga");
new Image("testdata/logo.png");
new Image("testdata/rocket.png");
new Image("testdata/testpack.png");
font = new AngelCodeFont("testdata/demo.fnt", "testdata/demo_00.tga");
}
示例6: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST);
rocket = sheet.getSprite("rocket");
SpriteSheet anim = sheet.getSpriteSheet("runner");
runner = new Animation();
for (int y=0;y<2;y++) {
for (int x=0;x<6;x++) {
runner.addFrame(anim.getSprite(x,y), 50);
}
}
}
示例7: render
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void render(GameContainer container, Graphics g) {
image.draw(0,0);
image.draw(500,0,200,100);
scaleMe.draw(500,100,200,100);
scaled.draw(400,500);
Image flipped = scaled.getFlippedCopy(true, false);
flipped.draw(520,500);
Image flipped2 = flipped.getFlippedCopy(false, true);
flipped2.draw(520,380);
Image flipped3 = flipped2.getFlippedCopy(true, false);
flipped3.draw(400,380);
for (int i=0;i<3;i++) {
subImage.draw(200+(i*30),300);
}
g.translate(500, 200);
g.rotate(50, 50, rot);
g.scale(0.3f,0.3f);
image.draw();
g.resetTransform();
}
示例8: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
poly.addPoint(120, 120);
poly.addPoint(420, 100);
poly.addPoint(620, 420);
poly.addPoint(300, 320);
image = new Image("testdata/rocks.png");
texPaint = new TexCoordGenerator() {
public Vector2f getCoordFor(float x, float y) {
float tx = (texRect.getX() - x) / texRect.getWidth();
float ty = (texRect.getY() - y) / texRect.getHeight();
return new Vector2f(tx,ty);
}
};
}
示例9: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* This method inizializes map, images, animations and sounds
* @param container
* @throws SlickException
*/
@Override
public void init(GameContainer container) throws SlickException {
ready = new Image("data/ready.jpg");
gameOver = new Image("data/gameover.png");
youWin = new Image("data/youwin.png");
mazeMap = new TiledMap("data/maze/Maze.tmx");
initMapProperty();
initAnimations();
begin = new Sound("data/pacmanSound/begin.wav");
begin.play();
eatFruit = new Sound("data/pacmanSound/eatFruit.wav");
pacmanGame.initMaze(mazeMap,this);
}
示例10: setTileSetImage
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* Set the image to use for this sprite sheet image to use for this tileset
*
* @param image
* The image to use for this tileset
*/
public void setTileSetImage(Image image) {
tiles = new SpriteSheet(image, tileWidth, tileHeight, tileSpacing,
tileMargin);
tilesAcross = tiles.getHorizontalCount();
tilesDown = tiles.getVerticalCount();
if (tilesAcross <= 0) {
tilesAcross = 1;
}
if (tilesDown <= 0) {
tilesDown = 1;
}
lastGID = (tilesAcross * tilesDown) + firstGID - 1;
}
示例11: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
image = new Image("testdata/logo.tga", true);
Image temp = new Image("testdata/palette_tool.png");
container.setMouseCursor(temp, 0, 0);
container.setIcons(new String[] {"testdata/icon.tga"});
container.setTargetFrameRate(100);
poly = new Polygon();
float len = 100;
for (int x=0;x<360;x+=30) {
if (len == 100) {
len = 50;
} else {
len = 100;
}
poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len,
(float) FastTrig.sin(Math.toRadians(x)) * len);
}
}
示例12: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
poly.addPoint(100, 100);
poly.addPoint(120, 100);
poly.addPoint(120, 120);
poly.addPoint(100, 120);
image = new Image("testdata/rocks.png");
}
示例13: init
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
geomColor = Color.magenta;
overlayColor = Color.white;
magImage = new Image(21, 21);
}
示例14: render
import org.newdawn.slick.Image; //導入依賴的package包/類
public void render(Graphics g) {
Image img = AssetManager.getManager().getImage(image);
if(img == null) {
// Draw the text representing the button.
UnicodeFont fnt = AssetManager.getManager().getFont(FONT_NAME);
Color color = mouseOver() ? DEFAULT_HOVER : DEFAULT_TEXT;
g.setColor(color);
g.setFont(fnt);
g.drawString(text, position.x, position.y);
} else g.drawImage(img, position.x, position.y);
}
示例15: PBufferGraphics
import org.newdawn.slick.Image; //導入依賴的package包/類
/**
* Create a new graphics context around a pbuffer
*
* @param image The image we're rendering to
* @throws SlickException Indicates a failure to use pbuffers
*/
public PBufferGraphics(Image image) throws SlickException {
super(image.getTexture().getTextureWidth(), image.getTexture().getTextureHeight());
this.image = image;
Log.debug("Creating pbuffer(rtt) "+image.getWidth()+"x"+image.getHeight());
if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
throw new SlickException("Your OpenGL card does not support PBuffers and hence can't handle the dynamic images required for this application.");
}
if ((Pbuffer.getCapabilities() & Pbuffer.RENDER_TEXTURE_SUPPORTED) == 0) {
throw new SlickException("Your OpenGL card does not support Render-To-Texture and hence can't handle the dynamic images required for this application.");
}
init();
}