QUICK NAVIGATOR
PRODUCTS
TECHNOLOGIES
DEVELOPMENT TOOLS
* News
* Java Media Framework
* Intel Animation for Java
* Intel Spatial Audio for Java
* Runtime Software License
* SDK Software License
* System Requirements
* Download Area
* Documentation Online
* Gallery
* General FAQ
* Support Information

[INTEL NAVIGATION HEADER]

Intel Animation for Java* Package Tutorial

Lesson 7: Using Text and Sprites



This applet shows text in sprites. To make a sprite with text, create an awt.Image and draw the text. Then make a SingleImage from the awt.Image and create the sprite as usual. This is described in more detail below.

1. Create an awt.Image and draw the text

Image textimage = applet.createImage(TEXTSPRITE_WIDTH, TEXTSPRITE_HEIGHT);

Graphics gc = textimage.getGraphics();

Font f = new Font(FONT_TYPE, FONT_STYLE, FONT_SIZE);

gc.setFont(f);

gc.setColor(FONT_COLOR);

gc.drawString(TEXT, TEXT_X, TEXT_Y);

2. Create a SingleImage

SingleImage spriteSource = new SingleImage(textimage);

3. Set the transparency color of the SingleImage

spriteSource.setTransparency(COLOR);

4. Create the sprite

StaticDataSprite sprite = new StaticDataSprite();

5. Assign the SingleImage to the sprite

sprite.setData(spriteSource);

6. Assign the sprite to a surface

sprite.setDestination(animcanvas.getSurface());

7. Position the sprite on the surface

sprite.setPosition(new Point3D(x, y, z);

8. Draw the sprite on the screen

animcanvas.repaint();

This applet sets the transparency color to the color of the first pixel in the awt.Image. See the source code for more details.

Previous Lesson Tutorial Contents Next Lesson

View Source

 

This page was last updated on Feb 11th, 1997.

Legal Stuff

Free Web Hosting