Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
NinePatchImageParser Class Reference

A class for paring Android .9 patch image. More...

Public Member Functions

 NinePatchImageParser ()
 Default constructor.
 
 NinePatchImageParser (Image *image)
 Instantiate a NinePatchImageParser with a Image object. More...
 
 NinePatchImageParser (Image *image, const Rect &frameRect, bool ratated)
 Instantiate a NinePatchImageParser with a Image object and the spriteFrame info. More...
 
void setSpriteFrameInfo (Image *image, const Rect &frameRect, bool rotated)
 Change the sprite frame info. More...
 
virtual ~NinePatchImageParser ()
 Default destructor.
 
Rect parseCapInset () const
 Parsing the image data and extract the capInsets info. More...
 

Static Public Member Functions

static bool isNinePatchImage (const std::string &filename)
 Determines whether a filename contains ".9.png" suffix. More...
 

Detailed Description

A class for paring Android .9 patch image.

For more about Android .9 patch image format, please refer to http://developer.android.com/tools/help/draw9patch.html

The class could parse a single .9 patch image and produce the capInsets as well as a sprite atlas and store all the capInsets infos in a Texture2D. Note:

  • Currently only PixelFormat::RGBA8888 is supported.
  • TexturePacker Trim mode is not supported at the moment.

Constructor & Destructor Documentation

NinePatchImageParser ( Image *  image)
explicit

Instantiate a NinePatchImageParser with a Image object.

A Image object pointer.

A NinePatchImageParser instance.

var NinePatchImageParser ( var  image)
explicit

Instantiate a NinePatchImageParser with a Image object.

A Image object pointer.

A NinePatchImageParser instance.

local NinePatchImageParser ( local  image)
explicit

Instantiate a NinePatchImageParser with a Image object.

A Image object pointer.

A NinePatchImageParser instance.

NinePatchImageParser ( Image *  image,
const Rect frameRect,
bool  ratated 
)

Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.

The spriteFrame contains the frame rect in the image atlas and whether it is rotated or not.

A Image object pointer. The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas. Been is Sprite frame is rotated in the image atlas.

var NinePatchImageParser ( var  image,
var  frameRect,
var  ratated 
)

Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.

The spriteFrame contains the frame rect in the image atlas and whether it is rotated or not.

A Image object pointer. The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas. Been is Sprite frame is rotated in the image atlas.

local NinePatchImageParser ( local  image,
local  frameRect,
local  ratated 
)

Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.

The spriteFrame contains the frame rect in the image atlas and whether it is rotated or not.

A Image object pointer. The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas. Been is Sprite frame is rotated in the image atlas.

Member Function Documentation

static bool isNinePatchImage ( const std::string &  filename)
static

Determines whether a filename contains ".9.png" suffix.

A 9-patch image name. If the filename contains ".9.png", then return true, otherwise false.

var isNinePatchImage ( var  filename)
static

Determines whether a filename contains ".9.png" suffix.

A 9-patch image name. If the filename contains ".9.png", then return true, otherwise false.

local isNinePatchImage ( local  filename)
static

Determines whether a filename contains ".9.png" suffix.

A 9-patch image name. If the filename contains ".9.png", then return true, otherwise false.

void setSpriteFrameInfo ( Image *  image,
const Rect frameRect,
bool  rotated 
)

Change the sprite frame info.

It is useful when parsing multiple sprite frame with only on NinePatchImageParser.

The Image object The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas.

var setSpriteFrameInfo ( var  image,
var  frameRect,
var  rotated 
)

Change the sprite frame info.

It is useful when parsing multiple sprite frame with only on NinePatchImageParser.

The Image object The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas.

local setSpriteFrameInfo ( local  image,
local  frameRect,
local  rotated 
)

Change the sprite frame info.

It is useful when parsing multiple sprite frame with only on NinePatchImageParser.

The Image object The sprite frame rect in the image atlas. Whether is sprite frame is rotated in the image atlas.

Rect parseCapInset ( ) const

Parsing the image data and extract the capInsets info.

The capInsets Rect.

var parseCapInset ( )

Parsing the image data and extract the capInsets info.

The capInsets Rect.

local parseCapInset ( )

Parsing the image data and extract the capInsets info.

The capInsets Rect.


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