001 package com.croftsoft.core.animation.awt; 002 003 import java.awt.*; 004 005 /********************************************************************* 006 * @version 007 * 1997-04-19 008 * @author 009 * <A HREF="http://www.alumni.caltech.edu/~croft">David W. Croft</A> 010 *********************************************************************/ 011 012 public class Sprite { 013 ////////////////////////////////////////////////////////////////////// 014 ////////////////////////////////////////////////////////////////////// 015 016 SpriteCanvas spriteCanvas; 017 Image image; 018 int x; 019 int y; 020 int z; 021 int w; 022 int h; 023 long id; 024 025 protected Image scratchImage; 026 protected Graphics scratchGraphics; 027 028 ////////////////////////////////////////////////////////////////////// 029 ////////////////////////////////////////////////////////////////////// 030 031 public Sprite ( SpriteCanvas spriteCanvas, Image image, 032 int x, int y, int z, int w, int h, long id ) { 033 ////////////////////////////////////////////////////////////////////// 034 this.spriteCanvas = spriteCanvas; 035 this.image = image; 036 this.x = x; 037 this.y = y; 038 this.z = z; 039 this.w = w; 040 this.h = h; 041 this.id = id; 042 } 043 044 public void setImage ( Image image ) { 045 ////////////////////////////////////////////////////////////////////// 046 try { 047 this.image = image; 048 // Assumes new image same size! 049 spriteCanvas.slip ( this, 0, 0 ); 050 } catch ( Exception e ) { e.printStackTrace ( ); } 051 } 052 053 ////////////////////////////////////////////////////////////////////// 054 ////////////////////////////////////////////////////////////////////// 055 }