org.gljava.opengl

Class Sprite

public class Sprite extends Object

A simple sprite which has a texture and knows how to draw itself given a context and co-ordinates

Version: $Id: Sprite.java,v 1.4 2005/02/10 04:18:56 ivan_ganza Exp $

Author: Ivan Z. Ganza

Field Summary
protected intheight
protected Texturetexture
protected intwidth
Constructor Summary
Sprite()
Sprite(Texture t)
Create a new sprite from given Texture
Sprite(GL gl, String texturePath)
Create a new sprite from the image given at texturePath
Sprite(GL gl, URL url)
Create a new sprite from the image given at url
Sprite(GL gl, String resourceName, boolean resource)
Create a new sprite from the image found at the given resourceName
Method Summary
voiddraw(GL gl, float x, float y)
Draw the sprite at the specified location
intgetHeight()
Get the height of this sprite in pixels
intgetWidth()
Get the width of this sprite in pixels
voidsetHeight(int h)
voidsetWidth(int w)

Field Detail

height

protected int height

texture

protected Texture texture

width

protected int width

Constructor Detail

Sprite

public Sprite()

Sprite

public Sprite(Texture t)
Create a new sprite from given Texture

Parameters: t a Texture value

Sprite

public Sprite(GL gl, String texturePath)
Create a new sprite from the image given at texturePath

Parameters: gl a GL value texturePath a String value

Throws: IOException if an error occurs

Sprite

public Sprite(GL gl, URL url)
Create a new sprite from the image given at url

Parameters: gl a GL value url an URL value

Throws: IOException if an error occurs

Sprite

public Sprite(GL gl, String resourceName, boolean resource)
Create a new sprite from the image found at the given resourceName

Parameters: gl a GL value resourceName a String value resource a boolean value

Throws: IOException if an error occurs

Method Detail

draw

public void draw(GL gl, float x, float y)
Draw the sprite at the specified location

Parameters: x The x location at which to draw this sprite y The y location at which to draw this sprite

getHeight

public int getHeight()
Get the height of this sprite in pixels

Returns: The height of this sprite in pixels

getWidth

public int getWidth()
Get the width of this sprite in pixels

Returns: The width of this sprite in pixels

setHeight

public void setHeight(int h)

setWidth

public void setWidth(int w)