Merge pull request #47 from cocos2d/v3

update cocos2d-x
This commit is contained in:
cocoscodeide 2014-07-12 10:49:44 +08:00
commit be5da3d74d
457 changed files with 17491 additions and 5017 deletions

View File

@ -886,6 +886,7 @@ Developers:
zhouxiaoxiaoxujian zhouxiaoxiaoxujian
Added TextField::getStringLength() Added TextField::getStringLength()
Add shadow, outline, glow filter support for UIText Add shadow, outline, glow filter support for UIText
Fix UITextField IME can't auto detach
QiuleiWang QiuleiWang
Fix the bug that calculated height of multi-line string was incorrect on iOS Fix the bug that calculated height of multi-line string was incorrect on iOS
@ -907,6 +908,9 @@ Developers:
Teivaz Teivaz
Custom uniform search optimization Custom uniform search optimization
chareice
Make `setup.py` work on zsh
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang
Author of windows port, CCTextField, Author of windows port, CCTextField,

View File

@ -1,4 +1,22 @@
cocos2d-x-3.2rc0 ?? cocos2d-x-3.2 ??
[FIX] Animation3D: getOrCreate is deprecated and replaced with Animation3D::create
[FIX] Animate3D: setSpeed() accept negtive value, which means play reverse, getPlayback and setPlayBack are deprecated
[FIX] GLView: cursor position is not correct if design resolution is different from device resolution
[FIX] Label: color can not be set correctly if using system font
[FIX] Lua-binding: support UIVideoPlayer
[FIX] Node: setRotation3D not work based on anchor point
[FIX] Node: modify regular of enumerateChildren, now it just searchs its children
[FIX] Setup.py: not work if using zsh
[FIX] SpriteBatchNode: opacity can not work
[FIX] Sprite3D: may crash on Android if playing animation and replace Scene after come from background
[FIX] UIdget: opacity is wrong when replace texture
[FIX] UITextField: keyboard can not hide if touching space outside of keyboard
[FIX] Others: don't release singleton objects correctly that are needed in the whole game, which will be treated
as memory leak when using VLD.
cocos2d-x-3.2rc0 Jul.7 2014
[NEW] FastTMXTiledMap: added fast tmx, which is much more faster for static tiled map [NEW] FastTMXTiledMap: added fast tmx, which is much more faster for static tiled map
[NEW] GLProgramState: can use uniform location to get/set uniform values [NEW] GLProgramState: can use uniform location to get/set uniform values
[NEW] HttpClient: added sendImmediate() [NEW] HttpClient: added sendImmediate()

View File

@ -8,7 +8,7 @@ import shutil
from optparse import OptionParser from optparse import OptionParser
CPP_SAMPLES = ['cpp-empty-test', 'cpp-tests', 'game-controller-test'] CPP_SAMPLES = ['cpp-empty-test', 'cpp-tests', 'game-controller-test']
LUA_SAMPLES = ['lua-empty-test', 'lua-tests'] LUA_SAMPLES = ['lua-empty-test', 'lua-tests', 'lua-game-controller-test']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
def get_num_of_cpu(): def get_num_of_cpu():
@ -172,6 +172,10 @@ def copy_resources(target, app_android_root):
resources_dir = os.path.join(app_android_root, "../../../cpp-tests/Resources") resources_dir = os.path.join(app_android_root, "../../../cpp-tests/Resources")
copy_files(resources_dir, assets_res_dir) copy_files(resources_dir, assets_res_dir)
if target == "lua-game-controller-test":
print("coming generator game controller")
resources_dir = os.path.join(app_android_root, "../../../game-controller-test/Resources")
copy_files(resources_dir, assets_res_dir)
def build_samples(target,ndk_build_param,android_platform,build_mode): def build_samples(target,ndk_build_param,android_platform,build_mode):
@ -203,7 +207,8 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
"game-controller-test": "tests/game-controller-test/proj.android", "game-controller-test": "tests/game-controller-test/proj.android",
"cpp-tests": "tests/cpp-tests/proj.android", "cpp-tests": "tests/cpp-tests/proj.android",
"lua-empty-test": "tests/lua-empty-test/project/proj.android", "lua-empty-test": "tests/lua-empty-test/project/proj.android",
"lua-tests": "tests/lua-tests/project/proj.android" "lua-tests": "tests/lua-tests/project/proj.android",
"lua-game-controller-test": "tests/lua-game-controller-test/project/proj.android"
} }
for target in build_targets: for target in build_targets:

View File

@ -1025,23 +1025,12 @@
373B912A187891FB00198F86 /* CCComBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 373B910718787C0B00198F86 /* CCComBase.h */; }; 373B912A187891FB00198F86 /* CCComBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 373B910718787C0B00198F86 /* CCComBase.h */; };
3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */; }; 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */; };
3E6176691960F89B00DE83F5 /* CCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176561960F89B00DE83F5 /* CCController.h */; }; 3E6176691960F89B00DE83F5 /* CCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176561960F89B00DE83F5 /* CCController.h */; };
3E61766A1960F89B00DE83F5 /* CCControllerAxisInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */; };
3E61766B1960F89B00DE83F5 /* CCControllerAxisInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */; };
3E61766C1960F89B00DE83F5 /* CCControllerButtonInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */; };
3E61766D1960F89B00DE83F5 /* CCControllerButtonInput.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */; };
3E61766E1960F89B00DE83F5 /* CCControllerDirectionPad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */; };
3E61766F1960F89B00DE83F5 /* CCControllerDirectionPad.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */; };
3E6176701960F89B00DE83F5 /* CCControllerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */; };
3E6176711960F89B00DE83F5 /* CCControllerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E61765E1960F89B00DE83F5 /* CCControllerElement.h */; };
3E6176721960F89B00DE83F5 /* CCControllerThumbstick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */; };
3E6176731960F89B00DE83F5 /* CCControllerThumbstick.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */; };
3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176611960F89B00DE83F5 /* CCEventController.cpp */; }; 3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176611960F89B00DE83F5 /* CCEventController.cpp */; };
3E6176751960F89B00DE83F5 /* CCEventController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176621960F89B00DE83F5 /* CCEventController.h */; }; 3E6176751960F89B00DE83F5 /* CCEventController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176621960F89B00DE83F5 /* CCEventController.h */; };
3E6176761960F89B00DE83F5 /* CCEventListenerController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */; }; 3E6176761960F89B00DE83F5 /* CCEventListenerController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */; };
3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */; }; 3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */; };
3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176651960F89B00DE83F5 /* CCGameController.h */; }; 3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176651960F89B00DE83F5 /* CCGameController.h */; };
3E6176791960F89B00DE83F5 /* CCGamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176661960F89B00DE83F5 /* CCGamepad.cpp */; }; 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61781C1966A5A300DE83F5 /* CCController.cpp */; };
3E61767A1960F89B00DE83F5 /* CCGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176671960F89B00DE83F5 /* CCGamepad.h */; };
3EA0FB6B191C841D00B170C8 /* UIVideoPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */; }; 3EA0FB6B191C841D00B170C8 /* UIVideoPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */; };
3EA0FB6C191C841D00B170C8 /* UIVideoPlayerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */; }; 3EA0FB6C191C841D00B170C8 /* UIVideoPlayerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */; };
3EA47870195478E00068D9D1 /* CCBundleReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */; }; 3EA47870195478E00068D9D1 /* CCBundleReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */; };
@ -2370,23 +2359,12 @@
37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = "<group>"; }; 37936A3E1869B76800E974DD /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = "<group>"; };
3E6176551960F89B00DE83F5 /* CCController-iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "CCController-iOS.mm"; path = "../base/CCController-iOS.mm"; sourceTree = "<group>"; }; 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "CCController-iOS.mm"; path = "../base/CCController-iOS.mm"; sourceTree = "<group>"; };
3E6176561960F89B00DE83F5 /* CCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCController.h; path = ../base/CCController.h; sourceTree = "<group>"; }; 3E6176561960F89B00DE83F5 /* CCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCController.h; path = ../base/CCController.h; sourceTree = "<group>"; };
3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerAxisInput.cpp; path = ../base/CCControllerAxisInput.cpp; sourceTree = "<group>"; };
3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerAxisInput.h; path = ../base/CCControllerAxisInput.h; sourceTree = "<group>"; };
3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerButtonInput.cpp; path = ../base/CCControllerButtonInput.cpp; sourceTree = "<group>"; };
3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerButtonInput.h; path = ../base/CCControllerButtonInput.h; sourceTree = "<group>"; };
3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerDirectionPad.cpp; path = ../base/CCControllerDirectionPad.cpp; sourceTree = "<group>"; };
3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerDirectionPad.h; path = ../base/CCControllerDirectionPad.h; sourceTree = "<group>"; };
3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerElement.cpp; path = ../base/CCControllerElement.cpp; sourceTree = "<group>"; };
3E61765E1960F89B00DE83F5 /* CCControllerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerElement.h; path = ../base/CCControllerElement.h; sourceTree = "<group>"; };
3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCControllerThumbstick.cpp; path = ../base/CCControllerThumbstick.cpp; sourceTree = "<group>"; };
3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCControllerThumbstick.h; path = ../base/CCControllerThumbstick.h; sourceTree = "<group>"; };
3E6176611960F89B00DE83F5 /* CCEventController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventController.cpp; path = ../base/CCEventController.cpp; sourceTree = "<group>"; }; 3E6176611960F89B00DE83F5 /* CCEventController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventController.cpp; path = ../base/CCEventController.cpp; sourceTree = "<group>"; };
3E6176621960F89B00DE83F5 /* CCEventController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventController.h; path = ../base/CCEventController.h; sourceTree = "<group>"; }; 3E6176621960F89B00DE83F5 /* CCEventController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventController.h; path = ../base/CCEventController.h; sourceTree = "<group>"; };
3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventListenerController.cpp; path = ../base/CCEventListenerController.cpp; sourceTree = "<group>"; }; 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCEventListenerController.cpp; path = ../base/CCEventListenerController.cpp; sourceTree = "<group>"; };
3E6176641960F89B00DE83F5 /* CCEventListenerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventListenerController.h; path = ../base/CCEventListenerController.h; sourceTree = "<group>"; }; 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventListenerController.h; path = ../base/CCEventListenerController.h; sourceTree = "<group>"; };
3E6176651960F89B00DE83F5 /* CCGameController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGameController.h; path = ../base/CCGameController.h; sourceTree = "<group>"; }; 3E6176651960F89B00DE83F5 /* CCGameController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGameController.h; path = ../base/CCGameController.h; sourceTree = "<group>"; };
3E6176661960F89B00DE83F5 /* CCGamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCGamepad.cpp; path = ../base/CCGamepad.cpp; sourceTree = "<group>"; }; 3E61781C1966A5A300DE83F5 /* CCController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCController.cpp; path = ../base/CCController.cpp; sourceTree = "<group>"; };
3E6176671960F89B00DE83F5 /* CCGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGamepad.h; path = ../base/CCGamepad.h; sourceTree = "<group>"; };
3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayer.h; sourceTree = "<group>"; }; 3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayer.h; sourceTree = "<group>"; };
3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIVideoPlayerIOS.mm; sourceTree = "<group>"; }; 3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIVideoPlayerIOS.mm; sourceTree = "<group>"; };
3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBundleReader.cpp; sourceTree = "<group>"; }; 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBundleReader.cpp; sourceTree = "<group>"; };
@ -3187,25 +3165,14 @@
1A5700A2180BC5E60088DEC7 /* base */ = { 1A5700A2180BC5E60088DEC7 /* base */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3E61781C1966A5A300DE83F5 /* CCController.cpp */,
3E6176551960F89B00DE83F5 /* CCController-iOS.mm */, 3E6176551960F89B00DE83F5 /* CCController-iOS.mm */,
3E6176561960F89B00DE83F5 /* CCController.h */, 3E6176561960F89B00DE83F5 /* CCController.h */,
3E6176571960F89B00DE83F5 /* CCControllerAxisInput.cpp */,
3E6176581960F89B00DE83F5 /* CCControllerAxisInput.h */,
3E6176591960F89B00DE83F5 /* CCControllerButtonInput.cpp */,
3E61765A1960F89B00DE83F5 /* CCControllerButtonInput.h */,
3E61765B1960F89B00DE83F5 /* CCControllerDirectionPad.cpp */,
3E61765C1960F89B00DE83F5 /* CCControllerDirectionPad.h */,
3E61765D1960F89B00DE83F5 /* CCControllerElement.cpp */,
3E61765E1960F89B00DE83F5 /* CCControllerElement.h */,
3E61765F1960F89B00DE83F5 /* CCControllerThumbstick.cpp */,
3E6176601960F89B00DE83F5 /* CCControllerThumbstick.h */,
3E6176611960F89B00DE83F5 /* CCEventController.cpp */, 3E6176611960F89B00DE83F5 /* CCEventController.cpp */,
3E6176621960F89B00DE83F5 /* CCEventController.h */, 3E6176621960F89B00DE83F5 /* CCEventController.h */,
3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */, 3E6176631960F89B00DE83F5 /* CCEventListenerController.cpp */,
3E6176641960F89B00DE83F5 /* CCEventListenerController.h */, 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */,
3E6176651960F89B00DE83F5 /* CCGameController.h */, 3E6176651960F89B00DE83F5 /* CCGameController.h */,
3E6176661960F89B00DE83F5 /* CCGamepad.cpp */,
3E6176671960F89B00DE83F5 /* CCGamepad.h */,
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */, 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */,
299754F3193EC95400A54AC3 /* ObjectFactory.h */, 299754F3193EC95400A54AC3 /* ObjectFactory.h */,
50ABBDC11925AB6E00A911A9 /* atitc.cpp */, 50ABBDC11925AB6E00A911A9 /* atitc.cpp */,
@ -5571,7 +5538,6 @@
1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */,
1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */,
5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */,
3E61766B1960F89B00DE83F5 /* CCControllerAxisInput.h in Headers */,
50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */,
50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */,
1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */,
@ -5608,7 +5574,6 @@
50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */, 50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */,
2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */, 2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */,
5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, 5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */,
3E6176711960F89B00DE83F5 /* CCControllerElement.h in Headers */,
50E6D33718E174130051CA34 /* UIHBox.h in Headers */, 50E6D33718E174130051CA34 /* UIHBox.h in Headers */,
1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, 1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */,
50E6D33F18E174130051CA34 /* UIVBox.h in Headers */, 50E6D33F18E174130051CA34 /* UIVBox.h in Headers */,
@ -5676,7 +5641,6 @@
5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */,
50ABBE981925AB6F00A911A9 /* CCProtocols.h in Headers */, 50ABBE981925AB6F00A911A9 /* CCProtocols.h in Headers */,
2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */, 2905FA8B18CF08D100240AA3 /* UITextField.h in Headers */,
3E6176731960F89B00DE83F5 /* CCControllerThumbstick.h in Headers */,
50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */, 50FCEBA618C72017004AD434 /* ListViewReader.h in Headers */,
50ABBD431925AB0000A911A9 /* CCMathBase.h in Headers */, 50ABBD431925AB0000A911A9 /* CCMathBase.h in Headers */,
50ABBE441925AB6F00A911A9 /* CCDirector.h in Headers */, 50ABBE441925AB6F00A911A9 /* CCDirector.h in Headers */,
@ -5695,7 +5659,6 @@
50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */, 50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */, 2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */,
50FCEB9A18C72017004AD434 /* CheckBoxReader.h in Headers */, 50FCEB9A18C72017004AD434 /* CheckBoxReader.h in Headers */,
3E61766D1960F89B00DE83F5 /* CCControllerButtonInput.h in Headers */,
1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */,
2905FA7F18CF08D100240AA3 /* UIText.h in Headers */, 2905FA7F18CF08D100240AA3 /* UIText.h in Headers */,
1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */,
@ -5708,7 +5671,6 @@
1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */,
50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */, 50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */, 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */,
3E61766F1960F89B00DE83F5 /* CCControllerDirectionPad.h in Headers */,
1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */,
0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */, 0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */,
1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */, 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */,
@ -5815,7 +5777,6 @@
1AD71ED0180E26E600808F54 /* Skeleton.h in Headers */, 1AD71ED0180E26E600808F54 /* Skeleton.h in Headers */,
50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */, 50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */,
1AD71ED4180E26E600808F54 /* SkeletonData.h in Headers */, 1AD71ED4180E26E600808F54 /* SkeletonData.h in Headers */,
3E61767A1960F89B00DE83F5 /* CCGamepad.h in Headers */,
1AD71ED8180E26E600808F54 /* SkeletonJson.h in Headers */, 1AD71ED8180E26E600808F54 /* SkeletonJson.h in Headers */,
1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */, 1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */,
1AD71EDC180E26E600808F54 /* Skin.h in Headers */, 1AD71EDC180E26E600808F54 /* Skin.h in Headers */,
@ -6752,7 +6713,6 @@
3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */, 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */,
2905FA8D18CF08D100240AA3 /* UIWidget.cpp in Sources */, 2905FA8D18CF08D100240AA3 /* UIWidget.cpp in Sources */,
29E99D1F1957BA7000046604 /* CocoLoader.cpp in Sources */, 29E99D1F1957BA7000046604 /* CocoLoader.cpp in Sources */,
3E61766C1960F89B00DE83F5 /* CCControllerButtonInput.cpp in Sources */,
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */, 0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */,
50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */, 50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */,
@ -6792,6 +6752,7 @@
1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */,
503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */, 503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */,
1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */,
3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */,
50ABC00E1926664800A911A9 /* CCFileUtils.cpp in Sources */, 50ABC00E1926664800A911A9 /* CCFileUtils.cpp in Sources */,
50ABBE241925AB6F00A911A9 /* base64.cpp in Sources */, 50ABBE241925AB6F00A911A9 /* base64.cpp in Sources */,
1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */,
@ -6831,13 +6792,11 @@
1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */,
1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */,
1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, 1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */,
3E6176791960F89B00DE83F5 /* CCGamepad.cpp in Sources */,
1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, 1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */,
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */,
B24AA986195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */, B24AA986195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */,
1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, 1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */,
50ABBD901925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */, 50ABBD901925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */,
3E6176701960F89B00DE83F5 /* CCControllerElement.cpp in Sources */,
2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */, 2905FA5718CF08D100240AA3 /* UILayout.cpp in Sources */,
2905FA7D18CF08D100240AA3 /* UIText.cpp in Sources */, 2905FA7D18CF08D100240AA3 /* UIText.cpp in Sources */,
50E6D33D18E174130051CA34 /* UIVBox.cpp in Sources */, 50E6D33D18E174130051CA34 /* UIVBox.cpp in Sources */,
@ -6853,7 +6812,6 @@
1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, 1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */,
1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */,
1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */,
3E61766A1960F89B00DE83F5 /* CCControllerAxisInput.cpp in Sources */,
1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */,
50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */, 50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */,
50ABBECC1925AB6F00A911A9 /* s3tc.cpp in Sources */, 50ABBECC1925AB6F00A911A9 /* s3tc.cpp in Sources */,
@ -6966,7 +6924,6 @@
50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */,
3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */, 3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */,
50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */, 50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */,
3E61766E1960F89B00DE83F5 /* CCControllerDirectionPad.cpp in Sources */,
503DD8E51926736A00CD74DD /* CCDirectorCaller.mm in Sources */, 503DD8E51926736A00CD74DD /* CCDirectorCaller.mm in Sources */,
50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */, 50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */,
50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */, 50ABC0121926664800A911A9 /* CCGLViewProtocol.cpp in Sources */,
@ -7005,7 +6962,6 @@
1A8C59D4180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */, 1A8C59D4180E930E00EF57C3 /* CCDecorativeDisplay.cpp in Sources */,
1A8C59D8180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */, 1A8C59D8180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */,
46C02E0818E91123004B7456 /* xxhash.c in Sources */, 46C02E0818E91123004B7456 /* xxhash.c in Sources */,
3E6176721960F89B00DE83F5 /* CCControllerThumbstick.cpp in Sources */,
50ABBED01925AB6F00A911A9 /* TGAlib.cpp in Sources */, 50ABBED01925AB6F00A911A9 /* TGAlib.cpp in Sources */,
2905FA4118CF08D100240AA3 /* CocosGUI.cpp in Sources */, 2905FA4118CF08D100240AA3 /* CocosGUI.cpp in Sources */,
1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */, 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -585,7 +585,7 @@ public:
virtual JumpTo* clone() const override; virtual JumpTo* clone() const override;
virtual JumpTo* reverse(void) const override; virtual JumpTo* reverse(void) const override;
private: CC_CONSTRUCTOR_ACCESS:
JumpTo() {} JumpTo() {}
virtual ~JumpTo() {} virtual ~JumpTo() {}
CC_DISALLOW_COPY_AND_ASSIGN(JumpTo); CC_DISALLOW_COPY_AND_ASSIGN(JumpTo);
@ -750,7 +750,7 @@ public:
virtual ScaleBy* clone() const override; virtual ScaleBy* clone() const override;
virtual ScaleBy* reverse(void) const override; virtual ScaleBy* reverse(void) const override;
protected: CC_CONSTRUCTOR_ACCESS:
ScaleBy() {} ScaleBy() {}
virtual ~ScaleBy() {} virtual ~ScaleBy() {}
@ -842,7 +842,7 @@ public:
void setReverseAction(FadeTo* ac); void setReverseAction(FadeTo* ac);
protected: CC_CONSTRUCTOR_ACCESS:
FadeIn():_reverseAction(nullptr) {} FadeIn():_reverseAction(nullptr) {}
virtual ~FadeIn() {} virtual ~FadeIn() {}
@ -869,7 +869,7 @@ public:
void setReverseAction(FadeTo* ac); void setReverseAction(FadeTo* ac);
protected: CC_CONSTRUCTOR_ACCESS:
FadeOut():_reverseAction(nullptr) {} FadeOut():_reverseAction(nullptr) {}
virtual ~FadeOut() {} virtual ~FadeOut() {}
private: private:
@ -961,7 +961,7 @@ public:
virtual DelayTime* reverse() const override; virtual DelayTime* reverse() const override;
virtual DelayTime* clone() const override; virtual DelayTime* clone() const override;
protected: CC_CONSTRUCTOR_ACCESS:
DelayTime() {} DelayTime() {}
virtual ~DelayTime() {} virtual ~DelayTime() {}

View File

@ -194,8 +194,8 @@ bool DrawNode::init()
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO // Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
/** listen the event that coming to foreground on Android */ /** listen the event that renderer was recreated on Android/WP8 */
this->init(); this->init();
}); });

View File

@ -31,6 +31,7 @@
#include "base/CCEventDispatcher.h" #include "base/CCEventDispatcher.h"
#include "base/CCEventType.h" #include "base/CCEventType.h"
NS_CC_BEGIN NS_CC_BEGIN
const int FontAtlas::CacheTextureWidth = 512; const int FontAtlas::CacheTextureWidth = 512;
@ -41,9 +42,9 @@ FontAtlas::FontAtlas(Font &theFont)
: _font(&theFont) : _font(&theFont)
, _currentPageData(nullptr) , _currentPageData(nullptr)
, _fontAscender(0) , _fontAscender(0)
, _toForegroundListener(nullptr) , _rendererRecreatedListener(nullptr)
, _toBackgroundListener(nullptr)
, _antialiasEnabled(true) , _antialiasEnabled(true)
, _rendererRecreate(false)
{ {
_font->retain(); _font->retain();
@ -77,12 +78,12 @@ FontAtlas::FontAtlas(Font &theFont)
addTexture(texture,0); addTexture(texture,0);
texture->release(); texture->release();
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
auto eventDispatcher = Director::getInstance()->getEventDispatcher(); auto eventDispatcher = Director::getInstance()->getEventDispatcher();
_toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(FontAtlas::listenToBackground, this));
eventDispatcher->addEventListenerWithFixedPriority(_toBackgroundListener, 1); _rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(FontAtlas::listenRendererRecreated, this));
_toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(FontAtlas::listenToForeground, this)); eventDispatcher->addEventListenerWithFixedPriority(_rendererRecreatedListener, 1);
eventDispatcher->addEventListenerWithFixedPriority(_toForegroundListener, 1);
#endif #endif
} }
} }
@ -91,19 +92,11 @@ FontAtlas::~FontAtlas()
{ {
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font); FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf) if (fontTTf && _rendererRecreatedListener)
{ {
auto eventDispatcher = Director::getInstance()->getEventDispatcher(); auto eventDispatcher = Director::getInstance()->getEventDispatcher();
if (_toForegroundListener) eventDispatcher->removeEventListener(_rendererRecreatedListener);
{ _rendererRecreatedListener = nullptr;
eventDispatcher->removeEventListener(_toForegroundListener);
_toForegroundListener = nullptr;
}
if (_toBackgroundListener)
{
eventDispatcher->removeEventListener(_toBackgroundListener);
_toBackgroundListener = nullptr;
}
} }
#endif #endif
@ -149,11 +142,10 @@ void FontAtlas::purgeTexturesAtlas()
} }
} }
void FontAtlas::listenToBackground(EventCustom *event) void FontAtlas::listenRendererRecreated(EventCustom *event)
{ {
#if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font); FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf && _atlasTextures.size() > 1) if (fontTTf)
{ {
for( auto &item: _atlasTextures) for( auto &item: _atlasTextures)
{ {
@ -171,30 +163,12 @@ void FontAtlas::listenToBackground(EventCustom *event)
_currentPage = 0; _currentPage = 0;
_currentPageOrigX = 0; _currentPageOrigX = 0;
_currentPageOrigY = 0; _currentPageOrigY = 0;
}
#endif
}
void FontAtlas::listenToForeground(EventCustom *event) _rendererRecreate = true;
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf)
{
if (_currentPageOrigX == 0 && _currentPageOrigY == 0)
{
auto eventDispatcher = Director::getInstance()->getEventDispatcher(); auto eventDispatcher = Director::getInstance()->getEventDispatcher();
eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this); eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
_rendererRecreate = false;
} }
else
{
auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
}
}
#endif
} }
void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition) void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition)
@ -332,6 +306,13 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
} }
if(existNewLetter) if(existNewLetter)
{
if (_rendererRecreate)
{
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
}
else
{ {
unsigned char *data = nullptr; unsigned char *data = nullptr;
if(pixelFormat == Texture2D::PixelFormat::AI88) if(pixelFormat == Texture2D::PixelFormat::AI88)
@ -345,6 +326,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
_atlasTextures[_currentPage]->updateWithData(data, 0, startY, _atlasTextures[_currentPage]->updateWithData(data, 0, startY,
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight); CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
} }
}
return true; return true;
} }

View File

@ -84,15 +84,10 @@ public:
Texture2D* getTexture(int slot); Texture2D* getTexture(int slot);
const Font* getFont() const; const Font* getFont() const;
/** Listen "come to background" message, and clear the texture atlas. /** listen the event that renderer was recreated on Android/WP8
It only has effect on Android. It only has effect on Android and WP8.
*/ */
void listenToBackground(EventCustom *event); void listenRendererRecreated(EventCustom *event);
/** Listen "come to foreground" message and restore the texture atlas.
It only has effect on Android.
*/
void listenToForeground(EventCustom *event);
/** Removes textures atlas. /** Removes textures atlas.
It will purge the textures atlas and if multiple texture exist in the FontAtlas. It will purge the textures atlas and if multiple texture exist in the FontAtlas.
@ -129,9 +124,9 @@ private:
bool _makeDistanceMap; bool _makeDistanceMap;
int _fontAscender; int _fontAscender;
EventListenerCustom* _toBackgroundListener; EventListenerCustom* _rendererRecreatedListener;
EventListenerCustom* _toForegroundListener;
bool _antialiasEnabled; bool _antialiasEnabled;
bool _rendererRecreate;
}; };

View File

@ -266,20 +266,13 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
setAnchorPoint(Vec2::ANCHOR_MIDDLE); setAnchorPoint(Vec2::ANCHOR_MIDDLE);
reset(); reset();
#if CC_ENABLE_CACHE_TEXTURE_DATA
auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF)
{
_batchNodes.clear();
_batchNodes.push_back(this);
Node::removeAllChildrenWithCleanup(true);
}
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this);
#endif
auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, [this](EventCustom* event){ auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas) if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{ {
Node::removeAllChildrenWithCleanup(true);
_batchNodes.clear();
_batchNodes.push_back(this);
alignText(); alignText();
} }
}); });

View File

@ -133,6 +133,11 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
//CCLabelAtlas - Atlas generation //CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues() void LabelAtlas::updateAtlasValues()
{ {
if(_itemsPerRow == 0)
{
return;
}
ssize_t n = _string.length(); ssize_t n = _string.length();
const unsigned char *s = (unsigned char*)_string.c_str(); const unsigned char *s = (unsigned char*)_string.c_str();

View File

@ -884,7 +884,7 @@ LayerMultiplex * LayerMultiplex::create(Layer * layer, ...)
LayerMultiplex * LayerMultiplex::createWithLayer(Layer* layer) LayerMultiplex * LayerMultiplex::createWithLayer(Layer* layer)
{ {
return LayerMultiplex::create(layer, NULL); return LayerMultiplex::create(layer, nullptr);
} }
LayerMultiplex* LayerMultiplex::create() LayerMultiplex* LayerMultiplex::create()

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "2d/CCMenu.h" #include "2d/CCMenu.h"
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "CCApplication.h"
#include "base/CCTouch.h" #include "base/CCTouch.h"
#include "CCStdC.h" #include "CCStdC.h"
#include "base/CCEventListenerTouch.h" #include "base/CCEventListenerTouch.h"

View File

@ -839,6 +839,18 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler s
return ret; return ret;
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MenuItemToggle * MenuItemToggle::createWithCallbackVA(const ccMenuCallback &callback, MenuItem* item, ...)
{
va_list args;
va_start(args, item);
MenuItemToggle *ret = new MenuItemToggle();
ret->initWithCallback(callback, item, args);
ret->autorelease();
va_end(args);
return ret;
}
#else
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...) MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...)
{ {
va_list args; va_list args;
@ -849,6 +861,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba
va_end(args); va_end(args);
return ret; return ret;
} }
#endif
MenuItemToggle * MenuItemToggle::create() MenuItemToggle * MenuItemToggle::create()
{ {

View File

@ -478,7 +478,25 @@ public:
/** creates a menu item from a Array with a callable object */ /** creates a menu item from a Array with a callable object */
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector<MenuItem*>& menuItems); static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector<MenuItem*>& menuItems);
/** creates a menu item from a list of items with a callable object */ /** creates a menu item from a list of items with a callable object */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef MenuItem* M;
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument
static MenuItemToggle* createWithCallbackVA(const ccMenuCallback& callback, M item, ...);
#else
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
#endif
/** creates a menu item with no target/selector and no items */ /** creates a menu item with no target/selector and no items */
static MenuItemToggle* create(); static MenuItemToggle* create();
/** creates a menu item with a item */ /** creates a menu item with a item */

View File

@ -842,24 +842,14 @@ void Node::enumerateChildren(const std::string &name, std::function<bool (Node *
size_t subStrStartPos = 0; // sub string start index size_t subStrStartPos = 0; // sub string start index
size_t subStrlength = length; // sub string length size_t subStrlength = length; // sub string length
// Starts with '/' or '//'? // Starts with '//'?
bool searchFromRoot = false; bool searchRecursively = false;
bool searchFromRootRecursive = false; if (length > 2 && name[0] == '/' && name[1] == '/')
if (name[0] == '/')
{ {
if (length > 2 && name[1] == '/') searchRecursively = true;
{
searchFromRootRecursive = true;
subStrStartPos = 2; subStrStartPos = 2;
subStrlength -= 2; subStrlength -= 2;
} }
else
{
searchFromRoot = true;
subStrStartPos = 1;
subStrlength -= 1;
}
}
// End with '/..'? // End with '/..'?
bool searchFromParent = false; bool searchFromParent = false;
@ -872,7 +862,7 @@ void Node::enumerateChildren(const std::string &name, std::function<bool (Node *
subStrlength -= 3; subStrlength -= 3;
} }
// Remove '/', '//', '/..' if exist // Remove '//', '/..' if exist
std::string newName = name.substr(subStrStartPos, subStrlength); std::string newName = name.substr(subStrStartPos, subStrlength);
if (searchFromParent) if (searchFromParent)
@ -880,23 +870,11 @@ void Node::enumerateChildren(const std::string &name, std::function<bool (Node *
newName.insert(0, "[[:alnum:]]+/"); newName.insert(0, "[[:alnum:]]+/");
} }
if (searchFromRoot)
{ if (searchRecursively)
// name is '/xxx'
auto root = getScene();
if (root)
{
root->doEnumerate(newName, callback);
}
}
else if (searchFromRootRecursive)
{ {
// name is '//xxx' // name is '//xxx'
auto root = getScene(); doEnumerateRecursive(this, newName, callback);
if (root)
{
doEnumerateRecursive(root, newName, callback);
}
} }
else else
{ {
@ -1305,6 +1283,9 @@ Mat4 Node::transform(const Mat4& parentTransform)
void Node::onEnter() void Node::onEnter()
{ {
if (_onEnterCallback)
_onEnterCallback();
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript) if (_scriptType == kScriptTypeJavascript)
{ {
@ -1332,6 +1313,9 @@ void Node::onEnter()
void Node::onEnterTransitionDidFinish() void Node::onEnterTransitionDidFinish()
{ {
if (_onEnterTransitionDidFinishCallback)
_onEnterTransitionDidFinishCallback();
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript) if (_scriptType == kScriptTypeJavascript)
{ {
@ -1354,6 +1338,9 @@ void Node::onEnterTransitionDidFinish()
void Node::onExitTransitionDidStart() void Node::onExitTransitionDidStart()
{ {
if (_onExitTransitionDidStartCallback)
_onExitTransitionDidStartCallback();
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript) if (_scriptType == kScriptTypeJavascript)
{ {
@ -1375,6 +1362,9 @@ void Node::onExitTransitionDidStart()
void Node::onExit() void Node::onExit()
{ {
if (_onExitCallback)
_onExitCallback();
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript) if (_scriptType == kScriptTypeJavascript)
{ {
@ -1623,17 +1613,19 @@ const Mat4& Node::getNodeToParentTransform() const
bool needsSkewMatrix = ( _skewX || _skewY ); bool needsSkewMatrix = ( _skewX || _skewY );
Vec2 anchorPoint;
anchorPoint.x = _anchorPointInPoints.x * _scaleX;
anchorPoint.y = _anchorPointInPoints.y * _scaleY;
// optimization: // optimization:
// inline anchor point calculation if skew is not needed // inline anchor point calculation if skew is not needed
// Adjusted transform calculation for rotational skew // Adjusted transform calculation for rotational skew
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO)) if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO))
{ {
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY; x += cy * -anchorPoint.x + -sx * -anchorPoint.y;
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY; y += sy * -anchorPoint.x + cx * -anchorPoint.y;
} }
// Build Transform Matrix // Build Transform Matrix
// Adjusted transform calculation for rotational skew // Adjusted transform calculation for rotational skew
float mat[] = { float mat[] = {
@ -1644,6 +1636,11 @@ const Mat4& Node::getNodeToParentTransform() const
_transform.set(mat); _transform.set(mat);
if(!_ignoreAnchorPointForPosition)
{
_transform.translate(anchorPoint.x, anchorPoint.y, 0);
}
// XXX // XXX
// FIX ME: Expensive operation. // FIX ME: Expensive operation.
// FIX ME: It should be done together with the rotationZ // FIX ME: It should be done together with the rotationZ
@ -1658,6 +1655,11 @@ const Mat4& Node::getNodeToParentTransform() const
_transform = _transform * rotX; _transform = _transform * rotX;
} }
if(!_ignoreAnchorPointForPosition)
{
_transform.translate(-anchorPoint.x, -anchorPoint.y, 0);
}
// XXX: Try to inline skew // XXX: Try to inline skew
// If skew is needed, apply skew and then anchor point // If skew is needed, apply skew and then anchor point
if (needsSkewMatrix) if (needsSkewMatrix)

View File

@ -714,23 +714,19 @@ public:
virtual Node* getChildByName(const std::string& name) const; virtual Node* getChildByName(const std::string& name) const;
/** Search the children of the receiving node to perform processing for nodes which share a name. /** Search the children of the receiving node to perform processing for nodes which share a name.
* *
* @param name The name to search for, supports c++11 regular expression * @param name The name to search for, supports c++11 regular expression.
* Search syntax options: * Search syntax options:
* `/` : When placed at the start of the search string, this indicates that the search should be performed on the tree's node. * `//`: Can only be placed at the begin of the search string. This indicates that it will search recursively.
* `//`: Can only be placed at the begin of the search string. This indicates that the search should be performed on the tree's node
* and be performed recursively across the entire node tree.
* `..`: The search should move up to the node's parent. Can only be placed at the end of string * `..`: The search should move up to the node's parent. Can only be placed at the end of string
* `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children * `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children.
* *
* @code * @code
* enumerateChildren("/MyName", ...): This searches the root's children and matches any node with the name `MyName`. * enumerateChildren("//MyName", ...): This searches the children recursively and matches any node with the name `MyName`.
* enumerateChildren("//MyName", ...): This searches the root's children recursively and matches any node with the name `MyName`.
* enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children. * enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children.
* enumerateChildren("/MyName", ...): This searches the node tree and matches the parent node of every node named `MyName`.
* enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9` * enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9`
* enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal` * enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal`
* and whose parent is named `Abby`. * and whose parent is named `Abby`.
* enumerateChildren("//Abby/Normal", ...): This searches the node tree and returns any node whose name is `Normal` and whose * enumerateChildren("//Abby/Normal", ...): This searches recursively and returns any node whose name is `Normal` and whose
* parent is named `Abby`. * parent is named `Abby`.
* @endcode * @endcode
* *
@ -1467,6 +1463,15 @@ public:
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);} virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
virtual bool isOpacityModifyRGB() const { return false; }; virtual bool isOpacityModifyRGB() const { return false; };
void setOnEnterCallback(const std::function<void()>& callback) { _onEnterCallback = callback; }
const std::function<void()>& getOnEnterCallback() const { return _onEnterCallback; }
void setOnExitCallback(const std::function<void()>& callback) { _onExitCallback = callback; }
const std::function<void()>& getOnExitCallback() const { return _onExitCallback; }
void setonEnterTransitionDidFinishCallback(const std::function<void()>& callback) { _onEnterTransitionDidFinishCallback = callback; }
const std::function<void()>& getonEnterTransitionDidFinishCallback() const { return _onEnterTransitionDidFinishCallback; }
void setonExitTransitionDidStartCallback(const std::function<void()>& callback) { _onExitTransitionDidStartCallback = callback; }
const std::function<void()>& getonExitTransitionDidStartCallback() const { return _onExitTransitionDidStartCallback; }
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
// Nodes should be created using create(); // Nodes should be created using create();
Node(); Node();
@ -1605,6 +1610,11 @@ protected:
static int s_globalOrderOfArrival; static int s_globalOrderOfArrival;
std::function<void()> _onEnterCallback;
std::function<void()> _onExitCallback;
std::function<void()> _onEnterTransitionDidFinishCallback;
std::function<void()> _onExitTransitionDidStartCallback;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(Node); CC_DISALLOW_COPY_AND_ASSIGN(Node);

View File

@ -135,7 +135,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO // Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(ParticleSystemQuad::listenBackToForeground, this)); auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(ParticleSystemQuad::listenRendererRecreated, this));
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
#endif #endif
@ -509,7 +509,7 @@ void ParticleSystemQuad::setupVBO()
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
} }
void ParticleSystemQuad::listenBackToForeground(EventCustom* event) void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
{ {
if (Configuration::getInstance()->supportsShareableVAO()) if (Configuration::getInstance()->supportsShareableVAO())
{ {

View File

@ -81,11 +81,11 @@ public:
*/ */
void setTextureWithRect(Texture2D *texture, const Rect& rect); void setTextureWithRect(Texture2D *texture, const Rect& rect);
/** listen the event that coming to foreground on Android /** listen the event that renderer was recreated on Android/WP8
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
void listenBackToForeground(EventCustom* event); void listenRendererRecreated(EventCustom* event);
/** /**
* @js NA * @js NA

View File

@ -85,6 +85,10 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity)
CCASSERT(capacity>=0, "Capacity must be >= 0"); CCASSERT(capacity>=0, "Capacity must be >= 0");
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
if(tex->hasPremultipliedAlpha())
{
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
}
_textureAtlas = new TextureAtlas(); _textureAtlas = new TextureAtlas();
if (capacity == 0) if (capacity == 0)

View File

@ -222,7 +222,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
<ClCompile Include="..\base\CCTouch.cpp" /> <ClCompile Include="..\base\CCTouch.cpp" />
<ClCompile Include="..\base\ccTypes.cpp" /> <ClCompile Include="..\base\ccTypes.cpp" />
<ClCompile Include="..\base\CCUserDefault.cpp" /> <ClCompile Include="..\base\CCUserDefault.cpp" />
<ClCompile Include="..\base\CCUserDefaultAndroid.cpp" />
<ClCompile Include="..\base\ccUTF8.cpp" /> <ClCompile Include="..\base\ccUTF8.cpp" />
<ClCompile Include="..\base\ccUtils.cpp" /> <ClCompile Include="..\base\ccUtils.cpp" />
<ClCompile Include="..\base\CCValue.cpp" /> <ClCompile Include="..\base\CCValue.cpp" />

View File

@ -353,7 +353,6 @@
<ClCompile Include="..\base\CCTouch.cpp" /> <ClCompile Include="..\base\CCTouch.cpp" />
<ClCompile Include="..\base\ccTypes.cpp" /> <ClCompile Include="..\base\ccTypes.cpp" />
<ClCompile Include="..\base\CCUserDefault.cpp" /> <ClCompile Include="..\base\CCUserDefault.cpp" />
<ClCompile Include="..\base\CCUserDefaultAndroid.cpp" />
<ClCompile Include="..\base\ccUTF8.cpp" /> <ClCompile Include="..\base\ccUTF8.cpp" />
<ClCompile Include="..\base\ccUtils.cpp" /> <ClCompile Include="..\base\ccUtils.cpp" />
<ClCompile Include="..\base\CCValue.cpp" /> <ClCompile Include="..\base\CCValue.cpp" />

View File

@ -280,7 +280,6 @@
<ClCompile Include="..\base\CCTouch.cpp" /> <ClCompile Include="..\base\CCTouch.cpp" />
<ClCompile Include="..\base\ccTypes.cpp" /> <ClCompile Include="..\base\ccTypes.cpp" />
<ClCompile Include="..\base\CCUserDefault.cpp" /> <ClCompile Include="..\base\CCUserDefault.cpp" />
<ClCompile Include="..\base\CCUserDefaultAndroid.cpp" />
<ClCompile Include="..\base\ccUTF8.cpp" /> <ClCompile Include="..\base\ccUTF8.cpp" />
<ClCompile Include="..\base\ccUtils.cpp" /> <ClCompile Include="..\base\ccUtils.cpp" />
<ClCompile Include="..\base\CCValue.cpp" /> <ClCompile Include="..\base\CCValue.cpp" />

View File

@ -7,7 +7,7 @@
<PropertyGroup /> <PropertyGroup />
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(GeneratedFilesDir)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\wp8-specific\zlib\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAsWinRT>true</CompileAsWinRT> <CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>

View File

@ -66,12 +66,12 @@ Animate3D* Animate3D::clone() const
auto animate = const_cast<Animate3D*>(this); auto animate = const_cast<Animate3D*>(this);
auto copy = Animate3D::create(animate->_animation); auto copy = Animate3D::create(animate->_animation);
copy->_speed = _speed; copy->_absSpeed = _absSpeed;
copy->_weight = _weight; copy->_weight = _weight;
copy->_elapsed = _elapsed; copy->_elapsed = _elapsed;
copy->_start = _start; copy->_start = _start;
copy->_last = _last; copy->_last = _last;
copy->_playBack = _playBack; copy->_playReverse = _playReverse;
copy->setDuration(animate->getDuration()); copy->setDuration(animate->getDuration());
return copy; return copy;
@ -81,7 +81,7 @@ Animate3D* Animate3D::clone() const
Animate3D* Animate3D::reverse() const Animate3D* Animate3D::reverse() const
{ {
auto animate = clone(); auto animate = clone();
animate->_playBack = !animate->_playBack; animate->_playReverse = !animate->_playReverse;
return animate; return animate;
} }
@ -112,16 +112,16 @@ void Animate3D::startWithTarget(Node *target)
//! called every frame with it's delta time. DON'T override unless you know what you are doing. //! called every frame with it's delta time. DON'T override unless you know what you are doing.
void Animate3D::step(float dt) void Animate3D::step(float dt)
{ {
ActionInterval::step(dt * _speed); ActionInterval::step(dt * _absSpeed);
} }
void Animate3D::update(float t) void Animate3D::update(float t)
{ {
if (_target) if (_target && _weight > 0.f)
{ {
float transDst[3], rotDst[4], scaleDst[3]; float transDst[3], rotDst[4], scaleDst[3];
float* trans = nullptr, *rot = nullptr, *scale = nullptr; float* trans = nullptr, *rot = nullptr, *scale = nullptr;
if (_playBack) if (_playReverse)
t = 1 - t; t = 1 - t;
t = _start + t * _last; t = _start + t * _last;
@ -149,13 +149,29 @@ void Animate3D::update(float t)
} }
float Animate3D::getSpeed() const
{
return _playReverse ? -_absSpeed : _absSpeed;
}
void Animate3D::setSpeed(float speed)
{
_absSpeed = fabsf(speed);
_playReverse = speed < 0;
}
void Animate3D::setWeight(float weight)
{
CCASSERT(weight >= 0.0f, "invalid weight");
_weight = fabsf(weight);
}
Animate3D::Animate3D() Animate3D::Animate3D()
: _speed(1) : _absSpeed(1.f)
, _weight(1.f) , _weight(1.f)
, _start(0.f) , _start(0.f)
, _last(1.f) , _last(1.f)
, _animation(nullptr) , _animation(nullptr)
, _playBack(false) , _playReverse(false)
{ {
} }

View File

@ -32,12 +32,13 @@
#include "base/ccMacros.h" #include "base/ccMacros.h"
#include "base/CCRef.h" #include "base/CCRef.h"
#include "base/ccTypes.h" #include "base/ccTypes.h"
#include "base/CCPlatformMacros.h"
#include "2d/CCActionInterval.h" #include "2d/CCActionInterval.h"
NS_CC_BEGIN NS_CC_BEGIN
class Animation3D; class Animation3D;
class Bone; class Bone3D;
/** /**
* Animate3D, Animates a Sprite3D given with an Animation3D * Animate3D, Animates a Sprite3D given with an Animation3D
*/ */
@ -66,17 +67,17 @@ public:
virtual void update(float t) override; virtual void update(float t) override;
/**get & set speed */ /**get & set speed, negative speed means playing reverse */
float getSpeed() const { return _speed; } float getSpeed() const;
void setSpeed(float speed) { _speed = speed; } void setSpeed(float speed);
/**get & set blend weight*/ /**get & set blend weight, weight must positive*/
float getWeight() const { return _weight; } float getWeight() const { return _weight; }
void setWeight(float weight) { _weight = weight; } void setWeight(float weight);
/**get & set play back*/ /**get & set play reverse, these are deprecated, use set negative speed instead*/
bool getPlayBack() const { return _playBack; } CC_DEPRECATED_ATTRIBUTE bool getPlayBack() const { return _playReverse; }
void setPlayBack(bool playBack) { _playBack = playBack; } CC_DEPRECATED_ATTRIBUTE void setPlayBack(bool reverse) { _playReverse = reverse; }
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
@ -86,12 +87,12 @@ CC_CONSTRUCTOR_ACCESS:
protected: protected:
Animation3D* _animation; //animation data Animation3D* _animation; //animation data
float _speed; //playing speed float _absSpeed; //playing speed
float _weight; //blend weight float _weight; //blend weight
float _start; //start time 0 - 1, used to generate sub Animate3D float _start; //start time 0 - 1, used to generate sub Animate3D
float _last; //last time 0 - 1, used to generate sub Animate3D float _last; //last time 0 - 1, used to generate sub Animate3D
bool _playBack; // is playing back bool _playReverse; // is playing reverse
std::map<Bone*, Animation3D::Curve*> _boneCurves; //weak ref std::map<Bone3D*, Animation3D::Curve*> _boneCurves; //weak ref
}; };
NS_CC_END NS_CC_END

View File

@ -30,7 +30,7 @@
NS_CC_BEGIN NS_CC_BEGIN
Animation3D* Animation3D::getOrCreate(const std::string& fileName, const std::string& animationName) Animation3D* Animation3D::create(const std::string& fileName, const std::string& animationName)
{ {
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName); std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
std::string key = fullPath + "#" + animationName; std::string key = fullPath + "#" + animationName;

View File

@ -59,8 +59,10 @@ public:
~Curve(); ~Curve();
}; };
/**read all animation or only the animation with given animationName? animationName == "" read all.*/ /**read all animation or only the animation with given animationName? animationName == "" read the first.*/
static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = ""); static Animation3D* create(const std::string& filename, const std::string& animationName = "");
CC_DEPRECATED_ATTRIBUTE static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = ""){ return create(filename, animationName); }
/**get duration*/ /**get duration*/
float getDuration() const { return _duration; } float getDuration() const { return _duration; }

View File

@ -447,8 +447,7 @@ bool Bundle3D::loadBinary(const std::string& path)
return false; return false;
} }
// Create bundle reader // Initialise bundle reader
//CC_SAFE_DELETE(_bundleReader);
_binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() ); _binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() );
// Read identifier info // Read identifier info
@ -463,8 +462,11 @@ bool Bundle3D::loadBinary(const std::string& path)
// Read version // Read version
unsigned char ver[2]; unsigned char ver[2];
if (_binaryReader.read(ver, 1, 2) == 2) if (_binaryReader.read(ver, 1, 2)!= 2){
{ CCLOG("Failed to read version:");
return false;
}
if (ver[0] != 0) { if (ver[0] != 0) {
clear(); clear();
CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]); CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]);
@ -476,7 +478,7 @@ bool Bundle3D::loadBinary(const std::string& path)
CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]); CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]);
return false; return false;
} }
}
// Read ref table size // Read ref table size
if (_binaryReader.read(&_referenceCount, 4, 1) != 1) if (_binaryReader.read(&_referenceCount, 4, 1) != 1)
@ -766,17 +768,37 @@ bool Bundle3D::loadAnimationDataBinary(Animation3DData* animationdata)
GLenum Bundle3D::parseGLType(const std::string& str) GLenum Bundle3D::parseGLType(const std::string& str)
{ {
if (str == "GL_FLOAT") if (str == "GL_BYTE")
{ {
return GL_FLOAT; return GL_BYTE;
}
else if(str == "GL_UNSIGNED_BYTE")
{
return GL_UNSIGNED_BYTE;
}
else if(str == "GL_SHORT")
{
return GL_SHORT;
}
else if(str == "GL_UNSIGNED_SHORT")
{
return GL_UNSIGNED_SHORT;
}
else if(str == "GL_INT")
{
return GL_INT;
} }
else if (str == "GL_UNSIGNED_INT") else if (str == "GL_UNSIGNED_INT")
{ {
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
} }
else if (str == "GL_FLOAT")
{
return GL_FLOAT;
}
else else
{ {
assert(0); CCASSERT(false, "Wrong GL type");
return 0; return 0;
} }
} }

View File

@ -5,7 +5,7 @@ NS_CC_BEGIN
BundleReader::BundleReader() BundleReader::BundleReader()
{ {
m_buffer = NULL; m_buffer = nullptr;
m_position = 0; m_position = 0;
m_length = 0; m_length = 0;
}; };
@ -65,7 +65,7 @@ char* BundleReader::readLine(int num,char* line)
char* p = line; char* p = line;
char c; char c;
ssize_t readNum = 0; ssize_t readNum = 0;
while((c=*buffer) != 10 && readNum < (ssize_t)num && m_position<(long int)m_length) while((c=*buffer) != 10 && readNum < (ssize_t)num && m_position < m_length)
{ {
*p = c; *p = c;
p++; p++;
@ -91,7 +91,7 @@ ssize_t BundleReader::length()
return m_length; return m_length;
} }
long int BundleReader::tell() ssize_t BundleReader::tell()
{ {
if (!m_buffer) if (!m_buffer)
return -1; return -1;
@ -123,7 +123,7 @@ bool BundleReader::seek(long int offset, int origin)
bool BundleReader::rewind() bool BundleReader::rewind()
{ {
if (m_buffer != NULL) if (m_buffer != nullptr)
{ {
m_position = 0; m_position = 0;
return true; return true;

View File

@ -112,7 +112,7 @@ public:
bool readMatrix(float* m); bool readMatrix(float* m);
private: private:
long int m_position; ssize_t m_position;
ssize_t m_length; ssize_t m_length;
char* m_buffer; char* m_buffer;
}; };
@ -136,6 +136,7 @@ inline bool BundleReader::readArray(unsigned int *length, std::vector<T> *values
{ {
return false; return false;
} }
if (*length > 0 && values) if (*length > 0 && values)
{ {
values->resize(*length); values->resize(*length);

View File

@ -125,7 +125,7 @@ bool RenderMeshData::init(const std::vector<float>& positions,
return true; return true;
} }
bool RenderMeshData::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount) bool RenderMeshData::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, const std::vector<MeshVertexAttrib>& attribs)
{ {
_vertexs = vertices; _vertexs = vertices;
_indices = indices; _indices = indices;
@ -174,10 +174,10 @@ Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>
return nullptr; return nullptr;
} }
Mesh* Mesh::create(const std::vector<float> &vertices, int vertexSizeInFloat, const std::vector<unsigned short> &indices, int numIndex, const std::vector<MeshVertexAttrib> &attribs, int attribCount) Mesh* Mesh::create(const std::vector<float> &vertices, int vertexSizeInFloat, const std::vector<unsigned short> &indices, const std::vector<MeshVertexAttrib> &attribs)
{ {
auto mesh = new Mesh(); auto mesh = new Mesh();
if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, numIndex, attribs, attribCount)) if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, attribs))
{ {
mesh->autorelease(); mesh->autorelease();
return mesh; return mesh;
@ -192,17 +192,17 @@ bool Mesh::init(const std::vector<float>& positions, const std::vector<float>& n
if (!bRet) if (!bRet)
return false; return false;
restore(); buildBuffer();
return true; return true;
} }
bool Mesh::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount) bool Mesh::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, const std::vector<MeshVertexAttrib>& attribs)
{ {
bool bRet = _renderdata.init(vertices, vertexSizeInFloat, indices, numIndex, attribs, attribCount); bool bRet = _renderdata.init(vertices, vertexSizeInFloat, indices, attribs);
if (!bRet) if (!bRet)
return false; return false;
restore(); buildBuffer();
return true; return true;
} }
@ -242,20 +242,20 @@ void Mesh::buildBuffer()
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
unsigned int indexSize = 2; unsigned int indexSize = 2;
IndexFormat indexformat = IndexFormat::INDEX16;
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * _renderdata._indices.size(), &_renderdata._indices[0], GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * _renderdata._indices.size(), &_renderdata._indices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
_primitiveType = PrimitiveType::TRIANGLES; _primitiveType = PrimitiveType::TRIANGLES;
_indexFormat = indexformat; _indexFormat = IndexFormat::INDEX16;
_indexCount = _renderdata._indices.size(); _indexCount = _renderdata._indices.size();
} }
void Mesh::restore() void Mesh::restore()
{ {
cleanAndFreeBuffers(); _vertexBuffer = 0;
_indexBuffer = 0;
buildBuffer(); buildBuffer();
} }
@ -322,22 +322,22 @@ void MeshCache::removeUnusedMesh()
MeshCache::MeshCache() MeshCache::MeshCache()
{ {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// listen the event when app go to foreground // listen the event that renderer was recreated on Android/WP8
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCache::listenBackToForeground, this)); _rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCache::listenRendererRecreated, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
#endif #endif
} }
MeshCache::~MeshCache() MeshCache::~MeshCache()
{ {
removeAllMeshes(); removeAllMeshes();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
#endif #endif
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void MeshCache::listenBackToForeground(EventCustom* event) void MeshCache::listenRendererRecreated(EventCustom* event)
{ {
for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter) for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
{ {

View File

@ -49,7 +49,7 @@ public:
} }
bool hasVertexAttrib(int attrib); bool hasVertexAttrib(int attrib);
bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices); bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount); bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, const std::vector<MeshVertexAttrib>& attribs);
protected: protected:
@ -90,7 +90,10 @@ public:
static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices); static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
/**create mesh with vertex attributes*/ /**create mesh with vertex attributes*/
static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount); CC_DEPRECATED_ATTRIBUTE static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount) { return create(vertices, vertexSizeInFloat, indices, attribs); }
/**create mesh with vertex attributes*/
static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, const std::vector<MeshVertexAttrib>& attribs);
/**get vertex buffer*/ /**get vertex buffer*/
inline GLuint getVertexBuffer() const { return _vertexBuffer; } inline GLuint getVertexBuffer() const { return _vertexBuffer; }
@ -124,7 +127,7 @@ CC_CONSTRUCTOR_ACCESS:
bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices); bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
/**init mesh*/ /**init mesh*/
bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount); bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, const std::vector<MeshVertexAttrib>& attribs);
/**build buffer*/ /**build buffer*/
void buildBuffer(); void buildBuffer();
@ -163,8 +166,8 @@ public:
/**remove unused meshes*/ /**remove unused meshes*/
void removeUnusedMesh(); void removeUnusedMesh();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void listenBackToForeground(EventCustom* event); void listenRendererRecreated(EventCustom* event);
#endif #endif
CC_CONSTRUCTOR_ACCESS: CC_CONSTRUCTOR_ACCESS:
@ -178,8 +181,8 @@ protected:
std::unordered_map<std::string, Mesh*> _meshes; //cached meshes std::unordered_map<std::string, Mesh*> _meshes; //cached meshes
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
EventListenerCustom* _backToForegroundlistener; EventListenerCustom* _rendererRecreatedListener;
#endif #endif
}; };

View File

@ -36,22 +36,22 @@ NS_CC_BEGIN
* *
* @param m C3DMatrix representing the inverse bind pose for this Bone. * @param m C3DMatrix representing the inverse bind pose for this Bone.
*/ */
void Bone::setInverseBindPose(const Mat4& m) void Bone3D::setInverseBindPose(const Mat4& m)
{ {
_invBindPose = m; _invBindPose = m;
} }
const Mat4& Bone::getInverseBindPose() const Mat4& Bone3D::getInverseBindPose()
{ {
return _invBindPose; return _invBindPose;
} }
void Bone::setOriPose(const Mat4& m) void Bone3D::setOriPose(const Mat4& m)
{ {
_oriPose = m; _oriPose = m;
} }
void Bone::resetPose() void Bone3D::resetPose()
{ {
_local =_oriPose; _local =_oriPose;
@ -60,7 +60,7 @@ void Bone::resetPose()
} }
} }
void Bone::setWorldMatDirty(bool dirty) void Bone3D::setWorldMatDirty(bool dirty)
{ {
_worldDirty = dirty; _worldDirty = dirty;
for (auto it : _children) { for (auto it : _children) {
@ -69,7 +69,7 @@ void Bone::setWorldMatDirty(bool dirty)
} }
//update own world matrix and children's //update own world matrix and children's
void Bone::updateWorldMat() void Bone3D::updateWorldMat()
{ {
getWorldMat(); getWorldMat();
for (auto itor : _children) { for (auto itor : _children) {
@ -77,7 +77,7 @@ void Bone::updateWorldMat()
} }
} }
const Mat4& Bone::getWorldMat() const Mat4& Bone3D::getWorldMat()
{ {
if (_worldDirty) if (_worldDirty)
{ {
@ -95,7 +95,7 @@ const Mat4& Bone::getWorldMat()
return _world; return _world;
} }
void Bone::setAnimationValue(float* trans, float* rot, float* scale, void* tag, float weight) void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag, float weight)
{ {
for (auto& it : _blendStates) { for (auto& it : _blendStates) {
if (it.tag == tag) if (it.tag == tag)
@ -124,7 +124,7 @@ void Bone::setAnimationValue(float* trans, float* rot, float* scale, void* tag,
_blendStates.push_back(state); _blendStates.push_back(state);
} }
void Bone::clearBoneBlendState() void Bone3D::clearBoneBlendState()
{ {
_blendStates.clear(); _blendStates.clear();
for (auto it : _children) { for (auto it : _children) {
@ -135,14 +135,14 @@ void Bone::clearBoneBlendState()
/** /**
* Creates C3DBone. * Creates C3DBone.
*/ */
Bone* Bone::create(const std::string& id) Bone3D* Bone3D::create(const std::string& id)
{ {
auto bone = new Bone(id); auto bone = new Bone3D(id);
bone->autorelease(); bone->autorelease();
return bone; return bone;
} }
void Bone::updateJointMatrix(Vec4* matrixPalette) void Bone3D::updateJointMatrix(Vec4* matrixPalette)
{ {
{ {
static Mat4 t; static Mat4 t;
@ -154,37 +154,37 @@ void Bone::updateJointMatrix(Vec4* matrixPalette)
} }
} }
Bone* Bone::getParentBone() Bone3D* Bone3D::getParentBone()
{ {
return _parent; return _parent;
} }
ssize_t Bone::getChildBoneCount() const ssize_t Bone3D::getChildBoneCount() const
{ {
return _children.size(); return _children.size();
} }
Bone* Bone::getChildBoneByIndex(int index) Bone3D* Bone3D::getChildBoneByIndex(int index)
{ {
return _children.at(index); return _children.at(index);
} }
void Bone::addChildBone(Bone* bone) void Bone3D::addChildBone(Bone3D* bone)
{ {
if (_children.find(bone) == _children.end()) if (_children.find(bone) == _children.end())
_children.pushBack(bone); _children.pushBack(bone);
} }
void Bone::removeChildBoneByIndex(int index) void Bone3D::removeChildBoneByIndex(int index)
{ {
_children.erase(index); _children.erase(index);
} }
void Bone::removeChildBone(Bone* bone) void Bone3D::removeChildBone(Bone3D* bone)
{ {
_children.eraseObject(bone); _children.eraseObject(bone);
} }
void Bone::removeAllChildBone() void Bone3D::removeAllChildBone()
{ {
_children.clear(); _children.clear();
} }
Bone::Bone(const std::string& id) Bone3D::Bone3D(const std::string& id)
: _name(id) : _name(id)
, _parent(nullptr) , _parent(nullptr)
, _worldDirty(true) , _worldDirty(true)
@ -192,12 +192,12 @@ Bone::Bone(const std::string& id)
} }
Bone::~Bone() Bone3D::~Bone3D()
{ {
removeAllChildBone(); removeAllChildBone();
} }
void Bone::updateLocalMat() void Bone3D::updateLocalMat()
{ {
if (_blendStates.size()) if (_blendStates.size())
{ {
@ -299,13 +299,13 @@ bool MeshSkin::initFromSkinData(const SkinData& skindata)
{ {
ssize_t i = 0; ssize_t i = 0;
for (; i < skindata.skinBoneNames.size(); i++) { for (; i < skindata.skinBoneNames.size(); i++) {
auto bone = Bone::create(skindata.skinBoneNames[i]); auto bone = Bone3D::create(skindata.skinBoneNames[i]);
bone->_invBindPose = skindata.inverseBindPoseMatrices[i]; bone->_invBindPose = skindata.inverseBindPoseMatrices[i];
bone->setOriPose(skindata.skinBoneOriginMatrices[i]); bone->setOriPose(skindata.skinBoneOriginMatrices[i]);
addSkinBone(bone); addSkinBone(bone);
} }
for (i = 0; i < skindata.nodeBoneNames.size(); i++) { for (i = 0; i < skindata.nodeBoneNames.size(); i++) {
auto bone = Bone::create(skindata.nodeBoneNames[i]); auto bone = Bone3D::create(skindata.nodeBoneNames[i]);
bone->setOriPose(skindata.nodeBoneOriginMatrices[i]); bone->setOriPose(skindata.nodeBoneOriginMatrices[i]);
addNodeBone(bone); addNodeBone(bone);
} }
@ -330,7 +330,7 @@ ssize_t MeshSkin::getBoneCount() const
} }
//get bone //get bone
Bone* MeshSkin::getBoneByIndex(unsigned int index) const Bone3D* MeshSkin::getBoneByIndex(unsigned int index) const
{ {
if (index < _skinBones.size()) if (index < _skinBones.size())
return _skinBones.at(index); return _skinBones.at(index);
@ -340,7 +340,7 @@ Bone* MeshSkin::getBoneByIndex(unsigned int index) const
return nullptr; return nullptr;
} }
Bone* MeshSkin::getBoneByName(const std::string& id) const Bone3D* MeshSkin::getBoneByName(const std::string& id) const
{ {
//search from skin bones //search from skin bones
for (auto it : _skinBones) { for (auto it : _skinBones) {
@ -355,18 +355,18 @@ Bone* MeshSkin::getBoneByName(const std::string& id) const
return nullptr; return nullptr;
} }
Bone* MeshSkin::getRootBone() const Bone3D* MeshSkin::getRootBone() const
{ {
return _rootBone; return _rootBone;
} }
void MeshSkin::setRootBone(Bone* joint) void MeshSkin::setRootBone(Bone3D* joint)
{ {
CC_SAFE_RETAIN(joint); CC_SAFE_RETAIN(joint);
CC_SAFE_RELEASE(_rootBone); CC_SAFE_RELEASE(_rootBone);
_rootBone = joint; _rootBone = joint;
} }
int MeshSkin::getBoneIndex(Bone* bone) const int MeshSkin::getBoneIndex(Bone3D* bone) const
{ {
int i = 0; int i = 0;
for (; i < _skinBones.size(); i++) { for (; i < _skinBones.size(); i++) {
@ -419,12 +419,12 @@ void MeshSkin::removeAllBones()
CC_SAFE_RELEASE(_rootBone); CC_SAFE_RELEASE(_rootBone);
} }
void MeshSkin::addSkinBone(Bone* bone) void MeshSkin::addSkinBone(Bone3D* bone)
{ {
_skinBones.pushBack(bone); _skinBones.pushBack(bone);
} }
void MeshSkin::addNodeBone(Bone* bone) void MeshSkin::addNodeBone(Bone3D* bone)
{ {
_nodeBones.pushBack(bone); _nodeBones.pushBack(bone);
} }

View File

@ -40,7 +40,7 @@ NS_CC_BEGIN
/** /**
* Defines a basic hierachial structure of transformation spaces. * Defines a basic hierachial structure of transformation spaces.
*/ */
class Bone : public Ref class Bone3D : public Ref
{ {
friend class MeshSkin; friend class MeshSkin;
public: public:
@ -76,7 +76,7 @@ public:
/** /**
* Creates C3DBone. * Creates C3DBone.
*/ */
static Bone* create(const std::string& id); static Bone3D* create(const std::string& id);
/** /**
* Sets the inverse bind pose matrix. * Sets the inverse bind pose matrix.
@ -105,17 +105,17 @@ public:
void updateJointMatrix(Vec4* matrixPalette); void updateJointMatrix(Vec4* matrixPalette);
/**bone tree, we do not inherit from Node, Node has too many properties that we do not need. A clean Node is needed.*/ /**bone tree, we do not inherit from Node, Node has too many properties that we do not need. A clean Node is needed.*/
Bone* getParentBone(); Bone3D* getParentBone();
/**get child bone count*/ /**get child bone count*/
ssize_t getChildBoneCount() const; ssize_t getChildBoneCount() const;
/**get child bone by index*/ /**get child bone by index*/
Bone* getChildBoneByIndex(int index); Bone3D* getChildBoneByIndex(int index);
/**add child bone*/ /**add child bone*/
void addChildBone(Bone* bone); void addChildBone(Bone3D* bone);
/**remove child bone by index*/ /**remove child bone by index*/
void removeChildBoneByIndex(int index); void removeChildBoneByIndex(int index);
/**remove child bone*/ /**remove child bone*/
void removeChildBone(Bone* bone); void removeChildBone(Bone3D* bone);
/**remove all child bone*/ /**remove all child bone*/
void removeAllChildBone(); void removeAllChildBone();
@ -143,12 +143,12 @@ protected:
/** /**
* Constructor. * Constructor.
*/ */
Bone(const std::string& id); Bone3D(const std::string& id);
/** /**
* Destructor. * Destructor.
*/ */
virtual ~Bone(); virtual ~Bone3D();
/** /**
* Update local matrix * Update local matrix
@ -166,9 +166,9 @@ protected:
Mat4 _oriPose; //original bone pose Mat4 _oriPose; //original bone pose
Bone* _parent; //parent bone Bone3D* _parent; //parent bone
Vector<Bone*> _children; Vector<Bone3D*> _children;
bool _worldDirty; bool _worldDirty;
Mat4 _world; Mat4 _world;
@ -193,15 +193,15 @@ public:
ssize_t getBoneCount() const; ssize_t getBoneCount() const;
/**get bone*/ /**get bone*/
Bone* getBoneByIndex(unsigned int index) const; Bone3D* getBoneByIndex(unsigned int index) const;
Bone* getBoneByName(const std::string& id) const; Bone3D* getBoneByName(const std::string& id) const;
/**get & set root bone*/ /**get & set root bone*/
Bone* getRootBone() const; Bone3D* getRootBone() const;
void setRootBone(Bone* bone); void setRootBone(Bone3D* bone);
/**get bone index*/ /**get bone index*/
int getBoneIndex(Bone* bone) const; int getBoneIndex(Bone3D* bone) const;
/**compute matrix palette used by gpu skin*/ /**compute matrix palette used by gpu skin*/
Vec4* getMatrixPalette(); Vec4* getMatrixPalette();
@ -225,17 +225,17 @@ CC_CONSTRUCTOR_ACCESS:
void removeAllBones(); void removeAllBones();
/**add skin bone*/ /**add skin bone*/
void addSkinBone(Bone* bone); void addSkinBone(Bone3D* bone);
/**add Node bone*/ /**add Node bone*/
void addNodeBone(Bone* bone); void addNodeBone(Bone3D* bone);
protected: protected:
Vector<Bone*> _skinBones; // bones with skin Vector<Bone3D*> _skinBones; // bones with skin
Vector<Bone*> _nodeBones; //bones without skin, only used to compute transform of children Vector<Bone3D*> _nodeBones; //bones without skin, only used to compute transform of children
Bone* _rootBone; Bone3D* _rootBone;
// Pointer to the array of palette matrices. // Pointer to the array of palette matrices.
// This array is passed to the vertex shader as a uniform. // This array is passed to the vertex shader as a uniform.

View File

@ -193,7 +193,7 @@ bool Sprite3D::loadFromC3x(const std::string& path)
return false; return false;
} }
_mesh = Mesh::create(meshdata.vertex, meshdata.vertexSizeInFloat, meshdata.indices, meshdata.numIndex, meshdata.attribs, meshdata.attribCount); _mesh = Mesh::create(meshdata.vertex, meshdata.vertexSizeInFloat, meshdata.indices, meshdata.attribs);
CC_SAFE_RETAIN(_mesh); CC_SAFE_RETAIN(_mesh);
_skin = MeshSkin::create(fullPath, ""); _skin = MeshSkin::create(fullPath, "");
@ -342,7 +342,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
_meshCommand.setDepthTestEnabled(true); _meshCommand.setDepthTestEnabled(true);
if (_skin) if (_skin)
{ {
_meshCommand.setMatrixPaletteSize(_skin->getMatrixPaletteSize()); _meshCommand.setMatrixPaletteSize((int)_skin->getMatrixPaletteSize());
_meshCommand.setMatrixPalette(_skin->getMatrixPalette()); _meshCommand.setMatrixPalette(_skin->getMatrixPalette());
} }
//support tint and fade //support tint and fade

View File

@ -141,13 +141,8 @@ base/ccUTF8.cpp \
base/ccUtils.cpp \ base/ccUtils.cpp \
base/etc1.cpp \ base/etc1.cpp \
base/s3tc.cpp \ base/s3tc.cpp \
base/CCController.cpp \
base/CCController-android.cpp \ base/CCController-android.cpp \
base/CCControllerAxisInput.cpp \
base/CCControllerButtonInput.cpp \
base/CCControllerDirectionPad.cpp \
base/CCControllerElement.cpp \
base/CCControllerThumbstick.cpp \
base/CCGamepad.cpp \
base/ObjectFactory.cpp \ base/ObjectFactory.cpp \
renderer/CCBatchCommand.cpp \ renderer/CCBatchCommand.cpp \
renderer/CCCustomCommand.cpp \ renderer/CCCustomCommand.cpp \

View File

@ -222,7 +222,7 @@ static void _log(const char *format, va_list args)
WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; WCHAR wszBuf[MAX_LOG_LENGTH] = {0};
MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf));
OutputDebugStringW(wszBuf); OutputDebugStringW(wszBuf);
WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), nullptr, FALSE);
printf("%s", buf); printf("%s", buf);
fflush(stdout); fflush(stdout);
#else #else
@ -337,7 +337,7 @@ bool Console::listenOnTCP(int port)
#endif #endif
#endif #endif
if ( (n = getaddrinfo(NULL, serv, &hints, &res)) != 0) { if ( (n = getaddrinfo(nullptr, serv, &hints, &res)) != 0) {
fprintf(stderr,"net_listen error for %s: %s", serv, gai_strerror(n)); fprintf(stderr,"net_listen error for %s: %s", serv, gai_strerror(n));
return false; return false;
} }
@ -359,9 +359,9 @@ bool Console::listenOnTCP(int port)
#else #else
close(listenfd); close(listenfd);
#endif #endif
} while ( (res = res->ai_next) != NULL); } while ( (res = res->ai_next) != nullptr);
if (res == NULL) { if (res == nullptr) {
perror("net_listen:"); perror("net_listen:");
freeaddrinfo(ressave); freeaddrinfo(ressave);
return false; return false;
@ -372,14 +372,14 @@ bool Console::listenOnTCP(int port)
if (res->ai_family == AF_INET) { if (res->ai_family == AF_INET) {
char buf[INET_ADDRSTRLEN] = ""; char buf[INET_ADDRSTRLEN] = "";
struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr; struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr;
if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL ) if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != nullptr )
cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port));
else else
perror("inet_ntop"); perror("inet_ntop");
} else if (res->ai_family == AF_INET6) { } else if (res->ai_family == AF_INET6) {
char buf[INET6_ADDRSTRLEN] = ""; char buf[INET6_ADDRSTRLEN] = "";
struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr; struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr;
if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL ) if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != nullptr )
cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port));
else else
perror("inet_ntop"); perror("inet_ntop");
@ -1042,7 +1042,7 @@ void Console::loop()
copy_set = _read_set; copy_set = _read_set;
timeout_copy = timeout; timeout_copy = timeout;
int nready = select(_maxfd+1, &copy_set, NULL, NULL, &timeout_copy); int nready = select(_maxfd+1, &copy_set, nullptr, nullptr, &timeout_copy);
if( nready == -1 ) if( nready == -1 )
{ {

View File

@ -47,6 +47,7 @@ typedef SSIZE_T ssize_t;
#include <mutex> #include <mutex>
#include <stdarg.h> #include <stdarg.h>
#include "base/CCRef.h"
#include "base/ccMacros.h" #include "base/ccMacros.h"
#include "base/CCPlatformMacros.h" #include "base/CCPlatformMacros.h"
@ -73,6 +74,7 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
class CC_DLL Console class CC_DLL Console
: public Ref
{ {
public: public:
struct Command { struct Command {

View File

@ -26,258 +26,94 @@
#include "CCController.h" #include "CCController.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include <functional>
#include "CCGamepad.h"
#include "CCControllerDirectionPad.h"
#include "CCControllerButtonInput.h"
#include "CCControllerAxisInput.h"
#include "CCControllerThumbstick.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "CCEventDispatcher.h"
#include "CCEventController.h"
#include "CCEventListenerController.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "jni/JniHelper.h" #include "jni/JniHelper.h"
#include "base/CCEventController.h"
NS_CC_BEGIN NS_CC_BEGIN
enum class AndroidControllerCode
{
THUMBSTICK_LEFT_X = 100,
THUMBSTICK_LEFT_Y = 101,
THUMBSTICK_RIGHT_X = 102,
THUMBSTICK_RIGHT_Y = 103,
BUTTON_A = 110,
BUTTON_B = 111,
BUTTON_C = 112,
BUTTON_X = 113,
BUTTON_Y = 114,
BUTTON_Z = 115,
BUTTON_LEFT_SHOULDER = 120,
BUTTON_RIGHT_SHOULDER = 121,
BUTTON_LEFT_TRIGGER = 122,
BUTTON_RIGHT_TRIGGER = 123,
BUTTON_DPAD_UP = 130,
BUTTON_DPAD_DOWN = 131,
BUTTON_DPAD_LEFT = 132,
BUTTON_DPAD_RIGHT = 133,
BUTTON_DPAD_CENTER = 134,
BUTTON_LEFT_THUMBSTICK = 140,
BUTTON_RIGHT_THUMBSTICK = 141,
BUTTON_START = 150,
BUTTON_SELECT = 151,
};
class ControllerImpl class ControllerImpl
{ {
public: public:
ControllerImpl(Controller* controller) ControllerImpl(Controller* controller)
: _controller(controller) : _controller(controller)
, _controllerID(-1)
{ {
} }
static std::vector<Controller*>::iterator findController(const std::string& vendorName, int controllerID) static std::vector<Controller*>::iterator findController(const std::string& deviceName, int deviceId)
{ {
auto iter = std::find_if(Controller::_controllers.begin(), Controller::_controllers.end(), [&](Controller* controller){ auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
return (vendorName == controller->getVendorName()) && (controllerID == controller->_impl->_controllerID); return (deviceName == controller->_deviceName) && (deviceId == controller->_deviceId);
}); });
return iter;
} }
static void onConnected(const std::string& vendorName, int controllerID) static void onConnected(const std::string& deviceName, int deviceId)
{ {
// Check whether the controller is already connected. // Check whether the controller is already connected.
auto iter = findController(vendorName, controllerID); CCLOG("onConnected %s,%d", deviceName.c_str(),deviceId);
if (iter != Controller::_controllers.end())
auto iter = findController(deviceName, deviceId);
if (iter != Controller::s_allController.end())
return; return;
// It's a new controller being connected. // It's a new controller being connected.
auto controller = new cocos2d::Controller(); auto controller = new cocos2d::Controller();
controller->_vendorName = vendorName; controller->_deviceId = deviceId;
Controller::_controllers.push_back(controller); controller->_deviceName = deviceName;
controller->_impl->_controllerID = controllerID; Controller::s_allController.push_back(controller);
EventController evt(EventController::ControllerEventType::CONNECTION, controller, true);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); controller->onConnected();
} }
static void onDisconnected(const std::string& vendorName, int controllerID) static void onDisconnected(const std::string& deviceName, int deviceId)
{ {
auto iter = findController(vendorName, controllerID); CCLOG("onDisconnected %s,%d", deviceName.c_str(),deviceId);
if (iter == Controller::_controllers.end())
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{ {
CCLOGERROR("Could not find the controller!"); CCLOGERROR("Could not find the controller!");
return; return;
} }
EventController evt(EventController::ControllerEventType::CONNECTION, *iter, false); (*iter)->onDisconnected();
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); Controller::s_allController.erase(iter);
Controller::_controllers.erase(iter);
} }
void sendEventButton(ControllerButtonInput* button, bool isPressed, float value, bool isAnalog) static void onButtonEvent(const std::string& deviceName, int deviceId, int keyCode, bool isPressed, float value, bool isAnalog)
{ {
button->setPressed(isPressed); auto iter = findController(deviceName, deviceId);
button->setValue(value); if (iter == Controller::s_allController.end())
button->setAnalog(isAnalog); {
EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, _controller, button); CCLOG("onButtonEvent:connect new controller.");
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt); onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
} }
void sendEventAxis(ControllerAxisInput* axis, float value, bool isAnalog) (*iter)->onButtonEvent(keyCode, isPressed, value, isAnalog);
{
axis->setValue(value);
axis->setAnalog(isAnalog);
EventController evt(EventController::ControllerEventType::AXIS_STATUS_CHANGED, _controller, axis);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
} }
static void onButtonEvent(const std::string& vendorName, int controllerID, AndroidControllerCode btnCode, bool isPressed, float value, bool isAnalog) static void onAxisEvent(const std::string& deviceName, int deviceId, int axisCode, float value, bool isAnalog)
{ {
auto iter = findController(vendorName, controllerID); auto iter = findController(deviceName, deviceId);
if (iter == Controller::_controllers.end()) if (iter == Controller::s_allController.end())
{ {
onConnected(vendorName, controllerID); CCLOG("onAxisEvent:connect new controller.");
iter = findController(vendorName, controllerID); onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
} }
auto gamepad = (*iter)->getGamepad(); (*iter)->onAxisEvent(axisCode, value, isAnalog);
auto thiz = (*iter)->getImpl();
switch(btnCode)
{
case AndroidControllerCode::BUTTON_A:
{
thiz->sendEventButton(gamepad->getButtonA(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_B:
{
thiz->sendEventButton(gamepad->getButtonB(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_X:
{
thiz->sendEventButton(gamepad->getButtonX(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_Y:
{
thiz->sendEventButton(gamepad->getButtonY(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_LEFT_SHOULDER:
{
thiz->sendEventButton(gamepad->getLeftShoulder(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_RIGHT_SHOULDER:
{
thiz->sendEventButton(gamepad->getRightShoulder(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_LEFT_TRIGGER:
{
thiz->sendEventButton(gamepad->getLeftTrigger(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_RIGHT_TRIGGER:
{
thiz->sendEventButton(gamepad->getRightTrigger(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_DPAD_UP:
{
thiz->sendEventButton(gamepad->getDirectionPad()->getUp(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_DPAD_DOWN:
{
thiz->sendEventButton(gamepad->getDirectionPad()->getDown(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_DPAD_LEFT:
{
thiz->sendEventButton(gamepad->getDirectionPad()->getLeft(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_DPAD_RIGHT:
{
thiz->sendEventButton(gamepad->getDirectionPad()->getRight(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_START:
{
thiz->sendEventButton(gamepad->getButtonStart(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_SELECT:
{
thiz->sendEventButton(gamepad->getButtonSelect(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_LEFT_THUMBSTICK:
{
thiz->sendEventButton(gamepad->getLeftThumbstick()->getButton(), isPressed, value, isAnalog);
}
break;
case AndroidControllerCode::BUTTON_RIGHT_THUMBSTICK:
{
thiz->sendEventButton(gamepad->getRightThumbstick()->getButton(), isPressed, value, isAnalog);
}
break;
default:
// CCASSERT(false, "Invalid controller button code!");
break;
}
}
static void onAxisEvent(const std::string& vendorName, int controllerID, AndroidControllerCode axisCode, float value, bool isAnalog)
{
// log("vendorName: %s, controller id: %d, axis: %d, value: %f", vendorName.c_str(), controllerID, axisCode, value);
auto iter = findController(vendorName, controllerID);
if (iter == Controller::_controllers.end())
{
onConnected(vendorName, controllerID);
iter = findController(vendorName, controllerID);
}
auto gamepad = (*iter)->getGamepad();
auto thiz = (*iter)->getImpl();
switch (axisCode)
{
case AndroidControllerCode::THUMBSTICK_LEFT_X:
thiz->sendEventAxis(gamepad->getLeftThumbstick()->getAxisX(), value, isAnalog);
break;
case AndroidControllerCode::THUMBSTICK_LEFT_Y:
thiz->sendEventAxis(gamepad->getLeftThumbstick()->getAxisY(), value, isAnalog);
break;
case AndroidControllerCode::THUMBSTICK_RIGHT_X:
thiz->sendEventAxis(gamepad->getRightThumbstick()->getAxisX(), value, isAnalog);
break;
case AndroidControllerCode::THUMBSTICK_RIGHT_Y:
thiz->sendEventAxis(gamepad->getRightThumbstick()->getAxisY(), value, isAnalog);
break;
default:
CCASSERT(false, "Invalid controller axis code!");
break;
}
} }
private: private:
Controller* _controller; Controller* _controller;
int _controllerID;
}; };
std::vector<Controller*> Controller::_controllers;
const std::vector<Controller*>& Controller::getControllers()
{
return _controllers;
}
void Controller::startDiscoveryController() void Controller::startDiscoveryController()
{ {
// Empty implementation on Android // Empty implementation on Android
@ -288,9 +124,17 @@ void Controller::stopDiscoveryController()
// Empty implementation on Android // Empty implementation on Android
} }
const std::string& Controller::getVendorName() Controller::~Controller()
{
delete _impl;
delete _connectEvent;
delete _keyEvent;
delete _axisEvent;
}
void Controller::registerListeners()
{ {
return _vendorName;
} }
bool Controller::isConnected() const bool Controller::isConnected() const
@ -301,61 +145,50 @@ bool Controller::isConnected() const
return true; return true;
} }
int Controller::getPlayerIndex() const
{
return _playerIndex;
}
void Controller::setPlayerIndex(int playerIndex)
{
_playerIndex = playerIndex;
}
Gamepad* Controller::getGamepad() const
{
return _gamepad;
}
Controller::Controller() Controller::Controller()
: _playerIndex(PLAYER_INDEX_UNSET) : _controllerTag(TAG_UNSET)
, _gamepad(new Gamepad)
, _impl(new ControllerImpl(this)) , _impl(new ControllerImpl(this))
, _connectEvent(nullptr)
, _keyEvent(nullptr)
, _axisEvent(nullptr)
{ {
_gamepad->_controller = this; init();
} }
Controller::~Controller() void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
{ {
CC_SAFE_DELETE(_impl); JniMethodInfo t;
CC_SAFE_DELETE(_gamepad); if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/GameControllerHelper", "receiveExternalKeyEvent", "(IIZ)V")) {
t.env->CallStaticVoidMethod(t.classID, t.methodID, _deviceId, externalKeyCode, receive);
t.env->DeleteLocalRef(t.classID);
}
} }
NS_CC_END NS_CC_END
extern "C" { extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerConnected(JNIEnv* env, jobject thiz, jstring vendorName, jint controllerID) void Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerConnected(JNIEnv* env, jobject thiz, jstring deviceName, jint controllerID)
{ {
CCLOG("controller id: %d connected!", controllerID); CCLOG("controller id: %d connected!", controllerID);
cocos2d::ControllerImpl::onConnected(cocos2d::JniHelper::jstring2string(vendorName), controllerID); cocos2d::ControllerImpl::onConnected(cocos2d::JniHelper::jstring2string(deviceName), controllerID);
} }
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerDisconnected(JNIEnv* env, jobject thiz, jstring vendorName, jint controllerID) void Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerDisconnected(JNIEnv* env, jobject thiz, jstring deviceName, jint controllerID)
{ {
CCLOG("controller id: %d disconnected!", controllerID); CCLOG("controller id: %d disconnected!", controllerID);
cocos2d::ControllerImpl::onDisconnected(cocos2d::JniHelper::jstring2string(vendorName), controllerID); cocos2d::ControllerImpl::onDisconnected(cocos2d::JniHelper::jstring2string(deviceName), controllerID);
} }
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerButtonEvent(JNIEnv* env, jobject thiz, jstring vendorName, jint controllerID, jint button, jboolean isPressed, jfloat value, jboolean isAnalog) void Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerButtonEvent(JNIEnv* env, jobject thiz, jstring deviceName, jint controllerID, jint button, jboolean isPressed, jfloat value, jboolean isAnalog)
{ {
CCLOG("controller id: %d, btn code: %d, isPressed: %d, value: %f, isAnalog:%d", controllerID, button, (int)isPressed, value, (int)isAnalog); cocos2d::ControllerImpl::onButtonEvent(cocos2d::JniHelper::jstring2string(deviceName), controllerID, button, isPressed, value, isAnalog);
cocos2d::ControllerImpl::onButtonEvent(cocos2d::JniHelper::jstring2string(vendorName), controllerID, static_cast<cocos2d::AndroidControllerCode>(button), isPressed, value, isAnalog);
} }
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerAxisEvent(JNIEnv* env, jobject thiz, jstring vendorName, jint controllerID, jint axis, jfloat value, jboolean isAnalog) void Java_org_cocos2dx_lib_GameControllerAdapter_nativeControllerAxisEvent(JNIEnv* env, jobject thiz, jstring deviceName, jint controllerID, jint axis, jfloat value, jboolean isAnalog)
{ {
// CCLOG("controller id: %d, axis code: %d, value: %f, isAnalog:%d", controllerID, axis, value, (int)isAnalog); cocos2d::ControllerImpl::onAxisEvent(cocos2d::JniHelper::jstring2string(deviceName), controllerID, axis, value, isAnalog);
cocos2d::ControllerImpl::onAxisEvent(cocos2d::JniHelper::jstring2string(vendorName), controllerID, static_cast<cocos2d::AndroidControllerCode>(axis), value, isAnalog);
} }
} // extern "C" { } // extern "C" {

View File

@ -27,17 +27,12 @@
#include "base/CCPlatformConfig.h" #include "base/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "CCGamepad.h"
#include "CCControllerDirectionPad.h"
#include "CCControllerButtonInput.h"
#include "CCControllerAxisInput.h"
#include "CCControllerThumbstick.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "CCEventDispatcher.h" #include "CCEventDispatcher.h"
#include "CCEventController.h" #include "CCEventController.h"
#include "CCEventListenerController.h" #include "CCEventListenerController.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "CCLabel.h"
#import <GameController/GameController.h> #import <GameController/GameController.h>
@ -105,90 +100,49 @@ static GCControllerConnectionEventHandler* __instance = nil;
NS_CC_BEGIN NS_CC_BEGIN
#define sendEventButton(dstID, srcID) \
dstID->setPressed(srcID.isPressed); \
dstID->setValue(srcID.value); \
dstID->setAnalog(srcID.isAnalog); \
EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, _gamepad->_controller, dstID); \
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
#define sendEventAxis(dstID, srcID) \
\
dstID->setValue(srcID.value); \
dstID->setAnalog(srcID.isAnalog); \
\
EventController evt(EventController::ControllerEventType::AXIS_STATUS_CHANGED, _gamepad->_controller, dstID); \
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
class ControllerImpl class ControllerImpl
{ {
public: public:
ControllerImpl(Controller* controller) ControllerImpl(Controller* controller)
: _controller(controller) : _controller(controller)
, _gcController(nil) , _gcController(nil)
, _lazyRegisterListener(true)
{
}
~ControllerImpl()
{ {
} }
Controller* _controller; Controller* _controller;
GCController* _gcController; GCController* _gcController;
bool _lazyRegisterListener;
}; };
std::vector<Controller*> Controller::_controllers;
const std::vector<Controller*>& Controller::getControllers()
{
return _controllers;
}
void Controller::startDiscoveryController() void Controller::startDiscoveryController()
{ {
[GCController startWirelessControllerDiscoveryWithCompletionHandler: nil]; [GCController startWirelessControllerDiscoveryWithCompletionHandler: nil];
[[GCControllerConnectionEventHandler getInstance] observerConnection: ^(GCController* gcController) { [[GCControllerConnectionEventHandler getInstance] observerConnection: ^(GCController* gcController) {
auto controller = new Controller(); auto controller = new Controller();
controller->_impl->_gcController = gcController; controller->_impl->_gcController = gcController;
controller->_deviceName = [gcController.vendorName UTF8String];
gcController.controllerPausedHandler = ^(GCController* gcCon){ s_allController.push_back(controller);
auto iter = std::find_if(_controllers.begin(), _controllers.end(), [gcCon](Controller* c){ return c->_impl->_gcController == gcCon; }); controller->registerListeners();
controller->getDeviceName();
CCASSERT(iter != _controllers.end(), "Could not find the controller"); controller->onConnected();
auto button = (*iter)->getGamepad()->getButtonPause();
button->setPressed(true);
EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, (*iter), button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
// Reset the pause button status to unpressed.
button->setPressed(false);
};
_controllers.push_back(controller);
EventController evt(EventController::ControllerEventType::CONNECTION, controller, true);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
} disconnection: ^(GCController* gcController) { } disconnection: ^(GCController* gcController) {
auto iter = std::find_if(s_allController.begin(), s_allController.end(), [gcController](Controller* c){ return c->_impl->_gcController == gcController; });
auto iter = std::find_if(_controllers.begin(), _controllers.end(), [gcController](Controller* c){ return c->_impl->_gcController == gcController; }); if(iter == s_allController.end())
{
log("disconnect:Could not find the controller");
return;
}
CCASSERT(iter != _controllers.end(), "Could not find the controller"); (*iter)->onDisconnected();
s_allController.erase(iter);
EventController evt(EventController::ControllerEventType::CONNECTION, *iter, false);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
delete (*iter);
_controllers.erase(iter);
}]; }];
} }
@ -198,26 +152,156 @@ void Controller::stopDiscoveryController()
} }
Controller::Controller() Controller::Controller()
: _controllerTag(TAG_UNSET)
, _impl(new ControllerImpl(this))
, _connectEvent(nullptr)
, _keyEvent(nullptr)
, _axisEvent(nullptr)
, _deviceId(0)
{ {
_playerIndex = PLAYER_INDEX_UNSET; init();
_gamepad = new Gamepad();
_gamepad->_controller = this;
_impl = new ControllerImpl(this);
} }
Controller::~Controller() Controller::~Controller()
{ {
CC_SAFE_DELETE(_impl); delete _impl;
CC_SAFE_DELETE(_gamepad);
delete _connectEvent;
delete _keyEvent;
delete _axisEvent;
} }
const std::string& Controller::getVendorName() void Controller::registerListeners()
{ {
if (_vendorName.empty()) if (_impl->_gcController.extendedGamepad != nil)
{ {
_vendorName = [_impl->_gcController.vendorName UTF8String]; _impl->_gcController.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_UP, pressed, value, button.isAnalog);
};
_impl->_gcController.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_DOWN, pressed, value, button.isAnalog);
};
_impl->_gcController.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_LEFT, pressed, value, button.isAnalog);
};
_impl->_gcController.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_RIGHT, pressed, value, button.isAnalog);
};
_impl->_gcController.extendedGamepad.leftThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
onAxisEvent(Key::JOYSTICK_LEFT_X, value, axis.isAnalog);
};
_impl->_gcController.extendedGamepad.leftThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
onAxisEvent(Key::JOYSTICK_LEFT_Y, value, axis.isAnalog);
};
_impl->_gcController.extendedGamepad.rightThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
onAxisEvent(Key::JOYSTICK_RIGHT_X, value, axis.isAnalog);
};
_impl->_gcController.extendedGamepad.rightThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
onAxisEvent(Key::JOYSTICK_RIGHT_Y, value, axis.isAnalog);
};
_impl->_gcController.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element){
if (element == gamepad.buttonA)
{
onButtonEvent(Key::BUTTON_A, gamepad.buttonA.isPressed, gamepad.buttonA.value, gamepad.buttonA.isAnalog);
} }
return _vendorName; else if (element == gamepad.buttonB)
{
onButtonEvent(Key::BUTTON_B, gamepad.buttonB.isPressed, gamepad.buttonB.value, gamepad.buttonB.isAnalog);
}
else if (element == gamepad.buttonX)
{
onButtonEvent(Key::BUTTON_X, gamepad.buttonX.isPressed, gamepad.buttonX.value, gamepad.buttonX.isAnalog);
}
else if (element == gamepad.buttonY)
{
onButtonEvent(Key::BUTTON_Y, gamepad.buttonY.isPressed, gamepad.buttonY.value, gamepad.buttonY.isAnalog);
}
else if (element == gamepad.leftShoulder)
{
onButtonEvent(Key::BUTTON_LEFT_SHOULDER, gamepad.leftShoulder.isPressed, gamepad.leftShoulder.value, gamepad.leftShoulder.isAnalog);
}
else if (element == gamepad.rightShoulder)
{
onButtonEvent(Key::BUTTON_RIGHT_SHOULDER, gamepad.rightShoulder.isPressed, gamepad.rightShoulder.value, gamepad.rightShoulder.isAnalog);
}
else if (element == gamepad.leftTrigger)
{
onAxisEvent(Key::AXIS_LEFT_TRIGGER, gamepad.leftTrigger.value, gamepad.leftTrigger.isAnalog);
}
else if (element == gamepad.rightTrigger)
{
onAxisEvent(Key::AXIS_RIGHT_TRIGGER, gamepad.rightTrigger.value, gamepad.rightTrigger.isAnalog);
}
};
}
else
{
_impl->_gcController.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_UP, pressed, value, button.isAnalog);
};
_impl->_gcController.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_DOWN, pressed, value, button.isAnalog);
};
_impl->_gcController.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_LEFT, pressed, value, button.isAnalog);
};
_impl->_gcController.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
onButtonEvent(Key::BUTTON_DPAD_RIGHT, pressed, value, button.isAnalog);
};
_impl->_gcController.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, GCControllerElement *element){
if (element == gamepad.buttonA)
{
onButtonEvent(Key::BUTTON_A, gamepad.buttonA.isPressed, gamepad.buttonA.value, gamepad.buttonA.isAnalog);
}
else if (element == gamepad.buttonB)
{
onButtonEvent(Key::BUTTON_B, gamepad.buttonB.isPressed, gamepad.buttonB.value, gamepad.buttonB.isAnalog);
}
else if (element == gamepad.buttonX)
{
onButtonEvent(Key::BUTTON_X, gamepad.buttonX.isPressed, gamepad.buttonX.value, gamepad.buttonX.isAnalog);
}
else if (element == gamepad.buttonY)
{
onButtonEvent(Key::BUTTON_Y, gamepad.buttonY.isPressed, gamepad.buttonY.value, gamepad.buttonY.isAnalog);
}
else if (element == gamepad.leftShoulder)
{
onButtonEvent(Key::BUTTON_LEFT_SHOULDER, gamepad.leftShoulder.isPressed, gamepad.leftShoulder.value, gamepad.leftShoulder.isAnalog);
}
else if (element == gamepad.rightShoulder)
{
onButtonEvent(Key::BUTTON_RIGHT_SHOULDER, gamepad.rightShoulder.isPressed, gamepad.rightShoulder.value, gamepad.rightShoulder.isAnalog);
}
};
}
_impl->_gcController.controllerPausedHandler = ^(GCController* gcCon){
auto iter = std::find_if(s_allController.begin(), s_allController.end(), [gcCon](Controller* c){ return c->_impl->_gcController == gcCon; });
if(iter == s_allController.end())
{
log("Could not find the controller");
return;
}
onButtonEvent(Key::BUTTON_PAUSE, true, 1.0f, false);
onButtonEvent(Key::BUTTON_PAUSE, false, 0.0f, false);
};
} }
bool Controller::isConnected() const bool Controller::isConnected() const
@ -225,145 +309,8 @@ bool Controller::isConnected() const
return _impl->_gcController.isAttachedToDevice == YES; return _impl->_gcController.isAttachedToDevice == YES;
} }
int Controller::getPlayerIndex() const void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
{ {
return _playerIndex;
}
void Controller::setPlayerIndex(int playerIndex)
{
_playerIndex = playerIndex;
}
Gamepad* Controller::getGamepad() const
{
if (_impl->_gcController == nil)
return nullptr;
if(_impl->_gcController.gamepad == nil && _impl->_gcController.extendedGamepad == nil)
{
CCASSERT(false, "No gamepad was found!");
}
else if (_impl->_lazyRegisterListener)
{
_impl->_lazyRegisterListener = false;
if (_impl->_gcController.extendedGamepad != nil)
{
_impl->_gcController.extendedGamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getUp(), button);
};
_impl->_gcController.extendedGamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getDown(), button);
};
_impl->_gcController.extendedGamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getLeft(), button);
};
_impl->_gcController.extendedGamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getRight(), button);
};
_impl->_gcController.extendedGamepad.leftThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
sendEventAxis(_gamepad->getLeftThumbstick()->getAxisX(), axis);
};
_impl->_gcController.extendedGamepad.leftThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
sendEventAxis(_gamepad->getLeftThumbstick()->getAxisY(), axis);
};
_impl->_gcController.extendedGamepad.rightThumbstick.xAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
sendEventAxis(_gamepad->getRightThumbstick()->getAxisX(), axis);
};
_impl->_gcController.extendedGamepad.rightThumbstick.yAxis.valueChangedHandler = ^(GCControllerAxisInput *axis, float value){
sendEventAxis(_gamepad->getRightThumbstick()->getAxisY(), axis);
};
_impl->_gcController.extendedGamepad.valueChangedHandler = ^(GCExtendedGamepad *gamepad, GCControllerElement *element){
if (element == gamepad.buttonA)
{
sendEventButton(_gamepad->getButtonA(), gamepad.buttonA);
}
else if (element == gamepad.buttonB)
{
sendEventButton(_gamepad->getButtonB(), gamepad.buttonB);
}
else if (element == gamepad.buttonX)
{
sendEventButton(_gamepad->getButtonX(), gamepad.buttonX);
}
else if (element == gamepad.buttonY)
{
sendEventButton(_gamepad->getButtonY(), gamepad.buttonY);
}
else if (element == gamepad.leftShoulder)
{
sendEventButton(_gamepad->getLeftShoulder(), gamepad.leftShoulder);
}
else if (element == gamepad.rightShoulder)
{
sendEventButton(_gamepad->getRightShoulder(), gamepad.rightShoulder);
}
else if (element == gamepad.leftTrigger)
{
sendEventButton(_gamepad->getLeftTrigger(), gamepad.leftTrigger);
}
else if (element == gamepad.rightTrigger)
{
sendEventButton(_gamepad->getRightTrigger(), gamepad.rightTrigger);
}
};
}
else
{
_impl->_gcController.gamepad.dpad.up.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getUp(), button);
};
_impl->_gcController.gamepad.dpad.down.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getDown(), button);
};
_impl->_gcController.gamepad.dpad.left.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getLeft(), button);
};
_impl->_gcController.gamepad.dpad.right.valueChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed){
sendEventButton(_gamepad->getDirectionPad()->getRight(), button);
};
_impl->_gcController.gamepad.valueChangedHandler = ^(GCGamepad *gamepad, GCControllerElement *element){
if (element == gamepad.buttonA)
{
sendEventButton(_gamepad->getButtonA(), gamepad.buttonA);
}
else if (element == gamepad.buttonB)
{
sendEventButton(_gamepad->getButtonB(), gamepad.buttonB);
}
else if (element == gamepad.buttonX)
{
sendEventButton(_gamepad->getButtonX(), gamepad.buttonX);
}
else if (element == gamepad.buttonY)
{
sendEventButton(_gamepad->getButtonY(), gamepad.buttonY);
}
else if (element == gamepad.leftShoulder)
{
sendEventButton(_gamepad->getLeftShoulder(), gamepad.leftShoulder);
}
else if (element == gamepad.rightShoulder)
{
sendEventButton(_gamepad->getRightShoulder(), gamepad.rightShoulder);
}
};
}
}
return _gamepad;
} }
NS_CC_END NS_CC_END

117
cocos/base/CCController.cpp Normal file
View File

@ -0,0 +1,117 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCController.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "ccMacros.h"
#include "CCEventDispatcher.h"
#include "CCEventController.h"
#include "CCEventListenerController.h"
#include "CCDirector.h"
NS_CC_BEGIN
std::vector<Controller*> Controller::s_allController;
Controller* Controller::getControllerByTag(int tag)
{
for (auto controller:Controller::s_allController)
{
if (controller->_controllerTag == tag)
{
return controller;
}
}
return nullptr;
}
void Controller::init()
{
for (int key = Key::JOYSTICK_LEFT_X; key < Key::KEY_MAX; ++key)
{
_allKeyStatus[key].isPressed = false;
_allKeyStatus[key].value = 0.0f;
_allKeyPrevStatus[key].isPressed = false;
_allKeyPrevStatus[key].value = 0.0f;
}
_eventDispatcher = Director::getInstance()->getEventDispatcher();
_connectEvent = new EventController(EventController::ControllerEventType::CONNECTION, this, false);
_keyEvent = new EventController(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, this, 0);
_axisEvent = new EventController(EventController::ControllerEventType::AXIS_STATUS_CHANGED, this, 0);
}
const Controller::KeyStatus& Controller::getKeyStatus(int keyCode)
{
if (_allKeyStatus.find(keyCode) == _allKeyStatus.end())
{
_allKeyStatus[keyCode].isPressed = false;
_allKeyStatus[keyCode].value = 0.0f;
}
return _allKeyStatus[keyCode];
}
void Controller::onConnected()
{
_connectEvent->setConnectStatus(true);
_eventDispatcher->dispatchEvent(_connectEvent);
}
void Controller::onDisconnected()
{
_connectEvent->setConnectStatus(false);
_eventDispatcher->dispatchEvent(_connectEvent);
delete this;
}
void Controller::onButtonEvent(int keyCode, bool isPressed, float value, bool isAnalog)
{
_allKeyPrevStatus[keyCode] = _allKeyStatus[keyCode];
_allKeyStatus[keyCode].isPressed = isPressed;
_allKeyStatus[keyCode].value = value;
_allKeyStatus[keyCode].isAnalog = isAnalog;
_keyEvent->setKeyCode(keyCode);
_eventDispatcher->dispatchEvent(_keyEvent);
}
void Controller::onAxisEvent(int axisCode, float value, bool isAnalog)
{
_allKeyPrevStatus[axisCode] = _allKeyStatus[axisCode];
_allKeyStatus[axisCode].value = value;
_allKeyStatus[axisCode].isAnalog = isAnalog;
_axisEvent->setKeyCode(axisCode);
_eventDispatcher->dispatchEvent(_axisEvent);
}
NS_CC_END
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

View File

@ -27,50 +27,140 @@
#define __cocos2d_libs__CCController__ #define __cocos2d_libs__CCController__
#include "CCPlatformMacros.h" #include "CCPlatformMacros.h"
#include <string> #include <string>
#include <vector> #include <vector>
#include <functional> #include <unordered_map>
NS_CC_BEGIN NS_CC_BEGIN
class Gamepad;
class ControllerImpl; class ControllerImpl;
class EventListenerController;
class EventController;
class EventDispatcher;
class Controller class Controller
{ {
public: public:
static const std::vector<Controller*>& getControllers(); /** Controllers' standard key
* Controller receives only standard key which contained within enum Key by default.
*/
enum Key
{
JOYSTICK_LEFT_X = 1000,
JOYSTICK_LEFT_Y,
JOYSTICK_RIGHT_X,
JOYSTICK_RIGHT_Y,
BUTTON_A,
BUTTON_B,
BUTTON_C,
BUTTON_X,
BUTTON_Y,
BUTTON_Z,
BUTTON_DPAD_UP,
BUTTON_DPAD_DOWN,
BUTTON_DPAD_LEFT,
BUTTON_DPAD_RIGHT,
BUTTON_DPAD_CENTER,
BUTTON_LEFT_SHOULDER,
BUTTON_RIGHT_SHOULDER,
AXIS_LEFT_TRIGGER,
AXIS_RIGHT_TRIGGER,
BUTTON_LEFT_THUMBSTICK,
BUTTON_RIGHT_THUMBSTICK,
BUTTON_START,
BUTTON_SELECT,
BUTTON_PAUSE,
KEY_MAX
};
typedef struct _keyStatus
{
bool isPressed;
float value;
bool isAnalog;
}KeyStatus;
static const int TAG_UNSET = -1;
static const std::vector<Controller*>& getAllController(){ return s_allController;}
/** Gets a controller with its tag
* @param tag An identifier to find the controller.
*/
static Controller* getControllerByTag(int tag);
/** To start discovering new controllers
* @warning The API only work on the IOS platform.Empty implementation on Android
*/
static void startDiscoveryController(); static void startDiscoveryController();
/** End the discovery process
* @warning The API only work on the IOS platform.Empty implementation on Android
*/
static void stopDiscoveryController(); static void stopDiscoveryController();
const std::string& getVendorName(); const std::string& getDeviceName() const { return _deviceName;}
int getDeviceId() const { return _deviceId;}
bool isConnected() const; bool isConnected() const;
static const int PLAYER_INDEX_UNSET = -1; const KeyStatus& getKeyStatus(int keyCode);
int getPlayerIndex() const; /** Activate receives key event from external key. e.g. back,menu.
void setPlayerIndex(int playerIndex); * Controller receives only standard key which contained within enum Key by default.
* @warning The API only work on the android platform for support diversified game controller.
*
* @param externalKeyCode external key code
* @param receive true if external key event on this controller should be receive, false otherwise.
*/
void receiveExternalKeyEvent(int externalKeyCode,bool receive);
Gamepad* getGamepad() const; /** Changes the tag that is used to identify the controller easily.
* @param tag A integer that identifies the controller.
*/
void setTag(int tag) { _controllerTag = tag;}
/**
* Returns a tag that is used to identify the controller easily.
*
* @return An integer that identifies the controller.
*/
int getTag() const { return _controllerTag;}
// For internal use only private:
inline ControllerImpl* getImpl() const { return _impl; }; static std::vector<Controller*> s_allController;
Controller(); Controller();
virtual ~Controller(); virtual ~Controller();
private: void init();
static std::vector<Controller*> _controllers;
std::string _vendorName; void onConnected();
int _playerIndex; void onDisconnected();
Gamepad* _gamepad; void onButtonEvent(int keyCode, bool isPressed, float value, bool isAnalog);
void onAxisEvent(int axisCode, float value, bool isAnalog);
void registerListeners();
std::unordered_map<int, KeyStatus> _allKeyStatus;
std::unordered_map<int, KeyStatus> _allKeyPrevStatus;
std::string _deviceName;
int _deviceId;
int _controllerTag;
ControllerImpl* _impl;
EventDispatcher* _eventDispatcher;
EventController *_connectEvent;
EventController *_keyEvent;
EventController *_axisEvent;
friend class ControllerImpl; friend class ControllerImpl;
ControllerImpl* _impl; friend class EventListenerController;
}; };

View File

@ -1,63 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__CCControllerButtonInput__
#define __cocos2d_libs__CCControllerButtonInput__
#include "CCPlatformMacros.h"
#include "CCControllerElement.h"
NS_CC_BEGIN
class ControllerButtonInput : public ControllerElement
{
public:
float getValue() const;
bool isPressed() const;
bool isPrevStatusPressed() const;
protected:
ControllerButtonInput();
virtual ~ControllerButtonInput();
void setValue(float value);
void setPressed(bool isPressed);
float _value;
bool _isPressed;
bool _isPrevStatusPressed; // Whether previous status is pressed
friend class Controller;
friend class ControllerImpl;
friend class ControllerDirectionPad;
friend class ControllerThumbstick;
friend class Gamepad;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCControllerButtonInput__) */

View File

@ -1,74 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCControllerDirectionPad.h"
#include "CCControllerAxisInput.h"
#include "CCControllerButtonInput.h"
NS_CC_BEGIN
ControllerDirectionPad::ControllerDirectionPad()
: _up(new ControllerButtonInput())
, _down(new ControllerButtonInput())
, _left(new ControllerButtonInput())
, _right(new ControllerButtonInput())
{
_up->setCollection(this);
_down->setCollection(this);
_left->setCollection(this);
_right->setCollection(this);
}
ControllerDirectionPad::~ControllerDirectionPad()
{
CC_SAFE_DELETE(_up);
CC_SAFE_DELETE(_down);
CC_SAFE_DELETE(_left);
CC_SAFE_DELETE(_right);
}
ControllerButtonInput* ControllerDirectionPad::getUp() const
{
return _up;
}
ControllerButtonInput* ControllerDirectionPad::getDown() const
{
return _down;
}
ControllerButtonInput* ControllerDirectionPad::getLeft() const
{
return _left;
}
ControllerButtonInput* ControllerDirectionPad::getRight() const
{
return _right;
}
NS_CC_END

View File

@ -1,61 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__CCControllerDirectionPad__
#define __cocos2d_libs__CCControllerDirectionPad__
#include "CCPlatformMacros.h"
#include "CCControllerElement.h"
NS_CC_BEGIN
class ControllerAxisInput;
class ControllerButtonInput;
class ControllerDirectionPad : public ControllerElement
{
public:
ControllerButtonInput* getUp() const;
ControllerButtonInput* getDown() const;
ControllerButtonInput* getLeft() const;
ControllerButtonInput* getRight() const;
protected:
friend class Controller;
friend class Gamepad;
ControllerDirectionPad();
virtual ~ControllerDirectionPad();
ControllerButtonInput* _up;
ControllerButtonInput* _down;
ControllerButtonInput* _left;
ControllerButtonInput* _right;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCControllerDirectionPad__) */

View File

@ -1,64 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__CCControllerElement__
#define __cocos2d_libs__CCControllerElement__
#include "CCPlatformMacros.h"
NS_CC_BEGIN
/**
Every controller element knows which collection it belongs to and whether its input value is analog or digital.
*/
class ControllerElement
{
public:
/**
Each element can be part of a wider collection of inputs that map to a single logical element. A directional pad (dpad)
is a logical collection of two axis inputs and thus each axis belongs to the same collection element - the dpad.
*/
ControllerElement * getCollection();
/**
Check if the element can support more than just digital values, such as decimal ranges between 0 and 1.
*/
bool isAnalog() const;
protected:
ControllerElement();
virtual ~ControllerElement();
void setAnalog(bool isAnalog);
void setCollection(ControllerElement* collection);
bool _isAnalog;
ControllerElement* _collection;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCControllerElement__) */

View File

@ -1,66 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCControllerThumbstick.h"
#include "CCControllerAxisInput.h"
#include "CCControllerButtonInput.h"
NS_CC_BEGIN
ControllerThumbstick::ControllerThumbstick()
: _axisX(new ControllerAxisInput())
, _axisY(new ControllerAxisInput())
, _button(new ControllerButtonInput())
{
_axisX->setCollection(this);
_axisY->setCollection(this);
_button->setCollection(this);
}
ControllerThumbstick::~ControllerThumbstick()
{
CC_SAFE_DELETE(_axisX);
CC_SAFE_DELETE(_axisY);
CC_SAFE_DELETE(_button);
}
ControllerAxisInput* ControllerThumbstick::getAxisX() const
{
return _axisX;
}
ControllerAxisInput* ControllerThumbstick::getAxisY() const
{
return _axisY;
}
ControllerButtonInput* ControllerThumbstick::getButton() const
{
return _button;
}
NS_CC_END

View File

@ -177,7 +177,6 @@ Director::~Director(void)
CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_scheduler);
CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_actionManager);
delete _eventAfterUpdate; delete _eventAfterUpdate;
delete _eventAfterDraw; delete _eventAfterDraw;
delete _eventAfterVisit; delete _eventAfterVisit;
@ -191,12 +190,11 @@ Director::~Director(void)
CC_SAFE_RELEASE(_eventDispatcher); CC_SAFE_RELEASE(_eventDispatcher);
// clean auto release pool
PoolManager::destroyInstance();
// delete _lastUpdate // delete _lastUpdate
CC_SAFE_DELETE(_lastUpdate); CC_SAFE_DELETE(_lastUpdate);
Configuration::destroyInstance();
s_SharedDirector = nullptr; s_SharedDirector = nullptr;
} }
@ -976,7 +974,6 @@ void Director::purgeDirector()
GLProgramCache::destroyInstance(); GLProgramCache::destroyInstance();
GLProgramStateCache::destroyInstance(); GLProgramStateCache::destroyInstance();
FileUtils::destroyInstance(); FileUtils::destroyInstance();
Configuration::destroyInstance();
// cocos2d-x specific data structures // cocos2d-x specific data structures
UserDefault::destroyInstance(); UserDefault::destroyInstance();

View File

@ -27,10 +27,10 @@
NS_CC_BEGIN NS_CC_BEGIN
EventController::EventController(ControllerEventType type, Controller* controller, ControllerElement* element) EventController::EventController(ControllerEventType type, Controller* controller, int keyCode)
: Event(Type::GAME_CONTROLLER) : Event(Type::GAME_CONTROLLER)
, _controllerEventType(type) , _controllerEventType(type)
, _element(element) , _keyCode(keyCode)
, _controller(controller) , _controller(controller)
, _isConnected(true) , _isConnected(true)
{ {
@ -40,31 +40,11 @@ EventController::EventController(ControllerEventType type, Controller* controlle
EventController::EventController(ControllerEventType type, Controller* controller, bool isConnected) EventController::EventController(ControllerEventType type, Controller* controller, bool isConnected)
: Event(Type::GAME_CONTROLLER) : Event(Type::GAME_CONTROLLER)
, _controllerEventType(type) , _controllerEventType(type)
, _element(nullptr)
, _controller(controller) , _controller(controller)
, _isConnected(isConnected) , _isConnected(isConnected)
, _keyCode(0)
{ {
} }
EventController::ControllerEventType EventController::getControllerEventType() const
{
return _controllerEventType;
}
Controller* EventController::getController() const
{
return _controller;
}
ControllerElement* EventController::getControllerElement() const
{
return _element;
}
bool EventController::isConnected() const
{
return _isConnected;
}
NS_CC_END NS_CC_END

View File

@ -31,10 +31,8 @@
NS_CC_BEGIN NS_CC_BEGIN
class ControllerButtonInput;
class ControllerAxisInput;
class ControllerElement;
class Controller; class Controller;
class EventListenerController;
class EventController : public Event class EventController : public Event
{ {
@ -46,19 +44,25 @@ public:
AXIS_STATUS_CHANGED, AXIS_STATUS_CHANGED,
}; };
EventController(ControllerEventType type, Controller* controller, ControllerElement* element); EventController(ControllerEventType type, Controller* controller, int keyCode);
EventController(ControllerEventType type, Controller* controller, bool isConnected); EventController(ControllerEventType type, Controller* controller, bool isConnected);
ControllerEventType getControllerEventType() const; ControllerEventType getControllerEventType() const { return _controllerEventType; }
Controller* getController() const; Controller* getController() const { return _controller; }
ControllerElement* getControllerElement() const;
bool isConnected() const; int getKeyCode() const{ return _keyCode; }
void setKeyCode(int keyCode) { _keyCode = keyCode;}
void setConnectStatus(bool isConnected) {_isConnected = isConnected;}
bool isConnected() const { return _isConnected; }
protected: protected:
ControllerEventType _controllerEventType; ControllerEventType _controllerEventType;
ControllerElement* _element;
Controller* _controller; Controller* _controller;
int _keyCode;
bool _isConnected; bool _isConnected;
friend class EventListenerController;
}; };
NS_CC_END NS_CC_END

View File

@ -211,6 +211,7 @@ EventDispatcher::EventDispatcher()
// Therefore, internal listeners would not be cleaned when removeAllEventListeners is invoked. // Therefore, internal listeners would not be cleaned when removeAllEventListeners is invoked.
_internalCustomListenerIDs.insert(EVENT_COME_TO_FOREGROUND); _internalCustomListenerIDs.insert(EVENT_COME_TO_FOREGROUND);
_internalCustomListenerIDs.insert(EVENT_COME_TO_BACKGROUND); _internalCustomListenerIDs.insert(EVENT_COME_TO_BACKGROUND);
_internalCustomListenerIDs.insert(EVENT_RENDERER_RECREATED);
} }
EventDispatcher::~EventDispatcher() EventDispatcher::~EventDispatcher()
@ -613,7 +614,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (l->getAssociatedNode() != nullptr) if (l->getAssociatedNode() != nullptr)
{ {
dissociateNodeAndEventListener(l->getAssociatedNode(), l); dissociateNodeAndEventListener(l->getAssociatedNode(), l);
l->setAssociatedNode(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes. l->setAssociatedNode(nullptr); // nullptr out the node pointer so we don't have any dangling pointers to destroyed nodes.
} }
if (_inDispatch == 0) if (_inDispatch == 0)
@ -1276,7 +1277,7 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
if (l->getAssociatedNode() != nullptr) if (l->getAssociatedNode() != nullptr)
{ {
dissociateNodeAndEventListener(l->getAssociatedNode(), l); dissociateNodeAndEventListener(l->getAssociatedNode(), l);
l->setAssociatedNode(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes. l->setAssociatedNode(nullptr); // nullptr out the node pointer so we don't have any dangling pointers to destroyed nodes.
} }
if (_inDispatch == 0) if (_inDispatch == 0)

View File

@ -25,9 +25,8 @@
#include "CCEventListenerController.h" #include "CCEventListenerController.h"
#include "CCEventController.h" #include "CCEventController.h"
#include "CCControllerButtonInput.h"
#include "CCControllerAxisInput.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "base/CCController.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -51,8 +50,9 @@ bool EventListenerController::init()
{ {
auto listener = [this](Event* event){ auto listener = [this](Event* event){
auto evtController = static_cast<EventController*>(event); auto evtController = static_cast<EventController*>(event);
if (evtController->getControllerEventType() == EventController::ControllerEventType::CONNECTION) switch (evtController->getControllerEventType())
{ {
case EventController::ControllerEventType::CONNECTION:
if (evtController->isConnected()) if (evtController->isConnected())
{ {
if (this->onConnected) if (this->onConnected)
@ -63,35 +63,31 @@ bool EventListenerController::init()
if (this->onDisconnected) if (this->onDisconnected)
this->onDisconnected(evtController->getController(), event); this->onDisconnected(evtController->getController(), event);
} }
} break;
else
{
switch (evtController->getControllerEventType()) {
case EventController::ControllerEventType::BUTTON_STATUS_CHANGED: case EventController::ControllerEventType::BUTTON_STATUS_CHANGED:
{ {
auto button = static_cast<ControllerButtonInput*>(evtController->getControllerElement()); const auto& keyStatus = evtController->_controller->_allKeyStatus[evtController->_keyCode];
const auto& keyPrevStatus = evtController->_controller->_allKeyPrevStatus[evtController->_keyCode];
if (this->onButtonPressed && button->isPressed() && !button->isPrevStatusPressed()) if (this->onKeyDown && keyStatus.isPressed && !keyPrevStatus.isPressed)
{ {
this->onButtonPressed(evtController->getController(), button, event); this->onKeyDown(evtController->_controller, evtController->_keyCode, event);
} }
else if (this->onButtonReleased && !button->isPressed() && button->isPrevStatusPressed()) else if (this->onKeyUp && !keyStatus.isPressed && keyPrevStatus.isPressed)
{ {
this->onButtonReleased(evtController->getController(), button, event); this->onKeyUp(evtController->_controller, evtController->_keyCode, event);
} }
else if (this->onKeyRepeat && keyStatus.isPressed && keyPrevStatus.isPressed)
if (this->onButtonValueChanged)
{ {
this->onButtonValueChanged(evtController->getController(), button, event); this->onKeyRepeat(evtController->_controller, evtController->_keyCode, event);
} }
} }
break; break;
case EventController::ControllerEventType::AXIS_STATUS_CHANGED: case EventController::ControllerEventType::AXIS_STATUS_CHANGED:
{ {
if (this->onAxisValueChanged) if (this->onAxisEvent)
{ {
auto axis = static_cast<ControllerAxisInput*>(evtController->getControllerElement()); this->onAxisEvent(evtController->_controller, evtController->_keyCode, event);
this->onAxisValueChanged(evtController->getController(), axis, event);
} }
} }
break; break;
@ -99,7 +95,6 @@ bool EventListenerController::init()
CCASSERT(false, "Invalid EventController type"); CCASSERT(false, "Invalid EventController type");
break; break;
} }
}
}; };
if (EventListener::init(EventListener::Type::GAME_CONTROLLER, LISTENER_ID, listener)) if (EventListener::init(EventListener::Type::GAME_CONTROLLER, LISTENER_ID, listener))

View File

@ -33,8 +33,6 @@ NS_CC_BEGIN
class Event; class Event;
class Controller; class Controller;
class ControllerButtonInput;
class ControllerAxisInput;
class EventListenerController : public EventListener class EventListenerController : public EventListener
{ {
@ -50,11 +48,11 @@ public:
std::function<void(Controller*, Event*)> onConnected; std::function<void(Controller*, Event*)> onConnected;
std::function<void(Controller*, Event*)> onDisconnected; std::function<void(Controller*, Event*)> onDisconnected;
std::function<void(Controller*, ControllerButtonInput*, Event*)> onButtonPressed; std::function<void(Controller*, int, Event*)> onKeyDown;
std::function<void(Controller*, ControllerButtonInput*, Event*)> onButtonReleased; std::function<void(Controller*, int, Event*)> onKeyUp;
std::function<void(Controller*, ControllerButtonInput*, Event*)> onButtonValueChanged; std::function<void(Controller*, int, Event*)> onKeyRepeat;
std::function<void(Controller*, ControllerAxisInput*, Event*)> onAxisValueChanged; std::function<void(Controller*, int, Event*)> onAxisEvent;
protected: protected:
bool init(); bool init();

View File

@ -30,7 +30,7 @@ NS_CC_BEGIN
EventMouse::EventMouse(MouseEventType mouseEventCode) EventMouse::EventMouse(MouseEventType mouseEventCode)
: Event(Type::MOUSE) : Event(Type::MOUSE)
, _mouseEventType(mouseEventCode) , _mouseEventType(mouseEventCode)
, _mouseButton(0) , _mouseButton(-1)
, _x(0.0f) , _x(0.0f)
, _y(0.0f) , _y(0.0f)
, _scrollX(0.0f) , _scrollX(0.0f)

View File

@ -30,13 +30,17 @@
*/ */
// The application will come to foreground. // The application will come to foreground.
// This message is used for reloading resources before come to foreground on Android. // This message is posted in cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp.
// This message is posted in main.cpp.
#define EVENT_COME_TO_FOREGROUND "event_come_to_foreground" #define EVENT_COME_TO_FOREGROUND "event_come_to_foreground"
// The renderer[android:GLSurfaceView.Renderer WP8:Cocos2dRenderer] was recreated.
// This message is used for reloading resources before renderer is recreated on Android/WP8.
// This message is posted in cocos/platform/android/javaactivity.cpp and cocos\platform\wp8-xaml\cpp\Cocos2dRenderer.cpp.
#define EVENT_RENDERER_RECREATED "event_renderer_recreated"
// The application will come to background. // The application will come to background.
// This message is used for doing something before coming to background, such as save RenderTexture. // This message is used for doing something before coming to background, such as save RenderTexture.
// This message is posted in cocos2dx/platform/android/jni/MessageJni.cpp. // This message is posted in cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp and cocos\platform\wp8-xaml\cpp\Cocos2dRenderer.cpp.
#define EVENT_COME_TO_BACKGROUND "event_come_to_background" #define EVENT_COME_TO_BACKGROUND "event_come_to_background"
#endif // __CCEVENT_TYPE_H__ #endif // __CCEVENT_TYPE_H__

View File

@ -26,12 +26,6 @@
#ifndef __cocos2d_libs__CCGameController__ #ifndef __cocos2d_libs__CCGameController__
#define __cocos2d_libs__CCGameController__ #define __cocos2d_libs__CCGameController__
#include "CCControllerElement.h"
#include "CCControllerButtonInput.h"
#include "CCControllerAxisInput.h"
#include "CCControllerDirectionPad.h"
#include "CCControllerThumbstick.h"
#include "CCGamepad.h"
#include "CCController.h" #include "CCController.h"
#include "CCEventController.h" #include "CCEventController.h"
#include "CCEventListenerController.h" #include "CCEventListenerController.h"

View File

@ -1,146 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCGamepad.h"
#include "CCControllerDirectionPad.h"
#include "CCControllerButtonInput.h"
#include "CCControllerThumbstick.h"
NS_CC_BEGIN
Gamepad::Gamepad()
: _controller(nullptr)
, _directionPad(new ControllerDirectionPad())
, _buttonA(new ControllerButtonInput())
, _buttonB(new ControllerButtonInput())
, _buttonX(new ControllerButtonInput())
, _buttonY(new ControllerButtonInput())
, _buttonSelect(new ControllerButtonInput())
, _buttonStart(new ControllerButtonInput())
, _buttonPause(new ControllerButtonInput())
, _leftShoulder(new ControllerButtonInput())
, _rightShoulder(new ControllerButtonInput())
, _leftThumbstick(new ControllerThumbstick())
, _rightThumbstick(new ControllerThumbstick())
, _leftTrigger(new ControllerButtonInput())
, _rightTrigger(new ControllerButtonInput())
{
}
Gamepad::~Gamepad()
{
CC_SAFE_DELETE(_directionPad);
CC_SAFE_DELETE(_buttonA);
CC_SAFE_DELETE(_buttonB);
CC_SAFE_DELETE(_buttonX);
CC_SAFE_DELETE(_buttonY);
CC_SAFE_DELETE(_buttonSelect);
CC_SAFE_DELETE(_buttonStart);
CC_SAFE_DELETE(_buttonPause);
CC_SAFE_DELETE(_leftShoulder);
CC_SAFE_DELETE(_rightShoulder);
CC_SAFE_DELETE(_leftThumbstick);
CC_SAFE_DELETE(_rightThumbstick);
CC_SAFE_DELETE(_leftTrigger);
CC_SAFE_DELETE(_rightTrigger);
}
Controller* Gamepad::getController()
{
return _controller;
}
ControllerDirectionPad* Gamepad::getDirectionPad() const
{
return _directionPad;
}
ControllerButtonInput* Gamepad::getButtonA() const
{
return _buttonA;
}
ControllerButtonInput* Gamepad::getButtonB() const
{
return _buttonB;
}
ControllerButtonInput* Gamepad::getButtonX() const
{
return _buttonX;
}
ControllerButtonInput* Gamepad::getButtonY() const
{
return _buttonY;
}
ControllerButtonInput* Gamepad::getButtonPause() const
{
return _buttonPause;
}
ControllerButtonInput* Gamepad::getButtonSelect() const
{
return _buttonSelect;
}
ControllerButtonInput* Gamepad::getButtonStart() const
{
return _buttonStart;
}
ControllerButtonInput* Gamepad::getLeftShoulder() const
{
return _leftShoulder;
}
ControllerButtonInput* Gamepad::getRightShoulder() const
{
return _rightShoulder;
}
ControllerThumbstick* Gamepad::getLeftThumbstick() const
{
return _leftThumbstick;
}
ControllerThumbstick* Gamepad::getRightThumbstick() const
{
return _rightThumbstick;
}
ControllerButtonInput* Gamepad::getLeftTrigger() const
{
return _leftTrigger;
}
ControllerButtonInput* Gamepad::getRightTrigger() const
{
return _rightTrigger;
}
NS_CC_END

View File

@ -1,122 +0,0 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __cocos2d_libs__CCGamepad__
#define __cocos2d_libs__CCGamepad__
#include "CCPlatformMacros.h"
NS_CC_BEGIN
class ControllerButtonInput;
class ControllerDirectionPad;
class ControllerThumbstick;
class Controller;
class Gamepad
{
public:
/**
A profile keeps a reference to the controller that this profile is mapping input from.
*/
Controller* getController();
// API for Standard / Extended Gamepad
ControllerDirectionPad* getDirectionPad() const;
/**
All face buttons are required to be analog in the Extended profile. These must be arranged
in the diamond pattern given below:
Y
/ \
X B
\ /
A
*/
ControllerButtonInput* getButtonA() const;
ControllerButtonInput* getButtonB() const;
ControllerButtonInput* getButtonX() const;
ControllerButtonInput* getButtonY() const;
// Select button
ControllerButtonInput* getButtonSelect() const;
// Start button
ControllerButtonInput* getButtonStart() const;
// Pause button
ControllerButtonInput* getButtonPause() const;
// Shoulder buttons
ControllerButtonInput* getLeftShoulder() const;
ControllerButtonInput* getRightShoulder() const;
// API for Extended Gamepad only
/**
A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog.
*/
ControllerThumbstick* getLeftThumbstick() const;
ControllerThumbstick* getRightThumbstick() const;
/**
If Trigger button supports analog inputs, it could be used as acceleration and decelleration in a driving game for example.
*/
ControllerButtonInput* getLeftTrigger() const;
ControllerButtonInput* getRightTrigger() const;
protected:
Gamepad();
virtual ~Gamepad();
friend class Controller;
Controller* _controller;
ControllerDirectionPad* _directionPad;
ControllerButtonInput* _buttonA;
ControllerButtonInput* _buttonB;
ControllerButtonInput* _buttonX;
ControllerButtonInput* _buttonY;
ControllerButtonInput* _buttonSelect;
ControllerButtonInput* _buttonStart;
ControllerButtonInput* _buttonPause;
ControllerButtonInput* _leftShoulder;
ControllerButtonInput* _rightShoulder;
ControllerThumbstick* _leftThumbstick;
ControllerThumbstick* _rightThumbstick;
ControllerButtonInput* _leftTrigger;
ControllerButtonInput* _rightTrigger;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCGamepad__) */

View File

@ -46,6 +46,7 @@ Ref::Ref()
static unsigned int uObjectCount = 0; static unsigned int uObjectCount = 0;
_luaID = 0; _luaID = 0;
_ID = ++uObjectCount; _ID = ++uObjectCount;
_scriptObject = nullptr;
#endif #endif
#if CC_USE_MEM_LEAK_DETECTION #if CC_USE_MEM_LEAK_DETECTION
@ -64,7 +65,7 @@ Ref::~Ref()
else else
{ {
ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript) if (pEngine != nullptr && pEngine->getScriptType() == kScriptTypeJavascript)
{ {
pEngine->removeScriptObjectByObject(this); pEngine->removeScriptObjectByObject(this);
} }

View File

@ -142,6 +142,8 @@ public:
unsigned int _ID; unsigned int _ID;
/// Lua reference id /// Lua reference id
int _luaID; int _luaID;
/// scriptObject, support for swift
void* _scriptObject;
#endif #endif
// Memory leak diagnostic data (only included when CC_USE_MEM_LEAK_DETECTION is defined and its value isn't zero) // Memory leak diagnostic data (only included when CC_USE_MEM_LEAK_DETECTION is defined and its value isn't zero)

View File

@ -173,7 +173,7 @@ public:
/** /**
* @js NA * @js NA
*/ */
const static std::string& getXMLFilePath(); static const std::string& getXMLFilePath();
/** /**
* @js NA * @js NA
*/ */

View File

@ -455,7 +455,7 @@ void UserDefault::setDataForKey(const char* pKey, const Data& value)
deleteNodeByKey(pKey); deleteNodeByKey(pKey);
#endif #endif
CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), value.getSize()); CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), (int)(value.getSize()));
char * encodedData = nullptr; char * encodedData = nullptr;
unsigned int encodedDataLen = base64Encode(value.getBytes(), value.getSize(), &encodedData); unsigned int encodedDataLen = base64Encode(value.getBytes(), value.getSize(), &encodedData);

View File

@ -181,7 +181,7 @@ void tgaFlipImage( tImageTGA *info )
unsigned char *row = (unsigned char *)malloc(rowbytes); unsigned char *row = (unsigned char *)malloc(rowbytes);
int y; int y;
if (row == NULL) return; if (row == nullptr) return;
for( y = 0; y < (info->height/2); y++ ) for( y = 0; y < (info->height/2); y++ )
{ {
@ -233,7 +233,7 @@ tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size)
info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total); info->imageData = (unsigned char *)malloc(sizeof(unsigned char) * total);
// check to make sure we have the memory required // check to make sure we have the memory required
if (info->imageData == NULL) if (info->imageData == nullptr)
{ {
info->status = TGA_ERROR_MEMORY; info->status = TGA_ERROR_MEMORY;
break; break;

View File

@ -202,9 +202,6 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
0 -- disabled 0 -- disabled
1 -- draw bounding box 1 -- draw bounding box
2 -- draw texture box 2 -- draw texture box
0 -- disabled
1 -- draw bounding box
2 -- draw texture box
*/ */
#ifndef CC_SPRITE_DEBUG_DRAW #ifndef CC_SPRITE_DEBUG_DRAW
#define CC_SPRITE_DEBUG_DRAW 0 #define CC_SPRITE_DEBUG_DRAW 0

View File

@ -33,6 +33,7 @@ THE SOFTWARE.
#include "math/CCGeometry.h" #include "math/CCGeometry.h"
#include "math/CCMath.h" #include "math/CCMath.h"
#include "CCGL.h" #include "CCGL.h"
#include "CCRef.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -65,15 +66,15 @@ struct Color3B
GLubyte g; GLubyte g;
GLubyte b; GLubyte b;
const static Color3B WHITE; static const Color3B WHITE;
const static Color3B YELLOW; static const Color3B YELLOW;
const static Color3B BLUE; static const Color3B BLUE;
const static Color3B GREEN; static const Color3B GREEN;
const static Color3B RED; static const Color3B RED;
const static Color3B MAGENTA; static const Color3B MAGENTA;
const static Color3B BLACK; static const Color3B BLACK;
const static Color3B ORANGE; static const Color3B ORANGE;
const static Color3B GRAY; static const Color3B GRAY;
}; };
/** RGBA color composed of 4 bytes /** RGBA color composed of 4 bytes
@ -98,15 +99,15 @@ struct Color4B
GLubyte b; GLubyte b;
GLubyte a; GLubyte a;
const static Color4B WHITE; static const Color4B WHITE;
const static Color4B YELLOW; static const Color4B YELLOW;
const static Color4B BLUE; static const Color4B BLUE;
const static Color4B GREEN; static const Color4B GREEN;
const static Color4B RED; static const Color4B RED;
const static Color4B MAGENTA; static const Color4B MAGENTA;
const static Color4B BLACK; static const Color4B BLACK;
const static Color4B ORANGE; static const Color4B ORANGE;
const static Color4B GRAY; static const Color4B GRAY;
}; };
@ -137,15 +138,15 @@ struct Color4F
GLfloat b; GLfloat b;
GLfloat a; GLfloat a;
const static Color4F WHITE; static const Color4F WHITE;
const static Color4F YELLOW; static const Color4F YELLOW;
const static Color4F BLUE; static const Color4F BLUE;
const static Color4F GREEN; static const Color4F GREEN;
const static Color4F RED; static const Color4F RED;
const static Color4F MAGENTA; static const Color4F MAGENTA;
const static Color4F BLACK; static const Color4F BLACK;
const static Color4F ORANGE; static const Color4F ORANGE;
const static Color4F GRAY; static const Color4F GRAY;
}; };
/** A vertex composed of 2 floats: x, y /** A vertex composed of 2 floats: x, y
@ -334,13 +335,13 @@ struct BlendFunc
GLenum dst; GLenum dst;
//! Blending disabled. Uses {GL_ONE, GL_ZERO} //! Blending disabled. Uses {GL_ONE, GL_ZERO}
const static BlendFunc DISABLE; static const BlendFunc DISABLE;
//! Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} //! Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}
const static BlendFunc ALPHA_PREMULTIPLIED; static const BlendFunc ALPHA_PREMULTIPLIED;
//! Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} //! Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}
const static BlendFunc ALPHA_NON_PREMULTIPLIED; static const BlendFunc ALPHA_NON_PREMULTIPLIED;
//! Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE} //! Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE}
const static BlendFunc ADDITIVE; static const BlendFunc ADDITIVE;
bool operator==(const BlendFunc &a) const bool operator==(const BlendFunc &a) const
{ {
@ -484,6 +485,7 @@ public:
@brief The device accelerometer reports values for each axis in units of g-force @brief The device accelerometer reports values for each axis in units of g-force
*/ */
class Acceleration class Acceleration
: public Ref
{ {
public: public:
double x; double x;

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion() const char* cocos2dVersion()
{ {
return "cocos2d-x 3.2alpha0"; return "cocos2d-x 3.2beta0";
} }
NS_CC_END NS_CC_END

View File

@ -253,6 +253,8 @@ THE SOFTWARE.
#include "2d/CCTMXTiledMap.h" #include "2d/CCTMXTiledMap.h"
#include "2d/CCTMXXMLParser.h" #include "2d/CCTMXXMLParser.h"
#include "2d/CCTileMapAtlas.h" #include "2d/CCTileMapAtlas.h"
#include "2d/CCFastTMXTiledMap.h"
#include "2d/CCFastTMXLayer.h"
// component // component
#include "2d/CCComponent.h" #include "2d/CCComponent.h"
@ -261,6 +263,10 @@ THE SOFTWARE.
//3d //3d
#include "3d/CCSprite3D.h" #include "3d/CCSprite3D.h"
#include "3d/CCMesh.h" #include "3d/CCMesh.h"
#include "3d/CCMeshSkin.h"
#include "3d/CCAnimate3D.h"
#include "3d/CCAnimation3D.h"
#include "3d/CCSprite3DMaterial.h"
// Audio // Audio
#include "audio/include/SimpleAudioEngine.h" #include "audio/include/SimpleAudioEngine.h"

View File

@ -1020,7 +1020,7 @@ CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnableVertexAttribs(unsigned int
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2D(GLuint textureId) { GL::bindTexture2D(textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2D(GLuint textureId) { GL::bindTexture2D(textureId); }
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) { GL::bindTexture2DN(textureUnit, textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) { GL::bindTexture2DN(textureUnit, textureId); }
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTexture(GLuint textureId) { GL::deleteTexture(textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTexture(GLuint textureId) { GL::deleteTexture(textureId); }
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) { GL::deleteTextureN(textureUnit, textureId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) { GL::deleteTexture(textureId); }
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindVAO(GLuint vaoId) { GL::bindVAO(vaoId); } CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindVAO(GLuint vaoId) { GL::bindVAO(vaoId); }
CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnable( int flags ) { /* ignore */ }; CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnable( int flags ) { /* ignore */ };
CC_DEPRECATED_ATTRIBUTE typedef int ccGLServerState; CC_DEPRECATED_ATTRIBUTE typedef int ccGLServerState;

View File

@ -97,7 +97,7 @@ unsigned int __Dictionary::count()
__Array* __Dictionary::allKeys() __Array* __Dictionary::allKeys()
{ {
int iKeyCount = this->count(); int iKeyCount = this->count();
if (iKeyCount <= 0) return NULL; if (iKeyCount <= 0) return nullptr;
__Array* array = __Array::createWithCapacity(iKeyCount); __Array* array = __Array::createWithCapacity(iKeyCount);
@ -127,7 +127,7 @@ __Array* __Dictionary::allKeys()
__Array* __Dictionary::allKeysForObject(Ref* object) __Array* __Dictionary::allKeysForObject(Ref* object)
{ {
int iKeyCount = this->count(); int iKeyCount = this->count();
if (iKeyCount <= 0) return NULL; if (iKeyCount <= 0) return nullptr;
__Array* array = __Array::create(); __Array* array = __Array::create();
DictElement *pElement, *tmp; DictElement *pElement, *tmp;
@ -161,16 +161,16 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
Ref* __Dictionary::objectForKey(const std::string& key) Ref* __Dictionary::objectForKey(const std::string& key)
{ {
// if dictionary wasn't initialized, return NULL directly. // if dictionary wasn't initialized, return nullptr directly.
if (_dictType == kDictUnknown) return NULL; if (_dictType == kDictUnknown) return nullptr;
// __Dictionary only supports one kind of key, string or integer. // __Dictionary only supports one kind of key, string or integer.
// This method uses string as key, therefore we should make sure that the key type of this __Dictionary is string. // This method uses string as key, therefore we should make sure that the key type of this __Dictionary is string.
CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key."); CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key.");
Ref* pRetObject = NULL; Ref* pRetObject = nullptr;
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), pElement); HASH_FIND_STR(_elements, key.c_str(), pElement);
if (pElement != NULL) if (pElement != nullptr)
{ {
pRetObject = pElement->_object; pRetObject = pElement->_object;
} }
@ -179,16 +179,16 @@ Ref* __Dictionary::objectForKey(const std::string& key)
Ref* __Dictionary::objectForKey(intptr_t key) Ref* __Dictionary::objectForKey(intptr_t key)
{ {
// if dictionary wasn't initialized, return NULL directly. // if dictionary wasn't initialized, return nullptr directly.
if (_dictType == kDictUnknown) return NULL; if (_dictType == kDictUnknown) return nullptr;
// __Dictionary only supports one kind of key, string or integer. // __Dictionary only supports one kind of key, string or integer.
// This method uses integer as key, therefore we should make sure that the key type of this __Dictionary is integer. // This method uses integer as key, therefore we should make sure that the key type of this __Dictionary is integer.
CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key."); CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key.");
Ref* pRetObject = NULL; Ref* pRetObject = nullptr;
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement); HASH_FIND_PTR(_elements, &key, pElement);
if (pElement != NULL) if (pElement != nullptr)
{ {
pRetObject = pElement->_object; pRetObject = pElement->_object;
} }
@ -198,7 +198,7 @@ Ref* __Dictionary::objectForKey(intptr_t key)
const __String* __Dictionary::valueForKey(const std::string& key) const __String* __Dictionary::valueForKey(const std::string& key)
{ {
__String* pStr = dynamic_cast<__String*>(objectForKey(key)); __String* pStr = dynamic_cast<__String*>(objectForKey(key));
if (pStr == NULL) if (pStr == nullptr)
{ {
pStr = __String::create(""); pStr = __String::create("");
} }
@ -208,7 +208,7 @@ const __String* __Dictionary::valueForKey(const std::string& key)
const __String* __Dictionary::valueForKey(intptr_t key) const __String* __Dictionary::valueForKey(intptr_t key)
{ {
__String* pStr = dynamic_cast<__String*>(objectForKey(key)); __String* pStr = dynamic_cast<__String*>(objectForKey(key));
if (pStr == NULL) if (pStr == nullptr)
{ {
pStr = __String::create(""); pStr = __String::create("");
} }
@ -217,7 +217,7 @@ const __String* __Dictionary::valueForKey(intptr_t key)
void __Dictionary::setObject(Ref* pObject, const std::string& key) void __Dictionary::setObject(Ref* pObject, const std::string& key)
{ {
CCASSERT(key.length() > 0 && pObject != NULL, "Invalid Argument!"); CCASSERT(key.length() > 0 && pObject != nullptr, "Invalid Argument!");
if (_dictType == kDictUnknown) if (_dictType == kDictUnknown)
{ {
_dictType = kDictStr; _dictType = kDictStr;
@ -225,9 +225,9 @@ void __Dictionary::setObject(Ref* pObject, const std::string& key)
CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as key."); CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as key.");
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), pElement); HASH_FIND_STR(_elements, key.c_str(), pElement);
if (pElement == NULL) if (pElement == nullptr)
{ {
setObjectUnSafe(pObject, key); setObjectUnSafe(pObject, key);
} }
@ -243,7 +243,7 @@ void __Dictionary::setObject(Ref* pObject, const std::string& key)
void __Dictionary::setObject(Ref* pObject, intptr_t key) void __Dictionary::setObject(Ref* pObject, intptr_t key)
{ {
CCASSERT(pObject != NULL, "Invalid Argument!"); CCASSERT(pObject != nullptr, "Invalid Argument!");
if (_dictType == kDictUnknown) if (_dictType == kDictUnknown)
{ {
_dictType = kDictInt; _dictType = kDictInt;
@ -251,9 +251,9 @@ void __Dictionary::setObject(Ref* pObject, intptr_t key)
CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as key."); CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as key.");
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement); HASH_FIND_PTR(_elements, &key, pElement);
if (pElement == NULL) if (pElement == nullptr)
{ {
setObjectUnSafe(pObject, key); setObjectUnSafe(pObject, key);
} }
@ -277,7 +277,7 @@ void __Dictionary::removeObjectForKey(const std::string& key)
CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as its key"); CCASSERT(_dictType == kDictStr, "this dictionary doesn't use string as its key");
CCASSERT(key.length() > 0, "Invalid Argument!"); CCASSERT(key.length() > 0, "Invalid Argument!");
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), pElement); HASH_FIND_STR(_elements, key.c_str(), pElement);
removeObjectForElememt(pElement); removeObjectForElememt(pElement);
} }
@ -290,7 +290,7 @@ void __Dictionary::removeObjectForKey(intptr_t key)
} }
CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as its key"); CCASSERT(_dictType == kDictInt, "this dictionary doesn't use integer as its key");
DictElement *pElement = NULL; DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement); HASH_FIND_PTR(_elements, &key, pElement);
removeObjectForElememt(pElement); removeObjectForElememt(pElement);
} }
@ -311,7 +311,7 @@ void __Dictionary::setObjectUnSafe(Ref* pObject, const intptr_t key)
void __Dictionary::removeObjectsForKeys(__Array* pKey__Array) void __Dictionary::removeObjectsForKeys(__Array* pKey__Array)
{ {
Ref* pObj = NULL; Ref* pObj = nullptr;
CCARRAY_FOREACH(pKey__Array, pObj) CCARRAY_FOREACH(pKey__Array, pObj)
{ {
__String* pStr = static_cast<__String*>(pObj); __String* pStr = static_cast<__String*>(pObj);
@ -321,7 +321,7 @@ void __Dictionary::removeObjectsForKeys(__Array* pKey__Array)
void __Dictionary::removeObjectForElememt(DictElement* pElement) void __Dictionary::removeObjectForElememt(DictElement* pElement)
{ {
if (pElement != NULL) if (pElement != nullptr)
{ {
HASH_DEL(_elements, pElement); HASH_DEL(_elements, pElement);
pElement->_object->release(); pElement->_object->release();
@ -345,7 +345,7 @@ Ref* __Dictionary::randomObject()
{ {
if (_dictType == kDictUnknown) if (_dictType == kDictUnknown)
{ {
return NULL; return nullptr;
} }
Ref* key = allKeys()->getRandomObject(); Ref* key = allKeys()->getRandomObject();
@ -360,7 +360,7 @@ Ref* __Dictionary::randomObject()
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -566,9 +566,9 @@ __Dictionary* __Dictionary::clone() const
{ {
__Dictionary* newDict = __Dictionary::create(); __Dictionary* newDict = __Dictionary::create();
DictElement* element = NULL; DictElement* element = nullptr;
Ref* tmpObj = NULL; Ref* tmpObj = nullptr;
Clonable* obj = NULL; Clonable* obj = nullptr;
if (_dictType == kDictInt) if (_dictType == kDictInt)
{ {
CCDICT_FOREACH(this, element) CCDICT_FOREACH(this, element)

View File

@ -66,7 +66,7 @@ __Set * __Set::create()
{ {
__Set * pRet = new __Set(); __Set * pRet = new __Set();
if (pRet != NULL) if (pRet != nullptr)
{ {
pRet->autorelease(); pRet->autorelease();
} }

View File

@ -69,7 +69,7 @@ bool __String::initWithFormatAndValist(const char* format, va_list ap)
{ {
bool bRet = false; bool bRet = false;
char* pBuf = (char*)malloc(kMaxStringLen); char* pBuf = (char*)malloc(kMaxStringLen);
if (pBuf != NULL) if (pBuf != nullptr)
{ {
vsnprintf(pBuf, kMaxStringLen, format, ap); vsnprintf(pBuf, kMaxStringLen, format, ap);
_string = pBuf; _string = pBuf;
@ -170,7 +170,7 @@ void __String::appendWithFormat(const char* format, ...)
va_start(ap, format); va_start(ap, format);
char* pBuf = (char*)malloc(kMaxStringLen); char* pBuf = (char*)malloc(kMaxStringLen);
if (pBuf != NULL) if (pBuf != nullptr)
{ {
vsnprintf(pBuf, kMaxStringLen, format, ap); vsnprintf(pBuf, kMaxStringLen, format, ap);
_string.append(pBuf); _string.append(pBuf);
@ -207,7 +207,7 @@ bool __String::isEqual(const Ref* pObject)
{ {
bool bRet = false; bool bRet = false;
const __String* pStr = dynamic_cast<const __String*>(pObject); const __String* pStr = dynamic_cast<const __String*>(pObject);
if (pStr != NULL) if (pStr != nullptr)
{ {
if (0 == _string.compare(pStr->_string)) if (0 == _string.compare(pStr->_string))
{ {
@ -226,11 +226,11 @@ __String* __String::create(const std::string& str)
__String* __String::createWithData(const unsigned char* data, size_t nLen) __String* __String::createWithData(const unsigned char* data, size_t nLen)
{ {
__String* ret = NULL; __String* ret = nullptr;
if (data != NULL) if (data != nullptr)
{ {
char* pStr = (char*)malloc(nLen+1); char* pStr = (char*)malloc(nLen+1);
if (pStr != NULL) if (pStr != nullptr)
{ {
pStr[nLen] = '\0'; pStr[nLen] = '\0';
if (nLen > 0) if (nLen > 0)

View File

@ -86,15 +86,15 @@ void ControlButtonLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, con
void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL); ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL);
} }
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED); ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED);
} }
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED); ((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED);
} }
} else { } else {

View File

@ -10,15 +10,15 @@ namespace cocosbuilder {
void MenuItemImageLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { void MenuItemImageLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((MenuItemImage *)pNode)->setNormalSpriteFrame(pSpriteFrame); ((MenuItemImage *)pNode)->setNormalSpriteFrame(pSpriteFrame);
} }
} else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { } else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((MenuItemImage *)pNode)->setSelectedSpriteFrame(pSpriteFrame); ((MenuItemImage *)pNode)->setSelectedSpriteFrame(pSpriteFrame);
} }
} else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { } else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((MenuItemImage *)pNode)->setDisabledSpriteFrame(pSpriteFrame); ((MenuItemImage *)pNode)->setDisabledSpriteFrame(pSpriteFrame);
} }
} else { } else {

View File

@ -9,7 +9,7 @@ namespace cocosbuilder {
void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) { void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) { if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) {
if (NULL != pBlockData) // Add this condition to allow MenuItemImage without target/selector predefined if (nullptr != pBlockData) // Add this condition to allow MenuItemImage without target/selector predefined
{ {
((MenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->_target, std::placeholders::_1) ); ((MenuItem *)pNode)->setCallback( std::bind( pBlockData->mSELMenuHandler, pBlockData->_target, std::placeholders::_1) );
// ((MenuItem *)pNode)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler); // ((MenuItem *)pNode)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler);

View File

@ -71,7 +71,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
// #endif // #endif
// Forward properties for sub ccb files // Forward properties for sub ccb files
if (dynamic_cast<CCBFile*>(pNode) != NULL) if (dynamic_cast<CCBFile*>(pNode) != nullptr)
{ {
CCBFile *ccbNode = (CCBFile*)pNode; CCBFile *ccbNode = (CCBFile*)pNode;
if (ccbNode->getCCBFileNode() && isExtraProp) if (ccbNode->getCCBFileNode() && isExtraProp)
@ -80,7 +80,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
// Skip properties that doesn't have a value to override // Skip properties that doesn't have a value to override
__Array *extraPropsNames = (__Array*)pNode->getUserObject(); __Array *extraPropsNames = (__Array*)pNode->getUserObject();
Ref* pObj = NULL; Ref* pObj = nullptr;
bool bFound = false; bool bFound = false;
CCARRAY_FOREACH(extraPropsNames, pObj) CCARRAY_FOREACH(extraPropsNames, pObj)
{ {
@ -346,7 +346,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
case CCBReader::PropertyType::BLOCK_CONTROL: case CCBReader::PropertyType::BLOCK_CONTROL:
{ {
BlockControlData * blockControlData = this->parsePropTypeBlockControl(pNode, pParent, ccbReader); BlockControlData * blockControlData = this->parsePropTypeBlockControl(pNode, pParent, ccbReader);
if(setProp && blockControlData != NULL) { if(setProp && blockControlData != nullptr) {
this->onHandlePropTypeBlockControl(pNode, pParent, propertyName.c_str(), blockControlData, ccbReader); this->onHandlePropTypeBlockControl(pNode, pParent, propertyName.c_str(), blockControlData, ccbReader);
} }
CC_SAFE_DELETE(blockControlData); CC_SAFE_DELETE(blockControlData);
@ -574,14 +574,14 @@ SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent,
std::string spriteSheet = ccbReader->readCachedString(); std::string spriteSheet = ccbReader->readCachedString();
std::string spriteFile = ccbReader->readCachedString(); std::string spriteFile = ccbReader->readCachedString();
SpriteFrame *spriteFrame = NULL; SpriteFrame *spriteFrame = nullptr;
if (spriteFile.length() != 0) if (spriteFile.length() != 0)
{ {
if (spriteSheet.length() == 0) if (spriteSheet.length() == 0)
{ {
spriteFile = ccbReader->getCCBRootPath() + spriteFile; spriteFile = ccbReader->getCCBRootPath() + spriteFile;
Texture2D * texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str()); Texture2D * texture = Director::getInstance()->getTextureCache()->addImage(spriteFile.c_str());
if(texture != NULL) { if(texture != nullptr) {
Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height); Rect bounds = Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height);
spriteFrame = SpriteFrame::createWithTexture(texture, bounds); spriteFrame = SpriteFrame::createWithTexture(texture, bounds);
} }
@ -613,7 +613,7 @@ Animation * NodeLoader::parsePropTypeAnimation(Node * pNode, Node * pParent, CCB
std::string animationFile = ccbReader->getCCBRootPath() + ccbReader->readCachedString(); std::string animationFile = ccbReader->getCCBRootPath() + ccbReader->readCachedString();
std::string animation = ccbReader->readCachedString(); std::string animation = ccbReader->readCachedString();
Animation * ccAnimation = NULL; Animation * ccAnimation = nullptr;
// Support for stripping relative file paths, since ios doesn't currently // Support for stripping relative file paths, since ios doesn't currently
// know what to do with them, since its pulling from bundle. // know what to do with them, since its pulling from bundle.
@ -642,7 +642,7 @@ Texture2D * NodeLoader::parsePropTypeTexture(Node * pNode, Node * pParent, CCBRe
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -761,7 +761,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
if(selectorTarget != CCBReader::TargetType::NONE) if(selectorTarget != CCBReader::TargetType::NONE)
{ {
Ref* target = NULL; Ref* target = nullptr;
if(!ccbReader->isJSControlled()) if(!ccbReader->isJSControlled())
{ {
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
@ -773,7 +773,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
target = ccbReader->getOwner(); target = ccbReader->getOwner();
} }
if(target != NULL) if(target != nullptr)
{ {
if(selectorName.length() > 0) if(selectorName.length() > 0)
{ {
@ -781,7 +781,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
if(targetAsCCBSelectorResolver != NULL) if(targetAsCCBSelectorResolver != nullptr)
{ {
selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
} }
@ -789,7 +789,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
if(selMenuHandler == 0) if(selMenuHandler == 0)
{ {
CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver(); CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver();
if(ccbSelectorResolver != NULL) if(ccbSelectorResolver != nullptr)
{ {
selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
} }
@ -809,7 +809,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
CCLOG("Unexpected empty selector."); CCLOG("Unexpected empty selector.");
} }
} else { } else {
CCLOG("Unexpected NULL target for selector."); CCLOG("Unexpected nullptr target for selector.");
} }
} }
else else
@ -831,7 +831,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
} }
} }
return NULL; return nullptr;
} }
BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pParent, CCBReader * ccbReader) BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pParent, CCBReader * ccbReader)
@ -844,7 +844,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
{ {
if(!ccbReader->isJSControlled()) if(!ccbReader->isJSControlled())
{ {
Ref* target = NULL; Ref* target = nullptr;
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
{ {
target = ccbReader->getAnimationManager()->getRootNode(); target = ccbReader->getAnimationManager()->getRootNode();
@ -854,7 +854,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
target = ccbReader->getOwner(); target = ccbReader->getOwner();
} }
if(target != NULL) if(target != nullptr)
{ {
if(selectorName.length() > 0) if(selectorName.length() > 0)
{ {
@ -862,7 +862,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
if(targetAsCCBSelectorResolver != NULL) if(targetAsCCBSelectorResolver != nullptr)
{ {
selControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); selControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
} }
@ -870,7 +870,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
if(selControlHandler == 0) if(selControlHandler == 0)
{ {
CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver(); CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver();
if(ccbSelectorResolver != NULL) if(ccbSelectorResolver != nullptr)
{ {
selControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); selControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
} }
@ -894,7 +894,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
CCLOG("Unexpected empty selector."); CCLOG("Unexpected empty selector.");
} }
} else { } else {
CCLOG("Unexpected NULL target for selector."); CCLOG("Unexpected nullptr target for selector.");
} }
} }
else else
@ -914,7 +914,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
} }
} }
return NULL; return nullptr;
} }
Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader * pCCBReader) { Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader * pCCBReader) {
@ -960,7 +960,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
reader->getAnimationManager()->runAnimationsForSequenceIdTweenDuration(reader->getAnimationManager()->getAutoPlaySequenceId(), 0); reader->getAnimationManager()->runAnimationsForSequenceIdTweenDuration(reader->getAnimationManager()->getAutoPlaySequenceId(), 0);
} }
if (reader->isJSControlled() && pCCBReader->isJSControlled() && NULL == reader->_owner) if (reader->isJSControlled() && pCCBReader->isJSControlled() && nullptr == reader->_owner)
{ {
//set variables and callback to owner //set variables and callback to owner
//set callback //set callback

View File

@ -79,10 +79,10 @@ void NodeLoaderLibrary::purge(bool pReleaseNodeLoaders) {
static NodeLoaderLibrary * sSharedNodeLoaderLibrary = NULL; static NodeLoaderLibrary * sSharedNodeLoaderLibrary = nullptr;
NodeLoaderLibrary * NodeLoaderLibrary::getInstance() { NodeLoaderLibrary * NodeLoaderLibrary::getInstance() {
if(sSharedNodeLoaderLibrary == NULL) { if(sSharedNodeLoaderLibrary == nullptr) {
sSharedNodeLoaderLibrary = new NodeLoaderLibrary(); sSharedNodeLoaderLibrary = new NodeLoaderLibrary();
sSharedNodeLoaderLibrary->registerDefaultNodeLoaders(); sSharedNodeLoaderLibrary->registerDefaultNodeLoaders();

View File

@ -12,10 +12,10 @@ namespace cocosbuilder {
void SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { void SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) {
if(pSpriteFrame != NULL) { if(pSpriteFrame != nullptr) {
((Sprite *)pNode)->setSpriteFrame(pSpriteFrame); ((Sprite *)pNode)->setSpriteFrame(pSpriteFrame);
} else { } else {
CCLOG("ERROR: SpriteFrame NULL"); CCLOG("ERROR: SpriteFrame nullptr");
} }
} else { } else {
NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader); NodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pSpriteFrame, ccbReader);

View File

@ -278,8 +278,8 @@ void ActionTimeline::emitFrameEvent(Frame* frame)
void ActionTimeline::gotoFrame(int frameIndex) void ActionTimeline::gotoFrame(int frameIndex)
{ {
int size = _timelineList.size(); ssize_t size = _timelineList.size();
for(int i = 0; i<size; i++) for(ssize_t i = 0; i < size; i++)
{ {
_timelineList.at(i)->gotoFrame(frameIndex); _timelineList.at(i)->gotoFrame(frameIndex);
} }
@ -287,8 +287,8 @@ void ActionTimeline::gotoFrame(int frameIndex)
void ActionTimeline::stepToFrame(int frameIndex) void ActionTimeline::stepToFrame(int frameIndex)
{ {
int size = _timelineList.size(); ssize_t size = _timelineList.size();
for(int i = 0; i<size; i++) for(ssize_t i = 0; i < size; i++)
{ {
_timelineList.at(i)->stepToFrame(frameIndex); _timelineList.at(i)->stepToFrame(frameIndex);
} }

View File

@ -68,7 +68,7 @@ VisibleFrame* VisibleFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
VisibleFrame::VisibleFrame() VisibleFrame::VisibleFrame()
@ -104,7 +104,7 @@ TextureFrame* TextureFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
TextureFrame::TextureFrame() TextureFrame::TextureFrame()
@ -155,7 +155,7 @@ RotationFrame* RotationFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
RotationFrame::RotationFrame() RotationFrame::RotationFrame()
@ -204,7 +204,7 @@ SkewFrame* SkewFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
SkewFrame::SkewFrame() SkewFrame::SkewFrame()
@ -261,7 +261,7 @@ RotationSkewFrame* RotationSkewFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
RotationSkewFrame::RotationSkewFrame() RotationSkewFrame::RotationSkewFrame()
@ -314,7 +314,7 @@ PositionFrame* PositionFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
PositionFrame::PositionFrame() PositionFrame::PositionFrame()
@ -366,7 +366,7 @@ ScaleFrame* ScaleFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
ScaleFrame::ScaleFrame() ScaleFrame::ScaleFrame()
@ -421,7 +421,7 @@ AnchorPointFrame* AnchorPointFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
AnchorPointFrame::AnchorPointFrame() AnchorPointFrame::AnchorPointFrame()
@ -457,7 +457,7 @@ InnerActionFrame* InnerActionFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
InnerActionFrame::InnerActionFrame() InnerActionFrame::InnerActionFrame()
@ -493,7 +493,7 @@ ColorFrame* ColorFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
ColorFrame::ColorFrame() ColorFrame::ColorFrame()
@ -559,7 +559,7 @@ EventFrame* EventFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
EventFrame::EventFrame() EventFrame::EventFrame()
@ -594,7 +594,7 @@ ZOrderFrame* ZOrderFrame::create()
return frame; return frame;
} }
CC_SAFE_DELETE(frame); CC_SAFE_DELETE(frame);
return NULL; return nullptr;
} }
ZOrderFrame::ZOrderFrame() ZOrderFrame::ZOrderFrame()
@ -605,7 +605,7 @@ ZOrderFrame::ZOrderFrame()
void ZOrderFrame::onEnter(Frame *nextFrame) void ZOrderFrame::onEnter(Frame *nextFrame)
{ {
if(_node) if(_node)
_node->setZOrder(_zorder); _node->setLocalZOrder(_zorder);
} }

View File

@ -284,9 +284,9 @@ void NodeReader::initNode(Node* node, const rapidjson::Value& json)
if (rotation != 0) if (rotation != 0)
node->setRotation(rotation); node->setRotation(rotation);
if(rotationSkewX != 0) if(rotationSkewX != 0)
node->setRotationX(rotationSkewX); node->setRotationSkewX(rotationSkewX);
if(rotationSkewY != 0) if(rotationSkewY != 0)
node->setRotationY(rotationSkewY); node->setRotationSkewY(rotationSkewY);
if(skewx != 0) if(skewx != 0)
node->setSkewX(skewx); node->setSkewX(skewx);
if(skewy != 0) if(skewy != 0)
@ -296,19 +296,17 @@ void NodeReader::initNode(Node* node, const rapidjson::Value& json)
if(width != 0 || height != 0) if(width != 0 || height != 0)
node->setContentSize(Size(width, height)); node->setContentSize(Size(width, height));
if(zorder != 0) if(zorder != 0)
node->setZOrder(zorder); node->setLocalZOrder(zorder);
if(visible != true) if(visible != true)
node->setVisible(visible); node->setVisible(visible);
if(alpha != 255) if(alpha != 255)
{ {
node->setOpacity(alpha); node->setOpacity(alpha);
node->setCascadeOpacityEnabled(true);
} }
if(red != 255 || green != 255 || blue != 255) if(red != 255 || green != 255 || blue != 255)
{ {
node->setColor(Color3B(red, green, blue)); node->setColor(Color3B(red, green, blue));
node->setCascadeColorEnabled(true);
} }

View File

@ -104,7 +104,7 @@ void Timeline::insertFrame(Frame* frame, int index)
void Timeline::removeFrame(Frame* frame) void Timeline::removeFrame(Frame* frame)
{ {
_frames.eraseObject(frame); _frames.eraseObject(frame);
frame->setTimeline(NULL); frame->setTimeline(nullptr);
} }
void Timeline::setNode(Node* node) void Timeline::setNode(Node* node)
@ -131,8 +131,8 @@ void Timeline::apply(int frameIndex)
void Timeline::binarySearchKeyFrame(int frameIndex) void Timeline::binarySearchKeyFrame(int frameIndex)
{ {
Frame *from = NULL; Frame *from = nullptr;
Frame *to = NULL; Frame *to = nullptr;
long length = _frames.size(); long length = _frames.size();
bool needEnterFrame = false; bool needEnterFrame = false;

View File

@ -402,9 +402,9 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t
Skin *skin = static_cast<Skin *>(node); Skin *skin = static_cast<Skin *>(node);
skin->updateTransform(); skin->updateTransform();
bool blendDirty = bone->isBlendDirty(); BlendFunc func = bone->getBlendFunc();
if (blendDirty) if (func.src != _blendFunc.src || func.dst != _blendFunc.dst)
{ {
skin->setBlendFunc(bone->getBlendFunc()); skin->setBlendFunc(bone->getBlendFunc());
} }

View File

@ -201,8 +201,8 @@ void Bone::update(float delta)
_worldInfo->y = _tweenData->y + _position.y; _worldInfo->y = _tweenData->y + _position.y;
_worldInfo->scaleX = _tweenData->scaleX * _scaleX; _worldInfo->scaleX = _tweenData->scaleX * _scaleX;
_worldInfo->scaleY = _tweenData->scaleY * _scaleY; _worldInfo->scaleY = _tweenData->scaleY * _scaleY;
_worldInfo->skewX = _tweenData->skewX + _skewX + _rotationX; _worldInfo->skewX = _tweenData->skewX + _skewX + _rotationZ_X;
_worldInfo->skewY = _tweenData->skewY + _skewY - _rotationY; _worldInfo->skewY = _tweenData->skewY + _skewY - _rotationZ_Y;
if(_parentBone) if(_parentBone)
{ {

View File

@ -1311,7 +1311,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
length = DICTOOL->getArrayCount_json(json, CONFIG_FILE_PATH); // json[CONFIG_FILE_PATH].IsNull() ? 0 : json[CONFIG_FILE_PATH].Size(); length = DICTOOL->getArrayCount_json(json, CONFIG_FILE_PATH); // json[CONFIG_FILE_PATH].IsNull() ? 0 : json[CONFIG_FILE_PATH].Size();
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
const char *path = DICTOOL->getStringValueFromArray_json(json, CONFIG_FILE_PATH, i); // json[CONFIG_FILE_PATH][i].IsNull() ? NULL : json[CONFIG_FILE_PATH][i].GetString(); const char *path = DICTOOL->getStringValueFromArray_json(json, CONFIG_FILE_PATH, i); // json[CONFIG_FILE_PATH][i].IsNull() ? nullptr : json[CONFIG_FILE_PATH][i].GetString();
if (path == nullptr) if (path == nullptr)
{ {
CCLOG("load CONFIG_FILE_PATH error."); CCLOG("load CONFIG_FILE_PATH error.");
@ -2426,21 +2426,21 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
} }
else if (key.compare(A_HEIGHT) == 0) else if (key.compare(A_HEIGHT) == 0)
{ {
if(str != NULL) if(str != nullptr)
{ {
textureData->height = atof(str); textureData->height = atof(str);
} }
} }
else if (key.compare(A_PIVOT_X) == 0) else if (key.compare(A_PIVOT_X) == 0)
{ {
if(str != NULL) if(str != nullptr)
{ {
textureData->pivotX = atof(str); textureData->pivotX = atof(str);
} }
} }
else if (key.compare(A_PIVOT_Y) == 0) else if (key.compare(A_PIVOT_Y) == 0)
{ {
if(str != NULL) if(str != nullptr)
{ {
textureData->pivotY = atof(str); textureData->pivotY = atof(str);
} }

View File

@ -351,7 +351,7 @@ Widget* GUIReader::widgetFromBinaryFile(const char *fileName)
const char* fileVersion = ""; const char* fileVersion = "";
ui::Widget* widget = nullptr; ui::Widget* widget = nullptr;
if (pBuffer != NULL && nSize > 0) if (pBuffer != nullptr && nSize > 0)
{ {
CocoLoader tCocoLoader; CocoLoader tCocoLoader;
if(true == tCocoLoader.ReadCocoBinBuff((char*)pBuffer)) if(true == tCocoLoader.ReadCocoBinBuff((char*)pBuffer))
@ -494,7 +494,7 @@ Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, c
if (widget->getContentSize().equals(Size::ZERO)) if (widget->getContentSize().equals(Size::ZERO))
{ {
Layout* rootWidget = dynamic_cast<Layout*>(widget); Layout* rootWidget = dynamic_cast<Layout*>(widget);
rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); rootWidget->setContentSize(Size(fileDesignWidth, fileDesignHeight));
} }
/* ********************** */ /* ********************** */
@ -608,7 +608,7 @@ void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widg
float w = DICTOOL->getFloatValue_json(options, "width"); float w = DICTOOL->getFloatValue_json(options, "width");
float h = DICTOOL->getFloatValue_json(options, "height"); float h = DICTOOL->getFloatValue_json(options, "height");
widget->setSize(Size(w, h)); widget->setContentSize(Size(w, h));
widget->setTag(DICTOOL->getIntValue_json(options, "tag")); widget->setTag(DICTOOL->getIntValue_json(options, "tag"));
widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag"));
@ -707,7 +707,7 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widg
{ {
float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float swf = DICTOOL->getFloatValue_json(options, "scale9Width");
float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height");
button->setSize(Size(swf, shf)); button->setContentSize(Size(swf, shf));
} }
} }
else else
@ -823,7 +823,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*w
{ {
float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); float swf = DICTOOL->getFloatValue_json(options, "scale9Width");
float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); float shf = DICTOOL->getFloatValue_json(options, "scale9Height");
imageView->setSize(Size(swf, shf)); imageView->setContentSize(Size(swf, shf));
} }
float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); float cx = DICTOOL->getFloatValue_json(options, "capInsetsX");
@ -1016,7 +1016,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg
{ {
slider->loadBarTexture(imageFileName_tp); slider->loadBarTexture(imageFileName_tp);
} }
slider->setSize(Size(barLength, slider->getContentSize().height)); slider->setContentSize(Size(barLength, slider->getContentSize().height));
} }
else else
{ {
@ -1204,7 +1204,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
if (widget->getContentSize().equals(Size::ZERO)) if (widget->getContentSize().equals(Size::ZERO))
{ {
Layout* rootWidget = dynamic_cast<Layout*>(widget); Layout* rootWidget = dynamic_cast<Layout*>(widget);
rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); rootWidget->setContentSize(Size(fileDesignWidth, fileDesignHeight));
} }
/* ********************** */ /* ********************** */
@ -1268,7 +1268,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
if (widget->getContentSize().equals(Size::ZERO)) if (widget->getContentSize().equals(Size::ZERO))
{ {
Layout* rootWidget = dynamic_cast<Layout*>(widget); Layout* rootWidget = dynamic_cast<Layout*>(widget);
rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); rootWidget->setContentSize(Size(fileDesignWidth, fileDesignHeight));
} }
} }
} }
@ -1340,7 +1340,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
setPropsForAllWidgetFromBinary(reader, widget, cocoLoader, optionsNode); setPropsForAllWidgetFromBinary(reader, widget, cocoLoader, optionsNode);
// 2nd., custom widget parse with custom reader // 2nd., custom widget parse with custom reader
//2nd. parse custom property //2nd. parse custom property
const char* customProperty = NULL; const char* customProperty = nullptr;
stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader); stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader);
for (int k = 0; k < optionsNode->GetChildNum(); ++k) { for (int k = 0; k < optionsNode->GetChildNum(); ++k) {
std::string key = optionChildNode[k].GetName(cocoLoader); std::string key = optionChildNode[k].GetName(cocoLoader);
@ -1459,7 +1459,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
} }
setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict); setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict);
}else{ }else{
CCLOG("Widget or WidgetReader doesn't exists!!! Please check your csb file."); CCLOG("Widget or WidgetReader doesn't exists!!! Please check your json file.");
} }
} }

View File

@ -531,7 +531,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
else if (key == "zorder") else if (key == "zorder")
{ {
nZorder = atoi(value.c_str()); nZorder = atoi(value.c_str());
node->setZOrder(nZorder); node->setLocalZOrder(nZorder);
} }
else if(key == "scalex") else if(key == "scalex")
{ {

View File

@ -92,7 +92,7 @@ Type stExpCocoNode::GetType(CocoLoader* pCoco)
char* stExpCocoNode::GetName(CocoLoader* pCoco) char* stExpCocoNode::GetName(CocoLoader* pCoco)
{ {
char* szName = NULL ; char* szName = nullptr ;
if(m_ObjIndex >= 0) if(m_ObjIndex >= 0)
{ {
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray(); stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
@ -132,8 +132,14 @@ char* stExpCocoNode::GetName(CocoLoader* pCoco)
char* stExpCocoNode::GetValue(CocoLoader* pCoco) char* stExpCocoNode::GetValue(CocoLoader* pCoco)
{ {
return ( pCoco->GetMemoryAddr_String() + m_szValue ); char* szValue = ( pCoco->GetMemoryAddr_String() + m_szValue );
if( 0==strcmp(szValue,"null") && GetType(pCoco) == kStringType )
{
strcpy(szValue,"");
} }
return szValue;
}
int stExpCocoNode::GetChildNum() int stExpCocoNode::GetChildNum()
{ {
@ -147,9 +153,9 @@ stExpCocoNode* stExpCocoNode::GetChildArray(CocoLoader* pCoco)
CocoLoader::CocoLoader() CocoLoader::CocoLoader()
{ {
m_pRootNode = NULL; m_pRootNode = nullptr;
m_pObjectDescArray = NULL; m_pObjectDescArray = nullptr;
m_pMemoryBuff = NULL; m_pMemoryBuff = nullptr;
} }
CocoLoader::~CocoLoader() CocoLoader::~CocoLoader()
@ -157,7 +163,7 @@ CocoLoader::~CocoLoader()
if(m_pMemoryBuff) if(m_pMemoryBuff)
{ {
delete[] m_pMemoryBuff; delete[] m_pMemoryBuff;
m_pMemoryBuff = NULL; m_pMemoryBuff = nullptr;
} }
} }
@ -176,7 +182,7 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
char* pDestBuff = new char[m_pFileHeader->m_nDataSize]; char* pDestBuff = new char[m_pFileHeader->m_nDataSize];
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize; uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;
uLongf dwDestSize = m_pFileHeader->m_nDataSize; uLongf dwDestSize = m_pFileHeader->m_nDataSize;
int nRes = uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize); uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize);
pStartAddr = m_pMemoryBuff = pDestBuff; pStartAddr = m_pMemoryBuff = pDestBuff;
} }
@ -198,7 +204,7 @@ stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc)
return &m_pObjectDescArray[i]; return &m_pObjectDescArray[i];
} }
} }
return NULL; return nullptr;
} }
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex) stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
@ -207,7 +213,7 @@ stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
{ {
return &m_pObjectDescArray[vIndex]; return &m_pObjectDescArray[vIndex];
} }
return NULL; return nullptr;
} }
char* CocoLoader::GetMemoryAddr_AttribDesc() char* CocoLoader::GetMemoryAddr_AttribDesc()

View File

@ -115,7 +115,7 @@ void TriggerMng::parse(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCoc
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
bool useBindings = engine != NULL; bool useBindings = engine != nullptr;
if (useBindings) if (useBindings)
{ {
@ -234,7 +234,7 @@ bool TriggerMng::isEmpty(void) const
const char *str2 = pActionArray[i3].GetValue(pCocoLoader); const char *str2 = pActionArray[i3].GetValue(pCocoLoader);
if (key2.compare("classname") == 0) if (key2.compare("classname") == 0)
{ {
if (str2 != NULL) if (str2 != nullptr)
{ {
action.AddMember("classname", str2, allocator); action.AddMember("classname", str2, allocator);
} }
@ -255,7 +255,7 @@ bool TriggerMng::isEmpty(void) const
const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader); const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader);
if (key3.compare("key") == 0) if (key3.compare("key") == 0)
{ {
if (str3 != NULL) if (str3 != nullptr)
{ {
dataitem.AddMember("key", str3, allocator); dataitem.AddMember("key", str3, allocator);
} }
@ -310,7 +310,7 @@ bool TriggerMng::isEmpty(void) const
const char *str4 = pConditionArray[i7].GetValue(pCocoLoader); const char *str4 = pConditionArray[i7].GetValue(pCocoLoader);
if (key4.compare("classname") == 0) if (key4.compare("classname") == 0)
{ {
if (str4 != NULL) if (str4 != nullptr)
{ {
cond.AddMember("classname", str4, allocator); cond.AddMember("classname", str4, allocator);
} }
@ -331,7 +331,7 @@ bool TriggerMng::isEmpty(void) const
const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader); const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader);
if (key5.compare("key") == 0) if (key5.compare("key") == 0)
{ {
if (str5 != NULL) if (str5 != nullptr)
{ {
dataitem.AddMember("key", str5, allocator); dataitem.AddMember("key", str5, allocator);
} }
@ -380,7 +380,7 @@ bool TriggerMng::isEmpty(void) const
stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader); stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader);
std::string key6 = pEventArray[0].GetName(pCocoLoader); std::string key6 = pEventArray[0].GetName(pCocoLoader);
const char *str6 = pEventArray[0].GetValue(pCocoLoader); const char *str6 = pEventArray[0].GetValue(pCocoLoader);
if (key6.compare("id") == 0 && str6 != NULL) if (key6.compare("id") == 0 && str6 != nullptr)
{ {
event.AddMember("id", atoi(str6), allocator); event.AddMember("id", atoi(str6), allocator);
eventsItem.PushBack(event, allocator); eventsItem.PushBack(event, allocator);
@ -390,7 +390,7 @@ bool TriggerMng::isEmpty(void) const
} }
else if (key1.compare("id") == 0) else if (key1.compare("id") == 0)
{ {
if (str1 != NULL) if (str1 != nullptr)
{ {
vElemItem.AddMember("id", atoi(str1), allocator); vElemItem.AddMember("id", atoi(str1), allocator);
} }

View File

@ -253,7 +253,7 @@ void TriggerObj::serialize(const rapidjson::Value &val)
const char* str0 = pTriggerObjArray[i0].GetValue(pCocoLoader); const char* str0 = pTriggerObjArray[i0].GetValue(pCocoLoader);
if (key.compare("id") == 0) if (key.compare("id") == 0)
{ {
if (str0 != NULL) if (str0 != nullptr)
{ {
_id = atoi(str0); //(unsigned int)(DICTOOL->getIntValue_json(val, "id")); _id = atoi(str0); //(unsigned int)(DICTOOL->getIntValue_json(val, "id"));
} }
@ -292,7 +292,7 @@ void TriggerObj::serialize(const rapidjson::Value &val)
continue; continue;
} }
BaseTriggerAction *act = dynamic_cast<BaseTriggerAction*>(ObjectFactory::getInstance()->createObject(classname)); BaseTriggerAction *act = dynamic_cast<BaseTriggerAction*>(ObjectFactory::getInstance()->createObject(classname));
CCAssert(act != NULL, "class named classname can not implement!"); CCAssert(act != nullptr, "class named classname can not implement!");
act->serialize(pCocoLoader, &pActionArray[1]); act->serialize(pCocoLoader, &pActionArray[1]);
act->init(); act->init();
_acts.pushBack(act); _acts.pushBack(act);

View File

@ -152,7 +152,7 @@ namespace cocostudio
if (button->isScale9Enabled()) { if (button->isScale9Enabled()) {
button->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight)); button->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight));
button->setSize(Size(scale9Width, scale9Height)); button->setContentSize(Size(scale9Width, scale9Height));
} }
button->setTitleColor(Color3B(cri, cgi, cbi)); button->setTitleColor(Color3B(cri, cgi, cbi));
@ -203,7 +203,7 @@ namespace cocostudio
{ {
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width); float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width);
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height); float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height);
button->setSize(Size(swf, shf)); button->setContentSize(Size(swf, shf));
} }
} }
bool tt = DICTOOL->checkObjectExist_json(options, P_Text); bool tt = DICTOOL->checkObjectExist_json(options, P_Text);

View File

@ -15,7 +15,7 @@ namespace cocostudio
static const char* P_BackGroundBoxDisabledData = "backGroundBoxDisabledData"; static const char* P_BackGroundBoxDisabledData = "backGroundBoxDisabledData";
static const char* P_FrontCrossDisabledData = "frontCrossDisabledData"; static const char* P_FrontCrossDisabledData = "frontCrossDisabledData";
static CheckBoxReader* instanceCheckBoxReader = NULL; static CheckBoxReader* instanceCheckBoxReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(CheckBoxReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(CheckBoxReader)

View File

@ -19,7 +19,7 @@ namespace cocostudio
static const char* P_Scale9Height = "scale9Height"; static const char* P_Scale9Height = "scale9Height";
static ImageViewReader* instanceImageViewReader = NULL; static ImageViewReader* instanceImageViewReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(ImageViewReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(ImageViewReader)
@ -128,7 +128,7 @@ namespace cocostudio
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f); float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f);
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f); float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f);
imageView->setSize(Size(swf, shf)); imageView->setContentSize(Size(swf, shf));
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX); float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);

View File

@ -34,7 +34,7 @@ namespace cocostudio
static const char* P_BackGroundImageData = "backGroundImageData"; static const char* P_BackGroundImageData = "backGroundImageData";
static const char* P_LayoutType = "layoutType"; static const char* P_LayoutType = "layoutType";
static LayoutReader* instanceLayoutReader = NULL; static LayoutReader* instanceLayoutReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(LayoutReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(LayoutReader)
@ -72,7 +72,7 @@ namespace cocostudio
int ecr=0, ecg=0, ecb= 0; int ecr=0, ecg=0, ecb= 0;
float bgcv1 = 0.0f, bgcv2= 0.0f; float bgcv1 = 0.0f, bgcv2= 0.0f;
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
Layout::Type layoutType; Layout::Type layoutType = Layout::Type::ABSOLUTE;
int bgColorOpacity = panel->getBackGroundColorOpacity(); int bgColorOpacity = panel->getBackGroundColorOpacity();
for (int i = 0; i < cocoNode->GetChildNum(); ++i) { for (int i = 0; i < cocoNode->GetChildNum(); ++i) {

View File

@ -12,7 +12,7 @@ namespace cocostudio
static const char* P_Direction = "direction"; static const char* P_Direction = "direction";
static const char* P_ItemMargin = "itemMargin"; static const char* P_ItemMargin = "itemMargin";
static ListViewReader* instanceListViewReader = NULL; static ListViewReader* instanceListViewReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(ListViewReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(ListViewReader)

View File

@ -19,7 +19,7 @@ namespace cocostudio
static const char* P_Direction = "direction"; static const char* P_Direction = "direction";
static const char* P_Percent = "percent"; static const char* P_Percent = "percent";
static LoadingBarReader* instanceLoadingBar = NULL; static LoadingBarReader* instanceLoadingBar = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(LoadingBarReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(LoadingBarReader)
@ -130,7 +130,7 @@ namespace cocostudio
float width = DICTOOL->getFloatValue_json(options, P_Width); float width = DICTOOL->getFloatValue_json(options, P_Width);
float height = DICTOOL->getFloatValue_json(options, P_Height); float height = DICTOOL->getFloatValue_json(options, P_Height);
loadingBar->setSize(Size(width, height)); loadingBar->setContentSize(Size(width, height));
/**/ /**/

View File

@ -18,9 +18,7 @@ namespace cocostudio
static const char* P_BallDisabledData = "ballDisabledData"; static const char* P_BallDisabledData = "ballDisabledData";
static const char* P_ProgressBarData = "progressBarData"; static const char* P_ProgressBarData = "progressBarData";
static const char* P_BarFileName = "barFileName"; static SliderReader* instanceSliderReader = nullptr;
static SliderReader* instanceSliderReader = NULL;
IMPLEMENT_CLASS_WIDGET_READER_INFO(SliderReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(SliderReader)
@ -125,7 +123,7 @@ namespace cocostudio
} //end of for loop } //end of for loop
if (slider->isScale9Enabled()) { if (slider->isScale9Enabled()) {
slider->setSize(Size(barLength, slider->getContentSize().height)); slider->setContentSize(Size(barLength, slider->getContentSize().height));
} }
slider->setPercent(percent); slider->setPercent(percent);

View File

@ -15,10 +15,7 @@ namespace cocostudio
static const char* P_ItemHeight = "itemHeight"; static const char* P_ItemHeight = "itemHeight";
static const char* P_StartCharMap = "startCharMap"; static const char* P_StartCharMap = "startCharMap";
static TextAtlasReader* instanceTextAtalsReader = nullptr;
static const char* P_CharMapFile = "charMapFile";
static TextAtlasReader* instanceTextAtalsReader = NULL;
IMPLEMENT_CLASS_WIDGET_READER_INFO(TextAtlasReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(TextAtlasReader)

View File

@ -12,7 +12,7 @@ namespace cocostudio
static const char* P_FileNameData = "fileNameData"; static const char* P_FileNameData = "fileNameData";
static const char* P_Text = "text"; static const char* P_Text = "text";
static TextBMFontReader* instanceTextBMFontReader = NULL; static TextBMFontReader* instanceTextBMFontReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(TextBMFontReader) IMPLEMENT_CLASS_WIDGET_READER_INFO(TextBMFontReader)

Some files were not shown because too many files have changed in this diff Show More