update luabinding scripts

This commit is contained in:
dualface 2014-10-11 01:27:12 +08:00
parent 68f71b3df4
commit 20cbbfdbe5
21 changed files with 259 additions and 209 deletions

View File

@ -1,10 +1,11 @@
cc = cc or {}
function cc.clampf(value, min_inclusive, max_inclusive)
-- body
local temp = 0
if min_inclusive > max_inclusive then
temp = min_inclusive
temp = min_inclusive
min_inclusive = max_inclusive
max_inclusive = temp
end
@ -110,7 +111,7 @@ function cc.pIsLineIntersect(A, B, C, D, s, t)
return false, s, t
end
s = s / denom
t = t / denom
@ -153,7 +154,7 @@ function cc.pFromSize(sz)
return { x = sz.width, y = sz.height }
end
function cc.pLerp(pt1,pt2,alpha)
function cc.pLerp(pt1,pt2,alpha)
return cc.pAdd(cc.pMul(pt1, 1.0 - alpha), cc.pMul(pt2,alpha) )
end
@ -166,13 +167,13 @@ function cc.pFuzzyEqual(pt1,pt2,variance)
end
function cc.pRotateByAngle(pt1, pt2, angle)
return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle)))
return cc.pAdd(pt2, cc.pRotate( cc.pSub(pt1, pt2),cc.pForAngle(angle)))
end
function cc.pIsSegmentIntersect(pt1,pt2,pt3,pt4)
local s,t,ret = 0,0,false
ret,s,t =cc.pIsLineIntersect(pt1, pt2, pt3, pt4,s,t)
if ret and s >= 0.0 and s <= 1.0 and t >= 0.0 and t <= 0.0 then
return true;
end
@ -182,7 +183,7 @@ end
function cc.pGetIntersectPoint(pt1,pt2,pt3,pt4)
local s,t, ret = 0,0,false
ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t)
ret,s,t = cc.pIsLineIntersect(pt1,pt2,pt3,pt4,s,t)
if ret then
return cc.p(pt1.x + s * (pt2.x - pt1.x), pt1.y + s * (pt2.y - pt1.y))
else
@ -235,7 +236,7 @@ end
function cc.rectContainsPoint( rect, point )
local ret = false
if (point.x >= rect.x) and (point.x <= rect.x + rect.width) and
(point.y >= rect.y) and (point.y <= rect.y + rect.height) then
ret = true
@ -407,18 +408,18 @@ function cc.mat4.new(...)
else
obj[i] = 0
end
end
end
elseif 16 == size then
if params[i] ~= nil then
mat4[i] = params[i]
else
mat4[i] = 0
end
end
end
setmetatable(obj, {__index = cc.mat4})
return obj
return obj
end
function cc.mat4.getInversed(self)

View File

@ -1,3 +1,4 @@
cc = cc or {}
cc.SPRITE_INDEX_NOT_INITIALIZED = 0xffffffff
@ -204,7 +205,7 @@ cc.LANGUAGE_ARABIC = 11
cc.NODE_ON_ENTER = 0
cc.NODE_ON_EXIT = 1
cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2
cc.NODE_ON_EXIT_TRANSITION_DID_START = 3
cc.NODE_ON_EXIT_TRANSITION_DID_START = 3
cc.NODE_ON_CLEAN_UP = 4
cc.Handler = cc.Handler or {}
@ -289,7 +290,7 @@ cc.GLYPHCOLLECTION_NEHE = 1
cc.GLYPHCOLLECTION_ASCII = 2
cc.GLYPHCOLLECTION_CUSTOM = 3
cc.ResolutionPolicy =
cc.ResolutionPolicy =
{
EXACT_FIT = 0,
NO_BORDER = 1,
@ -299,7 +300,7 @@ cc.ResolutionPolicy =
UNKNOWN = 5,
}
cc.LabelEffect =
cc.LabelEffect =
{
NORMAL = 0,
OUTLINE = 1,
@ -496,7 +497,7 @@ cc.EventCode =
cc.DIRECTOR_PROJECTION_2D = 0
cc.DIRECTOR_PROJECTION_3D = 1
cc.ConfigType =
cc.ConfigType =
{
NONE = 0,
COCOSTUDIO = 1,
@ -505,7 +506,7 @@ cc.ConfigType =
cc.AUDIO_INVAILD_ID = -1
cc.AUDIO_TIME_UNKNOWN = -1.0
cc.CameraFlag =
cc.CameraFlag =
{
DEFAULT = 1,
USER1 = 2,
@ -518,7 +519,7 @@ cc.CameraFlag =
USER8 = 256,
}
cc.BillBoard_Mode =
cc.BillBoard_Mode =
{
VIEW_POINT_ORIENTED = 0,
VIEW_PLANE_ORIENTED = 1,
@ -544,7 +545,7 @@ cc.GLProgram_VERTEX_ATTRIB =
TEX_COORDS = 2,
}
cc.MATRIX_STACK_TYPE =
cc.MATRIX_STACK_TYPE =
{
MODELVIEW = 0,
PROJECTION = 1,

View File

@ -1,13 +1,12 @@
require "Cocos2dConstants.lua"
require "OpenglConstants.lua"
--Enums will be deprecated,begin
_G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT
_G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT
_G.kCCTextAlignmentCenter = cc.TEXT_ALIGNMENT_CENTER
_G.kCCVerticalTextAlignmentTop = cc.VERTICAL_TEXT_ALIGNMENT_TOP
_G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER
_G.kCCVerticalTextAlignmentCenter = cc.VERTICAL_TEXT_ALIGNMENT_CENTER
_G.kCCVerticalTextAlignmentBottom = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM
_G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D
_G.kCCDirectorProjection3D = cc.DIRECTOR_PROJECTION3_D
_G.kCCDirectorProjection2D = cc.DIRECTOR_PROJECTION2_D
_G.kCCDirectorProjectionCustom = cc.DIRECTOR_PROJECTION_CUSTOM
_G.kCCDirectorProjectionDefault = cc.DIRECTOR_PROJECTION_DEFAULT
@ -18,14 +17,14 @@ _G.kCCTexture2DPixelFormat_RGBA8888 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888
_G.kCCTexture2DPixelFormat_RGB888 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B888
_G.kCCTexture2DPixelFormat_RGB565 = cc.TEXTURE2_D_PIXEL_FORMAT_RG_B565
_G.kCCTexture2DPixelFormat_A8 = cc.TEXTURE2_D_PIXEL_FORMAT_A8
_G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8
_G.kCCTexture2DPixelFormat_I8 = cc.TEXTURE2_D_PIXEL_FORMAT_I8
_G.kCCTexture2DPixelFormat_AI88 = cc.TEXTURE2_D_PIXEL_FORMAT_A_I88
_G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444
_G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1
_G.kCCTexture2DPixelFormat_RGBA4444 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A4444
_G.kCCTexture2DPixelFormat_RGB5A1 = cc.TEXTURE2_D_PIXEL_FORMAT_RGB5_A1
_G.kCCTexture2DPixelFormat_PVRTC4 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC4
_G.kCCTexture2DPixelFormat_PVRTC2 = cc.TEXTURE2_D_PIXEL_FORMAT_PVRTC2
_G.kCCTexture2DPixelFormat_Default = cc.TEXTURE2_D_PIXEL_FORMAT_DEFAULT
_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG
_G.kCCImageFormatPNG = cc.IMAGE_FORMAT_PNG
_G.kCCImageFormatJPEG = cc.IMAGE_FORMAT_JPEG
_G.kCCTouchesOneByOne = cc.TOUCHES_ONE_BY_ONE
_G.kCCTouchesAllAtOnce = cc.TOUCHES_ALL_AT_ONCE
@ -35,18 +34,18 @@ _G.kCCTransitionOrientationUpOver = cc.TRANSITION_ORIENTATION_UP_OVER
_G.kCCTransitionOrientationDownOver = cc.TRANSITION_ORIENTATION_DOWN_OVER
_G.kCCActionTagInvalid = cc.ACTION_TAG_INVALID
_G.kCCLabelAutomaticWidth = cc.LABEL_AUTOMATIC_WIDTH
_G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING
_G.kCCMenuStateWaiting = cc.MENU_STATE_WAITING
_G.kCCMenuStateTrackingTouch = cc.MENU_STATE_TRACKING_TOUCH
_G.kCCMenuHandlerPriority = cc.MENU_HANDLER_PRIORITY
_G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY
_G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE
_G.kCCParticleDurationInfinity = cc.PARTICLE_DURATION_INFINITY
_G.kCCParticleStartSizeEqualToEndSize = cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE
_G.kCCParticleStartRadiusEqualToEndRadius = cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS
_G.kCCParticleModeGravity = cc.PARTICLE_MODE_GRAVITY
_G.kCCParticleModeRadius = cc.PARTICLE_MODE_RADIUS
_G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE
_G.kCCPositionTypeFree = cc.POSITION_TYPE_FREE
_G.kCCPositionTypeRelative = cc.POSITION_TYPE_RELATIVE
_G.kCCPositionTypeGrouped = cc.POSITION_TYPE_GROUPED
_G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL
_G.kCCProgressTimerTypeRadial = cc.PROGRESS_TIMER_TYPE_RADIAL
_G.kCCProgressTimerTypeBar = cc.PROGRESS_TIMER_TYPE_BAR
_G.kCCTMXTileHorizontalFlag = cc.TMX_TILE_HORIZONTAL_FLAG
_G.kCCTMXTileVerticalFlag = cc.TMX_TILE_VERTICAL_FLAG
@ -54,9 +53,9 @@ _G.kCCTMXTileDiagonalFlag = cc.TMX_TILE_DIAGONAL_FLAG
_G.kCCFlipedAll = cc.FLIPED_ALL
_G.kCCFlippedMask = cc.FLIPPED_MASK
_G.kLanguageEnglish = cc.LANGUAGE_ENGLISH
_G.kLanguageChinese = cc.LANGUAGE_CHINESE
_G.kLanguageFrench = cc.LANGUAGE_FRENCH
_G.kLanguageEnglish = cc.LANGUAGE_ENGLISH
_G.kLanguageChinese = cc.LANGUAGE_CHINESE
_G.kLanguageFrench = cc.LANGUAGE_FRENCH
_G.kLanguageItalian = cc.LANGUAGE_ITALIAN
_G.kLanguageGerman = cc.LANGUAGE_GERMAN
_G.kLanguageSpanish = cc.LANGUAGE_SPANISH
@ -67,21 +66,21 @@ _G.kLanguageHungarian = cc.LANGUAGE_HUNGARIAN
_G.kLanguagePortuguese = cc.LANGUAGE_PORTUGUESE
_G.kLanguageArabic = cc.LANGUAGE_ARABIC
_G.kTargetWindows = cc.PLATFORM_OS_WINDOWS
_G.kTargetLinux = cc.PLATFORM_OS_LINUX
_G.kTargetLinux = cc.PLATFORM_OS_LINUX
_G.kTargetMacOS = cc.PLATFORM_OS_MAC
_G.kTargetAndroid = cc.PLATFORM_OS_ANDROID
_G.kTargetIphone = cc.PLATFORM_OS_IPHONE
_G.kTargetIpad = cc.PLATFORM_OS_IPAD
_G.kTargetIpad = cc.PLATFORM_OS_IPAD
_G.kTargetBlackBerry = cc.PLATFORM_OS_BLACKBERRY
_G.GL_ZERO = gl.ZERO
_G.GL_ONE = gl.ONE
_G.GL_SRC_COLOR = gl.SRC_COLOR
_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR
_G.GL_SRC_ALPHA = gl.SRC_ALPHA
_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR
_G.GL_SRC_ALPHA = gl.SRC_ALPHA
_G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA
_G.GL_DST_ALPHA = gl.DST_ALPHA
_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA
_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA
_G.GL_DST_COLOR = gl.DST_COLOR
_G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR
_G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT

View File

@ -1,10 +1,9 @@
require "Cocos2d.lua"
--tip
local function deprecatedTip(old_name,new_name)
print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
end
--functions of CCDirector will be deprecated,begin
local CCDirectorDeprecated = { }
function CCDirectorDeprecated.sharedDirector()
@ -308,7 +307,7 @@ rawset(_G,"ccc3",ccc3)
local function ccp(x,y)
deprecatedTip("ccp(x,y)","cc.p(x,y)")
return cc.p(x,y)
end
end
rawset(_G,"ccp",ccp)
local function CCSizeMake(width,height)
@ -337,7 +336,7 @@ rawset(_G,"ccc4f",ccc4f)
local function ccc4FFromccc4B(color4B)
deprecatedTip("ccc4FFromccc4B(color4B)","cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)")
return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)
return cc.c4f(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)
end
rawset(_G,"ccc4FFromccc4B",ccc4FFromccc4B)
@ -360,7 +359,7 @@ rawset(_G,"ccpLineIntersect",ccpLineIntersect)
local function CCPointMake(x,y)
deprecatedTip("CCPointMake(x,y)","cc.p(x,y)")
return cc.p(x,y)
end
end
rawset(_G,"CCPointMake",CCPointMake)
@ -494,7 +493,7 @@ rawset(_G,"ccpFromSize",ccpFromSize)
local function ccpLerp(pt1,pt2,alpha)
deprecatedTip("ccpLerp","cc.pLerp")
return cc.pLerp(pt1,pt2,alpha)
return cc.pLerp(pt1,pt2,alpha)
end
rawset(_G,"ccpLerp",ccpLerp)
@ -557,11 +556,11 @@ local function tex2(u,v)
deprecatedTip("tex2(u,v)","cc.tex2f(u,v)")
return cc.tex2f(u,v)
end
rawset(_G,"tex2",tex2)
rawset(_G,"tex2",tex2)
local function ccc4BFromccc4F(color4F)
deprecatedTip("ccc4BFromccc4F(color4F)","Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)")
return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)
return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)
end
rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F)

View File

@ -1,3 +1,4 @@
local dp_initialized = false
local dp_shader = nil
local dp_colorLocation = -1
@ -31,7 +32,7 @@ end
local function setDrawProperty()
gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION )
dp_shader:use()
dp_shader:setUniformsForBuiltins()
dp_shader:setUniformsForBuiltins()
dp_shader:setUniformLocationWith4fv(dp_colorLocation, dp_color, 1)
end
@ -204,7 +205,7 @@ function ccDrawSolidPoly(points,numOfPoints,color)
gl.glEnableVertexAttribs( CCConstants.VERTEX_ATTRIB_FLAG_POSITION )
dp_shader:use()
dp_shader:setUniformsForBuiltins()
dp_shader:setUniformsForBuiltins()
dp_shader:setUniformLocationWith4fv(dp_colorLocation, color, 1)
gl.bindBuffer(gl.ARRAY_BUFFER,vertexBuffer.buffer_id)
@ -316,7 +317,7 @@ function ccDrawQuadBezier(origin, control, destination, segments)
local vertexBuffer = { }
local function initBuffer()
local vertices = { }
local vertices = { }
local i = 1
local t = 0.0
@ -325,7 +326,7 @@ function ccDrawQuadBezier(origin, control, destination, segments)
vertices[2 * i] = math.pow(1 - t,2) * origin.y + 2.0 * (1 - t) * t * control.y + t * t * destination.y
t = t + 1.0 / segments
end
vertices[2 * (segments + 1) - 1] = destination.x
vertices[2 * (segments + 1)] = destination.y
@ -353,7 +354,7 @@ function ccDrawCubicBezier(origin, control1, control2, destination, segments)
local vertexBuffer = { }
local function initBuffer()
local vertices = { }
local vertices = { }
local t = 0
local i = 1

View File

@ -1,6 +1,5 @@
require "OpenglConstants"
gl = gl or {}
if not gl then return end
--Create functions
function gl.createTexture()
@ -112,7 +111,7 @@ function gl.bindTexture(target, texture)
end
gl._bindTexture(target,texture_id)
end
end
function gl.bindBuffer( target,buffer )
local buffer_id = 0
@ -211,7 +210,7 @@ function gl.linkProgram( program )
gl._linkProgram(program_id)
end
function gl.getProgramParameter(program, e)
function gl.getProgramParameter(program, e)
local program_id = 0
if "number" == type(program) then
@ -296,4 +295,3 @@ end
function gl.glNodeCreate()
return cc.GLNode:create()
end

View File

@ -1,5 +1,5 @@
--Encapsulate opengl constants.
gl = gl or {}
if not gl then return end
gl.GCCSO_SHADER_BINARY_FJ = 0x9260
gl._3DC_XY_AMD = 0x87fa

View File

@ -2,15 +2,16 @@
bit = bit or {}
bit.data32 = {}
for i=1,32 do
bit.data32[i]=2^(32-i)
end
function bit._b2d(arg)
local nr=0
function bit._b2d(arg)
local nr=0
for i=1,32 do
if arg[i] ==1 then
nr=nr+bit.data32[i]
nr=nr+bit.data32[i]
end
end
return nr
@ -18,23 +19,23 @@ end
function bit._d2b(arg)
arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1)
local tr={}
local tr={}
for i=1,32 do
if arg >= bit.data32[i] then
tr[i]=1
arg=arg-bit.data32[i]
tr[i]=1
arg=arg-bit.data32[i]
else
tr[i]=0
tr[i]=0
end
end
return tr
end
function bit._and(a,b)
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 and op2[i]==1 then
r[i]=1
@ -43,11 +44,11 @@ function bit._and(a,b)
end
end
return bit._b2d(r)
end
function bit._rshift(a,n)
local op1=bit._d2b(a)
local op1=bit._d2b(a)
n = n <= 32 and n or 32
n = n >= 0 and n or 0
@ -57,13 +58,13 @@ function bit._rshift(a,n)
for i=1, n do
op1[i] = 0
end
return bit._b2d(op1)
end
function bit._not(a)
local op1=bit._d2b(a)
local r={}
function bit._not(a)
local op1=bit._d2b(a)
local r={}
for i=1,32 do
if op1[i]==1 then
@ -72,14 +73,14 @@ function bit._not(a)
r[i]=1
end
end
return bit._b2d(r)
return bit._b2d(r)
end
function bit._or(a,b)
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 or op2[i]==1 then
r[i]=1
@ -87,9 +88,9 @@ function bit._or(a,b)
r[i]=0
end
end
return bit._b2d(r)
return bit._b2d(r)
end
bit.band = bit.band or bit._and
bit.band = bit.band or bit._and
bit.rshift = bit.rshift or bit._rshift
bit.bnot = bit.bnot or bit._not
bit.bnot = bit.bnot or bit._not

View File

@ -1,3 +1,4 @@
function clone(object)
local lookup_table = {}
local function _copy(object)
@ -90,4 +91,3 @@ function performWithDelay(node, callback, delay)
node:runAction(sequence)
return sequence
end

View File

@ -18,7 +18,7 @@
-- compat-5.1 if using Lua 5.0
--
-- CHANGELOG
-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix).
-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix).
-- Fixed Lua 5.1 compatibility issues.
-- Introduced json.null to have null values in associative arrays.
-- encode() performance improvement (more than 50%) through table.concat rather than ..
@ -65,19 +65,19 @@ function encode (v)
if v==nil then
return "null"
end
local vtype = base.type(v)
local vtype = base.type(v)
-- Handle strings
if vtype=='string' then
if vtype=='string' then
return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string
end
-- Handle booleans
if vtype=='number' or vtype=='boolean' then
return base.tostring(v)
end
-- Handle tables
if vtype=='table' then
local rval = {}
@ -100,12 +100,12 @@ function encode (v)
return '{' .. table.concat(rval,',') .. '}'
end
end
-- Handle null values
if vtype=='function' and v==null then
return 'null'
end
base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v))
end
@ -191,14 +191,14 @@ function decode_scanComment(s, startPos)
base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos)
local endPos = string.find(s,'*/',startPos+2)
base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos)
return endPos+2
return endPos+2
end
--- Scans for given constants: true, false or null
-- Returns the appropriate Lua type, and the position of the next character to read.
-- @param s The string being scanned.
-- @param startPos The position in the string at which to start scanning.
-- @return object, int The object (true, false or nil) and the position at which the next character should be
-- @return object, int The object (true, false or nil) and the position at which the next character should be
-- scanned.
function decode_scanConstant(s, startPos)
local consts = { ["true"] = true, ["false"] = false, ["null"] = nil }
@ -290,7 +290,7 @@ function decode_scanString(s,startPos)
local stringLen = string.len(s)
repeat
local curChar = string.sub(s,endPos,endPos)
if not escaped then
if not escaped then
if curChar==[[\]] then
escaped = true
else
@ -306,7 +306,7 @@ function decode_scanString(s,startPos)
local stringValue = 'return ' .. string.sub(s, startPos, endPos-1)
local stringEval = base.loadstring(stringValue)
base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos)
return stringEval(), endPos
return stringEval(), endPos
end
--- Scans a JSON string skipping all whitespace from the current start position.
@ -334,7 +334,7 @@ function encodeString(s)
s = string.gsub(s,"'","\\'")
s = string.gsub(s,'\n','\\n')
s = string.gsub(s,'\t','\\t')
return s
return s
end
-- Determines whether the given Lua type is an array or a table / dictionary.
@ -344,9 +344,9 @@ end
-- @param t The table to evaluate as an array
-- @return boolean, number True if the table can be represented as an array, false otherwise. If true,
-- the second returned value is the maximum
-- number of indexed elements in the array.
-- number of indexed elements in the array.
function isArray(t)
-- Next we count all the elements, ensuring that any non-indexed elements are not-encodable
-- Next we count all the elements, ensuring that any non-indexed elements are not-encodable
-- (with the possible exception of 'n')
local maxIndex = 0
for k,v in base.pairs(t) do
@ -371,6 +371,6 @@ end
-- @return boolean True if the object should be JSON encoded, false if it should be ignored.
function isEncodable(o)
local t = base.type(o)
return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null)
return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null)
end

View File

@ -1,4 +1,5 @@
--Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects.
--Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects.
local M = {}
function M.stopAllEffects()
@ -105,16 +106,4 @@ function M.destroyInstance()
return cc.SimpleAudioEngine:destroyInstance()
end
local modename = "AudioEngine"
local proxy = {}
local mt = {
__index = M,
__newindex = function (t ,k ,v)
print("attemp to update a read-only table")
end
}
setmetatable(proxy,mt)
_G[modename] = proxy
package.loaded[modename] = proxy
AudioEngine = M

View File

@ -1,11 +1,15 @@
require "json"
require "extern"
if not json then
require "cocos.cocos2d.json"
end
ccs = ccs or {}
require "cocos.cocosstudio.StudioConstants"
function ccs.sendTriggerEvent(event)
local triggerObjArr = ccs.TriggerMng.getInstance():get(event)
if nil == triggerObjArr then
return
end
@ -106,7 +110,7 @@ end
function ccs.TriggerObj:detect()
if (not self._enable) or (table.getn(self._cons) == 0) then
return true
end
end
local ret = true
local obj = nil
@ -355,7 +359,7 @@ end
function ccs.TriggerMng:removeTriggerObj(id)
local obj = self.getTriggerObj(id)
if nil == obj then
return false
end

View File

@ -1,8 +1,8 @@
ccs = ccs or {}
ccs = ccs or {}
ccs.MovementEventType = {
start = 0,
complete = 1,
loopComplete = 2,
loopComplete = 2,
}

View File

@ -1,3 +1,4 @@
cc = cc or {}
cc.ControllerKey =
@ -13,7 +14,7 @@ cc.ControllerKey =
BUTTON_X = 1007,
BUTTON_Y = 1008,
BUTTON_Z = 1009,
BUTTON_DPAD_UP = 1010,
BUTTON_DPAD_DOWN = 1011,
BUTTON_DPAD_LEFT = 1012,

View File

@ -1,3 +1,4 @@
cc = cc or {}
cc.CONTROL_STATE_NORMAL = 1

View File

@ -0,0 +1,55 @@
require "cocos.cocos2d.Cocos2d"
require "cocos.cocos2d.Cocos2dConstants"
require "cocos.cocos2d.extern"
-- opengl
require "cocos.cocos2d.Opengl"
require "cocos.cocos2d.OpenglConstants"
-- cocosdenshion
require "cocos.cocosdenshion.AudioEngine"
-- cocosstudio
require "cocos.cocosstudio.CocosStudio"
-- ui
require "cocos.ui.GuiConstants"
-- extensions
require "cocos.extension.ExtensionConstants"
-- network
require "cocos.network.NetworkConstants"
if CC_USE_DEPRECATED_API then
-- CCLuaEngine
require "cocos.cocos2d.DeprecatedCocos2dClass"
require "cocos.cocos2d.DeprecatedCocos2dEnum"
require "cocos.cocos2d.DeprecatedCocos2dFunc"
-- register_cocostudio_module
require "cocos.cocosstudio.DeprecatedCocoStudioClass"
require "cocos.cocosstudio.DeprecatedCocoStudioFunc"
-- register_cocosbuilder_module
require "cocos.cocosbuilder.DeprecatedCocosBuilderClass"
-- register_cocosdenshion_module
require "cocos.cocosdenshion.DeprecatedCocosDenshionClass"
require "cocos.cocosdenshion.DeprecatedCocosDenshionFunc"
-- register_extension_module
require "cocos.extension.DeprecatedExtensionClass"
require "cocos.extension.DeprecatedExtensionEnum"
require "cocos.extension.DeprecatedExtensionFunc"
-- register_network_module
require "cocos.network.DeprecatedNetworkClass"
require "cocos.network.DeprecatedNetworkEnum"
require "cocos.network.DeprecatedNetworkFunc"
-- register_ui_moudle
require "cocos.ui.DeprecatedUIEnum"
require "cocos.ui.DeprecatedUIFunc"
end

View File

@ -1,3 +1,4 @@
cc = cc or {}
cc.WEBSOCKET_OPEN = 0
@ -10,9 +11,8 @@ cc.WEBSOCKET_STATE_OPEN = 1
cc.WEBSOCKET_STATE_CLOSING = 2
cc.WEBSOCKET_STATE_CLOSED = 3
cc.XMLHTTPREQUEST_RESPONSE_STRING = 0
cc.XMLHTTPREQUEST_RESPONSE_STRING = 0
cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1
cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2
cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3
cc.XMLHTTPREQUEST_RESPONSE_JSON = 4
cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2
cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3
cc.XMLHTTPREQUEST_RESPONSE_JSON = 4

View File

@ -1,92 +1,91 @@
require("GuiConstants")
_G.LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none
_G.LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid
_G.LAYOUT_COLOR_GRADIENT = ccui.LayoutBackGroundColorType.gradient
LAYOUT_COLOR_NONE = ccui.LayoutBackGroundColorType.none
LAYOUT_COLOR_SOLID = ccui.LayoutBackGroundColorType.solid
LAYOUT_COLOR_GRADIENT = ccui.LayoutBackGroundColorType.gradient
_G.LAYOUT_ABSOLUTE = ccui.LayoutType.ABSOLUTE
_G.LAYOUT_LINEAR_VERTICAL = ccui.LayoutType.VERTICAL
_G.LAYOUT_LINEAR_HORIZONTAL = ccui.LayoutType.HORIZONTAL
_G.LAYOUT_RELATIVE = ccui.LayoutType.RELATIVE
LAYOUT_ABSOLUTE = ccui.LayoutType.ABSOLUTE
LAYOUT_LINEAR_VERTICAL = ccui.LayoutType.VERTICAL
LAYOUT_LINEAR_HORIZONTAL = ccui.LayoutType.HORIZONTAL
LAYOUT_RELATIVE = ccui.LayoutType.RELATIVE
_G.BRIGHT_NONE = ccui.BrightStyle.none
_G.BRIGHT_NORMAL = ccui.BrightStyle.normal
_G.BRIGHT_HIGHLIGHT = ccui.BrightStyle.highlight
BRIGHT_NONE = ccui.BrightStyle.none
BRIGHT_NORMAL = ccui.BrightStyle.normal
BRIGHT_HIGHLIGHT = ccui.BrightStyle.highlight
_G.UI_TEX_TYPE_LOCAL = ccui.TextureResType.localType
_G.UI_TEX_TYPE_PLIST = ccui.TextureResType.plistType
UI_TEX_TYPE_LOCAL = ccui.TextureResType.localType
UI_TEX_TYPE_PLIST = ccui.TextureResType.plistType
_G.TOUCH_EVENT_BEGAN = ccui.TouchEventType.began
_G.TOUCH_EVENT_MOVED = ccui.TouchEventType.moved
_G.TOUCH_EVENT_ENDED = ccui.TouchEventType.ended
_G.TOUCH_EVENT_CANCELED = ccui.TouchEventType.canceled
_G.SIZE_ABSOLUTE = ccui.SizeType.absolute
_G.SIZE_PERCENT = ccui.SizeType.percent
TOUCH_EVENT_BEGAN = ccui.TouchEventType.began
TOUCH_EVENT_MOVED = ccui.TouchEventType.moved
TOUCH_EVENT_ENDED = ccui.TouchEventType.ended
TOUCH_EVENT_CANCELED = ccui.TouchEventType.canceled
_G.POSITION_ABSOLUTE = ccui.PositionType.absolute
_G.POSITION_PERCENT = ccui.PositionType.percent
SIZE_ABSOLUTE = ccui.SizeType.absolute
SIZE_PERCENT = ccui.SizeType.percent
_G.CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected
_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected
POSITION_ABSOLUTE = ccui.PositionType.absolute
POSITION_PERCENT = ccui.PositionType.percent
_G.CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected
_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected
CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected
CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected
_G.LoadingBarTypeLeft = ccui.LoadingBarDirection.LEFT
_G.LoadingBarTypeRight = ccui.LoadingBarDirection.RIGHT
CHECKBOX_STATE_EVENT_SELECTED = ccui.CheckBoxEventType.selected
CHECKBOX_STATE_EVENT_UNSELECTED = ccui.CheckBoxEventType.unselected
_G.LoadingBarTypeRight = ccui.SliderEventType.percent_changed
LoadingBarTypeLeft = ccui.LoadingBarDirection.LEFT
LoadingBarTypeRight = ccui.LoadingBarDirection.RIGHT
_G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccui.TextFiledEventType.attach_with_ime
_G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccui.TextFiledEventType.detach_with_ime
_G.TEXTFIELD_EVENT_INSERT_TEXT = ccui.TextFiledEventType.insert_text
_G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccui.TextFiledEventType.delete_backward
LoadingBarTypeRight = ccui.SliderEventType.percent_changed
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollViewDir.none
_G.SCROLLVIEW_DIR_VERTICAL = ccui.ScrollViewDir.vertical
_G.SCROLLVIEW_DIR_HORIZONTAL = ccui.ScrollViewDir.horizontal
_G.SCROLLVIEW_DIR_BOTH = ccui.ScrollViewDir.both
TEXTFIELD_EVENT_ATTACH_WITH_IME = ccui.TextFiledEventType.attach_with_ime
TEXTFIELD_EVENT_DETACH_WITH_IME = ccui.TextFiledEventType.detach_with_ime
TEXTFIELD_EVENT_INSERT_TEXT = ccui.TextFiledEventType.insert_text
TEXTFIELD_EVENT_DELETE_BACKWARD = ccui.TextFiledEventType.delete_backward
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.scrollToTop
_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.scrollToBottom
_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.scrollToLeft
_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.scrollToRight
_G.SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.scrolling
_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.bounceTop
_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.bounceBottom
_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.bounceLeft
_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.bounceRight
SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollViewDir.none
SCROLLVIEW_DIR_VERTICAL = ccui.ScrollViewDir.vertical
SCROLLVIEW_DIR_HORIZONTAL = ccui.ScrollViewDir.horizontal
SCROLLVIEW_DIR_BOTH = ccui.ScrollViewDir.both
_G.PAGEVIEW_EVENT_TURNING = ccui.PageViewEventType.turning
SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.scrollToTop
SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.scrollToBottom
SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.scrollToLeft
SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.scrollToRight
SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.scrolling
SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.bounceTop
SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.bounceBottom
SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.bounceLeft
SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.bounceRight
_G.PAGEVIEW_TOUCHLEFT = ccui.PVTouchDir.touch_left
_G.PAGEVIEW_TOUCHRIGHT = ccui.PVTouchDir.touch_right
PAGEVIEW_EVENT_TURNING = ccui.PageViewEventType.turning
_G.LISTVIEW_DIR_NONE = ccui.ListViewDirection.none
_G.LISTVIEW_DIR_VERTICAL = ccui.ListViewDirection.vertical
_G.LISTVIEW_DIR_HORIZONTAL = ccui.ListViewDirection.horizontal
PAGEVIEW_TOUCHLEFT = ccui.PVTouchDir.touch_left
PAGEVIEW_TOUCHRIGHT = ccui.PVTouchDir.touch_right
_G.LISTVIEW_MOVE_DIR_NONE = ccui.ListViewMoveDirection.none
_G.LISTVIEW_MOVE_DIR_UP = ccui.ListViewMoveDirection.up
_G.LISTVIEW_MOVE_DIR_DOWN = ccui.ListViewMoveDirection.down
_G.LISTVIEW_MOVE_DIR_LEFT = ccui.ListViewMoveDirection.left
_G.LISTVIEW_MOVE_DIR_RIGHT = ccui.ListViewMoveDirection.right
LISTVIEW_DIR_NONE = ccui.ListViewDirection.none
LISTVIEW_DIR_VERTICAL = ccui.ListViewDirection.vertical
LISTVIEW_DIR_HORIZONTAL = ccui.ListViewDirection.horizontal
_G.LISTVIEW_EVENT_INIT_CHILD = ccui.ListViewEventType.init_child
_G.LISTVIEW_EVENT_UPDATE_CHILD = ccui.ListViewEventType.update_child
LISTVIEW_MOVE_DIR_NONE = ccui.ListViewMoveDirection.none
LISTVIEW_MOVE_DIR_UP = ccui.ListViewMoveDirection.up
LISTVIEW_MOVE_DIR_DOWN = ccui.ListViewMoveDirection.down
LISTVIEW_MOVE_DIR_LEFT = ccui.ListViewMoveDirection.left
LISTVIEW_MOVE_DIR_RIGHT = ccui.ListViewMoveDirection.right
_G.LAYOUT_PARAMETER_NONE = ccui.LayoutParameterType.none
_G.LAYOUT_PARAMETER_LINEAR = ccui.LayoutParameterType.linear
_G.LAYOUT_PARAMETER_RELATIVE = ccui.LayoutParameterType.relative
LISTVIEW_EVENT_INIT_CHILD = ccui.ListViewEventType.init_child
LISTVIEW_EVENT_UPDATE_CHILD = ccui.ListViewEventType.update_child
ccui.LoadingBarType = ccui.LoadingBarDirection
ccui.LoadingBarType.left = ccui.LoadingBarDirection.LEFT
ccui.LoadingBarType.right = ccui.LoadingBarDirection.RIGHT
LAYOUT_PARAMETER_NONE = ccui.LayoutParameterType.none
LAYOUT_PARAMETER_LINEAR = ccui.LayoutParameterType.linear
LAYOUT_PARAMETER_RELATIVE = ccui.LayoutParameterType.relative
ccui.LayoutType.absolute = ccui.LayoutType.ABSOLUTE
ccui.LayoutType.linearVertical = ccui.LayoutType.VERTICAL
ccui.LayoutType.linearHorizontal = ccui.LayoutType.HORIZONTAL
ccui.LayoutType.relative = ccui.LayoutType.RELATIVE
ccui.LoadingBarType = ccui.LoadingBarDirection
ccui.LoadingBarType.left = ccui.LoadingBarDirection.LEFT
ccui.LoadingBarType.right = ccui.LoadingBarDirection.RIGHT
ccui.ListViewEventType.onsSelectedItem = ccui.ListViewEventType.ONSELECTEDITEM_START
ccui.LayoutType.absolute = ccui.LayoutType.ABSOLUTE
ccui.LayoutType.linearVertical = ccui.LayoutType.VERTICAL
ccui.LayoutType.linearHorizontal = ccui.LayoutType.HORIZONTAL
ccui.LayoutType.relative = ccui.LayoutType.RELATIVE
ccui.ListViewEventType.onsSelectedItem = ccui.ListViewEventType.ONSELECTEDITEM_START

View File

@ -1,19 +1,20 @@
ccui = ccui or {}
ccui.BrightStyle =
ccui.BrightStyle =
{
none = -1,
normal = 0,
highlight = 1,
}
ccui.TextureResType =
ccui.TextureResType =
{
localType = 0,
plistType = 1,
}
ccui.TouchEventType =
ccui.TouchEventType =
{
began = 0,
moved = 1,
@ -21,7 +22,7 @@ ccui.TouchEventType =
canceled = 3,
}
ccui.SizeType =
ccui.SizeType =
{
absolute = 0,
percent = 1,
@ -32,13 +33,13 @@ ccui.PositionType = {
percent = 1,
}
ccui.CheckBoxEventType =
ccui.CheckBoxEventType =
{
selected = 0,
unselected = 1,
}
ccui.TextFiledEventType =
ccui.TextFiledEventType =
{
attach_with_ime = 0,
detach_with_ime = 1,
@ -46,14 +47,14 @@ ccui.TextFiledEventType =
delete_backward = 3,
}
ccui.LayoutBackGroundColorType =
ccui.LayoutBackGroundColorType =
{
none = 0,
solid = 1,
gradient = 2,
}
ccui.LayoutType =
ccui.LayoutType =
{
ABSOLUTE = 0,
VERTICAL = 1,
@ -61,14 +62,14 @@ ccui.LayoutType =
RELATIVE = 3,
}
ccui.LayoutParameterType =
ccui.LayoutParameterType =
{
none = 0,
linear = 1,
relative = 2,
}
ccui.LinearGravity =
ccui.LinearGravity =
{
none = 0,
left = 1,
@ -79,7 +80,7 @@ ccui.LinearGravity =
centerHorizontal = 6,
}
ccui.RelativeAlign =
ccui.RelativeAlign =
{
alignNone = 0,
alignParentTopLeft = 1,
@ -156,7 +157,7 @@ ccui.ListViewEventType = {
}
ccui.PageViewEventType = {
turning = 0,
turning = 0,
}
ccui.PVTouchDir = {