sprite.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2005
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under the LGPL. 
00008         
00009         I kindly request you display a splash screen (provided in the HTML documentation)
00010         to promote Kyra and acknowledge the software and everyone who has contributed to it, 
00011         but it is not required by the license.
00012 
00013 --- LGPL License --
00014 
00015     This library is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU Lesser General Public
00017     License as published by the Free Software Foundation; either
00018     version 2.1 of the License, or (at your option) any later version.
00019 
00020     This library is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023     Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public
00026     License along with this library; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029         The full text of the license can be found in lgpl.txt
00030 */
00031 
00032 #ifndef KYRA_SPRITE_INCLUDED
00033 #define KYRA_SPRITE_INCLUDED
00034 
00035 #include "image.h"
00036 #include "spriteresource.h"
00037 
00038 
00061 class KrSprite : public KrImage
00062 {
00063   public:
00064         KrSprite( KrSpriteResource* resource );
00065         virtual ~KrSprite()             {}
00066 
00068         void SetFrame( int i );
00069 
00071         void SetAction( const std::string& actionName );
00072 
00083         void SetActionRotated( const std::string& actionName, int rotation );
00084 
00088         void SetAction( U32 id );
00089 
00091         KrAction* GetAction()   { return action; }
00093         std::string ActionName() const  { return action->Name(); }
00094 
00096         int  NumFrames() const          { return action->NumFrames(); }
00098         int  Frame() const                      { return frame; }
00100         KrRle* GetFrame() const         { return action->GetFrame( frame ); };
00101 
00106         void DoStep();  
00107         
00109         grinliz::Vector2I StepSize() const      { return action->GetFrame( frame )->StepSize(); }
00110 
00112         grinliz::Vector2I Stride();             
00113 
00114         virtual void QueryBoundingBox( grinliz::Rectangle2I* boundingBox, int window = 0 );
00115 
00117         KrSpriteResource*   SpriteResource()    { return resource; }
00118         virtual KrResource* Resource()                  { return resource; }
00119 
00120 
00121         virtual bool HitTest( int x, int y, int flags, std::vector<KrImage*>* results, int window );
00122         virtual KrImNode* Clone();
00123 
00124         // -- internal -- //
00125         // Recursive call to draw a node and all its children.
00126         virtual void Draw(      KrPaintInfo* paintInfo,
00127                                                 const grinliz::Rectangle2I& clip,
00128                                                 int window );
00129 
00130         virtual KrSprite* ToSprite()    { return this; }
00131         virtual void    CalcTransform( int win );
00132 
00133   private:
00134     KrSprite();                                 // not defined and not allowed
00135     KrSprite& operator=( const KrSprite& );    // not defined and not allowed.
00136 
00137         KrAction*                       action;
00138         KrSpriteResource*       resource;
00139         int                                     frame;
00140 };
00141 
00142 
00143 #endif

Generated on Thu Jul 20 20:45:32 2006 for Kyra by  doxygen 1.4.7