quick-cocos2dx cocos2dx.lua

cocos2dx.lua 重命名cocos2dx中的常用struct, 函数; 重定义一些常用宏;以及新定义了一些c++ to lua 的转换函数。如:
1、重命名struct
ccp = CCPoint
ccsize = CCSize
ccrect = CCRect

cc.p = CCPoint
cc.size = CCSize
cc.rect = CCRect

2、重命名函数
cc.c3 = ccc3
cc.c4 = ccc4
cc.c4f = ccc4f

3、冲定义宏
cc.TOUCH_IGNORE               = 0
cc.TOUCH_BEGAN                = 1
cc.TOUCH_BEGAN_SWALLOWS       = cc.TOUCH_BEGAN
cc.TOUCH_BEGAN_NO_SWALLOWS    = 2
cc.TOUCH_MOVED                = 1
cc.TOUCH_MOVED_SWALLOWS       = cc.TOUCH_MOVED
cc.TOUCH_MOVED_NO_SWALLOWS    = 0
cc.TOUCH_MOVED_RELEASE_OTHERS = 2
cc.MULTI_TOUCHES_ON           = true
cc.MULTI_TOUCHES_OFF          = false

 
 
 
 
 
 
4、转换函数
cc.size2t = function(size)		-- CCSize to table
    return {width = size.width, height = size.height}
end


cc.point2t = function(point)		-- CCPoint to table
    return {x = point.x, y = point.y}
end


cc.rect2t = function(rect)		-- CCRect to table
    return {origin = cc.point2t(rect.origin), size = cc.size2t(rect.size)}
end


cc.t2size = function(t)			-- table to CCSize
    return CCSize(t.width, t.height)
end


cc.t2point = function(t)		-- table to CCPoint
    return CCPoint(t.x, t.y)
end


cc.t2rect = function(t)			-- table to Rect
    return CCRect(t.origin.x, t.origin.y, t.size.width, t.size.height)
end


你可能感兴趣的:(cocos2d,lua,Quick,quick-lua)