cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cocos2d::utils Namespace Reference

Functions

void CC_DLL  (const std::function< void(bool, const std::string &)> &afterCaptured, const std::string &filename)
 Capture the entire screen. More...
 
std::vector< Node * > CC_DLL  (const Node &node, const std::string &name)
 Find children by name, it will return all child that has the same name. More...
 
double CC_DLL  (const char *str)
 Same to ::atof, but strip the string, remain 7 numbers after '. More...
 
double CC_DLL  ()
 Get current exact time, accurate to nanoseconds. More...
 
Rect CC_DLL  (Node *node)
 Calculate unionof bounding box of a node and its children. More...
 
var  ( var node)
 Calculate unionof bounding box of a node and its children. More...
 
local  ( local node)
 Calculate unionof bounding box of a node and its children. More...
 

Function Documentation

void CC_DLL
cocos2d::utils::captureScreen
( const std::function< void(bool, const std::string &)> &  afterCaptured,
const std::string &  filename 
)

Capture the entire screen.

To ensure the snapshot is applied after everything is updated and rendered in the current frame, we need to wrap the operation with a custom command which is then inserted into the tail of the render queue.

Parameters
afterCapturedspecify the callback function which will be invoked after the snapshot is done.
filenamespecify a filename where the snapshot is stored. This parameter can be either an absolute path or a simple base filename ("hello.png" etc.), don't use a relative path containing directory names.("mydir/hello.png" etc.).
Since
v3.2
var captureScreen ( var  afterCaptured,
var  filename 
)

Capture the entire screen.

To ensure the snapshot is applied after everything is updated and rendered in the current frame, we need to wrap the operation with a custom command which is then inserted into the tail of the render queue.

Parameters
afterCapturedspecify the callback function which will be invoked after the snapshot is done.
filenamespecify a filename where the snapshot is stored. This parameter can be either an absolute path or a simple base filename ("hello.png" etc.), don't use a relative path containing directory names.("mydir/hello.png" etc.).
Since
v3.2
local captureScreen ( local  afterCaptured,
local  filename 
)

Capture the entire screen.

To ensure the snapshot is applied after everything is updated and rendered in the current frame, we need to wrap the operation with a custom command which is then inserted into the tail of the render queue.

Parameters
afterCapturedspecify the callback function which will be invoked after the snapshot is done.
filenamespecify a filename where the snapshot is stored. This parameter can be either an absolute path or a simple base filename ("hello.png" etc.), don't use a relative path containing directory names.("mydir/hello.png" etc.).
Since
v3.2
std::vector<Node*> CC_DLL
cocos2d::utils::findChildren
( const Node &  node,
const std::string &  name 
)

Find children by name, it will return all child that has the same name.

It supports c++ 11 regular expression. It is a helper function of Node::enumerateChildren(). You can refer to Node::enumerateChildren() for detail information.

Parameters
nodeThe node to find
nameThe name to search for, it supports c++ 11 expression
Returns
Array of Nodes that matches the name
Since
v3.2
var findChildren ( var  node,
var  name 
)

Find children by name, it will return all child that has the same name.

It supports c++ 11 regular expression. It is a helper function of Node::enumerateChildren(). You can refer to Node::enumerateChildren() for detail information.

Parameters
nodeThe node to find
nameThe name to search for, it supports c++ 11 expression
Returns
Array of Nodes that matches the name
Since
v3.2
local findChildren ( local  node,
local  name 
)

Find children by name, it will return all child that has the same name.

It supports c++ 11 regular expression. It is a helper function of Node::enumerateChildren(). You can refer to Node::enumerateChildren() for detail information.

Parameters
nodeThe node to find
nameThe name to search for, it supports c++ 11 expression
Returns
Array of Nodes that matches the name
Since
v3.2
double CC_DLL cocos2d::utils::atof ( const char *  str)

Same to ::atof, but strip the string, remain 7 numbers after '.

' before call atof. Why we need this? Because in android c++_static, atof ( and std::atof ) is unsupported for numbers have long decimal part and contain several numbers can approximate to 1 ( like 90.099998474121094 ), it will return inf. This function is used to fix this bug.

Parameters
strThe string be to converted to double.
Returns
Returns converted value of a string.
var atof ( var  str)

Same to ::atof, but strip the string, remain 7 numbers after '.

' before call atof. Why we need this? Because in android c++_static, atof ( and std::atof ) is unsupported for numbers have long decimal part and contain several numbers can approximate to 1 ( like 90.099998474121094 ), it will return inf. This function is used to fix this bug.

Parameters
strThe string be to converted to double.
Returns
Returns converted value of a string.
local atof ( local  str)

Same to ::atof, but strip the string, remain 7 numbers after '.

' before call atof. Why we need this? Because in android c++_static, atof ( and std::atof ) is unsupported for numbers have long decimal part and contain several numbers can approximate to 1 ( like 90.099998474121094 ), it will return inf. This function is used to fix this bug.

Parameters
strThe string be to converted to double.
Returns
Returns converted value of a string.
double CC_DLL
cocos2d::utils::gettime
( )

Get current exact time, accurate to nanoseconds.

Returns
Returns the time in seconds since the Epoch.
var gettime ( )

Get current exact time, accurate to nanoseconds.

Returns
Returns the time in seconds since the Epoch.
local gettime ( )

Get current exact time, accurate to nanoseconds.

Returns
Returns the time in seconds since the Epoch.
Rect CC_DLL
cocos2d::utils::getCascadeBoundingBox
( Node *  node)

Calculate unionof bounding box of a node and its children.

Returns
Returns unionof bounding box of a node and its children.
var getCascadeBoundingBox ( var  node)

Calculate unionof bounding box of a node and its children.

Returns
Returns unionof bounding box of a node and its children.
local getCascadeBoundingBox ( local  node)

Calculate unionof bounding box of a node and its children.

Returns
Returns unionof bounding box of a node and its children.