AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
An image based game actor that can display a bitmap or portion of a bitmap. More...
#include <CzActorImage.h>
Public Member Functions | |
bool | setProperty (unsigned int property_name, const CzXomlProperty &data, bool delta) |
Sets the named property of the ActorImage. | |
bool | setProperty (unsigned int property_name, const CzString &data, bool delta) |
Sets the named property of the actor. | |
bool | getProperty (unsigned int property_name, CzXomlProperty &prop) |
Gets the named property of the actor. | |
CzActorImage () | |
virtual | ~CzActorImage () |
virtual bool | Init (IzBrush *brush, int width, int height) |
Initialise the bitmap based actor from a brush. | |
virtual bool | Init (CzImage *image, int width, int height) |
virtual bool | Init (CzImage *image, CzIRect *src_rect) |
Initialise the bitmap based actor from an image and a source rectangle. | |
virtual bool | Init (CzImage *image, int x, int y, int w, int h) |
Initialise the bitmap based actor from an image and a source rectangle. | |
bool | UpdateVisual () |
Updates the actors visual. | |
void | SetSrcDest (int x, int y, int w, int h) |
Sets bitmap source rectangle and visual size. | |
void | SetSrcRect (int x, int y, int w, int h) |
Sets bitmap source rectangle. | |
void | SetDestSize (int w, int h) |
Sets actors visual size. | |
virtual void | SetImage (CzImage *image) |
Sets the image associated with the actors visual. | |
virtual void | SetFromBrush (IzBrush *brush, bool resize=true) |
Sets the actirs brush. | |
CzGeometry * | getGeometry () |
void | setGeometry (CzGeometry *geom) |
Assigns a new geometry to the actor. | |
virtual void | NotifyOrientationChange (CzScene::eOrientation old_orientation, CzScene::eOrientation new_orientation) |
Handles the orientation change event. | |
int | LoadFromXoml (IzXomlResource *parent, bool load_children, CzXmlNode *node) |
Creates an instance of this class from XML. | |
bool | UpdateFromAnimation (CzAnimInstance *animation) |
Updates actor property from supplied animation. | |
Static Public Member Functions | |
static void | InitClass () |
Initialises the class. | |
static void | ReleaseClass () |
static bool | _setSize (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getSize (IzXomlResource *target) |
static bool | _setSrcRect (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getSrcRect (IzXomlResource *target) |
static bool | _setSrcTiling (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getSrcTiling (IzXomlResource *target) |
static bool | _setSrcTiled (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getSrcTiled (IzXomlResource *target) |
static bool | _setImage (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getImage (IzXomlResource *target) |
static bool | _setBrush (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getBrush (IzXomlResource *target) |
static bool | _setFlipX (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getFlipX (IzXomlResource *target) |
static bool | _setFlipY (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getFlipY (IzXomlResource *target) |
static bool | _setSkew (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getSkew (IzXomlResource *target) |
static bool | _setBeforeChildren (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getBeforeChildren (IzXomlResource *target) |
static bool | _setFilter (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getFilter (IzXomlResource *target) |
static bool | _setAspectLock (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getAspectLock (IzXomlResource *target) |
static bool | _setAlphaMode (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getAlphaMode (IzXomlResource *target) |
static bool | _setGeometry (IzXomlResource *target, const CzXomlProperty &prop, bool add) |
static CzXomlProperty | _getGeometry (IzXomlResource *target) |
Protected Member Functions | |
bool | InitWithImage (CzImage *image, int width, int height) |
Initialise the bitmap based actor from a brush. | |
bool | InitWithBrush (IzBrush *brush, int width, int height) |
Initialise the bitmap based actor from a brush. | |
bool | UpdateBinding (unsigned int property_name, CzXomlVariable *var) |
Updates an actor property from the supplied XOML variable. | |
void | UpdateAspect () |
Updates the aspect of this actor. | |
Protected Attributes | |
CzGeometry * | Geometry |
Visual geometry. | |
CzIVec2 | OldSrcSize |
Static Protected Attributes | |
static CzXomlClassDef * | ActorImageClassDef = NULL |
An image based game actor that can display a bitmap or portion of a bitmap.
Image actors or actors derived from them form the backbone of most of the games and apps developed with XOML. An image actor is an actor that represents itself on screen using an image or portion of an image. All of the user interface actors are derived from an image actor. Image actors have the following specific properties:
An image actor requires an Image or a Brush to be defined Because an image actor inherits from a basic actor, it inherits all of the basic actors properties as well as those properties shown above. Lets take a look at an image actor definition:
<ActorImage Brush=”Brush1” Position="10, 20" Size="-100, -100" />
<ActorImage Image=”Image1” SrcRect="0, 0, 64, 64" Position="10, 20" Size="-100, -100" />
Note that it is usually much more convenient and better practice to define and use brushes instead of using image and bitmap source ractangles (the area opf the bitmap that will be drawn onto the actor) as they can be re-used and easily modified later.
CzActorImage::CzActorImage | ( | ) | [inline] |
virtual CzActorImage::~CzActorImage | ( | ) | [inline, virtual] |
CzXomlProperty CzActorImage::_getAlphaMode | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getAspectLock | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getBeforeChildren | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getBrush | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getFilter | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getFlipX | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getFlipY | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getGeometry | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getImage | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getSize | ( | IzXomlResource * | target | ) | [static] |
Reimplemented in CzUIBase.
CzXomlProperty CzActorImage::_getSkew | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getSrcRect | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getSrcTiled | ( | IzXomlResource * | target | ) | [static] |
CzXomlProperty CzActorImage::_getSrcTiling | ( | IzXomlResource * | target | ) | [static] |
bool CzActorImage::_setAlphaMode | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setAspectLock | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setBeforeChildren | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setBrush | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setFilter | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setFlipX | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setFlipY | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setGeometry | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setImage | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setSize | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
Reimplemented in CzUIBase.
bool CzActorImage::_setSkew | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setSrcRect | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setSrcTiled | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
bool CzActorImage::_setSrcTiling | ( | IzXomlResource * | target, |
const CzXomlProperty & | prop, | ||
bool | add | ||
) | [static] |
CzGeometry* CzActorImage::getGeometry | ( | ) | [inline] |
bool CzActorImage::getProperty | ( | unsigned int | property_name, |
CzXomlProperty & | prop | ||
) | [virtual] |
Gets the named property of the actor.
Returns the named property of the actor. The properties value is returned in a CzXomlProperty which is a structure that contains a union of all possible property types. Note that as CzActorImage is derived from CzActor, all CzActor properties will also be checked against.
property_name | Name of the property. | |
[out] | prop | The property data that. |
Reimplemented from CzActor.
Reimplemented in CzUITabBar, CzUIBase, CzUIGrid, CzUIListBox, CzActorConnector, CzUIImageView, CzUISlider, CzUILabel, CzUITextView, CzUIWebView, CzUITab, CzUITextBox, CzUIVideoOverlay, CzUIStackPanel, and CzUIWrapPanel.
bool CzActorImage::Init | ( | IzBrush * | brush, |
int | width, | ||
int | height | ||
) | [virtual] |
Initialise the bitmap based actor from a brush.
Initialises the bitmap actor from a brush, width and height. The image and image's source rectangle will be taken from the brush. Note that this method will create a CzBitmapSprite visual and add it to the scenes sprite manager if the brush type is of IzBrush::BT_Image. If the brush type is IzBrush::BT_9Patch then a CzBitmapSprite9 sprite will be created instead.
[in] | brush | If non-null, the brush. |
width | The width. | |
height | The height. |
Reimplemented in CzUIBase.
bool CzActorImage::Init | ( | CzImage * | image, |
int | width, | ||
int | height | ||
) | [virtual] |
bool CzActorImage::Init | ( | CzImage * | image, |
CzIRect * | src_rect | ||
) | [virtual] |
Initialise the bitmap based actor from an image and a source rectangle.
Initialises the bitmap actor from an image and a source rectangle. The actors visual size will be calculated from the width and height of the source rectangle. Note that this method will create a CzBitmapSprite visual and add it to the scenes sprite manager.
[in] | image | If non-null, the image. |
[in] | src_rect | The width. |
bool CzActorImage::Init | ( | CzImage * | image, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) | [virtual] |
Initialise the bitmap based actor from an image and a source rectangle.
Initialises the bitmap actor from an image and a source rectangle. The actors visual size will be calculated from the width and height of the source rectangle. Note that this method will create a CzBitmapSprite visual and add it to the scenes sprite manager.
[in,out] | image | If non-null, the image. |
x | The x coordinate. | |
y | The y coordinate. | |
w | The width. | |
h | The height. |
void CzActorImage::InitClass | ( | ) | [static] |
Initialises the class.
Sets up the classes avaiiable properties. Used by the XOML system to find, set amd get class properties.
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUITabBar, CzUIGrid, CzUIListBox, CzUIWebView, CzActorConnector, CzUIImageView, CzUISlider, CzUITextView, CzUILabel, CzUITab, CzUIVideoOverlay, CzUITextBox, CzUIStackPanel, and CzUIWrapPanel.
bool CzActorImage::InitWithBrush | ( | IzBrush * | brush, |
int | width, | ||
int | height | ||
) | [protected] |
Initialise the bitmap based actor from a brush.
Initialises the bitmap actor from a brush, width and height. The image and image's source rectangle will be taken from the brush. Note that this method will create a CzBitmapSprite visual and add it to the scenes sprite manager if the brush type is of IzBrush::BT_Image. If the brush type is IzBrush::BT_9Patch then a CzBitmapSprite9 sprite will be created instead.
[in] | brush | If non-null, the brush. |
width | The width. | |
height | The height. |
bool CzActorImage::InitWithImage | ( | CzImage * | image, |
int | width, | ||
int | height | ||
) | [protected] |
Initialise the bitmap based actor from a brush.
Initialises the bitmap actor from an image, width and height. Note that this method will create a CzBitmapSprite visual and add it to the scenes sprite manager
[in,out] | image | If non-null, the image. |
width | The display width of the actor. | |
height | The display height of the actor. |
int CzActorImage::LoadFromXoml | ( | IzXomlResource * | parent, |
bool | load_children, | ||
CzXmlNode * | node | ||
) | [virtual] |
Creates an instance of this class from XML.
LoadFromXoml is the main method used by all classes that can be instantiated from XOML mark-up. This method creates an instance of this class from the supplied XML node structure specified by node. if parent is not NULL then the created instance will utilise the supplied parent to determine where it should live within the app. For example, if the parent is a scene then the actor will be placed in that scene. if the parent is another actor then this actor will be placed into the scene of the supplied actor and linked as a child to the parent actor. If load_chlldren is true then any child nodes contained within the actor will also be loaded. Note that as CzActorImage is derived from CzActor, CzActor::LoadFromXoml() will also be called to load CzActor specific properties.
[in] | parent | If non-null, the parent. |
load_children | true to load child nodes. | |
[in] | node | If non-null, the XOML markup node that defines this object |
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUITabBar, CzUIGrid, CzUIListBox, CzUITabs, CzUIWebView, CzActorConnector, CzUIImageView, CzUISlider, CzUITextView, CzUILabel, CzUITab, CzUITextBox, CzUIVideoOverlay, CzUIStackPanel, CzUIWrapPanel, and CzUICanvas.
void CzActorImage::NotifyOrientationChange | ( | CzScene::eOrientation | old_orientation, |
CzScene::eOrientation | new_orientation | ||
) | [virtual] |
Handles the orientation change event.
When a screen orientation or size change occurs all actors will receive this event emabling them to modify themselves to take advantage of the new screen orientation / size. the default implementation for CzActorImage updates margin and visual sizes if they are precentage based. It also calls CzActor::NotifyOrientationChange() to update the position.
old_orientation | The old orientation. |
new_orientation | The new orientation. |
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUIGrid, CzUIWebView, CzUISlider, and CzUITab.
void CzActorImage::ReleaseClass | ( | ) | [static] |
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUITabBar, CzUIGrid, CzUIListBox, CzUIWebView, CzActorConnector, CzUIImageView, CzUISlider, CzUITextView, CzUILabel, CzUITab, CzUIVideoOverlay, CzUITextBox, CzUIStackPanel, and CzUIWrapPanel.
void CzActorImage::SetDestSize | ( | int | w, |
int | h | ||
) |
Sets actors visual size.
Sets the actor visual size in scene units.
w | The width in scene units. |
h | The height in scene units. |
void CzActorImage::SetFromBrush | ( | IzBrush * | brush, |
bool | resize = true |
||
) | [virtual] |
Sets the actirs brush.
Sets the actors brush from the supplied brush. If resie is true then the actors visual size will be resized to the size of the new brush.
[in] | brush | If non-null, the brush. |
resize | true to resize. |
Reimplemented in CzUILabel.
void CzActorImage::setGeometry | ( | CzGeometry * | geom | ) |
Assigns a new geometry to the actor.
[in] | geom | If non-null, the geometry. |
void CzActorImage::SetImage | ( | CzImage * | image | ) | [virtual] |
Sets the image associated with the actors visual.
Sets the image associated with the actors visual. if no visual is attached to this actor then a CzBitmapSprite is created and attached.
[in] | image | If non-null, the image. |
bool CzActorImage::setProperty | ( | unsigned int | property_name, |
const CzXomlProperty & | data, | ||
bool | delta | ||
) | [virtual] |
Sets the named property of the ActorImage.
Sets the named property of this ActorImage. The properties value supplied will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced.
property_name | Name of the property as a string hash (faster searching). | |
[in] | data | The property data. |
delta | true if property should be added to instead of replaced. |
Reimplemented from CzActor.
Reimplemented in CzUITabBar, CzUIBase, CzUIGrid, CzUIListBox, CzActorConnector, CzUIImageView, CzUISlider, CzUILabel, CzUITextView, CzUIWebView, CzUITab, CzUITextBox, CzUIVideoOverlay, CzUIStackPanel, and CzUIWrapPanel.
bool CzActorImage::setProperty | ( | unsigned int | property_name, |
const CzString & | data, | ||
bool | delta | ||
) | [virtual] |
Sets the named property of the actor.
Sets the named property of this actor. The properties value (data) is supplied as a string and will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced. Note that as CzActorImage is derived from CzActor, all CzActor properties will also be checked against.
property_name | Name of the property as a string hash (faster searching). | |
[in] | data | The property data. |
delta | true to property should be added to instead of replaced. |
Sets the named property of this actor. The properties value (data) is supplied as a string and will be converted. If delta is set to true then the existing value of the property will be added to instead of replaced. Note that as CzActorText is derived from CzActor, all CzActor properties will also be checked against.
property_name | Name of the property as a string hash (faster searching). | |
[in] | data | The property data. |
delta | true to property should be added to instead of replaced. |
Reimplemented from CzActor.
Reimplemented in CzUITabBar, CzUIBase, CzUIGrid, CzUIListBox, CzActorConnector, CzUIImageView, CzUISlider, CzUILabel, CzUITextView, CzUIWebView, CzUITab, CzUITextBox, CzUIVideoOverlay, CzUIStackPanel, and CzUIWrapPanel.
void CzActorImage::SetSrcDest | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Sets bitmap source rectangle and visual size.
Changes the source rectangle of the visual and changes its size to w, h.
x | The x coordinate. |
y | The y coordinate. |
w | The width. |
h | The height. |
void CzActorImage::SetSrcRect | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Sets bitmap source rectangle.
Changes the source rectangle of the visual.
x | The x coordinate. |
y | The y coordinate. |
w | The width. |
h | The height. |
void CzActorImage::UpdateAspect | ( | ) | [protected] |
Updates the aspect of this actor.
if this actor has been marked so that it locks its aspect ratio to the x or y axix then this utility method will calculate the final size of the actor based on the aspect ratio of the bitmap that is attached to this actors visual. Note that this method is automatically called by the actors Update() method.
bool CzActorImage::UpdateBinding | ( | unsigned int | property_name, |
CzXomlVariable * | var | ||
) | [protected, virtual] |
Updates an actor property from the supplied XOML variable.
Updates a single property from the value of the bound XOML variable. Note that as CzActorImage is derived from CzActor, all CzActor properties will also be checked against.
property_name | Name of the property. | |
[in,out] | var | If non-null, the variable. |
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUITabBar, CzUIGrid, CzUIListBox, CzActorConnector, CzUIImageView, CzUITextView, CzUISlider, CzUILabel, CzUIWebView, CzUITab, CzUITextBox, CzUIVideoOverlay, CzUIStackPanel, and CzUIWrapPanel.
bool CzActorImage::UpdateFromAnimation | ( | CzAnimInstance * | animation | ) | [virtual] |
Updates actor property from supplied animation.
Updates the actors property that is specified by the supplied animation. When a timeline animation targets the property of an actor this method will be called by the animation to move the animations frame data into its target property. Note that as CzActorImage is derived from CzActor, all CzActor properties will also be checked against.
[in] | animation | If non-null, the animation. |
Reimplemented from CzActor.
Reimplemented in CzUIBase, CzUITabBar, CzUIGrid, CzUIListBox, CzUIWebView, CzActorConnector, CzUIImageView, CzUISlider, CzUITextView, CzUILabel, CzUITab, CzUITextBox, CzUIStackPanel, CzUIVideoOverlay, and CzUIWrapPanel.
bool CzActorImage::UpdateVisual | ( | ) | [virtual] |
Updates the actors visual.
Transfers visual data from the actor to the visual such as position, angle, scale, colour etc..
Reimplemented from CzActor.
Reimplemented in CzUIWebView, CzUIImageView, and CzUITextView.
CzXomlClassDef * CzActorImage::ActorImageClassDef = NULL [static, protected] |
CzGeometry* CzActorImage::Geometry [protected] |
Visual geometry.
CzIVec2 CzActorImage::OldSrcSize [protected] |