AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzBitmapSprite.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CCZ_BITMAP_SPRITE_H_)
00015 #define _CCZ_BITMAP_SPRITE_H_
00016 
00017 #include "CzSprite.h"
00018 
00019 /**
00020  @class CzBitmapSprite
00021 
00022  @brief A BitmapSprite is a bitmapped visual representation of an on screen game object.
00023 
00024  */
00025 class CzBitmapSprite : public CzSprite
00026 {
00027 public:
00028     enum eImageTransform
00029     {
00030         ImageTransform_None = 0, 
00031         ImageTransform_FlipX = 1, 
00032         ImageTransform_FlipY = 2, 
00033         ImageTransform_FlipXY = 3, 
00034     };
00035 
00036     // Properties
00037 protected:
00038     int                 SrcX, SrcY;             ///< Top left position in source texture
00039     int                 SrcWidth, SrcHeight;    ///< Width and height of sprite in source texture
00040     float               SrcTileX, SrcTileY;     ///< X and Y axis tiling factors
00041     eImageTransform     ImageTransform;         ///< Marmalade image transform
00042     bool                UVsDirty;               ///< Dirty when source texture has changed
00043 public:
00044     void        setImage(CzImage* image);
00045     CzImage*    getImage()                                          { return Material->Image; }
00046     void        setColour(const CzColour& colour, bool use_parent = false);
00047     void        setColour(int index, const CzColour& colour);
00048     void        setSrcDest(int x, int y, int width, int height);
00049     void        setSrcRect(int x, int y, int width, int height);
00050     void        setSrcTile(float x, float y);
00051     void        setSrcTiled(bool tiled);
00052     void        setSrcRect(CzIRect* src);
00053     CzIRect     getSrcRect() const                                  { return CzIRect(SrcX, SrcY, SrcWidth, SrcHeight); }
00054     int         getSrcWidth() const                                 { return SrcWidth; }
00055     int         getSrcHeight() const                                { return SrcHeight; }
00056     CzVec2      getSrcTile() const                                  { return CzVec2(SrcTileX, SrcTileY); }
00057     bool        getSrcTiled() const                                 { return Material->Tiled; }
00058     void        setFromBrush(CzBrushImage* brush);
00059     void        setImageTransform(eImageTransform transform)        { ImageTransform = transform; }
00060     eImageTransform getImageTransform() const                       { return ImageTransform; }
00061     CzVec2* getUVList()                                             { return Prim->UVs; }
00062     void        setUVList(CzVec2* uvs, int num_uvs);                    // Replaces the entire UV list (Note that the sprite will take over management of the UV List)
00063     void        setUVList(CzVec2* uvs, int offset, int num_uvs);        // Modifies UV's in an existing UV list
00064     void        setUV(CzVec2* uv, int offset);                          // Modifies single UV's in an existing UV list
00065     void        setGeometry(CzGeometry* geom);
00066 
00067     // Properties End
00068 
00069 protected:
00070     void                RebuildUVList();
00071 
00072 public:
00073 
00074     CzBitmapSprite() : CzSprite(), SrcX(0), SrcY(0), SrcWidth(0), SrcHeight(0), SrcTileX(1.0f), SrcTileY(1.0f), ImageTransform(ImageTransform_None) { setSpriteType(ST_Image); }
00075     virtual ~CzBitmapSprite()
00076     {
00077     }
00078 
00079     void    Init(int vertex_count = 4);
00080     
00081     void    Draw();
00082 };
00083 
00084 
00085 
00086 
00087 
00088 #endif // _CCZ_BITMAP_SPRITE_H_