Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.newdawn.slick.tools.packulike;
  
  import java.io.File;
  
A simple sprite holder that allows the tool to name images

Author(s):
kevin
 
 public class Sprite {
The name of the sprite
 
 	private String name;
The x position of the sprite
 
 	private int x;
The y position of the sprite
 
 	private int y;
The width of the sprite
 
 	private int width;
The y position of the sprite
 
 	private int height;

The image for the sprite
 
 	private BufferedImage image;

Create a sprite based on a file

Parameters:
file The file containing the sprite image
Throws:
java.io.IOException Indicates a failure to load the image from the given file
 
 	public Sprite(File filethrows IOException {
 		this(file.getName(), ImageIO.read(file));
 	}

Create a new sprite

Parameters:
name The name of the sprite
image The image stored
 
 	public Sprite(String nameBufferedImage image) {
 		this. = name;
 		this. = image;
 		this. = image.getWidth();
 		this. = image.getHeight();
 	}

Set the position within the sheet of this sprite

Parameters:
x The x position of the sprite
y The y position of the sprite
 
 	public void setPosition(int xint y) {
 		this. = x;
 		this. = y;
 	}

Get the name of this sprite

Returns:
The name of this sprite
 
 	public String getName() {
 		return ;
 	}

Get the x position of this sprite within the sheet

Returns:
The x position of this sprite within the sheet
 
 	public int getX() {
 		return ;
 	}

Get the y position of this sprite within the sheet

Returns:
The y position of this sprite within the sheet
 
 	public int getY() {
 		return ;
 	}

Get the width of this sprite within the sheet

Returns:
The width of this sprite within the sheet
 
 	public int getWidth() {
 		return ;
 	}

Get the height of this sprite within the sheet

Returns:
The height of this sprite within the sheet
	public int getHeight() {
		return ;
	}

Get the image of this sprite

Returns:
The image of this sprite
	public BufferedImage getImage() {
		return ;
	}

Check if this sprite location contains the given x,y position

Parameters:
xp The x position of the sprite
yp The y position of the sprite
Returns:
True if the sprite contains the point
	public boolean contains(int xpint yp) {
		if (xp < ) {
			return false;
		}
		if (yp < ) {
			return false;
		}
		if (xp >= +) {
			return false;
		}
		if (yp >= +) {
			return false;
		}
		return true;
	}
New to GrepCode? Check out our FAQ X