This commit is contained in:
edwardzhou 2014-07-10 16:10:11 +08:00
commit 814f45179e
416 changed files with 44708 additions and 8304 deletions

View File

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

View File

@ -1,4 +1,21 @@
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] 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] GLProgramState: can use uniform location to get/set uniform values
[NEW] HttpClient: added sendImmediate()

View File

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

View File

@ -827,8 +827,6 @@
3E6177351960FB4000DE83F5 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176DE1960FA6300DE83F5 /* AppController.mm */; };
3E6177361960FB5A00DE83F5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176EE1960FA6300DE83F5 /* main.m */; };
3E6177371960FB5E00DE83F5 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3E6176F01960FA6300DE83F5 /* RootViewController.mm */; };
3E6177391960FBB800DE83F5 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E6177381960FBB800DE83F5 /* SystemConfiguration.framework */; };
3E61773B1960FBC300DE83F5 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E61773A1960FBC300DE83F5 /* CFNetwork.framework */; };
3E61773D1960FBD200DE83F5 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E61773C1960FBD100DE83F5 /* GameController.framework */; };
3E6177F41960FEFE00DE83F5 /* fonts in Resources */ = {isa = PBXBuildFile; fileRef = 3E6177F01960FEFE00DE83F5 /* fonts */; };
3E6177F51960FEFE00DE83F5 /* ipad in Resources */ = {isa = PBXBuildFile; fileRef = 3E6177F11960FEFE00DE83F5 /* ipad */; };
@ -2132,8 +2130,6 @@
buildActionMask = 2147483647;
files = (
3E61773D1960FBD200DE83F5 /* GameController.framework in Frameworks */,
3E61773B1960FBC300DE83F5 /* CFNetwork.framework in Frameworks */,
3E6177391960FBB800DE83F5 /* SystemConfiguration.framework in Frameworks */,
3E6177211960FAED00DE83F5 /* libchipmunk iOS.a in Frameworks */,
3E6177221960FAED00DE83F5 /* libcocos2dx iOS.a in Frameworks */,
3E6177231960FAED00DE83F5 /* libCocosDenshion iOS.a in Frameworks */,
@ -5728,6 +5724,7 @@
"$(inherited)",
CC_TARGET_OS_IPHONE,
);
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
INFOPLIST_FILE = "$(SRCROOT)/../tests/game-controller-test/proj.ios/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = "game-controller-test IOS";
@ -5745,6 +5742,7 @@
"$(inherited)",
CC_TARGET_OS_IPHONE,
);
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
INFOPLIST_FILE = "$(SRCROOT)/../tests/game-controller-test/proj.ios/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = "game-controller-test IOS";

View File

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

View File

@ -237,7 +237,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
else
{
//do nothing, do not support
CCASSERT(0, "TMX invalid value");
//CCASSERT(0, "TMX invalid value");
}
_indicesVertexZNumber.clear();
@ -264,9 +264,8 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
int offset = iter->second;
iter->second++;
//CC_ASSERT(_tileToQuadIndex.find(tileIndex) != _tileToQuadIndex.end() && _tileToQuadIndex[tileIndex] <= _totalQuads.size()-1);
int quadIndex = (int)_tileToQuadIndex[tileIndex];
int quadIndex = _tileToQuadIndex[tileIndex];
CC_ASSERT(-1 != quadIndex);
_indices[6 * offset + 0] = quadIndex * 4 + 0;
_indices[6 * offset + 1] = quadIndex * 4 + 1;
_indices[6 * offset + 2] = quadIndex * 4 + 2;
@ -387,7 +386,13 @@ Mat4 FastTMXLayer::tileToNodeTransform()
}
case FAST_TMX_ORIENTATION_HEX:
{
_tileToNodeTransform = Mat4::IDENTITY;
_tileToNodeTransform = Mat4
(
h * sqrtf(0.75), 0, 0, 0,
-h/2, -h, 0, offY,
0, 0, 1, 0,
0, 0, 0, 1
);
return _tileToNodeTransform;
}
default:
@ -408,6 +413,7 @@ void FastTMXLayer::updateTotalQuads()
_tileToQuadIndex.clear();
_totalQuads.resize(int(_layerSize.width * _layerSize.height));
_indices.resize(6 * int(_layerSize.width * _layerSize.height));
_tileToQuadIndex.resize(int(_layerSize.width * _layerSize.height),-1);
_indicesVertexZOffsets.clear();
int quadIndex = 0;
@ -617,7 +623,7 @@ int FastTMXLayer::getVertexZForPos(const Vec2& pos)
ret = static_cast<int>(-(_layerSize.height-pos.y));
break;
case FAST_TMX_ORIENTATION_HEX:
CCASSERT(0, "TMX Hexa zOrder not supported");
CCASSERT(0, "TMX Hexa vertexZ not supported");
break;
default:
CCASSERT(0, "TMX invalid value");

View File

@ -239,7 +239,7 @@ protected:
Mat4 _tileToNodeTransform;
/** data for rendering */
bool _quadsDirty;
std::unordered_map<ssize_t, ssize_t> _tileToQuadIndex;
std::vector<int> _tileToQuadIndex;
std::vector<V3F_C4B_T2F_Quad> _totalQuads;
std::vector<int> _indices;
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;

View File

@ -133,6 +133,11 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
//CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues()
{
if(_itemsPerRow == 0)
{
return;
}
ssize_t n = _string.length();
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)
{
return LayerMultiplex::create(layer, NULL);
return LayerMultiplex::create(layer, nullptr);
}
LayerMultiplex* LayerMultiplex::create()

View File

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

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

View File

@ -714,23 +714,19 @@ public:
virtual Node* getChildByName(const std::string& name) const;
/** 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:
* `/` : 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 the search should be performed on the tree's node
* and be performed recursively across the entire node tree.
* `//`: Can only be placed at the begin of the search string. This indicates that it will search recursively.
* `..`: 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
* enumerateChildren("/MyName", ...): This searches the root's children 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("//MyName", ...): This searches the children recursively and matches any node with the name `MyName`.
* 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("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal`
* 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`.
* @endcode
*
@ -1467,6 +1463,15 @@ public:
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
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:
// Nodes should be created using create();
Node();
@ -1605,6 +1610,11 @@ protected:
static int s_globalOrderOfArrival;
std::function<void()> _onEnterCallback;
std::function<void()> _onExitCallback;
std::function<void()> _onEnterTransitionDidFinishCallback;
std::function<void()> _onExitTransitionDidStartCallback;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Node);

View File

@ -85,6 +85,10 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity)
CCASSERT(capacity>=0, "Capacity must be >= 0");
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
if(tex->hasPremultipliedAlpha())
{
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
}
_textureAtlas = new TextureAtlas();
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\ccTypes.cpp" />
<ClCompile Include="..\base\CCUserDefault.cpp" />
<ClCompile Include="..\base\CCUserDefaultAndroid.cpp" />
<ClCompile Include="..\base\ccUTF8.cpp" />
<ClCompile Include="..\base\ccUtils.cpp" />
<ClCompile Include="..\base\CCValue.cpp" />

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<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>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>

View File

@ -66,12 +66,12 @@ Animate3D* Animate3D::clone() const
auto animate = const_cast<Animate3D*>(this);
auto copy = Animate3D::create(animate->_animation);
copy->_speed = _speed;
copy->_absSpeed = _absSpeed;
copy->_weight = _weight;
copy->_elapsed = _elapsed;
copy->_start = _start;
copy->_last = _last;
copy->_playBack = _playBack;
copy->_playReverse = _playReverse;
copy->setDuration(animate->getDuration());
return copy;
@ -81,7 +81,7 @@ Animate3D* Animate3D::clone() const
Animate3D* Animate3D::reverse() const
{
auto animate = clone();
animate->_playBack = !animate->_playBack;
animate->_playReverse = !animate->_playReverse;
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.
void Animate3D::step(float dt)
{
ActionInterval::step(dt * _speed);
ActionInterval::step(dt * _absSpeed);
}
void Animate3D::update(float t)
{
if (_target)
if (_target && _weight > 0.f)
{
float transDst[3], rotDst[4], scaleDst[3];
float* trans = nullptr, *rot = nullptr, *scale = nullptr;
if (_playBack)
if (_playReverse)
t = 1 - t;
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()
: _speed(1)
: _absSpeed(1.f)
, _weight(1.f)
, _start(0.f)
, _last(1.f)
, _animation(nullptr)
, _playBack(false)
, _playReverse(false)
{
}

View File

@ -32,6 +32,7 @@
#include "base/ccMacros.h"
#include "base/CCRef.h"
#include "base/ccTypes.h"
#include "base/CCPlatformMacros.h"
#include "2d/CCActionInterval.h"
NS_CC_BEGIN
@ -66,17 +67,17 @@ public:
virtual void update(float t) override;
/**get & set speed */
float getSpeed() const { return _speed; }
void setSpeed(float speed) { _speed = speed; }
/**get & set speed, negative speed means playing reverse */
float getSpeed() const;
void setSpeed(float speed);
/**get & set blend weight*/
/**get & set blend weight, weight must positive*/
float getWeight() const { return _weight; }
void setWeight(float weight) { _weight = weight; }
void setWeight(float weight);
/**get & set play back*/
bool getPlayBack() const { return _playBack; }
void setPlayBack(bool playBack) { _playBack = playBack; }
/**get & set play reverse, these are deprecated, use set negative speed instead*/
CC_DEPRECATED_ATTRIBUTE bool getPlayBack() const { return _playReverse; }
CC_DEPRECATED_ATTRIBUTE void setPlayBack(bool reverse) { _playReverse = reverse; }
CC_CONSTRUCTOR_ACCESS:
@ -86,11 +87,11 @@ CC_CONSTRUCTOR_ACCESS:
protected:
Animation3D* _animation; //animation data
float _speed; //playing speed
float _absSpeed; //playing speed
float _weight; //blend weight
float _start; //start 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
};

View File

@ -30,7 +30,7 @@
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 key = fullPath + "#" + animationName;

View File

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

View File

@ -447,8 +447,7 @@ bool Bundle3D::loadBinary(const std::string& path)
return false;
}
// Create bundle reader
//CC_SAFE_DELETE(_bundleReader);
// Initialise bundle reader
_binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() );
// Read identifier info
@ -463,8 +462,11 @@ bool Bundle3D::loadBinary(const std::string& path)
// Read version
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) {
clear();
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]);
return false;
}
}
// Read ref table size
if (_binaryReader.read(&_referenceCount, 4, 1) != 1)
@ -766,17 +768,37 @@ bool Bundle3D::loadAnimationDataBinary(Animation3DData* animationdata)
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")
{
return GL_UNSIGNED_INT;
}
else if (str == "GL_FLOAT")
{
return GL_FLOAT;
}
else
{
assert(0);
CCASSERT(false, "Wrong GL type");
return 0;
}
}

View File

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

View File

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

View File

@ -125,7 +125,7 @@ bool RenderMeshData::init(const std::vector<float>& positions,
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;
_indices = indices;
@ -174,10 +174,10 @@ Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>
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();
if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, numIndex, attribs, attribCount))
if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, attribs))
{
mesh->autorelease();
return mesh;
@ -192,17 +192,17 @@ bool Mesh::init(const std::vector<float>& positions, const std::vector<float>& n
if (!bRet)
return false;
restore();
buildBuffer();
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)
return false;
restore();
buildBuffer();
return true;
}
@ -242,20 +242,20 @@ void Mesh::buildBuffer()
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
unsigned int indexSize = 2;
IndexFormat indexformat = IndexFormat::INDEX16;
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * _renderdata._indices.size(), &_renderdata._indices[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
_primitiveType = PrimitiveType::TRIANGLES;
_indexFormat = indexformat;
_indexFormat = IndexFormat::INDEX16;
_indexCount = _renderdata._indices.size();
}
void Mesh::restore()
{
cleanAndFreeBuffers();
_vertexBuffer = 0;
_indexBuffer = 0;
buildBuffer();
}

View File

@ -49,7 +49,7 @@ public:
}
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>& 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:
@ -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);
/**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*/
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);
/**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*/
void buildBuffer();

View File

@ -193,7 +193,7 @@ bool Sprite3D::loadFromC3x(const std::string& path)
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);
_skin = MeshSkin::create(fullPath, "");
@ -342,7 +342,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
_meshCommand.setDepthTestEnabled(true);
if (_skin)
{
_meshCommand.setMatrixPaletteSize(_skin->getMatrixPaletteSize());
_meshCommand.setMatrixPaletteSize((int)_skin->getMatrixPaletteSize());
_meshCommand.setMatrixPalette(_skin->getMatrixPalette());
}
//support tint and fade

View File

@ -141,13 +141,8 @@ base/ccUTF8.cpp \
base/ccUtils.cpp \
base/etc1.cpp \
base/s3tc.cpp \
base/CCController.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 \
renderer/CCBatchCommand.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};
MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(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);
fflush(stdout);
#else
@ -337,7 +337,7 @@ bool Console::listenOnTCP(int port)
#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));
return false;
}
@ -359,9 +359,9 @@ bool Console::listenOnTCP(int port)
#else
close(listenfd);
#endif
} while ( (res = res->ai_next) != NULL);
} while ( (res = res->ai_next) != nullptr);
if (res == NULL) {
if (res == nullptr) {
perror("net_listen:");
freeaddrinfo(ressave);
return false;
@ -372,14 +372,14 @@ bool Console::listenOnTCP(int port)
if (res->ai_family == AF_INET) {
char buf[INET_ADDRSTRLEN] = "";
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));
else
perror("inet_ntop");
} else if (res->ai_family == AF_INET6) {
char buf[INET6_ADDRSTRLEN] = "";
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));
else
perror("inet_ntop");
@ -1042,7 +1042,7 @@ void Console::loop()
copy_set = _read_set;
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 )
{

View File

@ -47,6 +47,7 @@ typedef SSIZE_T ssize_t;
#include <mutex>
#include <stdarg.h>
#include "base/CCRef.h"
#include "base/ccMacros.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)
class CC_DLL Console
: public Ref
{
public:
struct Command {

View File

@ -26,258 +26,94 @@
#include "CCController.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "CCGamepad.h"
#include "CCControllerDirectionPad.h"
#include "CCControllerButtonInput.h"
#include "CCControllerAxisInput.h"
#include "CCControllerThumbstick.h"
#include <functional>
#include "ccMacros.h"
#include "CCEventDispatcher.h"
#include "CCEventController.h"
#include "CCEventListenerController.h"
#include "CCDirector.h"
#include "jni/JniHelper.h"
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
{
public:
ControllerImpl(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){
return (vendorName == controller->getVendorName()) && (controllerID == controller->_impl->_controllerID);
auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
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.
auto iter = findController(vendorName, controllerID);
if (iter != Controller::_controllers.end())
CCLOG("onConnected %s,%d", deviceName.c_str(),deviceId);
auto iter = findController(deviceName, deviceId);
if (iter != Controller::s_allController.end())
return;
// It's a new controller being connected.
auto controller = new cocos2d::Controller();
controller->_vendorName = vendorName;
Controller::_controllers.push_back(controller);
controller->_impl->_controllerID = controllerID;
EventController evt(EventController::ControllerEventType::CONNECTION, controller, true);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
controller->_deviceId = deviceId;
controller->_deviceName = deviceName;
Controller::s_allController.push_back(controller);
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);
if (iter == Controller::_controllers.end())
CCLOG("onDisconnected %s,%d", deviceName.c_str(),deviceId);
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
CCLOGERROR("Could not find the controller!");
return;
}
EventController evt(EventController::ControllerEventType::CONNECTION, *iter, false);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
Controller::_controllers.erase(iter);
(*iter)->onDisconnected();
Controller::s_allController.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);
button->setValue(value);
button->setAnalog(isAnalog);
EventController evt(EventController::ControllerEventType::BUTTON_STATUS_CHANGED, _controller, button);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
CCLOG("onButtonEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
void sendEventAxis(ControllerAxisInput* axis, float value, bool isAnalog)
{
axis->setValue(value);
axis->setAnalog(isAnalog);
EventController evt(EventController::ControllerEventType::AXIS_STATUS_CHANGED, _controller, axis);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&evt);
(*iter)->onButtonEvent(keyCode, isPressed, value, isAnalog);
}
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);
if (iter == Controller::_controllers.end())
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
onConnected(vendorName, controllerID);
iter = findController(vendorName, controllerID);
CCLOG("onAxisEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
auto gamepad = (*iter)->getGamepad();
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;
}
(*iter)->onAxisEvent(axisCode, value, isAnalog);
}
private:
Controller* _controller;
int _controllerID;
};
std::vector<Controller*> Controller::_controllers;
const std::vector<Controller*>& Controller::getControllers()
{
return _controllers;
}
void Controller::startDiscoveryController()
{
// Empty implementation on Android
@ -288,9 +124,17 @@ void Controller::stopDiscoveryController()
// 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
@ -301,61 +145,50 @@ bool Controller::isConnected() const
return true;
}
int Controller::getPlayerIndex() const
{
return _playerIndex;
}
void Controller::setPlayerIndex(int playerIndex)
{
_playerIndex = playerIndex;
}
Gamepad* Controller::getGamepad() const
{
return _gamepad;
}
Controller::Controller()
: _playerIndex(PLAYER_INDEX_UNSET)
, _gamepad(new Gamepad)
: _controllerTag(TAG_UNSET)
, _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);
CC_SAFE_DELETE(_gamepad);
JniMethodInfo t;
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
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);
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);
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(vendorName), controllerID, static_cast<cocos2d::AndroidControllerCode>(button), isPressed, value, isAnalog);
cocos2d::ControllerImpl::onButtonEvent(cocos2d::JniHelper::jstring2string(deviceName), controllerID, 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(vendorName), controllerID, static_cast<cocos2d::AndroidControllerCode>(axis), value, isAnalog);
cocos2d::ControllerImpl::onAxisEvent(cocos2d::JniHelper::jstring2string(deviceName), controllerID, axis, value, isAnalog);
}
} // extern "C" {

View File

@ -27,17 +27,12 @@
#include "base/CCPlatformConfig.h"
#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 "CCEventDispatcher.h"
#include "CCEventController.h"
#include "CCEventListenerController.h"
#include "CCDirector.h"
#include "CCLabel.h"
#import <GameController/GameController.h>
@ -105,90 +100,49 @@ static GCControllerConnectionEventHandler* __instance = nil;
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
{
public:
ControllerImpl(Controller* controller)
: _controller(controller)
, _gcController(nil)
, _lazyRegisterListener(true)
{
}
~ControllerImpl()
{
}
Controller* _controller;
GCController* _gcController;
bool _lazyRegisterListener;
};
std::vector<Controller*> Controller::_controllers;
const std::vector<Controller*>& Controller::getControllers()
{
return _controllers;
}
void Controller::startDiscoveryController()
{
[GCController startWirelessControllerDiscoveryWithCompletionHandler: nil];
[[GCControllerConnectionEventHandler getInstance] observerConnection: ^(GCController* gcController) {
auto controller = new Controller();
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");
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);
controller->onConnected();
} 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()
: _controllerTag(TAG_UNSET)
, _impl(new ControllerImpl(this))
, _connectEvent(nullptr)
, _keyEvent(nullptr)
, _axisEvent(nullptr)
, _deviceId(0)
{
_playerIndex = PLAYER_INDEX_UNSET;
_gamepad = new Gamepad();
_gamepad->_controller = this;
_impl = new ControllerImpl(this);
init();
}
Controller::~Controller()
{
CC_SAFE_DELETE(_impl);
CC_SAFE_DELETE(_gamepad);
delete _impl;
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
@ -225,145 +309,8 @@ bool Controller::isConnected() const
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

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,121 @@
#define __cocos2d_libs__CCController__
#include "CCPlatformMacros.h"
#include <string>
#include <vector>
#include <functional>
#include <unordered_map>
NS_CC_BEGIN
class Gamepad;
class ControllerImpl;
class EventListenerController;
class EventController;
class EventDispatcher;
class Controller
{
public:
static const std::vector<Controller*>& getControllers();
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;}
static Controller* getControllerByTag(int tag);
static void startDiscoveryController();
static void stopDiscoveryController();
const std::string& getVendorName();
const std::string& getDeviceName() const { return _deviceName;}
int getDeviceId() const { return _deviceId;}
bool isConnected() const;
static const int PLAYER_INDEX_UNSET = -1;
const KeyStatus& getKeyStatus(int keyCode);
int getPlayerIndex() const;
void setPlayerIndex(int playerIndex);
/** Activate receives key event from external key. e.g. back,menu.
* 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;
void setTag(int tag) { _controllerTag = tag;}
int getTag() const { return _controllerTag;}
// For internal use only
inline ControllerImpl* getImpl() const { return _impl; };
private:
static std::vector<Controller*> s_allController;
Controller();
virtual ~Controller();
private:
static std::vector<Controller*> _controllers;
void init();
std::string _vendorName;
int _playerIndex;
Gamepad* _gamepad;
void onConnected();
void onDisconnected();
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;
ControllerImpl* _impl;
friend class EventListenerController;
};

View File

@ -1,52 +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 "CCControllerAxisInput.h"
NS_CC_BEGIN
ControllerAxisInput::ControllerAxisInput()
: _value(0.0f)
{
}
ControllerAxisInput::~ControllerAxisInput()
{
}
float ControllerAxisInput::getValue() const
{
return _value;
}
void ControllerAxisInput::setValue(float value)
{
_value = value;
}
NS_CC_END

View File

@ -1,55 +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__CCControllerAxisInput__
#define __cocos2d_libs__CCControllerAxisInput__
#include "CCPlatformMacros.h"
#include "CCControllerElement.h"
NS_CC_BEGIN
class ControllerAxisInput : public ControllerElement
{
public:
float getValue() const;
protected:
ControllerAxisInput();
virtual ~ControllerAxisInput();
void setValue(float value);
float _value;
friend class Controller;
friend class ControllerImpl;
friend class ControllerDirectionPad;
friend class ControllerThumbstick;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCControllerAxisInput__) */

View File

@ -1,69 +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 "CCControllerButtonInput.h"
NS_CC_BEGIN
ControllerButtonInput::ControllerButtonInput()
: _value(0.0f)
, _isPressed(false)
, _isPrevStatusPressed(false)
{
}
ControllerButtonInput::~ControllerButtonInput()
{
}
float ControllerButtonInput::getValue() const
{
return _value;
}
bool ControllerButtonInput::isPressed() const
{
return _isPressed;
}
bool ControllerButtonInput::isPrevStatusPressed() const
{
return _isPrevStatusPressed;
}
void ControllerButtonInput::setValue(float value)
{
_value = value;
}
void ControllerButtonInput::setPressed(bool isPressed)
{
_isPrevStatusPressed = _isPressed;
_isPressed = isPressed;
}
NS_CC_END

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,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.
****************************************************************************/
#include "CCControllerElement.h"
NS_CC_BEGIN
ControllerElement::ControllerElement()
: _isAnalog(false)
, _collection(nullptr)
{
}
ControllerElement::~ControllerElement()
{
}
bool ControllerElement::isAnalog() const
{
return _isAnalog;
}
void ControllerElement::setAnalog(bool isAnalog)
{
_isAnalog = isAnalog;
}
ControllerElement* ControllerElement::getCollection()
{
return _collection;
}
void ControllerElement::setCollection(ControllerElement* collection)
{
_collection = collection;
}
NS_CC_END

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

@ -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__CCControllerThumbStick__
#define __cocos2d_libs__CCControllerThumbStick__
#include "CCPlatformMacros.h"
#include "CCControllerElement.h"
NS_CC_BEGIN
class ControllerAxisInput;
class ControllerButtonInput;
class ControllerThumbstick : public ControllerElement
{
public:
ControllerAxisInput* getAxisX() const;
ControllerAxisInput* getAxisY() const;
ControllerButtonInput* getButton() const;
protected:
friend class Controller;
friend class Gamepad;
ControllerThumbstick();
virtual ~ControllerThumbstick();
ControllerAxisInput* _axisX;
ControllerAxisInput* _axisY;
ControllerButtonInput* _button;
};
NS_CC_END
#endif /* defined(__cocos2d_libs__CCControllerThumbStick__) */

View File

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

View File

@ -27,10 +27,10 @@
NS_CC_BEGIN
EventController::EventController(ControllerEventType type, Controller* controller, ControllerElement* element)
EventController::EventController(ControllerEventType type, Controller* controller, int keyCode)
: Event(Type::GAME_CONTROLLER)
, _controllerEventType(type)
, _element(element)
, _keyCode(keyCode)
, _controller(controller)
, _isConnected(true)
{
@ -40,31 +40,11 @@ EventController::EventController(ControllerEventType type, Controller* controlle
EventController::EventController(ControllerEventType type, Controller* controller, bool isConnected)
: Event(Type::GAME_CONTROLLER)
, _controllerEventType(type)
, _element(nullptr)
, _controller(controller)
, _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

View File

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

View File

@ -613,7 +613,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (l->getAssociatedNode() != nullptr)
{
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)
@ -1276,7 +1276,7 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
if (l->getAssociatedNode() != nullptr)
{
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)

View File

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

View File

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

View File

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

View File

@ -26,12 +26,6 @@
#ifndef __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 "CCEventController.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;
_luaID = 0;
_ID = ++uObjectCount;
_scriptObject = nullptr;
#endif
#if CC_USE_MEM_LEAK_DETECTION
@ -64,7 +65,7 @@ Ref::~Ref()
else
{
ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript)
if (pEngine != nullptr && pEngine->getScriptType() == kScriptTypeJavascript)
{
pEngine->removeScriptObjectByObject(this);
}

View File

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

View File

@ -181,7 +181,7 @@ void tgaFlipImage( tImageTGA *info )
unsigned char *row = (unsigned char *)malloc(rowbytes);
int y;
if (row == NULL) return;
if (row == nullptr) return;
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);
// check to make sure we have the memory required
if (info->imageData == NULL)
if (info->imageData == nullptr)
{
info->status = TGA_ERROR_MEMORY;
break;

View File

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

View File

@ -33,6 +33,7 @@ THE SOFTWARE.
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "CCGL.h"
#include "CCRef.h"
NS_CC_BEGIN
@ -484,6 +485,7 @@ public:
@brief The device accelerometer reports values for each axis in units of g-force
*/
class Acceleration
: public Ref
{
public:
double x;

View File

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

View File

@ -261,6 +261,10 @@ THE SOFTWARE.
//3d
#include "3d/CCSprite3D.h"
#include "3d/CCMesh.h"
#include "3d/CCMeshSkin.h"
#include "3d/CCAnimate3D.h"
#include "3d/CCAnimation3D.h"
#include "3d/CCSprite3DMaterial.h"
// Audio
#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 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 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 ccGLEnable( int flags ) { /* ignore */ };
CC_DEPRECATED_ATTRIBUTE typedef int ccGLServerState;

View File

@ -97,7 +97,7 @@ unsigned int __Dictionary::count()
__Array* __Dictionary::allKeys()
{
int iKeyCount = this->count();
if (iKeyCount <= 0) return NULL;
if (iKeyCount <= 0) return nullptr;
__Array* array = __Array::createWithCapacity(iKeyCount);
@ -127,7 +127,7 @@ __Array* __Dictionary::allKeys()
__Array* __Dictionary::allKeysForObject(Ref* object)
{
int iKeyCount = this->count();
if (iKeyCount <= 0) return NULL;
if (iKeyCount <= 0) return nullptr;
__Array* array = __Array::create();
DictElement *pElement, *tmp;
@ -161,16 +161,16 @@ __Array* __Dictionary::allKeysForObject(Ref* object)
Ref* __Dictionary::objectForKey(const std::string& key)
{
// if dictionary wasn't initialized, return NULL directly.
if (_dictType == kDictUnknown) return NULL;
// if dictionary wasn't initialized, return nullptr directly.
if (_dictType == kDictUnknown) return nullptr;
// __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.
CCASSERT(_dictType == kDictStr, "this dictionary does not use string as key.");
Ref* pRetObject = NULL;
DictElement *pElement = NULL;
Ref* pRetObject = nullptr;
DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), pElement);
if (pElement != NULL)
if (pElement != nullptr)
{
pRetObject = pElement->_object;
}
@ -179,16 +179,16 @@ Ref* __Dictionary::objectForKey(const std::string& key)
Ref* __Dictionary::objectForKey(intptr_t key)
{
// if dictionary wasn't initialized, return NULL directly.
if (_dictType == kDictUnknown) return NULL;
// if dictionary wasn't initialized, return nullptr directly.
if (_dictType == kDictUnknown) return nullptr;
// __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.
CCASSERT(_dictType == kDictInt, "this dictionary does not use integer as key.");
Ref* pRetObject = NULL;
DictElement *pElement = NULL;
Ref* pRetObject = nullptr;
DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement);
if (pElement != NULL)
if (pElement != nullptr)
{
pRetObject = pElement->_object;
}
@ -198,7 +198,7 @@ Ref* __Dictionary::objectForKey(intptr_t key)
const __String* __Dictionary::valueForKey(const std::string& key)
{
__String* pStr = dynamic_cast<__String*>(objectForKey(key));
if (pStr == NULL)
if (pStr == nullptr)
{
pStr = __String::create("");
}
@ -208,7 +208,7 @@ const __String* __Dictionary::valueForKey(const std::string& key)
const __String* __Dictionary::valueForKey(intptr_t key)
{
__String* pStr = dynamic_cast<__String*>(objectForKey(key));
if (pStr == NULL)
if (pStr == nullptr)
{
pStr = __String::create("");
}
@ -217,7 +217,7 @@ const __String* __Dictionary::valueForKey(intptr_t 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)
{
_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.");
DictElement *pElement = NULL;
DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), pElement);
if (pElement == NULL)
if (pElement == nullptr)
{
setObjectUnSafe(pObject, key);
}
@ -243,7 +243,7 @@ void __Dictionary::setObject(Ref* pObject, const std::string& key)
void __Dictionary::setObject(Ref* pObject, intptr_t key)
{
CCASSERT(pObject != NULL, "Invalid Argument!");
CCASSERT(pObject != nullptr, "Invalid Argument!");
if (_dictType == kDictUnknown)
{
_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.");
DictElement *pElement = NULL;
DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement);
if (pElement == NULL)
if (pElement == nullptr)
{
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(key.length() > 0, "Invalid Argument!");
DictElement *pElement = NULL;
DictElement *pElement = nullptr;
HASH_FIND_STR(_elements, key.c_str(), 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");
DictElement *pElement = NULL;
DictElement *pElement = nullptr;
HASH_FIND_PTR(_elements, &key, pElement);
removeObjectForElememt(pElement);
}
@ -311,7 +311,7 @@ void __Dictionary::setObjectUnSafe(Ref* pObject, const intptr_t key)
void __Dictionary::removeObjectsForKeys(__Array* pKey__Array)
{
Ref* pObj = NULL;
Ref* pObj = nullptr;
CCARRAY_FOREACH(pKey__Array, pObj)
{
__String* pStr = static_cast<__String*>(pObj);
@ -321,7 +321,7 @@ void __Dictionary::removeObjectsForKeys(__Array* pKey__Array)
void __Dictionary::removeObjectForElememt(DictElement* pElement)
{
if (pElement != NULL)
if (pElement != nullptr)
{
HASH_DEL(_elements, pElement);
pElement->_object->release();
@ -345,7 +345,7 @@ Ref* __Dictionary::randomObject()
{
if (_dictType == kDictUnknown)
{
return NULL;
return nullptr;
}
Ref* key = allKeys()->getRandomObject();
@ -360,7 +360,7 @@ Ref* __Dictionary::randomObject()
}
else
{
return NULL;
return nullptr;
}
}
@ -566,9 +566,9 @@ __Dictionary* __Dictionary::clone() const
{
__Dictionary* newDict = __Dictionary::create();
DictElement* element = NULL;
Ref* tmpObj = NULL;
Clonable* obj = NULL;
DictElement* element = nullptr;
Ref* tmpObj = nullptr;
Clonable* obj = nullptr;
if (_dictType == kDictInt)
{
CCDICT_FOREACH(this, element)

View File

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

View File

@ -69,7 +69,7 @@ bool __String::initWithFormatAndValist(const char* format, va_list ap)
{
bool bRet = false;
char* pBuf = (char*)malloc(kMaxStringLen);
if (pBuf != NULL)
if (pBuf != nullptr)
{
vsnprintf(pBuf, kMaxStringLen, format, ap);
_string = pBuf;
@ -170,7 +170,7 @@ void __String::appendWithFormat(const char* format, ...)
va_start(ap, format);
char* pBuf = (char*)malloc(kMaxStringLen);
if (pBuf != NULL)
if (pBuf != nullptr)
{
vsnprintf(pBuf, kMaxStringLen, format, ap);
_string.append(pBuf);
@ -207,7 +207,7 @@ bool __String::isEqual(const Ref* pObject)
{
bool bRet = false;
const __String* pStr = dynamic_cast<const __String*>(pObject);
if (pStr != NULL)
if (pStr != nullptr)
{
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* ret = NULL;
if (data != NULL)
__String* ret = nullptr;
if (data != nullptr)
{
char* pStr = (char*)malloc(nLen+1);
if (pStr != NULL)
if (pStr != nullptr)
{
pStr[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) {
if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) {
if(pSpriteFrame != NULL) {
if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::NORMAL);
}
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) {
if(pSpriteFrame != NULL) {
if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::HIGH_LIGHTED);
}
} else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) {
if(pSpriteFrame != NULL) {
if(pSpriteFrame != nullptr) {
((ControlButton *)pNode)->setBackgroundSpriteFrameForState(pSpriteFrame, Control::State::DISABLED);
}
} else {

View File

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

View File

@ -9,7 +9,7 @@ namespace cocosbuilder {
void MenuItemLoader::onHandlePropTypeBlock(Node * pNode, Node * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * ccbReader) {
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)->setTarget(pBlockData->_target, pBlockData->mSELMenuHandler);

View File

@ -71,7 +71,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
// #endif
// Forward properties for sub ccb files
if (dynamic_cast<CCBFile*>(pNode) != NULL)
if (dynamic_cast<CCBFile*>(pNode) != nullptr)
{
CCBFile *ccbNode = (CCBFile*)pNode;
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
__Array *extraPropsNames = (__Array*)pNode->getUserObject();
Ref* pObj = NULL;
Ref* pObj = nullptr;
bool bFound = false;
CCARRAY_FOREACH(extraPropsNames, pObj)
{
@ -346,7 +346,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
case CCBReader::PropertyType::BLOCK_CONTROL:
{
BlockControlData * blockControlData = this->parsePropTypeBlockControl(pNode, pParent, ccbReader);
if(setProp && blockControlData != NULL) {
if(setProp && blockControlData != nullptr) {
this->onHandlePropTypeBlockControl(pNode, pParent, propertyName.c_str(), blockControlData, ccbReader);
}
CC_SAFE_DELETE(blockControlData);
@ -574,14 +574,14 @@ SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent,
std::string spriteSheet = ccbReader->readCachedString();
std::string spriteFile = ccbReader->readCachedString();
SpriteFrame *spriteFrame = NULL;
SpriteFrame *spriteFrame = nullptr;
if (spriteFile.length() != 0)
{
if (spriteSheet.length() == 0)
{
spriteFile = ccbReader->getCCBRootPath() + spriteFile;
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);
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 animation = ccbReader->readCachedString();
Animation * ccAnimation = NULL;
Animation * ccAnimation = nullptr;
// Support for stripping relative file paths, since ios doesn't currently
// know what to do with them, since its pulling from bundle.
@ -642,7 +642,7 @@ Texture2D * NodeLoader::parsePropTypeTexture(Node * pNode, Node * pParent, CCBRe
}
else
{
return NULL;
return nullptr;
}
}
@ -761,7 +761,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
if(selectorTarget != CCBReader::TargetType::NONE)
{
Ref* target = NULL;
Ref* target = nullptr;
if(!ccbReader->isJSControlled())
{
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
@ -773,7 +773,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
target = ccbReader->getOwner();
}
if(target != NULL)
if(target != nullptr)
{
if(selectorName.length() > 0)
{
@ -781,7 +781,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
if(targetAsCCBSelectorResolver != NULL)
if(targetAsCCBSelectorResolver != nullptr)
{
selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
}
@ -789,7 +789,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
if(selMenuHandler == 0)
{
CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver();
if(ccbSelectorResolver != NULL)
if(ccbSelectorResolver != nullptr)
{
selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str());
}
@ -809,7 +809,7 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
CCLOG("Unexpected empty selector.");
}
} else {
CCLOG("Unexpected NULL target for selector.");
CCLOG("Unexpected nullptr target for selector.");
}
}
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)
@ -844,7 +844,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
{
if(!ccbReader->isJSControlled())
{
Ref* target = NULL;
Ref* target = nullptr;
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
{
target = ccbReader->getAnimationManager()->getRootNode();
@ -854,7 +854,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
target = ccbReader->getOwner();
}
if(target != NULL)
if(target != nullptr)
{
if(selectorName.length() > 0)
{
@ -862,7 +862,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target);
if(targetAsCCBSelectorResolver != NULL)
if(targetAsCCBSelectorResolver != nullptr)
{
selControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
}
@ -870,7 +870,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
if(selControlHandler == 0)
{
CCBSelectorResolver * ccbSelectorResolver = ccbReader->getCCBSelectorResolver();
if(ccbSelectorResolver != NULL)
if(ccbSelectorResolver != nullptr)
{
selControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str());
}
@ -894,7 +894,7 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
CCLOG("Unexpected empty selector.");
}
} else {
CCLOG("Unexpected NULL target for selector.");
CCLOG("Unexpected nullptr target for selector.");
}
}
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) {
@ -960,7 +960,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
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 callback

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ VisibleFrame* VisibleFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
VisibleFrame::VisibleFrame()
@ -104,7 +104,7 @@ TextureFrame* TextureFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
TextureFrame::TextureFrame()
@ -155,7 +155,7 @@ RotationFrame* RotationFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
RotationFrame::RotationFrame()
@ -204,7 +204,7 @@ SkewFrame* SkewFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
SkewFrame::SkewFrame()
@ -261,7 +261,7 @@ RotationSkewFrame* RotationSkewFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
RotationSkewFrame::RotationSkewFrame()
@ -314,7 +314,7 @@ PositionFrame* PositionFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
PositionFrame::PositionFrame()
@ -366,7 +366,7 @@ ScaleFrame* ScaleFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
ScaleFrame::ScaleFrame()
@ -421,7 +421,7 @@ AnchorPointFrame* AnchorPointFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
AnchorPointFrame::AnchorPointFrame()
@ -457,7 +457,7 @@ InnerActionFrame* InnerActionFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
InnerActionFrame::InnerActionFrame()
@ -493,7 +493,7 @@ ColorFrame* ColorFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
ColorFrame::ColorFrame()
@ -559,7 +559,7 @@ EventFrame* EventFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
EventFrame::EventFrame()
@ -594,7 +594,7 @@ ZOrderFrame* ZOrderFrame::create()
return frame;
}
CC_SAFE_DELETE(frame);
return NULL;
return nullptr;
}
ZOrderFrame::ZOrderFrame()
@ -605,7 +605,7 @@ ZOrderFrame::ZOrderFrame()
void ZOrderFrame::onEnter(Frame *nextFrame)
{
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)
node->setRotation(rotation);
if(rotationSkewX != 0)
node->setRotationX(rotationSkewX);
node->setRotationSkewX(rotationSkewX);
if(rotationSkewY != 0)
node->setRotationY(rotationSkewY);
node->setRotationSkewY(rotationSkewY);
if(skewx != 0)
node->setSkewX(skewx);
if(skewy != 0)
@ -296,19 +296,17 @@ void NodeReader::initNode(Node* node, const rapidjson::Value& json)
if(width != 0 || height != 0)
node->setContentSize(Size(width, height));
if(zorder != 0)
node->setZOrder(zorder);
node->setLocalZOrder(zorder);
if(visible != true)
node->setVisible(visible);
if(alpha != 255)
{
node->setOpacity(alpha);
node->setCascadeOpacityEnabled(true);
}
if(red != 255 || green != 255 || blue != 255)
{
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)
{
_frames.eraseObject(frame);
frame->setTimeline(NULL);
frame->setTimeline(nullptr);
}
void Timeline::setNode(Node* node)
@ -131,8 +131,8 @@ void Timeline::apply(int frameIndex)
void Timeline::binarySearchKeyFrame(int frameIndex)
{
Frame *from = NULL;
Frame *to = NULL;
Frame *from = nullptr;
Frame *to = nullptr;
long length = _frames.size();
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->updateTransform();
bool blendDirty = bone->isBlendDirty();
BlendFunc func = bone->getBlendFunc();
if (blendDirty)
if (func.src != _blendFunc.src || func.dst != _blendFunc.dst)
{
skin->setBlendFunc(bone->getBlendFunc());
}

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();
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)
{
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)
{
if(str != NULL)
if(str != nullptr)
{
textureData->height = atof(str);
}
}
else if (key.compare(A_PIVOT_X) == 0)
{
if(str != NULL)
if(str != nullptr)
{
textureData->pivotX = atof(str);
}
}
else if (key.compare(A_PIVOT_Y) == 0)
{
if(str != NULL)
if(str != nullptr)
{
textureData->pivotY = atof(str);
}

View File

@ -351,7 +351,7 @@ Widget* GUIReader::widgetFromBinaryFile(const char *fileName)
const char* fileVersion = "";
ui::Widget* widget = nullptr;
if (pBuffer != NULL && nSize > 0)
if (pBuffer != nullptr && nSize > 0)
{
CocoLoader tCocoLoader;
if(true == tCocoLoader.ReadCocoBinBuff((char*)pBuffer))
@ -494,7 +494,7 @@ Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, c
if (widget->getContentSize().equals(Size::ZERO))
{
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 h = DICTOOL->getFloatValue_json(options, "height");
widget->setSize(Size(w, h));
widget->setContentSize(Size(w, h));
widget->setTag(DICTOOL->getIntValue_json(options, "tag"));
widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag"));
@ -707,7 +707,7 @@ void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(Widget*widg
{
float swf = DICTOOL->getFloatValue_json(options, "scale9Width");
float shf = DICTOOL->getFloatValue_json(options, "scale9Height");
button->setSize(Size(swf, shf));
button->setContentSize(Size(swf, shf));
}
}
else
@ -823,7 +823,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*w
{
float swf = DICTOOL->getFloatValue_json(options, "scale9Width");
float shf = DICTOOL->getFloatValue_json(options, "scale9Height");
imageView->setSize(Size(swf, shf));
imageView->setContentSize(Size(swf, shf));
}
float cx = DICTOOL->getFloatValue_json(options, "capInsetsX");
@ -1016,7 +1016,7 @@ void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(Widget*widg
{
slider->loadBarTexture(imageFileName_tp);
}
slider->setSize(Size(barLength, slider->getContentSize().height));
slider->setContentSize(Size(barLength, slider->getContentSize().height));
}
else
{
@ -1204,7 +1204,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
if (widget->getContentSize().equals(Size::ZERO))
{
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))
{
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);
// 2nd., custom widget parse with custom reader
//2nd. parse custom property
const char* customProperty = NULL;
const char* customProperty = nullptr;
stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader);
for (int k = 0; k < optionsNode->GetChildNum(); ++k) {
std::string key = optionChildNode[k].GetName(cocoLoader);

View File

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

View File

@ -92,7 +92,7 @@ Type stExpCocoNode::GetType(CocoLoader* pCoco)
char* stExpCocoNode::GetName(CocoLoader* pCoco)
{
char* szName = NULL ;
char* szName = nullptr ;
if(m_ObjIndex >= 0)
{
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
@ -147,9 +147,9 @@ stExpCocoNode* stExpCocoNode::GetChildArray(CocoLoader* pCoco)
CocoLoader::CocoLoader()
{
m_pRootNode = NULL;
m_pObjectDescArray = NULL;
m_pMemoryBuff = NULL;
m_pRootNode = nullptr;
m_pObjectDescArray = nullptr;
m_pMemoryBuff = nullptr;
}
CocoLoader::~CocoLoader()
@ -157,7 +157,7 @@ CocoLoader::~CocoLoader()
if(m_pMemoryBuff)
{
delete[] m_pMemoryBuff;
m_pMemoryBuff = NULL;
m_pMemoryBuff = nullptr;
}
}
@ -176,7 +176,7 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
char* pDestBuff = new char[m_pFileHeader->m_nDataSize];
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;
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;
}
@ -198,7 +198,7 @@ stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc)
return &m_pObjectDescArray[i];
}
}
return NULL;
return nullptr;
}
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
@ -207,7 +207,7 @@ stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
{
return &m_pObjectDescArray[vIndex];
}
return NULL;
return nullptr;
}
char* CocoLoader::GetMemoryAddr_AttribDesc()

View File

@ -115,7 +115,7 @@ void TriggerMng::parse(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCoc
#if CC_ENABLE_SCRIPT_BINDING
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
bool useBindings = engine != NULL;
bool useBindings = engine != nullptr;
if (useBindings)
{
@ -234,7 +234,7 @@ bool TriggerMng::isEmpty(void) const
const char *str2 = pActionArray[i3].GetValue(pCocoLoader);
if (key2.compare("classname") == 0)
{
if (str2 != NULL)
if (str2 != nullptr)
{
action.AddMember("classname", str2, allocator);
}
@ -255,7 +255,7 @@ bool TriggerMng::isEmpty(void) const
const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader);
if (key3.compare("key") == 0)
{
if (str3 != NULL)
if (str3 != nullptr)
{
dataitem.AddMember("key", str3, allocator);
}
@ -310,7 +310,7 @@ bool TriggerMng::isEmpty(void) const
const char *str4 = pConditionArray[i7].GetValue(pCocoLoader);
if (key4.compare("classname") == 0)
{
if (str4 != NULL)
if (str4 != nullptr)
{
cond.AddMember("classname", str4, allocator);
}
@ -331,7 +331,7 @@ bool TriggerMng::isEmpty(void) const
const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader);
if (key5.compare("key") == 0)
{
if (str5 != NULL)
if (str5 != nullptr)
{
dataitem.AddMember("key", str5, allocator);
}
@ -380,7 +380,7 @@ bool TriggerMng::isEmpty(void) const
stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader);
std::string key6 = pEventArray[0].GetName(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);
eventsItem.PushBack(event, allocator);
@ -390,7 +390,7 @@ bool TriggerMng::isEmpty(void) const
}
else if (key1.compare("id") == 0)
{
if (str1 != NULL)
if (str1 != nullptr)
{
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);
if (key.compare("id") == 0)
{
if (str0 != NULL)
if (str0 != nullptr)
{
_id = atoi(str0); //(unsigned int)(DICTOOL->getIntValue_json(val, "id"));
}
@ -292,7 +292,7 @@ void TriggerObj::serialize(const rapidjson::Value &val)
continue;
}
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->init();
_acts.pushBack(act);

View File

@ -152,7 +152,7 @@ namespace cocostudio
if (button->isScale9Enabled()) {
button->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight));
button->setSize(Size(scale9Width, scale9Height));
button->setContentSize(Size(scale9Width, scale9Height));
}
button->setTitleColor(Color3B(cri, cgi, cbi));
@ -203,7 +203,7 @@ namespace cocostudio
{
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width);
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);

View File

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

View File

@ -19,7 +19,7 @@ namespace cocostudio
static const char* P_Scale9Height = "scale9Height";
static ImageViewReader* instanceImageViewReader = NULL;
static ImageViewReader* instanceImageViewReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(ImageViewReader)
@ -128,7 +128,7 @@ namespace cocostudio
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,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);

View File

@ -34,7 +34,7 @@ namespace cocostudio
static const char* P_BackGroundImageData = "backGroundImageData";
static const char* P_LayoutType = "layoutType";
static LayoutReader* instanceLayoutReader = NULL;
static LayoutReader* instanceLayoutReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(LayoutReader)
@ -72,7 +72,7 @@ namespace cocostudio
int ecr=0, ecg=0, ecb= 0;
float bgcv1 = 0.0f, bgcv2= 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();
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
@ -290,11 +290,14 @@ namespace cocostudio
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, P_LayoutType));
int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR);
int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG);
int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB);
int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR,255);
int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG,255);
int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB,255);
panel->setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb));
int bgimgopacity = DICTOOL->getIntValue_json(options, "opacity",255);
panel->setBackGroundImageOpacity(bgimgopacity);
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}

View File

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

View File

@ -19,7 +19,7 @@ namespace cocostudio
static const char* P_Direction = "direction";
static const char* P_Percent = "percent";
static LoadingBarReader* instanceLoadingBar = NULL;
static LoadingBarReader* instanceLoadingBar = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(LoadingBarReader)
@ -130,7 +130,7 @@ namespace cocostudio
float width = DICTOOL->getFloatValue_json(options, P_Width);
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_ProgressBarData = "progressBarData";
static const char* P_BarFileName = "barFileName";
static SliderReader* instanceSliderReader = NULL;
static SliderReader* instanceSliderReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(SliderReader)
@ -125,7 +123,7 @@ namespace cocostudio
} //end of for loop
if (slider->isScale9Enabled()) {
slider->setSize(Size(barLength, slider->getContentSize().height));
slider->setContentSize(Size(barLength, slider->getContentSize().height));
}
slider->setPercent(percent);

View File

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

View File

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

View File

@ -9,7 +9,7 @@ using namespace ui;
namespace cocostudio
{
static TextFieldReader* instanceTextFieldReader = NULL;
static TextFieldReader* instanceTextFieldReader = nullptr;
static const char* P_PlaceHolder = "placeHolder";
static const char* P_Text = "text";

View File

@ -18,7 +18,7 @@ namespace cocostudio
static const char* P_HAlignment = "hAlignment";
static const char* P_VAlignment = "vAlignment";
static TextReader* instanceTextReader = NULL;
static TextReader* instanceTextReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(TextReader)
@ -49,7 +49,7 @@ namespace cocostudio
Text* label = static_cast<Text*>(widget);
std::string jsonPath = GUIReader::getInstance()->getFilePath();
std::string binaryFilePath = GUIReader::getInstance()->getFilePath();
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
@ -69,7 +69,8 @@ namespace cocostudio
}else if(key == P_FontSize){
label->setFontSize(valueToInt(value));
}else if(key == P_FontName){
std::string fontFilePath = jsonPath.append(value);
std::string fontFilePath;
fontFilePath = binaryFilePath.append(value);
label->setFontName(fontFilePath);
}else if(key == P_AreaWidth){
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));

View File

@ -59,7 +59,7 @@ namespace cocostudio
const char* P_Path = "path";
static WidgetReader* instanceWidgetReader = NULL;
static WidgetReader* instanceWidgetReader = nullptr;
IMPLEMENT_CLASS_WIDGET_READER_INFO(WidgetReader)
@ -114,8 +114,10 @@ namespace cocostudio
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
if (ignoreSizeExsit) {
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
}
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
@ -137,7 +139,7 @@ namespace cocostudio
w = DICTOOL->getFloatValue_json(options, P_Width);
h = DICTOOL->getFloatValue_json(options, P_Height);
}
widget->setSize(Size(w, h));
widget->setContentSize(Size(w, h));
widget->setTag(DICTOOL->getIntValue_json(options, P_Tag));
widget->setActionTag(DICTOOL->getIntValue_json(options, P_ActionTag));
@ -257,7 +259,7 @@ namespace cocostudio
widget->setOpacity(_opacity);
//the setSize method will be conflict with scale9Width & scale9Height
if (!widget->isIgnoreContentAdaptWithSize()) {
widget->setSize(Size(_width, _height));
widget->setContentSize(Size(_width, _height));
}
widget->setPosition(_position);
widget->setAnchorPoint(_originalAnchorPoint);

View File

@ -174,7 +174,7 @@ namespace cocostudio
}else if(key == P_Visbile){ \
widget->setVisible(valueToBool(value)); \
}else if(key == P_ZOrder){ \
widget->setZOrder(valueToInt(value)); \
widget->setLocalZOrder(valueToInt(value)); \
}else if(key == P_LayoutParameter){ \
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(cocoLoader); \
ui::LinearLayoutParameter *linearParameter = ui::LinearLayoutParameter::create(); \

View File

@ -208,7 +208,7 @@
<SDLCheck>
</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)external\win32-specific\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>false</WholeProgramOptimization>
</ClCompile>

View File

@ -156,7 +156,7 @@ void Mat4::createOrthographicOffCenter(float left, float right, float bottom, fl
void Mat4::createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition,
const Vec3& cameraUpVector, Mat4* dst)
{
createBillboardHelper(objectPosition, cameraPosition, cameraUpVector, NULL, dst);
createBillboardHelper(objectPosition, cameraPosition, cameraUpVector, nullptr, dst);
}
void Mat4::createBillboard(const Vec3& objectPosition, const Vec3& cameraPosition,
@ -441,7 +441,7 @@ bool Mat4::decompose(Vec3* scale, Quaternion* rotation, Vec3* translation) const
}
// Nothing left to do.
if (scale == NULL && rotation == NULL)
if (scale == nullptr && rotation == nullptr)
return true;
// Extract the scale.
@ -469,7 +469,7 @@ bool Mat4::decompose(Vec3* scale, Quaternion* rotation, Vec3* translation) const
}
// Nothing left to do.
if (rotation == NULL)
if (rotation == nullptr)
return true;
// Scale too close to zero, can't decompose rotation.
@ -559,17 +559,17 @@ float Mat4::determinant() const
void Mat4::getScale(Vec3* scale) const
{
decompose(scale, NULL, NULL);
decompose(scale, nullptr, nullptr);
}
bool Mat4::getRotation(Quaternion* rotation) const
{
return decompose(NULL, rotation, NULL);
return decompose(nullptr, rotation, nullptr);
}
void Mat4::getTranslation(Vec3* translation) const
{
decompose(NULL, NULL, translation);
decompose(nullptr, nullptr, translation);
}
void Mat4::getUpVector(Vec3* dst) const

View File

@ -401,9 +401,9 @@ void SIOClientImpl::onMessage(WebSocket* ws, const WebSocket::Data& data)
s_data = payload;
SIOClient *c = NULL;
SIOClient *c = nullptr;
c = getClient(endpoint);
if (c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL");
if (c == nullptr) log("SIOClientImpl::onMessage client lookup returned nullptr");
switch(control)
{
@ -671,7 +671,7 @@ SIOClient* SocketIO::connect(const std::string& uri, SocketIO::SIODelegate& dele
//check if already connected to endpoint, handle
c = socket->getClient(path);
if(c == NULL)
if(c == nullptr)
{
c = new SIOClient(host, port, path, socket, delegate);

View File

@ -447,7 +447,7 @@ void WebSocket::onSubThreadStarted()
_path.c_str(), _host.c_str(), _host.c_str(),
name.c_str(), -1);
if(NULL == _wsInstance) {
if(nullptr == _wsInstance) {
WsMessage* msg = new WsMessage();
msg->what = WS_MSG_TO_UITHREAD_ERROR;
_readyState = State::CLOSING;

View File

@ -27,6 +27,8 @@ THE SOFTWARE.
#define __CC_APPLICATION_PROTOCOL_H__
#include "base/CCPlatformMacros.h"
#include "base/CCScriptSupport.h"
#include "base/CCAutoreleasePool.h"
NS_CC_BEGIN
@ -61,7 +63,11 @@ public:
* @js NA
* @lua NA
*/
virtual ~ApplicationProtocol() {}
virtual ~ApplicationProtocol(){
ScriptEngineManager::destroyInstance();
// clean auto release pool
PoolManager::destroyInstance();
}
/**
@brief Implement Director and Scene init code here.

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