cocos2d-x 3.0
- 首页 - 相关页面 - 模块 - 命名空间 - - 文件 -
宏定义 - 图1 宏定义 - 图2)
- 文件列表 - 文件成员

全部)) 命名空间) 文件) 函数) 变量) 类型定义) 枚举) 枚举值) 属性) 友元) 宏定义)))

宏定义

ccMacros.h 文件参考

#include "base/CCConsole.h"

#include "CCStdC.h"

#include "base/ccConfig.h"

## 宏定义
#define _USE_MATH_DEFINES
#define CCASSERT(cond, msg)
#define GP_ASSERT(cond) CCASSERT(cond, "")
#define CCAssert CCASSERT
#define CC_SWAP(x, y, type)
简单的宏 交换 2 变量 更多…
#define CCRANDOM_MINUS1_1() ((2.0f((float)rand()/RANDMAX))-1.0f)
返回-1和1之间的浮点型随机数 更多…
#define CCRANDOM_0_1() ((float)rand()/RANDMAX)
返回0和1之间的浮点型随机数 更多…
#define CC_DEGREES_TO_RADIANS(ANGLE) ((__ANGLE) 0.01745329252f)
将度转换为弧度 更多…
#define CC_RADIANS_TO_DEGREES(ANGLE) ((ANGLE) 57.29577951f)
将弧度转换为度 更多…
#define kRepeatForever (UINTMAX -1)
#define CC_BLEND_SRC GLONE
默认 gl 混合资源函数. 更多…
#define CC_BLEND_DST GLONEMINUSSRCALPHA
#define CC_NODE_DRAW_SETUP()
有用的宏用于建立GL 服务状态,正确的GL编程和设置模型食堂投影矩阵 更多…
#define CC_DIRECTOR_END()
停止和从内存移除director 更多…
#define CC_CONTENT_SCALE_FACTOR() Director::getInstance()->getContentScaleFactor()
在Mac上返回 1; 在iPhone上返回2表示Retina屏. 更多…
#define CC_RECT_PIXELS_TO_POINTS(rect_in_pixels)
RETINA DISPLAY ENABLED. 更多…
#define CC_RECT_POINTS_TO_PIXELS(rect_in_points_points)
转换一个矩形点到矩形像素 更多…
#define CC_POINT_PIXELS_TO_POINTS(pixels) Vec2( (pixels).x / CC_CONTENT_SCALE_FACTOR(), (__pixels).y / CC_CONTENT_SCALE_FACTOR())
转换一个点像素到点 更多…
#define CC_POINT_POINTS_TO_PIXELS(__points) Vec2( (__points).x CC_CONTENT_SCALE_FACTOR(), (points).y CC_CONTENT_SCALE_FACTOR())
转换一个点到像素点 更多…
#define CC_SIZE_PIXELS_TO_POINTS(size_in_pixels) Size( (size_in_pixels).width / CC_CONTENT_SCALE_FACTOR(), (size_in_pixels).height / CC_CONTENT_SCALE_FACTOR())
#define CC_SIZE_POINTS_TO_PIXELS(size_in_points) Size( (size_in_points).width CC_CONTENT_SCALE_FACTOR(), (size_in_points).height CC_CONTENT_SCALE_FACTOR())
#define FLT_EPSILON 1.192092896e-07F
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
#define CC_HOST_IS_BIG_ENDIAN (bool)((unsigned short *)"\0\xff" < 0x100)
助手宏,用于转换4字节的小/大端整数到机器本地数字表示 更多…
#define CC_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define CC_SWAP16(i) ((i & 0x00ff) << 8 | (i &0xff00) >> 8)
#define CC_SWAP_INT32_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) )
#define CC_SWAP_INT16_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) )
#define CC_SWAP_INT32_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i) : CC_SWAP32(i) )
#define CC_SWAP_INT16_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i): CC_SWAP16(i) )
#define CC_PROFILER_DISPLAY_TIMERS() do {} while (0)
Profiling Macros. 更多…
#define CC_PROFILER_PURGE_ALL() do {} while (0)
#define CC_PROFILER_START(name) do {} while (0)
#define CC_PROFILER_STOP(name) do {} while (0)
#define CC_PROFILER_RESET(name) do {} while (0)
#define CC_PROFILER_START_CATEGORY(cat, name) do {} while(0)
#define CC_PROFILER_STOP_CATEGORY(cat, name) do {} while(0)
#define CC_PROFILER_RESET_CATEGORY(cat, name) do {} while(0)
#define CC_PROFILER_START_INSTANCE(id, name) do {} while(0)
#define CC_PROFILER_STOP_INSTANCE(id, name) do {} while(0)
#define CC_PROFILER_RESET_INSTANCE(id, name) do {} while(0)
#define CHECK_GL_ERROR_DEBUG()
#define CC_INCREMENT_GL_DRAWS(n) Director::getInstance()->getRenderer()->addDrawnBatches(n)
#define CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(drawcalls, vertices)
#define AnimationFrameDisplayedNotification "CCAnimationFrameDisplayedNotification"
Notifications. 更多…
#define CC_CALLBACK_0(selector, target,…) std::bind(&selector,target, ##VA_ARGS)
#define CC_CALLBACK_1(selector, target,…) std::bind(&selector,target, std::placeholders::1, ##VA_ARGS)
#define CC_CALLBACK_2(selector, target,…) std::bind(&selector,target, std::placeholders::1, std::placeholders::2, ##VA_ARGS)
#define CC_CALLBACK_3(selector, target,…) std::bind(&selector,_target, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, ##__VA_ARGS)

宏定义说明

#define _USE_MATH_DEFINES

#define AnimationFrameDisplayedNotification "CCAnimationFrameDisplayedNotification"

Notifications.

精灵帧显示的通知名字

#define CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA

#define CC_BLEND_SRC GL_ONE

默认 gl 混合资源函数.

兼容透明通道图像.

#define CCCALLBACK0 ( selector,
target,
) std::bind(&selector,target, ##__VA_ARGS)

#define CCCALLBACK1 ( selector,
target,
) std::bind(&selector,target, std::placeholders::_1, ##__VA_ARGS)

#define CCCALLBACK2 ( selector,
target,
) std::bind(&selector,target, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS)

#define CCCALLBACK3 ( selector,
target,
) std::bind(&selector,target, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, ##__VA_ARGS)

#define CC_CONTENT_SCALE_FACTOR ( ) Director::getInstance()->getContentScaleFactor()

在Mac上返回 1; 在iPhone上返回2表示Retina屏.

相反返回1

#define CCDEGREESTORADIANS ( _ANGLE) ((__ANGLE) * 0.01745329252f)

将度转换为弧度

#define CC_DIRECTOR_END ( )

值:

do { \

Director *__director = Director::getInstance(); \

__director->end(); \

} while(0)

停止和从内存移除director

  • 自从
  • v0.99.4

#define CC_HOST_IS_BIG_ENDIAN (bool)((unsigned short )"\0\xff" < 0x100)

助手宏,用于转换4字节的小/大端整数到机器本地数字表示

它应该和苹果的 CFSwapInt32LittleToHost(..)作用一样when define returns true it means that our architecture uses big endian

#define CCINCREMENTGLDRAWNBATCHES_AND_VERTICES ( __drawcalls,
__vertices
)

值:

do { \

auto renderer = Director::getInstance()->getRenderer(); \

renderer->addDrawnBatches(drawcalls); \

renderer->addDrawnVertices(vertices); \

} while(0)

#define CCINCREMENTGLDRAWS ( _n) Director::getInstance()->getRenderer()->addDrawnBatches(__n)

#define CC_NODE_DRAW_SETUP ( )

值:

do { \

CCASSERT(getGLProgram(), "No shader program set for this node"); \

{ \

getGLProgram()->use(); \

getGLProgram()->setUniformsForBuiltins(_modelViewTransform); \

} \

} while(0)

CCASSERT

define CCASSERT(cond, msg)

Definition: ccMacros.h:53

有用的宏用于建立GL 服务状态,正确的GL编程和设置模型食堂投影矩阵

  • 自从
  • v2.0

#define CCPOINTPIXELSTOPOINTS ( pixels) Vec2( (__pixels).x / CC_CONTENT_SCALE_FACTOR(), (__pixels).y / CC_CONTENT_SCALE_FACTOR())

转换一个点像素到点

转换点像素到点

#define CCPOINTPOINTSTOPIXELS ( points) Vec2( (__points).x * CC_CONTENT_SCALE_FACTOR(), (__points).y * CC_CONTENT_SCALE_FACTOR())

转换一个点到像素点

转换点到像素

#define CC_PROFILER_DISPLAY_TIMERS ( ) do {} while (0)

Profiling Macros.

#define CC_PROFILER_PURGE_ALL ( ) do {} while (0)

#define CCPROFILERRESET ( __name) do {} while (0)

#define CCPROFILERRESETCATEGORY ( _cat,
__name
) do {} while(0)

#define CCPROFILERRESETINSTANCE ( _id,
__name
) do {} while(0)

#define CCPROFILERSTART ( __name) do {} while (0)

#define CCPROFILERSTARTCATEGORY ( _cat,
__name
) do {} while(0)

#define CCPROFILERSTARTINSTANCE ( _id,
__name
) do {} while(0)

#define CCPROFILERSTOP ( __name) do {} while (0)

#define CCPROFILERSTOPCATEGORY ( _cat,
__name
) do {} while(0)

#define CCPROFILERSTOPINSTANCE ( _id,
__name
) do {} while(0)

#define CCRADIANSTODEGREES ( _ANGLE) ((__ANGLE) * 57.29577951f)

将弧度转换为度

#define CCRECTPIXELS_TO_POINTS ( __rect_in_pixels)

值:

Rect( (rect_in_pixels).origin.x / CC_CONTENT_SCALE_FACTOR(), (rect_in_pixels).origin.y / CC_CONTENT_SCALE_FACTOR(), \

(rect_in_pixels).size.width / CC_CONTENT_SCALE_FACTOR(), (rect_in_pixels).size.height / CC_CONTENT_SCALE_FACTOR() )

CC_CONTENT_SCALE_FACTOR

define CC_CONTENT_SCALE_FACTOR()

在Mac上返回 1; 在iPhone上返回2表示Retina屏.

Definition: ccMacros.h:130

RETINA DISPLAY ENABLED.

转换一个矩形像素到矩形点

#define CCRECTPOINTS_TO_PIXELS ( __rect_in_points_points)

值:

Rect( (rect_in_points_points).origin.x CC_CONTENT_SCALE_FACTOR(), (rect_in_points_points).origin.y CC_CONTENT_SCALE_FACTOR(), \

(rect_in_points_points).size.width CC_CONTENT_SCALE_FACTOR(), (rect_in_points_points).size.height CC_CONTENT_SCALE_FACTOR() )

CC_CONTENT_SCALE_FACTOR

define CC_CONTENT_SCALE_FACTOR()

在Mac上返回 1; 在iPhone上返回2表示Retina屏.

Definition: ccMacros.h:130

转换一个矩形点到矩形像素

#define CCSIZEPIXELSTOPOINTS ( size_in_pixels) Size( (__size_in_pixels).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels).height / CC_CONTENT_SCALE_FACTOR())

#define CCSIZEPOINTSTOPIXELS ( size_in_points) Size( (__size_in_points).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points).height * CC_CONTENT_SCALE_FACTOR())

#define CC_SWAP ( x,
y,
type
)

值:

{ type temp = (x); \

x = y; y = temp; \

}

简单的宏 交换 2 变量

#define CC_SWAP16 ( i) ((i & 0x00ff) << 8 | (i &0xff00) >> 8)

#define CC_SWAP32 ( i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)

#define CC_SWAP_INT16_BIG_TO_HOST ( i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i): CC_SWAP16(i) )

#define CC_SWAP_INT16_LITTLE_TO_HOST ( i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) )

#define CC_SWAP_INT32_BIG_TO_HOST ( i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i) : CC_SWAP32(i) )

#define CC_SWAP_INT32_LITTLE_TO_HOST ( i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) )

#define CCASSERT ( cond,
msg
)

#define CCAssert CCASSERT

#define CCRANDOM_0_1 ( ) ((float)rand()/RAND_MAX)

返回0和1之间的浮点型随机数

#define CCRANDOM_MINUS1_1 ( ) ((2.0f*((float)rand()/RAND_MAX))-1.0f)

返回-1和1之间的浮点型随机数

#define CHECK_GL_ERROR_DEBUG ( )

#define DISALLOW_COPY_AND_ASSIGN ( TypeName)

值:

TypeName(const TypeName&);\

void operator=(const TypeName&)

#define FLT_EPSILON 1.192092896e-07F

#define GP_ASSERT ( cond) CCASSERT(cond, "")

#define kRepeatForever (UINT_MAX -1)