From fdb87cc69d958bc83d7dbc0f464f324d68893b7e Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Thu, 20 Mar 2014 17:40:41 +0800 Subject: [PATCH 01/17] ignore [] in command [console run]. --- tools/jenkins-scripts/cocos-console-test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index a596fbcec9..a40e05b6d4 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -8,13 +8,14 @@ import json # get payload argvs -console_param = 'create' +console_param = '[console create]' # payload = '' if os.environ.has_key('payload'): payload_str = os.environ['payload'] payload = json.loads(payload_str) if payload.has_key('console'): console_param = payload['console'] +console_param = console_param[1:len(strConsole)-1] print 'console_param:',console_param console_param_arr = console_param.split(' ') From d18ee126788c01075d169b2b4dde4bfd2bb1f6f9 Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Fri, 21 Mar 2014 14:15:59 +0800 Subject: [PATCH 02/17] for test close project in cocos-console-test.py. --- tools/jenkins-scripts/cocos-console-test.py | 49 ++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index a40e05b6d4..201b36c84b 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -5,31 +5,33 @@ import os import sys import json - +import time # get payload argvs -console_param = '[console create]' +console_param = '[console run]' # payload = '' if os.environ.has_key('payload'): payload_str = os.environ['payload'] payload = json.loads(payload_str) if payload.has_key('console'): console_param = payload['console'] -console_param = console_param[1:len(strConsole)-1] +console_param = console_param[1:len(console_param)-1] print 'console_param:',console_param console_param_arr = console_param.split(' ') -project_types = ['cpp', 'lua'] +# project_types = ['cpp', 'lua'] +project_types = ['cpp'] PROJ_SUFFIX = 'Proj' -phonePlats = ['mac','ios','android'] +# phonePlats = ['mac','ios','android'] +phonePlats = ['ios'] #need use console's position, perhaps should be set an env-param cocos_console_dir = 'tools/cocos2d-console/bin/' #now cocos2d-console suport different run on Platforms, e.g: only run android on win runSupport = { - 'darwin' : [1, 1, 1], + 'darwin' : [1, 1, 0], 'win' : [0, 0, 1], 'linux' : [0, 0, 1] } @@ -56,6 +58,36 @@ def create_project(): print proj,'cmd:',cmd info_create = os.system(cmd) #call cmd on win is diff print 'create project',proj,' is:', not info_create + +def getAppPID(name): + cmd = 'ps -eo pid,comm | grep '+name + output = os.popen(cmd) + result = output.read() + arrProcess = result.split('\n') + print 'arrProcess:', arrProcess + def getProcessId(proInfo): + if len(proInfo) > 0: + arrInfo = proInfo.split(' ') + return int(arrInfo[0]) + return -1 + arrProIdx = [] + for content in arrProcess: + idx = getProcessId(content) + if idx > 0: + arrProIdx.append(idx) + return arrProIdx +def close_proj(proj): + print 'close running project' + if curPlat == 'darwin': + print 'will close proj:',proj,', on',curPlat + arrPids = getAppPID(proj+PROJ_SUFFIX) + print 'arrPids:', arrPids + for pid in arrPids: + cmd = 'kill ' + cmd += str(pid) + print 'cmd:',cmd + os.system(cmd) + def build_run(): print 'will build and run' for proj in project_types: @@ -66,6 +98,10 @@ def build_run(): if runSupport[curPlat][idx]: info_run = os.system(cmd) print 'run project', proj, 'is:', not info_run + if info_run == 0: + time.sleep(5) + close_proj(proj) + time.sleep(2) idx += 1 def main(): @@ -73,6 +109,7 @@ def main(): create_project() if console_param_arr.count('run'): build_run() + # close_proj('cpp') # -------------- main -------------- if __name__ == '__main__': From c55910c2c0358838b3ae80808780b6339331e069 Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Fri, 21 Mar 2014 17:50:38 +0800 Subject: [PATCH 03/17] add-close app in console-test.py. --- tools/jenkins-scripts/cocos-console-test.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index 201b36c84b..7c6895f725 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -20,11 +20,9 @@ print 'console_param:',console_param console_param_arr = console_param.split(' ') -# project_types = ['cpp', 'lua'] -project_types = ['cpp'] +project_types = ['cpp', 'lua'] PROJ_SUFFIX = 'Proj' -# phonePlats = ['mac','ios','android'] -phonePlats = ['ios'] +phonePlats = ['mac','ios','android'] #need use console's position, perhaps should be set an env-param cocos_console_dir = 'tools/cocos2d-console/bin/' @@ -76,9 +74,14 @@ def getAppPID(name): if idx > 0: arrProIdx.append(idx) return arrProIdx -def close_proj(proj): +def close_proj(proj, phone): print 'close running project' if curPlat == 'darwin': + if phone == 'android': + cmd = 'adb shell pm uninstall -n org.cocos2dx.hello'+proj + infoUninstall = os.system(cmd) + print 'infoUninstall apk:', infoUninstall, cmd + return infoUninstall == 0 print 'will close proj:',proj,', on',curPlat arrPids = getAppPID(proj+PROJ_SUFFIX) print 'arrPids:', arrPids @@ -100,7 +103,7 @@ def build_run(): print 'run project', proj, 'is:', not info_run if info_run == 0: time.sleep(5) - close_proj(proj) + close_proj(proj, phone) time.sleep(2) idx += 1 @@ -109,7 +112,7 @@ def main(): create_project() if console_param_arr.count('run'): build_run() - # close_proj('cpp') + # close_proj('cpp', 'android') # -------------- main -------------- if __name__ == '__main__': From f0bb69bc5f13b86cb5a757888a80fb9b0e1418ce Mon Sep 17 00:00:00 2001 From: pandamicro Date: Thu, 27 Mar 2014 10:59:47 +0800 Subject: [PATCH 04/17] Revert "Reverse CONSTRUCTOR_ACCESS" This reverts commit 44d446ef1d63738ebc95459f33e92c74f5a9d342. --- cocos/2d/ccConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/ccConfig.h b/cocos/2d/ccConfig.h index a58092458f..e4455d21f1 100644 --- a/cocos/2d/ccConfig.h +++ b/cocos/2d/ccConfig.h @@ -273,7 +273,7 @@ To enable set it to a value different than 0. Disabled by default. protected by default. */ #ifndef CC_CONSTRUCTOR_ACCESS -#define CC_CONSTRUCTOR_ACCESS protected +#define CC_CONSTRUCTOR_ACCESS public #endif #endif // __CCCONFIG_H__ From fb780f82da4ee434f4a21711263fbcffbaefbdc8 Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Fri, 28 Mar 2014 13:40:24 +0800 Subject: [PATCH 05/17] add [director end] command in CCConsole.cpp. --- cocos/base/CCConsole.cpp | 4 + tools/jenkins-scripts/cocos-console-test.py | 175 +++++++++++++------- 2 files changed, 118 insertions(+), 61 deletions(-) diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 0f9d7f625f..f84b03efdc 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -616,6 +616,10 @@ void Console::commandDirector(int fd, const std::string& args) { director->startAnimation(); } + else if(args == "end") + { + director->end(); + } } diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index 7c6895f725..4207ccd248 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -6,6 +6,7 @@ import os import sys import json import time +import socket # get payload argvs console_param = '[console run]' @@ -20,6 +21,33 @@ print 'console_param:',console_param console_param_arr = console_param.split(' ') +class ENUM_PARAM: + new = 0 + compile = 1 + deploy = 2 + run = 3 + +LEVEL_COCOS = { + ENUM_PARAM.new : 1, + ENUM_PARAM.compile : 2, + ENUM_PARAM.deploy : 4, + ENUM_PARAM.run : 8 +} + +COCOS_CMD = { + ENUM_PARAM.new:'new', + ENUM_PARAM.compile:'compile', + ENUM_PARAM.deploy:'deploy', + ENUM_PARAM.run:'run' +} + +cocos_param = 0 +for level in LEVEL_COCOS: + if console_param_arr.count(COCOS_CMD[level]): + cocos_param = cocos_param + LEVEL_COCOS[level] +if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]: + cocos_param = LEVEL_COCOS[ENUM_PARAM.new] +print 'cocos_param:', cocos_param project_types = ['cpp', 'lua'] PROJ_SUFFIX = 'Proj' phonePlats = ['mac','ios','android'] @@ -29,9 +57,9 @@ cocos_console_dir = 'tools/cocos2d-console/bin/' #now cocos2d-console suport different run on Platforms, e.g: only run android on win runSupport = { - 'darwin' : [1, 1, 0], - 'win' : [0, 0, 1], - 'linux' : [0, 0, 1] + 'darwin' : {'mac':1,'ios':1,'android':0}, + 'win' : {'mac':0,'ios':0,'android':0}, + 'linux' : {'mac':0,'ios':0,'android':0} } curPlat = sys.platform @@ -48,71 +76,97 @@ def clean_project(): cmd = 'rm -rf '+proj+PROJ_SUFFIX os.system(cmd) -def create_project(): - print 'will create_project: ' - for proj in project_types: - print 'proj: ', proj - cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX - print proj,'cmd:',cmd - info_create = os.system(cmd) #call cmd on win is diff - print 'create project',proj,' is:', not info_create +FILE_PATH = '/Classes/AppDelegate.cpp' +FILE_DIR = { + 'cpp':'', + 'lua':'/frameworks/runtime-src' +} +PARSE_WORD = 'director->setDisplayStats(true);' +CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);' + +def addConsoleListenOnTCP(name): + filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH + print 'filePath:',filePath + strCont = '' + if os.path.isfile(filePath): + file_object = open(filePath, 'r') + strLine = file_object.readline() + while strLine: + strCont = strCont + strLine + if strLine.find(PARSE_WORD) > -1: + print 'add console listenOnTCP command.' + strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n' + strLine = file_object.readline() + + file_object.close() + file_object = open(filePath, 'w') + file_object.write(strCont) + file_object.close() + time.sleep(2) + else: + print 'file is not exist.' + +IP_PHONE = { + 'mac':'localhost', + 'ios':'localhost' +} +PORT = 5678 -def getAppPID(name): - cmd = 'ps -eo pid,comm | grep '+name - output = os.popen(cmd) - result = output.read() - arrProcess = result.split('\n') - print 'arrProcess:', arrProcess - def getProcessId(proInfo): - if len(proInfo) > 0: - arrInfo = proInfo.split(' ') - return int(arrInfo[0]) - return -1 - arrProIdx = [] - for content in arrProcess: - idx = getProcessId(content) - if idx > 0: - arrProIdx.append(idx) - return arrProIdx def close_proj(proj, phone): print 'close running project' - if curPlat == 'darwin': - if phone == 'android': - cmd = 'adb shell pm uninstall -n org.cocos2dx.hello'+proj - infoUninstall = os.system(cmd) - print 'infoUninstall apk:', infoUninstall, cmd - return infoUninstall == 0 - print 'will close proj:',proj,', on',curPlat - arrPids = getAppPID(proj+PROJ_SUFFIX) - print 'arrPids:', arrPids - for pid in arrPids: - cmd = 'kill ' - cmd += str(pid) - print 'cmd:',cmd - os.system(cmd) + # connect socket + if IP_PHONE.has_key(phone): + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + print proj, phone, IP_PHONE[phone] + try: + soc.connect((IP_PHONE[phone], PORT)) + cmd = 'director end\r\n' + print 'cmd close:', cmd + soc.send(cmd) + except Exception, e: + print 'socket is not connect.' + time.sleep(2) -def build_run(): - print 'will build and run' +def cocos_project(level): + print 'will cocos_project: ', level for proj in project_types: - idx = 0 - for phone in phonePlats: - cmd = './'+cocos_console_dir+'cocos run -p '+phone+' -s '+proj+PROJ_SUFFIX + print 'proj: ', proj + if level == ENUM_PARAM.new: + cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX print proj,'cmd:',cmd - if runSupport[curPlat][idx]: - info_run = os.system(cmd) - print 'run project', proj, 'is:', not info_run - if info_run == 0: - time.sleep(5) - close_proj(proj, phone) - time.sleep(2) - idx += 1 + info_create = os.system(cmd) #call cmd on win is diff + if info_create == 0: + time.sleep(12) + addConsoleListenOnTCP(proj) + print 'create project',proj,' is:', not info_create + else: + for phone in phonePlats: + print 'platform is: ', phone + cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone + print 'cmd:',cmd + if level == ENUM_PARAM.compile: + if runSupport[curPlat][phone]: + info_cmd = os.system(cmd) + print 'info '+COCOS_CMD[level]+':', not info_cmd + else : + if runSupport[curPlat][phone]: + info_cmd = os.system(cmd) + print 'info '+COCOS_CMD[level]+':', not info_cmd + if level == ENUM_PARAM.run: + time.sleep(10) + close_proj(proj, phone) + +def build_run(lv_ignore): + print 'will build and run' + for level in LEVEL_COCOS: + print 'level:', level, cocos_param, LEVEL_COCOS[level] + if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore: + if level == ENUM_PARAM.new: + clean_project() + cocos_project(level) def main(): - clean_project() - create_project() - if console_param_arr.count('run'): - build_run() - # close_proj('cpp', 'android') + build_run(-1) # -------------- main -------------- if __name__ == '__main__': @@ -124,4 +178,3 @@ if __name__ == '__main__': sys_ret = 1 finally: sys.exit(sys_ret) - From 411bb950250792440990c5c3ecff4d270ac741b2 Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Fri, 28 Mar 2014 13:50:06 +0800 Subject: [PATCH 06/17] add [director end] command's explain in CCConsole.cpp. --- cocos/base/CCConsole.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index f84b03efdc..792188a97d 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -586,6 +586,7 @@ void Console::commandDirector(int fd, const std::string& args) { const char help[] = "available director directives:\n" "\tpause, pause all scheduled timers, the draw rate will be 4 FPS to reduce CPU consumption\n" + "\tend, exit this app.\n" "\tresume, resume all scheduled timers\n" "\tstop, Stops the animation. Nothing will be drawn.\n" "\tstart, Restart the animation again, Call this function only if [director stop] was called earlier\n"; From 97883acfb1e4b3e29410da71b7f874d60ab81975 Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 28 Mar 2014 15:59:04 +0800 Subject: [PATCH 07/17] closed #4590, fixed rewind problems --- cocos/audio/ios/CDAudioManager.m | 2 ++ cocos/audio/mac/CDAudioManager.m | 1 + 2 files changed, 3 insertions(+) diff --git a/cocos/audio/ios/CDAudioManager.m b/cocos/audio/ios/CDAudioManager.m index beadffa7c8..56a6fb1be5 100644 --- a/cocos/audio/ios/CDAudioManager.m +++ b/cocos/audio/ios/CDAudioManager.m @@ -118,6 +118,8 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) rewind { self->paused = NO; [audioSourcePlayer setCurrentTime:0]; + [audioSourcePlayer play]; + stopped = NO; } -(void) resume { diff --git a/cocos/audio/mac/CDAudioManager.m b/cocos/audio/mac/CDAudioManager.m index 18d435e562..93a074fbf9 100644 --- a/cocos/audio/mac/CDAudioManager.m +++ b/cocos/audio/mac/CDAudioManager.m @@ -115,6 +115,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) rewind { self->paused = NO; [audioSourcePlayer setCurrentTime:0]; + [audioSourcePlayer play]; } -(void) resume { From 07d1a54a922c45b843c44621522cc65e296fafa1 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 28 Mar 2014 08:20:29 +0000 Subject: [PATCH 08/17] [AUTO]: updating luabinding automatically --- cocos/scripting/lua-bindings/auto/api/Label.lua | 10 +++++----- .../scripting/lua-bindings/auto/api/LabelBMFont.lua | 10 ++++++++++ cocos/scripting/lua-bindings/auto/api/LabelTTF.lua | 13 +++++++++---- .../auto/lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 - 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 391d6113bb..789d48198f 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -94,11 +94,6 @@ -- @param self -- @return FontDefinition#FontDefinition ret (return value: cc.FontDefinition) --------------------------------- --- @function [parent=#Label] getBoundingBox --- @param self --- @return rect_table#rect_table ret (return value: rect_table) - -------------------------------- -- @function [parent=#Label] getFontName -- @param self @@ -343,6 +338,11 @@ -- @param self -- @return size_table#size_table ret (return value: size_table) +-------------------------------- +-- @function [parent=#Label] getBoundingBox +-- @param self +-- @return rect_table#rect_table ret (return value: rect_table) + -------------------------------- -- @function [parent=#Label] updateDisplayedColor -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/LabelBMFont.lua b/cocos/scripting/lua-bindings/auto/api/LabelBMFont.lua index 825ce15f51..5c7e05d03a 100644 --- a/cocos/scripting/lua-bindings/auto/api/LabelBMFont.lua +++ b/cocos/scripting/lua-bindings/auto/api/LabelBMFont.lua @@ -89,6 +89,11 @@ -- @param #point_table point -- @return LabelBMFont#LabelBMFont ret (retunr value: cc.LabelBMFont) +-------------------------------- +-- @function [parent=#LabelBMFont] getBoundingBox +-- @param self +-- @return rect_table#rect_table ret (return value: rect_table) + -------------------------------- -- @function [parent=#LabelBMFont] getDescription -- @param self @@ -105,6 +110,11 @@ -- @param #int int -- @return Node#Node ret (return value: cc.Node) +-------------------------------- +-- @function [parent=#LabelBMFont] getContentSize +-- @param self +-- @return size_table#size_table ret (return value: size_table) + -------------------------------- -- @function [parent=#LabelBMFont] LabelBMFont -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua b/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua index a6a0ab9aa1..59ac364dab 100644 --- a/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua +++ b/cocos/scripting/lua-bindings/auto/api/LabelTTF.lua @@ -163,11 +163,9 @@ -- @return LabelTTF#LabelTTF ret (return value: cc.LabelTTF) -------------------------------- --- @function [parent=#LabelTTF] visit +-- @function [parent=#LabelTTF] getBoundingBox -- @param self --- @param #cc.Renderer renderer --- @param #kmMat4 kmmat4 --- @param #bool bool +-- @return rect_table#rect_table ret (return value: rect_table) -------------------------------- -- @function [parent=#LabelTTF] getDescription @@ -179,6 +177,13 @@ -- @param self -- @return size_table#size_table ret (return value: size_table) +-------------------------------- +-- @function [parent=#LabelTTF] visit +-- @param self +-- @param #cc.Renderer renderer +-- @param #kmMat4 kmmat4 +-- @param #bool bool + -------------------------------- -- @function [parent=#LabelTTF] LabelTTF -- @param self diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id index a9cb83db7d..3bc115b36a 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -7aff65efe54886d705b227ba45205bc6d4f8a650 \ No newline at end of file +55307bad4398fdd7bedf9a96f00adb57cbaa7d2e \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 682e55e5be..87bbdf1c67 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1561,7 +1561,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - #endif // __cocos2dx_h__ From 5a9af407dc207136d301ee0a10d1db42919d616e Mon Sep 17 00:00:00 2001 From: andyque Date: Fri, 28 Mar 2014 16:41:33 +0800 Subject: [PATCH 09/17] closed #4590, remove -> property access --- cocos/audio/ios/CDAudioManager.m | 20 ++++++++++---------- cocos/audio/mac/CDAudioManager.m | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos/audio/ios/CDAudioManager.m b/cocos/audio/ios/CDAudioManager.m index 56a6fb1be5..cc2d75c71e 100644 --- a/cocos/audio/ios/CDAudioManager.m +++ b/cocos/audio/ios/CDAudioManager.m @@ -95,9 +95,9 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) play { if (enabled_) { - self->systemPaused = NO; - self->paused = NO; - self->stopped = NO; + systemPaused = NO; + paused = NO; + stopped = NO; [audioSourcePlayer play]; } else { CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); @@ -105,18 +105,18 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; } -(void) stop { - self->paused = NO; - self->stopped = YES; + paused = NO; + stopped = YES; [audioSourcePlayer stop]; } -(void) pause { - self->paused = YES; + paused = YES; [audioSourcePlayer pause]; } -(void) rewind { - self->paused = NO; + paused = NO; [audioSourcePlayer setCurrentTime:0]; [audioSourcePlayer play]; stopped = NO; @@ -124,7 +124,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) resume { if (!stopped) { - self->paused = NO; + paused = NO; [audioSourcePlayer play]; } } @@ -625,7 +625,7 @@ static BOOL configured = FALSE; } - (void) applicationWillResignActive { - self->_resigned = YES; + _resigned = YES; //Set the audio sesssion to one that allows sharing so that other audio won't be clobbered on resume [self audioSessionSetCategory:AVAudioSessionCategoryAmbient]; @@ -670,7 +670,7 @@ static BOOL configured = FALSE; - (void) applicationDidBecomeActive { - if (self->_resigned) { + if (_resigned) { _resigned = NO; //Reset the mode incase something changed with audio while we were inactive [self setMode:_mode]; diff --git a/cocos/audio/mac/CDAudioManager.m b/cocos/audio/mac/CDAudioManager.m index 93a074fbf9..b5365af68c 100644 --- a/cocos/audio/mac/CDAudioManager.m +++ b/cocos/audio/mac/CDAudioManager.m @@ -94,8 +94,8 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) play { if (enabled_) { - self->systemPaused = NO; - self->paused = NO; + systemPaused = NO; + paused = NO; [audioSourcePlayer play]; } else { CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); @@ -103,23 +103,23 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; } -(void) stop { - self->paused = NO; + paused = NO; [audioSourcePlayer stop]; } -(void) pause { - self->paused = YES; + paused = YES; [audioSourcePlayer pause]; } -(void) rewind { - self->paused = NO; + paused = NO; [audioSourcePlayer setCurrentTime:0]; [audioSourcePlayer play]; } -(void) resume { - self->paused = NO; + paused = NO; [audioSourcePlayer resume]; } @@ -619,7 +619,7 @@ static BOOL configured = FALSE; } - (void) applicationWillResignActive { - self->_resigned = YES; + _resigned = YES; //Set the audio sesssion to one that allows sharing so that other audio won't be clobbered on resume [self audioSessionSetCategory:AVAudioSessionCategoryAmbient]; @@ -664,7 +664,7 @@ static BOOL configured = FALSE; - (void) applicationDidBecomeActive { - if (self->_resigned) { + if (_resigned) { _resigned = NO; //Reset the mode incase something changed with audio while we were inactive [self setMode:_mode]; From cb50741f5d6687ac9f7d20f7fffe6e3bab8d9444 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 28 Mar 2014 16:52:48 +0800 Subject: [PATCH 10/17] Fixed possible crash if invoking FontAtlasCache::purgeCachedData. --- cocos/2d/CCFontAtlasCache.cpp | 104 +++++++++++++++++----------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index c2679e464d..9a3f830d94 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -59,91 +59,91 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config) fontSize = Label::DistanceFieldFontSize / contentScaleFactor; } - std::string atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField); + auto atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField); atlasName.append("_outline_"); std::stringstream ss; ss << config.outlineSize; atlasName.append(ss.str()); - FontAtlas *tempAtlas = _atlasMap[atlasName]; + auto it = _atlasMap.find(atlasName); - if ( !tempAtlas ) + if ( it == _atlasMap.end() ) { - FontFreeType *font = FontFreeType::create(config.fontFilePath, fontSize * contentScaleFactor, config.glyphs, + auto font = FontFreeType::create(config.fontFilePath, fontSize * contentScaleFactor, config.glyphs, config.customGlyphs,useDistanceField,config.outlineSize * contentScaleFactor); if (font) { - tempAtlas = font->createFontAtlas(); + auto tempAtlas = font->createFontAtlas(); if (tempAtlas) + { _atlasMap[atlasName] = tempAtlas; - } - else - { - return nullptr; + return _atlasMap[atlasName]; + } } } else { - tempAtlas->retain(); + _atlasMap[atlasName]->retain(); + return _atlasMap[atlasName]; } - return tempAtlas; + return nullptr; } FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Point& imageOffset /* = Point::ZERO */) { std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false); - FontAtlas *tempAtlas = _atlasMap[atlasName]; - - if ( !tempAtlas ) + auto it = _atlasMap.find(atlasName); + + if ( it == _atlasMap.end() ) { - Font *font = FontFNT::create(fontFileName,imageOffset); + auto font = FontFNT::create(fontFileName,imageOffset); if(font) { - tempAtlas = font->createFontAtlas(); + auto tempAtlas = font->createFontAtlas(); if (tempAtlas) + { _atlasMap[atlasName] = tempAtlas; - } - else - { - return nullptr; + return _atlasMap[atlasName]; + } } } else { - tempAtlas->retain(); + _atlasMap[atlasName]->retain(); + return _atlasMap[atlasName]; } - return tempAtlas; + return nullptr; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& plistFile) { std::string atlasName = generateFontName(plistFile, 0, GlyphCollection::CUSTOM,false); - FontAtlas *tempAtlas = _atlasMap[atlasName]; + auto it = _atlasMap.find(atlasName); - if ( !tempAtlas ) + if ( it == _atlasMap.end() ) { - Font *font = FontCharMap::create(plistFile); + auto font = FontCharMap::create(plistFile); if(font) { - tempAtlas = font->createFontAtlas(); + auto tempAtlas = font->createFontAtlas(); if (tempAtlas) + { _atlasMap[atlasName] = tempAtlas; - } - else - { - return nullptr; + return _atlasMap[atlasName]; + } } } else { - tempAtlas->retain(); + _atlasMap[atlasName]->retain(); + return _atlasMap[atlasName]; } - return tempAtlas; + return nullptr; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap) @@ -151,57 +151,57 @@ FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidt char tmp[30]; sprintf(tmp,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap); std::string atlasName = generateFontName(tmp, 0, GlyphCollection::CUSTOM,false); - FontAtlas *tempAtlas = _atlasMap[atlasName]; - if ( !tempAtlas ) + auto it = _atlasMap.find(atlasName); + if ( it == _atlasMap.end() ) { - Font *font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap); + auto font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap); if(font) { - tempAtlas = font->createFontAtlas(); + auto tempAtlas = font->createFontAtlas(); if (tempAtlas) + { _atlasMap[atlasName] = tempAtlas; - } - else - { - return nullptr; + return _atlasMap[atlasName]; + } } } else { - tempAtlas->retain(); + _atlasMap[atlasName]->retain(); + return _atlasMap[atlasName]; } - return tempAtlas; + return nullptr; } FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { std::string atlasName = generateFontName(charMapFile, 0, GlyphCollection::CUSTOM,false); - FontAtlas *tempAtlas = _atlasMap[atlasName]; - if ( !tempAtlas ) + auto it = _atlasMap.find(atlasName); + if ( it == _atlasMap.end() ) { - Font *font = FontCharMap::create(charMapFile,itemWidth,itemHeight,startCharMap); + auto font = FontCharMap::create(charMapFile,itemWidth,itemHeight,startCharMap); if(font) { - tempAtlas = font->createFontAtlas(); + auto tempAtlas = font->createFontAtlas(); if (tempAtlas) + { _atlasMap[atlasName] = tempAtlas; - } - else - { - return nullptr; + return _atlasMap[atlasName]; + } } } else { - tempAtlas->retain(); + _atlasMap[atlasName]->retain(); + return _atlasMap[atlasName]; } - return tempAtlas; + return nullptr; } std::string FontAtlasCache::generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField) From 5d2c0eef78ef9c3d9cee015c95ac1f5e8ea5a45e Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 28 Mar 2014 17:24:15 +0800 Subject: [PATCH 11/17] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index 6b917c9e80..66756e9193 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -6c2de4f902af3946717774ed58863e53e6aa577b \ No newline at end of file +2edbaaa897088877d60090c2c8fc6725e699e4ee \ No newline at end of file From 5fc8050d9e61dcd858ed4320fd3e6a5a95400919 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 28 Mar 2014 17:45:06 +0800 Subject: [PATCH 12/17] Issue #3897: Add missed constructors --- cocos/2d/CCActionCamera.h | 37 +++++++++--------- cocos/2d/CCActionEase.h | 80 ++++++++++++++++++++------------------- cocos/2d/CCActionTween.h | 6 ++- 3 files changed, 66 insertions(+), 57 deletions(-) diff --git a/cocos/2d/CCActionCamera.h b/cocos/2d/CCActionCamera.h index 2c42590080..a5a027788e 100644 --- a/cocos/2d/CCActionCamera.h +++ b/cocos/2d/CCActionCamera.h @@ -96,20 +96,30 @@ class CC_DLL OrbitCamera : public ActionCamera // public: /** creates a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ static OrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + + /** positions the camera according to spherical coordinates */ + void sphericalRadius(float *r, float *zenith, float *azimuth); + + // Overrides + OrbitCamera *clone() const override; + virtual void startWithTarget(Node *target) override; + virtual void update(float time) override; + +CC_CONSTRUCTOR_ACCESS: /** * @js ctor */ OrbitCamera() - : _radius(0.0) - , _deltaRadius(0.0) - , _angleZ(0.0) - , _deltaAngleZ(0.0) - , _angleX(0.0) - , _deltaAngleX(0.0) - , _radZ(0.0) - , _radDeltaZ(0.0) - , _radX(0.0) - , _radDeltaX(0.0) + : _radius(0.0) + , _deltaRadius(0.0) + , _angleZ(0.0) + , _deltaAngleZ(0.0) + , _angleX(0.0) + , _deltaAngleX(0.0) + , _radZ(0.0) + , _radDeltaZ(0.0) + , _radX(0.0) + , _radDeltaX(0.0) {} /** * @js NA @@ -119,13 +129,6 @@ public: /** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); - /** positions the camera according to spherical coordinates */ - void sphericalRadius(float *r, float *zenith, float *azimuth); - - // Overrides - OrbitCamera *clone() const override; - virtual void startWithTarget(Node *target) override; - virtual void update(float time) override; protected: float _radius; diff --git a/cocos/2d/CCActionEase.h b/cocos/2d/CCActionEase.h index 0a988994e0..f427584c9b 100644 --- a/cocos/2d/CCActionEase.h +++ b/cocos/2d/CCActionEase.h @@ -55,12 +55,13 @@ public: virtual void stop() override; virtual void update(float time) override; -protected: +CC_CONSTRUCTOR_ACCESS: ActionEase() {} virtual ~ActionEase(); /** initializes the action */ bool initWithAction(ActionInterval *action); +protected: /** The inner action */ ActionInterval *_inner; private: @@ -85,12 +86,13 @@ public: virtual EaseRateAction* clone() const override = 0; virtual EaseRateAction* reverse() const override = 0; -protected: +CC_CONSTRUCTOR_ACCESS: EaseRateAction() {} virtual ~EaseRateAction(); /** Initializes the action with the inner action and the rate parameter */ bool initWithAction(ActionInterval *pAction, float fRate); +protected: float _rate; private: @@ -112,7 +114,7 @@ public: virtual EaseIn* clone() const override; virtual EaseIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseIn() {} virtual ~EaseIn() {} @@ -135,7 +137,7 @@ public: virtual EaseOut* clone() const override; virtual EaseOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseOut() {} virtual ~EaseOut() {} @@ -158,7 +160,7 @@ public: virtual EaseInOut* clone() const override; virtual EaseInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseInOut() {} virtual ~EaseInOut() {} @@ -181,7 +183,7 @@ public: virtual EaseExponentialIn* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseExponentialIn() {} virtual ~EaseExponentialIn() {} @@ -204,7 +206,7 @@ public: virtual EaseExponentialOut* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseExponentialOut() {} virtual ~EaseExponentialOut() {} @@ -227,7 +229,7 @@ public: virtual EaseExponentialInOut* clone() const override; virtual EaseExponentialInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseExponentialInOut() {} virtual ~EaseExponentialInOut() {} @@ -250,7 +252,7 @@ public: virtual EaseSineIn* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseSineIn() {} virtual ~EaseSineIn() {} @@ -273,7 +275,7 @@ public: virtual EaseSineOut* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseSineOut() {} virtual ~EaseSineOut() {} @@ -296,7 +298,7 @@ public: virtual EaseSineInOut* clone() const override; virtual EaseSineInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseSineInOut() {} virtual ~EaseSineInOut() {} @@ -324,12 +326,13 @@ public: virtual EaseElastic* clone() const override = 0; virtual EaseElastic* reverse() const override = 0; -protected: +CC_CONSTRUCTOR_ACCESS: EaseElastic() {} virtual ~EaseElastic() {} /** Initializes the action with the inner action and the period in radians (default is 0.3) */ bool initWithAction(ActionInterval *action, float period = 0.3f); +protected: float _period; private: @@ -355,7 +358,7 @@ public: virtual EaseElasticIn* clone() const override; virtual EaseElastic* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseElasticIn() {} virtual ~EaseElasticIn() {} @@ -381,7 +384,7 @@ public: virtual EaseElasticOut* clone() const override; virtual EaseElastic* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseElasticOut() {} virtual ~EaseElasticOut() {} @@ -407,7 +410,7 @@ public: virtual EaseElasticInOut* clone() const override; virtual EaseElasticInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseElasticInOut() {} virtual ~EaseElasticInOut() {} @@ -428,7 +431,7 @@ public: virtual EaseBounce* clone() const override = 0; virtual EaseBounce* reverse() const override = 0; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBounce() {} virtual ~EaseBounce() {} @@ -453,7 +456,7 @@ public: virtual EaseBounceIn* clone() const override; virtual EaseBounce* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBounceIn() {} virtual ~EaseBounceIn() {} @@ -478,7 +481,7 @@ public: virtual EaseBounceOut* clone() const override; virtual EaseBounce* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBounceOut() {} virtual ~EaseBounceOut() {} @@ -503,7 +506,7 @@ public: virtual EaseBounceInOut* clone() const override; virtual EaseBounceInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBounceInOut() {} virtual ~EaseBounceInOut() {} @@ -528,7 +531,7 @@ public: virtual EaseBackIn* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBackIn() {} virtual ~EaseBackIn() {} @@ -553,7 +556,7 @@ public: virtual EaseBackOut* clone() const override; virtual ActionEase* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBackOut() {} virtual ~EaseBackOut() {} @@ -578,7 +581,7 @@ public: virtual EaseBackInOut* clone() const override; virtual EaseBackInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseBackInOut() {} virtual ~EaseBackInOut() {} @@ -603,10 +606,11 @@ public: virtual void setBezierParamer( float p0, float p1, float p2, float p3); -protected: +CC_CONSTRUCTOR_ACCESS: EaseBezierAction() {} virtual ~EaseBezierAction() {} +protected: float _p0; float _p1; float _p2; @@ -630,7 +634,7 @@ public: virtual EaseQuadraticActionIn* clone() const override; virtual EaseQuadraticActionIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuadraticActionIn() {} virtual ~EaseQuadraticActionIn() {} @@ -653,7 +657,7 @@ public: virtual EaseQuadraticActionOut* clone() const override; virtual EaseQuadraticActionOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuadraticActionOut() {} virtual ~EaseQuadraticActionOut() {} @@ -676,7 +680,7 @@ public: virtual EaseQuadraticActionInOut* clone() const override; virtual EaseQuadraticActionInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuadraticActionInOut() {} virtual ~EaseQuadraticActionInOut() {} @@ -698,7 +702,7 @@ public: virtual EaseQuarticActionIn* clone() const override; virtual EaseQuarticActionIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuarticActionIn() {} virtual ~EaseQuarticActionIn() {} @@ -720,7 +724,7 @@ public: virtual EaseQuarticActionOut* clone() const override; virtual EaseQuarticActionOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuarticActionOut() {} virtual ~EaseQuarticActionOut() {} @@ -742,7 +746,7 @@ public: virtual EaseQuarticActionInOut* clone() const override; virtual EaseQuarticActionInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuarticActionInOut() {} virtual ~EaseQuarticActionInOut() {} @@ -765,7 +769,7 @@ public: virtual EaseQuinticActionIn* clone() const override; virtual EaseQuinticActionIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuinticActionIn() {} virtual ~EaseQuinticActionIn() {} @@ -787,7 +791,7 @@ public: virtual EaseQuinticActionOut* clone() const override; virtual EaseQuinticActionOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuinticActionOut() {} virtual ~EaseQuinticActionOut() {} @@ -809,7 +813,7 @@ public: virtual EaseQuinticActionInOut* clone() const override; virtual EaseQuinticActionInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseQuinticActionInOut() {} virtual ~EaseQuinticActionInOut() {} @@ -831,7 +835,7 @@ public: virtual EaseCircleActionIn* clone() const override; virtual EaseCircleActionIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCircleActionIn() {} virtual ~EaseCircleActionIn() {} @@ -853,7 +857,7 @@ public: virtual EaseCircleActionOut* clone() const override; virtual EaseCircleActionOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCircleActionOut() {} virtual ~EaseCircleActionOut() {} @@ -875,7 +879,7 @@ public: virtual EaseCircleActionInOut* clone() const override; virtual EaseCircleActionInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCircleActionInOut() {} virtual ~EaseCircleActionInOut() {} @@ -897,7 +901,7 @@ public: virtual EaseCubicActionIn* clone() const override; virtual EaseCubicActionIn* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCubicActionIn() {} virtual ~EaseCubicActionIn() {} @@ -919,7 +923,7 @@ public: virtual EaseCubicActionOut* clone() const override; virtual EaseCubicActionOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCubicActionOut() {} virtual ~EaseCubicActionOut() {} @@ -941,7 +945,7 @@ public: virtual EaseCubicActionInOut* clone() const override; virtual EaseCubicActionInOut* reverse() const override; -protected: +CC_CONSTRUCTOR_ACCESS: EaseCubicActionInOut() {} virtual ~EaseCubicActionInOut() {} diff --git a/cocos/2d/CCActionTween.h b/cocos/2d/CCActionTween.h index e4681a9037..51745887b5 100644 --- a/cocos/2d/CCActionTween.h +++ b/cocos/2d/CCActionTween.h @@ -71,14 +71,16 @@ class CC_DLL ActionTween : public ActionInterval public: /** creates an initializes the action with the property name (key), and the from and to parameters. */ static ActionTween* create(float duration, const std::string& key, float from, float to); - /** initializes the action with the property name (key), and the from and to parameters. */ - bool initWithDuration(float duration, const std::string& key, float from, float to); // Overrides void startWithTarget(Node *target) override; void update(float dt) override; ActionTween* reverse() const override; ActionTween *clone() const override; + +CC_CONSTRUCTOR_ACCESS: + /** initializes the action with the property name (key), and the from and to parameters. */ + bool initWithDuration(float duration, const std::string& key, float from, float to); protected: std::string _key; From 338fd43bebfb1e759c3a44d0892138ac0813b939 Mon Sep 17 00:00:00 2001 From: zhangbin Date: Fri, 28 Mar 2014 17:45:28 +0800 Subject: [PATCH 13/17] Solve the error effect of clipping in cpp-tests & lua-tests. --- .../src/org/cocos2dx/cpp_tests/AppActivity.java | 9 +++++++++ .../src/org/cocos2dx/lua_tests/AppActivity.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/tests/cpp-tests/proj.android/src/org/cocos2dx/cpp_tests/AppActivity.java b/tests/cpp-tests/proj.android/src/org/cocos2dx/cpp_tests/AppActivity.java index 0143698c6b..4934ed0bee 100644 --- a/tests/cpp-tests/proj.android/src/org/cocos2dx/cpp_tests/AppActivity.java +++ b/tests/cpp-tests/proj.android/src/org/cocos2dx/cpp_tests/AppActivity.java @@ -24,6 +24,15 @@ THE SOFTWARE. package org.cocos2dx.cpp_tests; import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxGLSurfaceView; public class AppActivity extends Cocos2dxActivity { + + public Cocos2dxGLSurfaceView onCreateView() { + Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); + // TestCpp should create stencil buffer + glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + + return glSurfaceView; + } } diff --git a/tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/AppActivity.java b/tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/AppActivity.java index 8ed200e445..03cc339979 100644 --- a/tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/AppActivity.java +++ b/tests/lua-tests/project/proj.android/src/org/cocos2dx/lua_tests/AppActivity.java @@ -1,6 +1,15 @@ package org.cocos2dx.lua_tests; import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxGLSurfaceView; public class AppActivity extends Cocos2dxActivity{ + + public Cocos2dxGLSurfaceView onCreateView() { + Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); + // Tests should create stencil buffer + glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + + return glSurfaceView; + } } From 26f5107381dc4e27809c49db25627a20320ceaa7 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 28 Mar 2014 17:45:35 +0800 Subject: [PATCH 14/17] Reverse CONSTRUCTOR_ACCESS to protected --- cocos/2d/ccConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/ccConfig.h b/cocos/2d/ccConfig.h index 87e2c19d7d..b9a7ef70a3 100644 --- a/cocos/2d/ccConfig.h +++ b/cocos/2d/ccConfig.h @@ -284,7 +284,7 @@ To enable set it to a value different than 0. Disabled by default. protected by default. */ #ifndef CC_CONSTRUCTOR_ACCESS -#define CC_CONSTRUCTOR_ACCESS public +#define CC_CONSTRUCTOR_ACCESS protected #endif #endif // __CCCONFIG_H__ From 27f1ded3cd0773f111e7eb3dd40b71949de0973f Mon Sep 17 00:00:00 2001 From: shujunqiao Date: Fri, 28 Mar 2014 17:50:07 +0800 Subject: [PATCH 15/17] add android part in cocos-console-test. --- tools/jenkins-scripts/cocos-console-test.py | 82 +++++++++++++++++---- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index 4207ccd248..7a6e999d77 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -1,16 +1,20 @@ #!/usr/bin/python -#create new project by cocos-console -#build new project and run +# create new project by cocos-console +# compile, deploy project and run +# perpose: for autotest cocos2d-console command. +# now support: mac- mac/ios/android +# will add: window-android,linux-android import os +import subprocess import sys import json import time import socket -# get payload argvs +# default console_param. console_param = '[console run]' -# payload = '' +# get param from commit. if os.environ.has_key('payload'): payload_str = os.environ['payload'] payload = json.loads(payload_str) @@ -21,12 +25,14 @@ print 'console_param:',console_param console_param_arr = console_param.split(' ') +# enum command type class ENUM_PARAM: new = 0 compile = 1 deploy = 2 run = 3 +# partition different level LEVEL_COCOS = { ENUM_PARAM.new : 1, ENUM_PARAM.compile : 2, @@ -34,6 +40,7 @@ LEVEL_COCOS = { ENUM_PARAM.run : 8 } +# level's cocos command COCOS_CMD = { ENUM_PARAM.new:'new', ENUM_PARAM.compile:'compile', @@ -41,6 +48,7 @@ COCOS_CMD = { ENUM_PARAM.run:'run' } +# set cocos_param for run different command cocos_param = 0 for level in LEVEL_COCOS: if console_param_arr.count(COCOS_CMD[level]): @@ -48,20 +56,25 @@ for level in LEVEL_COCOS: if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]: cocos_param = LEVEL_COCOS[ENUM_PARAM.new] print 'cocos_param:', cocos_param + +# project types project_types = ['cpp', 'lua'] +# project suffix PROJ_SUFFIX = 'Proj' +# different phone platform phonePlats = ['mac','ios','android'] -#need use console's position, perhaps should be set an env-param +# need use console's position, perhaps should be set an env-param cocos_console_dir = 'tools/cocos2d-console/bin/' -#now cocos2d-console suport different run on Platforms, e.g: only run android on win +# now cocos2d-console suport different run on Platforms, e.g: only run android on win runSupport = { - 'darwin' : {'mac':1,'ios':1,'android':0}, - 'win' : {'mac':0,'ios':0,'android':0}, - 'linux' : {'mac':0,'ios':0,'android':0} + 'darwin' : {'mac':1,'ios':1,'android':1}, + 'win' : {'mac':0,'ios':0,'android':1}, + 'linux' : {'mac':0,'ios':0,'android':1} } +# get current running system curPlat = sys.platform if curPlat.find('linux') >= 0: curPlat = 'linux' @@ -71,11 +84,13 @@ else: curPlat = 'win' print 'current platform is:', curPlat +# delete project.(will use different system command to delete.just mac now.) def clean_project(): for proj in project_types: cmd = 'rm -rf '+proj+PROJ_SUFFIX os.system(cmd) +# file path.(for add console listen command.) FILE_PATH = '/Classes/AppDelegate.cpp' FILE_DIR = { 'cpp':'', @@ -84,6 +99,7 @@ FILE_DIR = { PARSE_WORD = 'director->setDisplayStats(true);' CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);' +# add console listenOnTCP to AppDelegate.cpp. def addConsoleListenOnTCP(name): filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH print 'filePath:',filePath @@ -106,6 +122,19 @@ def addConsoleListenOnTCP(name): else: print 'file is not exist.' +# get current android devices count. +def getAndroidDevices(): + cmd = 'adb devices' + info_devices = os.popen(cmd).read() + arrDevices = info_devices.split('\n') + del arrDevices[0] + count = 0 + for device in arrDevices: + if len(device) > 0: + count += 1 + return count + +# close running app or exe by using console command. IP_PHONE = { 'mac':'localhost', 'ios':'localhost' @@ -127,8 +156,9 @@ def close_proj(proj, phone): print 'socket is not connect.' time.sleep(2) +# excute cocos command def cocos_project(level): - print 'will cocos_project: ', level + print 'will excute cocos_command: ', COCOS_CMD[level] for proj in project_types: print 'proj: ', proj if level == ENUM_PARAM.new: @@ -150,12 +180,16 @@ def cocos_project(level): print 'info '+COCOS_CMD[level]+':', not info_cmd else : if runSupport[curPlat][phone]: + if phone == 'android' and getAndroidDevices() == 0: + print 'no android device, please checkout the device is running ok.' + continue info_cmd = os.system(cmd) print 'info '+COCOS_CMD[level]+':', not info_cmd if level == ENUM_PARAM.run: - time.sleep(10) + time.sleep(20) close_proj(proj, phone) +# build and run according to params of provided.(lv_ignore: e.g:ignore new) def build_run(lv_ignore): print 'will build and run' for level in LEVEL_COCOS: @@ -165,16 +199,32 @@ def build_run(lv_ignore): clean_project() cocos_project(level) +# android simulator name. +ANDROID_SIMULATOR_NAME = 'console-test' +# start android simulator if no android devices connected. +def start_android_simulator(): + if getAndroidDevices() > 0: + print 'already connected android device.' + return + if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]: + cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ] + print 'cmd_start:', cmd_start + info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + print 'start an android simulator:', not info_start + def main(): + print 'in main:' + start_android_simulator() + print 'will build_run:' build_run(-1) # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 - try: - sys_ret = main() + try: + sys_ret = main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) From 74a4aa793ddf1f8cf17634f3d7f67c13dde2474f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 28 Mar 2014 18:00:25 +0800 Subject: [PATCH 16/17] Issue #3897: Move OrbitCamera constructor into cpp --- cocos/2d/CCActionCamera.cpp | 17 +++++++++++++++++ cocos/2d/CCActionCamera.h | 17 +++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index b11f6e40cd..55b4e8d255 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -129,6 +129,23 @@ void ActionCamera::updateTransform() // OrbitCamera // +OrbitCamera::OrbitCamera() +: _radius(0.0) +, _deltaRadius(0.0) +, _angleZ(0.0) +, _deltaAngleZ(0.0) +, _angleX(0.0) +, _deltaAngleX(0.0) +, _radZ(0.0) +, _radDeltaZ(0.0) +, _radX(0.0) +, _radDeltaX(0.0) +{ +} +OrbitCamera::~OrbitCamera() +{ +} + OrbitCamera * OrbitCamera::create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) { OrbitCamera * obitCamera = new OrbitCamera(); diff --git a/cocos/2d/CCActionCamera.h b/cocos/2d/CCActionCamera.h index a5a027788e..4cc1a44800 100644 --- a/cocos/2d/CCActionCamera.h +++ b/cocos/2d/CCActionCamera.h @@ -55,7 +55,7 @@ public: * @js NA * @lua NA */ - virtual ~ActionCamera(){} + virtual ~ActionCamera(){}; // Overrides virtual void startWithTarget(Node *target) override; @@ -109,23 +109,12 @@ CC_CONSTRUCTOR_ACCESS: /** * @js ctor */ - OrbitCamera() - : _radius(0.0) - , _deltaRadius(0.0) - , _angleZ(0.0) - , _deltaAngleZ(0.0) - , _angleX(0.0) - , _deltaAngleX(0.0) - , _radZ(0.0) - , _radDeltaZ(0.0) - , _radX(0.0) - , _radDeltaX(0.0) - {} + OrbitCamera(); /** * @js NA * @lua NA */ - virtual ~OrbitCamera(){} + virtual ~OrbitCamera(); /** initializes a OrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); From 494321a674dd95264135a5020e069bbd30f515d0 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 28 Mar 2014 10:11:08 +0000 Subject: [PATCH 17/17] [AUTO]: updating luabinding automatically --- .../lua-bindings/auto/api/ActionTween.lua | 9 --------- .../lua-bindings/auto/api/OrbitCamera.lua | 16 ---------------- .../auto/lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 3 --- 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/api/ActionTween.lua b/cocos/scripting/lua-bindings/auto/api/ActionTween.lua index 459497dfdd..eb876c924d 100644 --- a/cocos/scripting/lua-bindings/auto/api/ActionTween.lua +++ b/cocos/scripting/lua-bindings/auto/api/ActionTween.lua @@ -3,15 +3,6 @@ -- @module ActionTween -- @extend ActionInterval --------------------------------- --- @function [parent=#ActionTween] initWithDuration --- @param self --- @param #float float --- @param #string str --- @param #float float --- @param #float float --- @return bool#bool ret (return value: bool) - -------------------------------- -- @function [parent=#ActionTween] create -- @param self diff --git a/cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua b/cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua index f36b94ebbd..f2e0677478 100644 --- a/cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua +++ b/cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua @@ -10,18 +10,6 @@ -- @param #float float -- @param #float float --------------------------------- --- @function [parent=#OrbitCamera] initWithDuration --- @param self --- @param #float float --- @param #float float --- @param #float float --- @param #float float --- @param #float float --- @param #float float --- @param #float float --- @return bool#bool ret (return value: bool) - -------------------------------- -- @function [parent=#OrbitCamera] create -- @param self @@ -49,8 +37,4 @@ -- @param self -- @param #float float --------------------------------- --- @function [parent=#OrbitCamera] OrbitCamera --- @param self - return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id index 3bc115b36a..74a075d651 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -55307bad4398fdd7bedf9a96f00adb57cbaa7d2e \ No newline at end of file +ff3f22e8f1e3ebfc8f908ea0a9d6cb9d0b06ba54 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 87bbdf1c67..ed1d7969aa 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1556,9 +1556,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - - -