00001 /*--License: 00002 Kyra Sprite Engine 00003 Copyright Lee Thomason (Grinning Lizard Software) 2001-2002 00004 www.grinninglizard.com/kyra 00005 www.sourceforge.net/projects/kyra 00006 00007 Kyra is provided under 2 licenses: 00008 00009 - The GPL, with no additional restrictions. 00010 - The LGPL, provided you display the Kyra splash screen, described below. 00011 00012 00013 --- GPL License -- 00014 This program is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License 00016 as published by the Free Software Foundation; either version 2 00017 of the License, or (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00027 00028 The full text of the license can be found in license.txt 00029 00030 00031 --- LGPL License -- 00032 **Provided you kindly display the Kyra splash screen (details below), 00033 you may use the LGPL license:** 00034 00035 This library is free software; you can redistribute it and/or 00036 modify it under the terms of the GNU Lesser General Public 00037 License as published by the Free Software Foundation; either 00038 version 2.1 of the License, or (at your option) any later version. 00039 00040 This library is distributed in the hope that it will be useful, 00041 but WITHOUT ANY WARRANTY; without even the implied warranty of 00042 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00043 Lesser General Public License for more details. 00044 00045 You should have received a copy of the GNU Lesser General Public 00046 License along with this library; if not, write to the Free Software 00047 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 00049 The full text of the license can be found in lgpl.txt 00050 00051 00052 --- Kyra Splash Screen. 00053 00054 It would be appreciate if you display the Kyra splash screen when using 00055 either license, however it is only required for the LGPL. All the 00056 resources for the splash are compiled into the library, and it can be 00057 accessed through the following API: 00058 00059 KrEngine::StartSplash 00060 KrEngine::UpdateSplash 00061 KrEngine::EndSplash 00062 00063 Full documentation is provided with the KrEngine class. The splash screen 00064 should be displayed for 2 seconds. 00065 00066 Thank you. 00067 */ 00068 00069 #ifndef KYRA_SPRITE_INCLUDED 00070 #define KYRA_SPRITE_INCLUDED 00071 00072 #include "image.h" 00073 #include "spriteresource.h" 00074 00075 00098 class KrSprite : public KrImage 00099 { 00100 public: 00101 KrSprite( KrSpriteResource* resource ); 00102 virtual ~KrSprite() {} 00103 00105 void SetFrame( int i ); 00106 00108 void SetAction( const std::string& actionName ); 00109 00120 void SetActionRotated( const std::string& actionName, int rotation ); 00121 00125 void SetAction( U32 id ); 00126 00128 KrAction* GetAction() { return action; } 00130 std::string ActionName() const { return action->Name(); } 00131 00133 int NumFrames() const { return action->NumFrames(); } 00135 int Frame() const { return frame; } 00136 00141 void DoStep(); 00142 00144 KrVector2 Stride(); 00145 00146 virtual void QueryBoundingBox( KrRect* boundingBox, int window = 0 ); 00147 00149 KrSpriteResource* SpriteResource() { return resource; } 00150 virtual KrResource* Resource() { return resource; } 00151 00152 00153 virtual bool HitTest( int x, int y, int flags, GlDynArray<KrImage*>* results, int window ); 00154 virtual KrImNode* Clone(); 00155 00156 // -- internal -- // 00157 // Recursive call to draw a node and all its children. 00158 virtual void Draw( KrPaintInfo* paintInfo, 00159 const KrRect& clip, 00160 int window ); 00161 00162 virtual KrSprite* ToSprite() { return this; } 00163 virtual void CalcTransform( int win ); 00164 00165 private: 00166 KrSprite(); // not defined and not allowed 00167 KrSprite& operator=( const KrSprite& ); // not defined and not allowed. 00168 00169 KrSpriteResource* resource; 00170 KrAction* action; 00171 int frame; 00172 }; 00173 00174 00175 #endif