org.gljava.opengl
Class Sprite

java.lang.Object
  extended by org.gljava.opengl.Sprite

public class Sprite
extends java.lang.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  int height
           
protected  Texture texture
           
protected  int width
           
 
Constructor Summary
Sprite()
           
Sprite(GL gl, java.lang.String texturePath)
          Create a new sprite from the image given at texturePath
Sprite(GL gl, java.lang.String resourceName, boolean resource)
          Create a new sprite from the image found at the given resourceName
Sprite(GL gl, java.net.URL url)
          Create a new sprite from the image given at url
Sprite(Texture t)
          Create a new sprite from given Texture
 
Method Summary
 void draw(GL gl, float x, float y)
          Draw the sprite at the specified location
 int getHeight()
          Get the height of this sprite in pixels
 int getWidth()
          Get the width of this sprite in pixels
 void setHeight(int h)
           
 void setWidth(int w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

texture

protected Texture texture

width

protected int width

height

protected int height
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,
              java.lang.String texturePath)
       throws java.io.IOException
Create a new sprite from the image given at texturePath

Parameters:
gl - a GL value
texturePath - a String value
Throws:
java.io.IOException - if an error occurs

Sprite

public Sprite(GL gl,
              java.net.URL url)
       throws java.io.IOException
Create a new sprite from the image given at url

Parameters:
gl - a GL value
url - an URL value
Throws:
java.io.IOException - if an error occurs

Sprite

public Sprite(GL gl,
              java.lang.String resourceName,
              boolean resource)
       throws java.io.IOException
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:
java.io.IOException - if an error occurs
Method Detail

getWidth

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

Returns:
The width of this sprite in pixels

setWidth

public void setWidth(int w)

getHeight

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

Returns:
The height of this sprite in pixels

setHeight

public void setHeight(int h)

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