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
CzActorImage Class Reference

An image based game actor that can display a bitmap or portion of a bitmap. More...

#include <CzActorImage.h>

Inheritance diagram for CzActorImage:
CzActor IzXomlResource IzAnimTarget CzActorConnector CzUIBase CzUIBigImage CzUINavBar CzUIPicker CzUIStepper CzUIToolBar CzUIGrid CzUIIcon CzUIImageView CzUILabel CzUIListBox CzUIPanel CzUISlider CzUIVideoOverlay CzUIWebView

List of all members.

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.
CzGeometrygetGeometry ()
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

CzGeometryGeometry
 Visual geometry.
CzIVec2 OldSrcSize

Static Protected Attributes

static CzXomlClassDefActorImageClassDef = NULL

Detailed Description

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:

  • Brush (brush) - Specifies a brush that is used to define the image and source rectangle
  • Image (image) - The image that is to be used as the actors visual (deprecated, use brushes instead, with exception to particle actors)
  • Size (x, y) - The world size of the actor
  • SrcRect (x, y, width, height) - The position and source of the source rectangle in the image atlas (x, y, w, h rect). Used for panning the portion of a sprite atlas shown allowing frame based animation. (deprecated, use brushes instead, with exception to particle actors)
  • Tiling (x, y) - Sets the UV tiling factor for this actor (default is 1,1), if tiling factor is > 1.0 on either axis then Tiled will automatically be set to true
  • Tiled (x, y) - Informs the system that this actor should be rendered with tiling enabled
  • FlipX (boolean) - If true then this actor is horizontally flipped
  • FlipY (boolean) - If true then this actor is vertically flipped
  • Skew (top, bottom, left, right) - Four parameter skewing, which allows the actor to be skewed in four different directions
  • BeforeChildren (boolean) - When set to true this actor will be rendered before its children, otherwise it will be rendered afterwards (default is true)
  • Filter (boolean) - When set to true this actor will rendered using filtering (default is true)
  • AlphaMode (alpha_mode) - Sets the mode to use when mixing transparency (alpha) from the image. AlphaMode can be one of none, half, add, sub and blend (default mode is blend)
  • AspectLock (lock_mode) - Locks the aspect ratio of the actor to fit to the screens aspect ratio lock_mode can be one of x, y or none (default is none) Notes:
  • Anchor (topleft or centre) - Sets the draw anchor (topleft causes the actor to be displayed relative to its top-left cornr whilst centre will use the actors centre)

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:

XOML Example using brushes:
 <ActorImage Brush=”Brush1” Position="10, 20" Size="-100, -100" />
XOML Example using image and src rectangle:
 <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.


Constructor & Destructor Documentation

virtual CzActorImage::~CzActorImage ( ) [inline, virtual]

Member Function Documentation

Reimplemented in CzUIBase.

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]
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.

Parameters:
property_nameName of the property.
[out]propThe property data that.
Returns:
true if it succeeds, false if property does not exist.

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.

Parameters:
[in]brushIf non-null, the brush.
widthThe width.
heightThe height.
Returns:
true if it succeeds, false if it fails.

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.

Parameters:
[in]imageIf non-null, the image.
[in]src_rectThe width.
Returns:
true if it succeeds, false if it fails.

param height The height.

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.

Parameters:
[in,out]imageIf non-null, the image.
xThe x coordinate.
yThe y coordinate.
wThe width.
hThe height.
Returns:
true if it succeeds, false if it fails.
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.

Parameters:
[in]brushIf non-null, the brush.
widthThe width.
heightThe height.
Returns:
true if it succeeds, false if it fails.
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

Parameters:
[in,out]imageIf non-null, the image.
widthThe display width of the actor.
heightThe display height of the actor.
Returns:
true if it succeeds, false if it fails.
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.

Parameters:
[in]parentIf non-null, the parent.
load_childrentrue to load child nodes.
[in]nodeIf non-null, the XOML markup node that defines this object
Returns:
negative value for error. if 0 then processing of further XOML will stop.

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.

Parameters:
old_orientationThe old orientation.
new_orientationThe new orientation.

Reimplemented from CzActor.

Reimplemented in CzUIBase, CzUIGrid, CzUIWebView, CzUISlider, and CzUITab.

void CzActorImage::SetDestSize ( int  w,
int  h 
)

Sets actors visual size.

Sets the actor visual size in scene units.

Parameters:
wThe width in scene units.
hThe 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.

Parameters:
[in]brushIf non-null, the brush.
resizetrue to resize.

Reimplemented in CzUILabel.

Assigns a new geometry to the actor.

Parameters:
[in]geomIf 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.

Parameters:
[in]imageIf 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.

Parameters:
property_nameName of the property as a string hash (faster searching).
[in]dataThe property data.
deltatrue if property should be added to instead of replaced.
Returns:
true if it succeeds, false if property does not exist.

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.

Parameters:
property_nameName of the property as a string hash (faster searching).
[in]dataThe property data.
deltatrue to property should be added to instead of replaced.
Returns:
true if it succeeds, false if property does not exist.

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.

Parameters:
property_nameName of the property as a string hash (faster searching).
[in]dataThe property data.
deltatrue to property should be added to instead of replaced.
Returns:
true if it succeeds, false if property does not exist.

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.

Parameters:
xThe x coordinate.
yThe y coordinate.
wThe width.
hThe height.
void CzActorImage::SetSrcRect ( int  x,
int  y,
int  w,
int  h 
)

Sets bitmap source rectangle.

Changes the source rectangle of the visual.

Parameters:
xThe x coordinate.
yThe y coordinate.
wThe width.
hThe 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.

Parameters:
property_nameName of the property.
[in,out]varIf non-null, the variable.
Returns:
true if it succeeds, false if property does not exist.

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.

Parameters:
[in]animationIf non-null, the animation.
Returns:
true if it succeeds, false if property does not exist.

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..

Returns:
true if it succeeds, false if it fails.

Reimplemented from CzActor.

Reimplemented in CzUIWebView, CzUIImageView, and CzUITextView.


Member Data Documentation

Visual geometry.


The documentation for this class was generated from the following files: