This commit is contained in:
songchengjiang 2014-10-23 10:53:14 +08:00
commit b2cfe366a1
82 changed files with 8274 additions and 8165 deletions

View File

@ -1013,6 +1013,7 @@ Developers:
zhongfq
Optimize decompress jpg data
Fixed memory leak of TextureCache::reloadTexture()
wohaaitinciu
WebView support on windows

View File

@ -34,6 +34,7 @@ cocos2d-x-3.3-rc0 Oct.21 2014
[FIX] Node: unscheduleAllSelectors() deprecated in favor of unscheudleAllCallbacks()
[FIX] Node: crashed if remove/add child too quickly when using integrated physics
[FIX] TextFieldTTF: will get wrong characters if using Chinese input method on WP8
[FIX] TextureCache: memory leak in reloadTexture()
[FIX] UI: Button: button remains gray when releasing it, this issue only happened if enable scale9 and only has one texture
[FIX] UI: Button: when creating a button with a title only, button content size is not immediately updated
[FIX] UI: EditBox: setMaxLength is invalid on mac

View File

@ -204,9 +204,9 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
exit(1)
if build_mode is None:
build_mode = 'release'
elif build_mode != 'debug':
build_mode = 'release'
build_mode = 'debug'
elif build_mode != 'release':
build_mode = 'debug'
app_android_root = ''

View File

@ -1291,14 +1291,14 @@
3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */; };
3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176651960F89B00DE83F5 /* CCGameController.h */; };
3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61781C1966A5A300DE83F5 /* CCController.cpp */; };
3EA1072F19D7F37700CAB794 /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA1072D19D7F37700CAB794 /* CCLight.cpp */; };
3EA1073019D7F37700CAB794 /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA1072D19D7F37700CAB794 /* CCLight.cpp */; };
3EA1073119D7F37700CAB794 /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA1072E19D7F37700CAB794 /* CCLight.h */; };
3EA1073219D7F37700CAB794 /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA1072E19D7F37700CAB794 /* CCLight.h */; };
3EA3EDBC1991CDFA00645534 /* CCCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA3EDBA1991CDFA00645534 /* CCCamera.cpp */; };
3EA3EDBD1991CDFA00645534 /* CCCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA3EDBA1991CDFA00645534 /* CCCamera.cpp */; };
3EA3EDBE1991CDFA00645534 /* CCCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA3EDBB1991CDFA00645534 /* CCCamera.h */; };
3EA3EDBF1991CDFA00645534 /* CCCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA3EDBB1991CDFA00645534 /* CCCamera.h */; };
3EACC9A019F5014D00EB3C5E /* CCCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */; };
3EACC9A119F5014D00EB3C5E /* CCCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */; };
3EACC9A219F5014D00EB3C5E /* CCCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EACC99D19F5014D00EB3C5E /* CCCamera.h */; };
3EACC9A319F5014D00EB3C5E /* CCCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EACC99D19F5014D00EB3C5E /* CCCamera.h */; };
3EACC9A419F5014D00EB3C5E /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EACC99E19F5014D00EB3C5E /* CCLight.cpp */; };
3EACC9A519F5014D00EB3C5E /* CCLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EACC99E19F5014D00EB3C5E /* CCLight.cpp */; };
3EACC9A619F5014D00EB3C5E /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EACC99F19F5014D00EB3C5E /* CCLight.h */; };
3EACC9A719F5014D00EB3C5E /* CCLight.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EACC99F19F5014D00EB3C5E /* CCLight.h */; };
464AD6E5197EBB1400E502D8 /* pvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 464AD6E3197EBB1400E502D8 /* pvr.cpp */; };
464AD6E6197EBB1400E502D8 /* pvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 464AD6E3197EBB1400E502D8 /* pvr.cpp */; };
464AD6E7197EBB1400E502D8 /* pvr.h in Headers */ = {isa = PBXBuildFile; fileRef = 464AD6E4197EBB1400E502D8 /* pvr.h */; };
@ -2462,10 +2462,10 @@
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 /* UIVideoPlayer-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIVideoPlayer-ios.mm"; sourceTree = "<group>"; };
3EA1072D19D7F37700CAB794 /* CCLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCLight.cpp; path = ../base/CCLight.cpp; sourceTree = "<group>"; };
3EA1072E19D7F37700CAB794 /* CCLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCLight.h; path = ../base/CCLight.h; sourceTree = "<group>"; };
3EA3EDBA1991CDFA00645534 /* CCCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCCamera.cpp; path = ../base/CCCamera.cpp; sourceTree = "<group>"; };
3EA3EDBB1991CDFA00645534 /* CCCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCCamera.h; path = ../base/CCCamera.h; sourceTree = "<group>"; };
3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCCamera.cpp; sourceTree = "<group>"; };
3EACC99D19F5014D00EB3C5E /* CCCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCamera.h; sourceTree = "<group>"; };
3EACC99E19F5014D00EB3C5E /* CCLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLight.cpp; sourceTree = "<group>"; };
3EACC99F19F5014D00EB3C5E /* CCLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLight.h; sourceTree = "<group>"; };
464AD6E3197EBB1400E502D8 /* pvr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pvr.cpp; path = ../base/pvr.cpp; sourceTree = "<group>"; };
464AD6E4197EBB1400E502D8 /* pvr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pvr.h; path = ../base/pvr.h; sourceTree = "<group>"; };
46A15FCC1807A544005B8026 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; name = AUTHORS; path = ../AUTHORS; sourceTree = "<group>"; };
@ -3222,12 +3222,8 @@
1A5700A2180BC5E60088DEC7 /* base */ = {
isa = PBXGroup;
children = (
3EA1072D19D7F37700CAB794 /* CCLight.cpp */,
3EA1072E19D7F37700CAB794 /* CCLight.h */,
299CF1F919A434BC00C378C1 /* ccRandom.cpp */,
299CF1FA19A434BC00C378C1 /* ccRandom.h */,
3EA3EDBA1991CDFA00645534 /* CCCamera.cpp */,
3EA3EDBB1991CDFA00645534 /* CCCamera.h */,
464AD6E3197EBB1400E502D8 /* pvr.cpp */,
464AD6E4197EBB1400E502D8 /* pvr.h */,
3E61781C1966A5A300DE83F5 /* CCController.cpp */,
@ -4637,6 +4633,10 @@
46A169A11807B037005B8026 /* 2d */ = {
isa = PBXGroup;
children = (
3EACC99C19F5014D00EB3C5E /* CCCamera.cpp */,
3EACC99D19F5014D00EB3C5E /* CCCamera.h */,
3EACC99E19F5014D00EB3C5E /* CCLight.cpp */,
3EACC99F19F5014D00EB3C5E /* CCLight.h */,
1A9DCA02180E6955007A3AD4 /* CCGLBufferedNode.cpp */,
1A9DCA03180E6955007A3AD4 /* CCGLBufferedNode.h */,
1A570046180BC59A0088DEC7 /* actions */,
@ -5129,7 +5129,6 @@
38B8E2E319E671D2002D7CE7 /* UILayoutComponent.h in Headers */,
5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */,
292DB14B19B4574100A80320 /* UIEditBoxImpl-mac.h in Headers */,
3EA1073119D7F37700CAB794 /* CCLight.h in Headers */,
B29A7E3F19EE1B7700872B35 /* AnimationState.h in Headers */,
50ABBE891925AB6F00A911A9 /* CCMap.h in Headers */,
50ABBE8D1925AB6F00A911A9 /* CCNS.h in Headers */,
@ -5518,7 +5517,6 @@
15AE189E19AAD33D00C27E9E /* CCNodeLoader.h in Headers */,
50ABBE7B1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
503DD8F91926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */,
3EA3EDBE1991CDFA00645534 /* CCCamera.h in Headers */,
15AE1B6619AADA9900C27E9E /* UIImageView.h in Headers */,
15AE1BB419AADFEF00C27E9E /* HttpResponse.h in Headers */,
15AE1A8519AAD40300C27E9E /* b2Joint.h in Headers */,
@ -5557,6 +5555,7 @@
50ABBEC91925AB6F00A911A9 /* firePngData.h in Headers */,
292DB16119B461CA00A80320 /* ExtensionDeprecated.h in Headers */,
503DD8F51926B0DB00CD74DD /* CCIMEDelegate.h in Headers */,
3EACC9A619F5014D00EB3C5E /* CCLight.h in Headers */,
50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */,
15AE1BDB19AAE01E00C27E9E /* CCControlSwitch.h in Headers */,
B24AA987195A675C007B4522 /* CCFastTMXLayer.h in Headers */,
@ -5630,6 +5629,7 @@
15AE190219AAD35000C27E9E /* CCComController.h in Headers */,
15AE18DE19AAD35000C27E9E /* TriggerObj.h in Headers */,
15AE183E19AAD2F700C27E9E /* CCSkeleton3D.h in Headers */,
3EACC9A219F5014D00EB3C5E /* CCCamera.h in Headers */,
50ABBECD1925AB6F00A911A9 /* s3tc.h in Headers */,
15AE1BD119AAE01E00C27E9E /* CCControlHuePicker.h in Headers */,
50ABBE771925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */,
@ -5652,6 +5652,7 @@
503DD8F01926736A00CD74DD /* CCStdC-ios.h in Headers */,
15AE1A9A19AAD40300C27E9E /* b2Math.h in Headers */,
46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */,
3EACC9A319F5014D00EB3C5E /* CCCamera.h in Headers */,
B29A7E1A19EE1B7700872B35 /* Event.h in Headers */,
15AE1AC719AAD40300C27E9E /* b2GearJoint.h in Headers */,
50ABBDA21925AB4100A911A9 /* CCGroupCommand.h in Headers */,
@ -5689,7 +5690,6 @@
15B3708719EE414C00ABE682 /* Downloader.h in Headers */,
15AE192619AAD35100C27E9E /* TriggerObj.h in Headers */,
50ABBE2E1925AB6F00A911A9 /* ccCArray.h in Headers */,
15AE1A0C19AAD3A700C27E9E /* CCSkeletonAnimation.h in Headers */,
15B3707B19EE414C00ABE682 /* AssetsManagerEx.h in Headers */,
15AE1B9119AADA9A00C27E9E /* UIWidget.h in Headers */,
50ABC0041926664800A911A9 /* CCLock-apple.h in Headers */,
@ -5820,7 +5820,6 @@
50ED2BE119BEAF7900A0AB90 /* UIEditBoxImpl-win32.h in Headers */,
15AE1ACB19AAD40300C27E9E /* b2MouseJoint.h in Headers */,
50ABBD3F1925AB0000A911A9 /* CCGeometry.h in Headers */,
3EA3EDBF1991CDFA00645534 /* CCCamera.h in Headers */,
B29A7DD019EE1B7700872B35 /* RegionAttachment.h in Headers */,
15AE1AD319AAD40300C27E9E /* b2RopeJoint.h in Headers */,
50ABBFFE1926664800A911A9 /* CCFileUtils-apple.h in Headers */,
@ -5872,6 +5871,7 @@
15AE1BFA19AAE01E00C27E9E /* CCControlSwitch.h in Headers */,
15AE182F19AAD2F700C27E9E /* CCMeshVertexIndexData.h in Headers */,
15AE1BAA19AADFDF00C27E9E /* UIVBox.h in Headers */,
3EACC9A719F5014D00EB3C5E /* CCLight.h in Headers */,
15AE194E19AAD35100C27E9E /* CCDataReaderHelper.h in Headers */,
3828C0A419EB8ACA002AB57B /* coded_stream_inl.h in Headers */,
15AE1ADB19AAD41000C27E9E /* b2Rope.h in Headers */,
@ -6129,7 +6129,6 @@
3828C0E219EB8ACA002AB57B /* stringprintf.h in Headers */,
50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */,
50ABBDC01925AB4100A911A9 /* CCTextureCache.h in Headers */,
3EA1073219D7F37700CAB794 /* CCLight.h in Headers */,
B276EF641988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */,
ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */,
50ABC0201926664800A911A9 /* CCThread.h in Headers */,
@ -6251,7 +6250,6 @@
50ABBE2B1925AB6F00A911A9 /* ccCArray.cpp in Sources */,
B29A7E3B19EE1B7700872B35 /* Animation.c in Sources */,
15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */,
3EA3EDBC1991CDFA00645534 /* CCCamera.cpp in Sources */,
292DB14F19B4574100A80320 /* UIEditBoxImpl-stub.cpp in Sources */,
B29A7E0B19EE1B7700872B35 /* Atlas.c in Sources */,
15AE199419AAD39600C27E9E /* LayoutReader.cpp in Sources */,
@ -6426,6 +6424,7 @@
1A5701DE180BCB8C0088DEC7 /* CCLayer.cpp in Sources */,
15AE1B5919AADA9900C27E9E /* UIText.cpp in Sources */,
15B3707C19EE414C00ABE682 /* CCEventAssetsManagerEx.cpp in Sources */,
3EACC9A419F5014D00EB3C5E /* CCLight.cpp in Sources */,
1A5701E2180BCB8C0088DEC7 /* CCScene.cpp in Sources */,
15AE1B9919AADFDF00C27E9E /* UIHBox.cpp in Sources */,
15AE199C19AAD39600C27E9E /* ScrollViewReader.cpp in Sources */,
@ -6435,7 +6434,6 @@
1A5701E6180BCB8C0088DEC7 /* CCTransition.cpp in Sources */,
B24AA985195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */,
15AE1A6A19AAD40300C27E9E /* b2ChainAndCircleContact.cpp in Sources */,
15AE19BE19AAD3A700C27E9E /* Event.cpp in Sources */,
15B3708819EE414C00ABE682 /* Manifest.cpp in Sources */,
1A5701EA180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */,
3828C0D719EB8ACA002AB57B /* once.cc in Sources */,
@ -6458,6 +6456,7 @@
292DB14D19B4574100A80320 /* UIEditBoxImpl-mac.mm in Sources */,
50ABBDB51925AB4100A911A9 /* CCTexture2D.cpp in Sources */,
B29A7DD719EE1B7700872B35 /* SkeletonData.c in Sources */,
3EACC9A019F5014D00EB3C5E /* CCCamera.cpp in Sources */,
1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */,
15AE1BD019AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */,
15AE18F219AAD35000C27E9E /* CCArmatureDataManager.cpp in Sources */,
@ -6558,7 +6557,6 @@
1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */,
1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */,
15B3707819EE414C00ABE682 /* AssetsManagerEx.cpp in Sources */,
15AE19E419AAD3A700C27E9E /* SkeletonJson.cpp in Sources */,
1A570358180BD0B00088DEC7 /* unzip.cpp in Sources */,
3828C0CF19EB8ACA002AB57B /* common.cc in Sources */,
B29A7DCB19EE1B7700872B35 /* Skeleton.c in Sources */,
@ -6596,7 +6594,6 @@
15AE199819AAD39600C27E9E /* LoadingBarReader.cpp in Sources */,
503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */,
50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
3EA1072F19D7F37700CAB794 /* CCLight.cpp in Sources */,
15AE18F019AAD35000C27E9E /* CCArmatureAnimation.cpp in Sources */,
50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */,
50ABC0051926664800A911A9 /* CCThread-apple.mm in Sources */,
@ -6808,6 +6805,7 @@
15AE184119AAD2F700C27E9E /* CCSprite3D.cpp in Sources */,
50ABBE5A1925AB6F00A911A9 /* CCEventKeyboard.cpp in Sources */,
15AE193A19AAD35100C27E9E /* CCArmatureDataManager.cpp in Sources */,
3EACC9A519F5014D00EB3C5E /* CCLight.cpp in Sources */,
15AE1B7A19AADA9A00C27E9E /* UIScrollView.cpp in Sources */,
1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */,
15AE19B219AAD39700C27E9E /* SliderReader.cpp in Sources */,
@ -6956,6 +6954,7 @@
15AE194919AAD35100C27E9E /* CCComController.cpp in Sources */,
1A57022A180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */,
15AE182919AAD2F700C27E9E /* CCMeshSkin.cpp in Sources */,
3EACC9A119F5014D00EB3C5E /* CCCamera.cpp in Sources */,
15AE1BBD19AADFF000C27E9E /* SocketIO.cpp in Sources */,
15AE1A4319AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */,
15AE1A3A19AAD3D500C27E9E /* b2BroadPhase.cpp in Sources */,
@ -6988,7 +6987,6 @@
15AE194D19AAD35100C27E9E /* CCDataReaderHelper.cpp in Sources */,
15AE1B8C19AADA9A00C27E9E /* UIScale9Sprite.cpp in Sources */,
15AE19AE19AAD39700C27E9E /* PageViewReader.cpp in Sources */,
3EA3EDBD1991CDFA00645534 /* CCCamera.cpp in Sources */,
1A570297180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */,
50ABBE321925AB6F00A911A9 /* CCConfiguration.cpp in Sources */,
15AE1A9F19AAD40300C27E9E /* b2Timer.cpp in Sources */,
@ -7095,7 +7093,6 @@
50ABBE201925AB6F00A911A9 /* atitc.cpp in Sources */,
50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */,
50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */,
3EA1073019D7F37700CAB794 /* CCLight.cpp in Sources */,
15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */,
15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */,
15AE180919AAD2F700C27E9E /* CCAABB.cpp in Sources */,

View File

@ -1,4 +1,5 @@
How to compile precompiled shaders for Windows Phone 8.0 (WP8)
You need to use VS2013 with update 3.
1. Open the VS project Cocos2dShaderCompiler\Cocos2dShaderCompiler.sln
2. Build and run the project

View File

@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "base/CCDirector.h"
#include "platform/CCGLView.h"
#include "2d/CCScene.h"

View File

@ -151,16 +151,16 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
else
{
StringUtils::trimUTF16Vector(last_word);
if (isStartOfLine)
//issue #8492:endless loop if not using system font, and constrained length is less than one character width
if (isStartOfLine && last_word.size() == 0)
last_word.push_back(character);
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
if (!isStartOfLine)
else
--j;
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
isStartOfWord = false;
isStartOfLine = false;
startOfWord = -1;

View File

@ -1,4 +1,4 @@
#include "base/CCLight.h"
#include "2d/CCLight.h"
#include "2d/CCScene.h"
NS_CC_BEGIN

View File

@ -37,7 +37,7 @@ THE SOFTWARE.
#include "base/CCDirector.h"
#include "base/CCScheduler.h"
#include "base/CCEventDispatcher.h"
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "2d/CCActionManager.h"
#include "2d/CCScene.h"
#include "2d/CCComponent.h"

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include "2d/CCScene.h"
#include "base/CCDirector.h"
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerCustom.h"
#include "renderer/CCRenderer.h"

View File

@ -20,6 +20,7 @@ set(COCOS_2D_SRC
2d/CCAnimationCache.cpp
2d/CCAnimation.cpp
2d/CCAtlasNode.cpp
2d/CCCamera.cpp
2d/CCClippingNode.cpp
2d/CCClippingRectangleNode.cpp
2d/CCComponentContainer.cpp
@ -43,6 +44,7 @@ set(COCOS_2D_SRC
2d/CCLabelTextFormatter.cpp
2d/CCLabelTTF.cpp
2d/CCLayer.cpp
2d/CCLight.cpp
2d/CCMenu.cpp
2d/CCMenuItem.cpp
2d/CCMotionStreak.cpp

View File

@ -253,7 +253,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\base\atitc.cpp" />
<ClCompile Include="..\base\base64.cpp" />
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
<ClCompile Include="..\base\CCCamera.cpp" />
<ClCompile Include="..\base\ccCArray.cpp" />
<ClCompile Include="..\base\CCConfiguration.cpp" />
<ClCompile Include="..\base\CCConsole.cpp" />
@ -277,7 +276,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\base\CCEventTouch.cpp" />
<ClCompile Include="..\base\ccFPSImages.c" />
<ClCompile Include="..\base\CCIMEDispatcher.cpp" />
<ClCompile Include="..\base\CCLight.cpp" />
<ClCompile Include="..\base\CCNS.cpp" />
<ClCompile Include="..\base\CCProfiling.cpp" />
<ClCompile Include="..\base\ccRandom.cpp" />
@ -481,6 +479,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="CCAnimation.cpp" />
<ClCompile Include="CCAnimationCache.cpp" />
<ClCompile Include="CCAtlasNode.cpp" />
<ClCompile Include="CCCamera.cpp" />
<ClCompile Include="CCClippingNode.cpp" />
<ClCompile Include="CCClippingRectangleNode.cpp" />
<ClCompile Include="CCComponent.cpp" />
@ -504,6 +503,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="CCLabelTextFormatter.cpp" />
<ClCompile Include="CCLabelTTF.cpp" />
<ClCompile Include="CCLayer.cpp" />
<ClCompile Include="CCLight.cpp" />
<ClCompile Include="CCMenu.cpp" />
<ClCompile Include="CCMenuItem.cpp" />
<ClCompile Include="CCMotionStreak.cpp" />
@ -637,7 +637,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\base\atitc.h" />
<ClInclude Include="..\base\base64.h" />
<ClInclude Include="..\base\CCAutoreleasePool.h" />
<ClInclude Include="..\base\CCCamera.h" />
<ClInclude Include="..\base\ccCArray.h" />
<ClInclude Include="..\base\ccConfig.h" />
<ClInclude Include="..\base\CCConfiguration.h" />
@ -664,7 +663,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\base\ccFPSImages.h" />
<ClInclude Include="..\base\CCIMEDelegate.h" />
<ClInclude Include="..\base\CCIMEDispatcher.h" />
<ClInclude Include="..\base\CCLight.h" />
<ClInclude Include="..\base\ccMacros.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNS.h" />
@ -905,6 +903,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="CCAnimation.h" />
<ClInclude Include="CCAnimationCache.h" />
<ClInclude Include="CCAtlasNode.h" />
<ClInclude Include="CCCamera.h" />
<ClInclude Include="CCClippingNode.h" />
<ClInclude Include="CCClippingRectangleNode.h" />
<ClInclude Include="CCComponent.h" />
@ -928,6 +927,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="CCLabelTextFormatter.h" />
<ClInclude Include="CCLabelTTF.h" />
<ClInclude Include="CCLayer.h" />
<ClInclude Include="CCLight.h" />
<ClInclude Include="CCMenu.h" />
<ClInclude Include="CCMenuItem.h" />
<ClInclude Include="CCMotionStreak.h" />

View File

@ -727,9 +727,6 @@
<ClCompile Include="CCProtectedNode.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\base\CCCamera.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\renderer\CCPrimitive.cpp">
<Filter>renderer</Filter>
</ClCompile>
@ -1198,9 +1195,6 @@
<ClCompile Include="..\ui\UIWebView.cpp">
<Filter>ui\UIWidgets</Filter>
</ClCompile>
<ClCompile Include="..\base\CCLight.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\audio\AudioEngine.cpp">
<Filter>audioengine</Filter>
</ClCompile>
@ -1265,6 +1259,12 @@
<ClCompile Include="..\..\external\protobuf-lite\src\google\protobuf\stubs\stringprintf.cc">
<Filter>cocostudio\json\protobuf-lite\stubs</Filter>
</ClCompile>
<ClCompile Include="CCCamera.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="CCLight.cpp">
<Filter>2d</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -1841,9 +1841,6 @@
<ClInclude Include="CCProtectedNode.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\base\CCCamera.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\renderer\CCPrimitive.h">
<Filter>renderer</Filter>
</ClInclude>
@ -2414,9 +2411,6 @@
<ClInclude Include="..\ui\UIWebView.h">
<Filter>ui\UIWidgets</Filter>
</ClInclude>
<ClInclude Include="..\base\CCLight.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\audio\include\AudioEngine.h">
<Filter>audioengine</Filter>
</ClInclude>
@ -2529,6 +2523,12 @@
<ClInclude Include="..\..\external\protobuf-lite\src\google\protobuf\stubs\type_traits.h">
<Filter>cocostudio\json\protobuf-lite\stubs</Filter>
</ClInclude>
<ClInclude Include="CCCamera.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="CCLight.h">
<Filter>2d</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -266,7 +266,6 @@
<ClInclude Include="..\base\atitc.h" />
<ClInclude Include="..\base\base64.h" />
<ClInclude Include="..\base\CCAutoreleasePool.h" />
<ClInclude Include="..\base\CCCamera.h" />
<ClInclude Include="..\base\ccCArray.h" />
<ClInclude Include="..\base\ccConfig.h" />
<ClInclude Include="..\base\CCConfiguration.h" />
@ -293,7 +292,6 @@
<ClInclude Include="..\base\ccFPSImages.h" />
<ClInclude Include="..\base\CCIMEDelegate.h" />
<ClInclude Include="..\base\CCIMEDispatcher.h" />
<ClInclude Include="..\base\CCLight.h" />
<ClInclude Include="..\base\ccMacros.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNS.h" />
@ -542,6 +540,7 @@
<ClInclude Include="CCAnimation.h" />
<ClInclude Include="CCAnimationCache.h" />
<ClInclude Include="CCAtlasNode.h" />
<ClInclude Include="CCCamera.h" />
<ClInclude Include="CCClippingNode.h" />
<ClInclude Include="CCClippingRectangleNode.h" />
<ClInclude Include="CCComponent.h" />
@ -565,6 +564,7 @@
<ClInclude Include="CCLabelTextFormatter.h" />
<ClInclude Include="CCLabelTTF.h" />
<ClInclude Include="CCLayer.h" />
<ClInclude Include="CCLight.h" />
<ClInclude Include="CCMenu.h" />
<ClInclude Include="CCMenuItem.h" />
<ClInclude Include="CCMotionStreak.h" />
@ -733,7 +733,6 @@
<ClCompile Include="..\base\atitc.cpp" />
<ClCompile Include="..\base\base64.cpp" />
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
<ClCompile Include="..\base\CCCamera.cpp" />
<ClCompile Include="..\base\ccCArray.cpp" />
<ClCompile Include="..\base\CCConfiguration.cpp" />
<ClCompile Include="..\base\CCConsole.cpp" />
@ -782,7 +781,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\base\CCIMEDispatcher.cpp" />
<ClCompile Include="..\base\CCLight.cpp" />
<ClCompile Include="..\base\CCNS.cpp" />
<ClCompile Include="..\base\CCProfiling.cpp" />
<ClCompile Include="..\base\ccRandom.cpp" />
@ -1000,6 +998,7 @@
<ClCompile Include="CCAnimation.cpp" />
<ClCompile Include="CCAnimationCache.cpp" />
<ClCompile Include="CCAtlasNode.cpp" />
<ClCompile Include="CCCamera.cpp" />
<ClCompile Include="CCClippingNode.cpp" />
<ClCompile Include="CCClippingRectangleNode.cpp" />
<ClCompile Include="CCComponent.cpp" />
@ -1023,6 +1022,7 @@
<ClCompile Include="CCLabelTextFormatter.cpp" />
<ClCompile Include="CCLabelTTF.cpp" />
<ClCompile Include="CCLayer.cpp" />
<ClCompile Include="CCLight.cpp" />
<ClCompile Include="CCMenu.cpp" />
<ClCompile Include="CCMenuItem.cpp" />
<ClCompile Include="CCMotionStreak.cpp" />

View File

@ -286,6 +286,9 @@
<ClCompile Include="CCAtlasNode.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="CCCamera.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="CCClippingNode.cpp">
<Filter>2d</Filter>
</ClCompile>
@ -352,6 +355,9 @@
<ClCompile Include="CCLayer.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="CCLight.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="CCMenu.cpp">
<Filter>2d</Filter>
</ClCompile>
@ -493,9 +499,6 @@
<ClCompile Include="..\base\CCAutoreleasePool.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCCamera.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\ccCArray.cpp">
<Filter>base</Filter>
</ClCompile>
@ -565,9 +568,6 @@
<ClCompile Include="..\base\CCIMEDispatcher.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCLight.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="..\base\CCNS.cpp">
<Filter>base</Filter>
</ClCompile>
@ -1343,6 +1343,9 @@
<ClInclude Include="CCAtlasNode.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="CCCamera.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="CCClippingNode.h">
<Filter>2d</Filter>
</ClInclude>
@ -1409,6 +1412,9 @@
<ClInclude Include="CCLayer.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="CCLight.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="CCMenu.h">
<Filter>2d</Filter>
</ClInclude>
@ -1556,9 +1562,6 @@
<ClInclude Include="..\base\CCAutoreleasePool.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCCamera.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\ccCArray.h">
<Filter>base</Filter>
</ClInclude>
@ -1637,9 +1640,6 @@
<ClInclude Include="..\base\CCIMEDispatcher.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\CCLight.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="..\base\ccMacros.h">
<Filter>base</Filter>
</ClInclude>

View File

@ -58,7 +58,7 @@ CC_CONSTRUCTOR_ACCESS:
protected:
Bone3D* _attachBone;
Bone3D* _attachBone;
};

View File

@ -25,7 +25,7 @@
#include "3d/CCBillBoard.h"
#include "2d/CCSpriteFrameCache.h"
#include "base/CCDirector.h"
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCGLProgramCache.h"

View File

@ -306,20 +306,6 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
return false;
}
bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
{
meshdata->resetData();
if (_isBinary)
{
return loadMeshDataBinary(meshdata);
}
else
{
return loadMeshDataJson(meshdata);
}
}
bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
{
skindata->resetData();
@ -334,20 +320,6 @@ bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
}
}
bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdata)
{
materialdata->resetData();
if (_isBinary)
{
return loadMaterialDataBinary(materialdata);
}
else
{
return loadMaterialDataJson(materialdata);
}
}
bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animationdata)
{
animationdata->resetData();
@ -368,14 +340,10 @@ bool Bundle3D::loadMeshDatas(MeshDatas& meshdatas)
meshdatas.resetData();
if (_isBinary)
{
if (_version == "0.1")
if (_version == "0.1" || _version == "0.2")
{
return loadMeshDatasBinary_0_1(meshdatas);
}
else if(_version == "0.2")
{
return loadMeshDatasBinary_0_2(meshdatas);
}
else
{
return loadMeshDatasBinary(meshdatas);
@ -383,14 +351,10 @@ bool Bundle3D::loadMeshDatas(MeshDatas& meshdatas)
}
else
{
if (_version == "1.2")
if (_version == "1.2" || _version == "0.2")
{
return loadMeshDataJson_0_1(meshdatas);
}
else if(_version == "0.2")
{
return loadMeshDataJson_0_2(meshdatas);
}
else
{
return loadMeshDatasJson(meshdatas);
@ -937,7 +901,7 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas)
if (texturePath.empty())
{
CCLOG("warning: Failed to read Materialdata: texturePath is empty '%s'.", _path.c_str());
return false;
return true;
}
NTextureData textureData;
@ -1005,6 +969,73 @@ bool Bundle3D::loadJson(const std::string& path)
return true;
}
bool Bundle3D::loadBinary(const std::string& path)
{
clear();
// get file data
CC_SAFE_DELETE(_binaryBuffer);
_binaryBuffer = new (std::nothrow) Data();
*_binaryBuffer = FileUtils::getInstance()->getDataFromFile(path);
if (_binaryBuffer->isNull())
{
clear();
CCLOG("warning: Failed to read file: %s", path.c_str());
return false;
}
// Initialise bundle reader
_binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() );
// Read identifier info
char identifier[] = { 'C', '3', 'B', '\0'};
char sig[4];
if (_binaryReader.read(sig, 1, 4) != 4 || memcmp(sig, identifier, 4) != 0)
{
clear();
CCLOG("warning: Invalid identifier: %s", path.c_str());
return false;
}
// Read version
unsigned char ver[2];
if (_binaryReader.read(ver, 1, 2)!= 2){
CCLOG("warning: Failed to read version:");
return false;
}
char version[20] = {0};
sprintf(version, "%d.%d", ver[0], ver[1]);
_version = version;
// Read ref table size
if (_binaryReader.read(&_referenceCount, 4, 1) != 1)
{
clear();
CCLOG("warning: Failed to read ref table size '%s'.", path.c_str());
return false;
}
// Read all refs
CC_SAFE_DELETE_ARRAY(_references);
_references = new (std::nothrow) Reference[_referenceCount];
for (ssize_t i = 0; i < _referenceCount; ++i)
{
if ((_references[i].id = _binaryReader.readString()).empty() ||
_binaryReader.read(&_references[i].type, 4, 1) != 1 ||
_binaryReader.read(&_references[i].offset, 4, 1) != 1)
{
clear();
CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str());
CC_SAFE_DELETE_ARRAY(_references);
return false;
}
}
return true;
}
bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
{
const rapidjson::Value& mesh_data_array = _jsonReader[MESH];
@ -1145,6 +1176,108 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata)
return true;
}
bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN))
return false;
std::string boneName = _binaryReader.readString();
// transform
float bindShape[16];
if (!_binaryReader.readMatrix(bindShape))
{
CCLOG("warning: Failed to read SkinData: bindShape matrix '%s'.", _path.c_str());
return false;
}
// bone count
unsigned int boneNum;
if (!_binaryReader.read(&boneNum))
{
CCLOG("warning: Failed to read SkinData: boneNum '%s'.", _path.c_str());
return false;
}
// bone names and bind pos
float bindpos[16];
for (unsigned int i = 0; i < boneNum; i++)
{
std::string skinBoneName = _binaryReader.readString();
skindata->skinBoneNames.push_back(skinBoneName);
if (!_binaryReader.readMatrix(bindpos))
{
CCLOG("warning: Failed to load SkinData: bindpos '%s'.", _path.c_str());
return false;
}
skindata->inverseBindPoseMatrices.push_back(bindpos);
}
skindata->skinBoneOriginMatrices.resize(boneNum);
boneName = _binaryReader.readString();
// bind shape
_binaryReader.readMatrix(bindShape);
int rootIndex = skindata->getSkinBoneNameIndex(boneName);
if(rootIndex < 0)
{
skindata->addNodeBoneNames(boneName);
rootIndex = skindata->getBoneNameIndex(boneName);
skindata->nodeBoneOriginMatrices.push_back(bindShape);
}
else
{
skindata->skinBoneOriginMatrices[rootIndex] = bindShape;
}
// set root bone index
skindata->rootBoneIndex = rootIndex;
// read parent and child relationship map
float transform[16];
unsigned int linkNum;
_binaryReader.read(&linkNum);
for (unsigned int i = 0; i < linkNum; ++i)
{
std::string id = _binaryReader.readString();
int index = skindata->getSkinBoneNameIndex(id);
std::string parentid = _binaryReader.readString();
if (!_binaryReader.readMatrix(transform))
{
CCLOG("warning: Failed to load SkinData: transform '%s'.", _path.c_str());
return false;
}
if(index < 0)
{
skindata->addNodeBoneNames(id);
index = skindata->getBoneNameIndex(id);
skindata->nodeBoneOriginMatrices.push_back(transform);
}
else
{
skindata->skinBoneOriginMatrices[index] = transform;
}
int parentIndex = skindata->getSkinBoneNameIndex(parentid);
if(parentIndex < 0)
{
skindata->addNodeBoneNames(parentid);
parentIndex = skindata->getBoneNameIndex(parentid);
}
skindata->boneChild[parentIndex].push_back(index);
}
return true;
}
bool Bundle3D::loadMaterialDataJson_0_1(MaterialDatas& materialdatas)
{
if (!_jsonReader.HasMember(MATERIAL))
@ -1269,361 +1402,6 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
return true;
}
bool Bundle3D::loadBinary(const std::string& path)
{
clear();
// get file data
CC_SAFE_DELETE(_binaryBuffer);
_binaryBuffer = new (std::nothrow) Data();
*_binaryBuffer = FileUtils::getInstance()->getDataFromFile(path);
if (_binaryBuffer->isNull())
{
clear();
CCLOG("warning: Failed to read file: %s", path.c_str());
return false;
}
// Initialise bundle reader
_binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() );
// Read identifier info
char identifier[] = { 'C', '3', 'B', '\0'};
char sig[4];
if (_binaryReader.read(sig, 1, 4) != 4 || memcmp(sig, identifier, 4) != 0)
{
clear();
CCLOG("warning: Invalid identifier: %s", path.c_str());
return false;
}
// Read version
unsigned char ver[2];
if (_binaryReader.read(ver, 1, 2)!= 2){
CCLOG("warning: Failed to read version:");
return false;
}
char version[20] = {0};
sprintf(version, "%d.%d", ver[0], ver[1]);
_version = version;
// Read ref table size
if (_binaryReader.read(&_referenceCount, 4, 1) != 1)
{
clear();
CCLOG("warning: Failed to read ref table size '%s'.", path.c_str());
return false;
}
// Read all refs
CC_SAFE_DELETE_ARRAY(_references);
_references = new (std::nothrow) Reference[_referenceCount];
for (ssize_t i = 0; i < _referenceCount; ++i)
{
if ((_references[i].id = _binaryReader.readString()).empty() ||
_binaryReader.read(&_references[i].type, 4, 1) != 1 ||
_binaryReader.read(&_references[i].offset, 4, 1) != 1)
{
clear();
CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str());
CC_SAFE_DELETE_ARRAY(_references);
return false;
}
}
return true;
}
bool Bundle3D::loadMeshDataBinary(MeshData* meshdata)
{
if (_version == "0.1")
{
return loadMeshDataBinary_0_1(meshdata);
}
else if(_version == "0.2")
{
return loadMeshDataBinary_0_2(meshdata);
}
else
{
CCLOG("warning: Unsupported version of loadMeshDataBinary() : %s", _version.c_str());
return false;
}
}
bool Bundle3D::loadMeshDataBinary_0_1(MeshData* meshdata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESH))
return false;
// read mesh data
if (_binaryReader.read(&meshdata->attribCount, 4, 1) != 1 || meshdata->attribCount < 1)
{
CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str());
return false;
}
meshdata->attribs.resize(meshdata->attribCount);
for (ssize_t i = 0; i < meshdata->attribCount; i++)
{
unsigned int vUsage, vSize;
if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1)
{
CCLOG("warning: Failed to read meshdata: usage or size '%s'.", _path.c_str());
return false;
}
meshdata->attribs[i].size = vSize;
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4;
meshdata->attribs[i].type = GL_FLOAT;
meshdata->attribs[i].vertexAttrib = vUsage;
}
// Read vertex data
if (_binaryReader.read(&meshdata->vertexSizeInFloat, 4, 1) != 1 || meshdata->vertexSizeInFloat == 0)
{
CCLOG("warning: Failed to read meshdata: vertexSizeInFloat '%s'.", _path.c_str());
return false;
}
meshdata->vertex.resize(meshdata->vertexSizeInFloat);
if (_binaryReader.read(&meshdata->vertex[0], 4, meshdata->vertexSizeInFloat) != meshdata->vertexSizeInFloat)
{
CCLOG("warning: Failed to read meshdata: vertex element '%s'.", _path.c_str());
return false;
}
// Read index data
unsigned int meshPartCount = 1;
//_binaryReader.read(&meshPartCount, 4, 1);
for (unsigned int i = 0; i < meshPartCount; ++i)
{
unsigned int nIndexCount;
if (_binaryReader.read(&nIndexCount, 4, 1) != 1)
{
CCLOG("warning: Failed to read meshdata: nIndexCount '%s'.", _path.c_str());
return false;
}
std::vector<unsigned short> indices;
indices.resize(nIndexCount);
if (_binaryReader.read(&indices[0], 2, nIndexCount) != nIndexCount)
{
CCLOG("warning: Failed to read meshdata: indices '%s'.", _path.c_str());
return false;
}
meshdata->subMeshIndices.push_back(indices);
}
return true;
}
bool Bundle3D::loadMeshDataBinary_0_2(MeshData* meshdata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESH))
return false;
meshdata->resetData();
// read mesh data
if (_binaryReader.read(&meshdata->attribCount, 4, 1) != 1 || meshdata->attribCount < 1)
{
CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str());
return false;
}
meshdata->attribs.resize(meshdata->attribCount);
for (ssize_t i = 0; i < meshdata->attribCount; i++)
{
unsigned int vUsage, vSize;
if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1)
{
CCLOG("warning: Failed to read meshdata: usage or size '%s'.", _path.c_str());
return false;
}
meshdata->attribs[i].size = vSize;
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4;
meshdata->attribs[i].type = GL_FLOAT;
meshdata->attribs[i].vertexAttrib = vUsage;
}
// Read vertex data
if (_binaryReader.read(&meshdata->vertexSizeInFloat, 4, 1) != 1 || meshdata->vertexSizeInFloat == 0)
{
CCLOG("warning: Failed to read meshdata: vertexSizeInFloat '%s'.", _path.c_str());
return false;
}
meshdata->vertex.resize(meshdata->vertexSizeInFloat);
if (_binaryReader.read(&meshdata->vertex[0], 4, meshdata->vertexSizeInFloat) != meshdata->vertexSizeInFloat)
{
CCLOG("warning: Failed to read meshdata: vertex element '%s'.", _path.c_str());
return false;
}
// read submesh
unsigned int submeshCount;
if (_binaryReader.read(&submeshCount, 4, 1) != 1)
{
CCLOG("warning: Failed to read meshdata: submeshCount '%s'.", _path.c_str());
return false;
}
for (unsigned int i = 0; i < submeshCount; ++i)
{
unsigned int nIndexCount;
if (_binaryReader.read(&nIndexCount, 4, 1) != 1)
{
CCLOG("warning: Failed to read meshdata: nIndexCount '%s'.", _path.c_str());
return false;
}
std::vector<unsigned short> indices;
indices.resize(nIndexCount);
if (_binaryReader.read(&indices[0], 2, nIndexCount) != nIndexCount)
{
CCLOG("warning: Failed to read meshdata: indices '%s'.", _path.c_str());
return false;
}
meshdata->subMeshIndices.push_back(indices);
}
return true;
}
bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
{
if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN))
return false;
std::string boneName = _binaryReader.readString();
// transform
float bindShape[16];
if (!_binaryReader.readMatrix(bindShape))
{
CCLOG("warning: Failed to read SkinData: bindShape matrix '%s'.", _path.c_str());
return false;
}
// bone count
unsigned int boneNum;
if (!_binaryReader.read(&boneNum))
{
CCLOG("warning: Failed to read SkinData: boneNum '%s'.", _path.c_str());
return false;
}
// bone names and bind pos
float bindpos[16];
for (unsigned int i = 0; i < boneNum; i++)
{
std::string skinBoneName = _binaryReader.readString();
skindata->skinBoneNames.push_back(skinBoneName);
if (!_binaryReader.readMatrix(bindpos))
{
CCLOG("warning: Failed to load SkinData: bindpos '%s'.", _path.c_str());
return false;
}
skindata->inverseBindPoseMatrices.push_back(bindpos);
}
skindata->skinBoneOriginMatrices.resize(boneNum);
boneName = _binaryReader.readString();
// bind shape
_binaryReader.readMatrix(bindShape);
int rootIndex = skindata->getSkinBoneNameIndex(boneName);
if(rootIndex < 0)
{
skindata->addNodeBoneNames(boneName);
rootIndex = skindata->getBoneNameIndex(boneName);
skindata->nodeBoneOriginMatrices.push_back(bindShape);
}
else
{
skindata->skinBoneOriginMatrices[rootIndex] = bindShape;
}
// set root bone index
skindata->rootBoneIndex = rootIndex;
// read parent and child relationship map
float transform[16];
unsigned int linkNum;
_binaryReader.read(&linkNum);
for (unsigned int i = 0; i < linkNum; ++i)
{
std::string id = _binaryReader.readString();
int index = skindata->getSkinBoneNameIndex(id);
std::string parentid = _binaryReader.readString();
if (!_binaryReader.readMatrix(transform))
{
CCLOG("warning: Failed to load SkinData: transform '%s'.", _path.c_str());
return false;
}
if(index < 0)
{
skindata->addNodeBoneNames(id);
index = skindata->getBoneNameIndex(id);
skindata->nodeBoneOriginMatrices.push_back(transform);
}
else
{
skindata->skinBoneOriginMatrices[index] = transform;
}
int parentIndex = skindata->getSkinBoneNameIndex(parentid);
if(parentIndex < 0)
{
skindata->addNodeBoneNames(parentid);
parentIndex = skindata->getBoneNameIndex(parentid);
}
skindata->boneChild[parentIndex].push_back(index);
}
return true;
}
bool Bundle3D::loadMaterialDataBinary(MaterialData* materialdata)
{
if (!seekToFirstType(BUNDLE_TYPE_MATERIAL))
return false;
unsigned int materialnum = 1;
if (_version == "0.2")
{
_binaryReader.read(&materialnum, 4, 1);
}
for (int i = 0; i < materialnum; i++)
{
std::string texturePath = _binaryReader.readString();
if (texturePath.empty())
{
CCLOG("warning: Failed to read Materialdata: texturePath is empty '%s'.", _path.c_str());
return false;
}
std::string path = _modelPath + texturePath;
materialdata->texturePaths[i] = path;
}
return true;
}
bool Bundle3D::loadAnimationDataBinary(const std::string& id, Animation3DData* animationdata)
{
if (!seekToFirstType(BUNDLE_TYPE_ANIMATIONS))

View File

@ -58,24 +58,12 @@ public:
*/
virtual bool load(const std::string& path);
/**
* load mesh data from bundle
* @param id The ID of the mesh, load the first Mesh in the bundle if it is empty
*/
virtual bool loadMeshData(const std::string& id, MeshData* meshdata);
/**
* load skin data from bundle
* @param id The ID of the skin, load the first Skin in the bundle if it is empty
*/
virtual bool loadSkinData(const std::string& id, SkinData* skindata);
/**
* load material data from bundle
* @param id The ID of the material, load the first Material in the bundle if it is empty
*/
virtual bool loadMaterialData(const std::string& id, MaterialData* materialdata);
/**
* load material data from bundle
* @param id The ID of the animation, load the first animation in the bundle if it is empty
@ -95,6 +83,7 @@ public:
protected:
bool loadJson(const std::string& path);
bool loadBinary(const std::string& path);
bool loadMeshDatasJson(MeshDatas& meshdatas);
bool loadMeshDataJson_0_1(MeshDatas& meshdatas);
bool loadMeshDataJson_0_2(MeshDatas& meshdatas);
@ -111,44 +100,13 @@ protected:
bool loadMeshDataJson_0_1(MeshData* meshdata){return true;}
bool loadMeshDataJson_0_2(MeshData* meshdata){return true;}
bool loadSkinDataJson(SkinData* skindata);
bool loadSkinDataBinary(SkinData* skindata);
bool loadMaterialDataJson(MaterialData* materialdata){return true;}
bool loadMaterialDataJson_0_1(MaterialData* materialdata){return true;}
bool loadMaterialDataJson_0_2(MaterialData* materialdata){return true;}
bool loadAnimationDataJson(const std::string& id,Animation3DData* animationdata);
/**
* load data in binary
* @param path The c3b file path
*/
bool loadBinary(const std::string& path);
/**
* load mesh data in binary
* @param meshdata The mesh data pointer
*/
bool loadMeshDataBinary(MeshData* meshdata);
bool loadMeshDataBinary_0_1(MeshData* meshdata);
bool loadMeshDataBinary_0_2(MeshData* meshdata);
/**
* load skin data in binary
* @param skindata The skin data pointer
*/
bool loadSkinDataBinary(SkinData* skindata);
/**
* load material data in binary
* @param materialdata The material pointer
*/
bool loadMaterialDataBinary(MaterialData* materialdata);
/**
* load animation data in binary
* @param animationdata The animation data pointer
*/
bool loadAnimationDataBinary(const std::string& id,Animation3DData* animationdata);
bool checkIsBone(const std::string& name);
/**
* load nodes of json
*/
@ -196,12 +154,9 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~Bundle3D();
protected:
static Bundle3D* _instance;
std::string _modelPath;
std::string _path;
std::string _path;
std::string _version;// the c3b or c3t version
// for json reading

View File

@ -414,7 +414,7 @@ bool OBB::intersects(const OBB& box) const
for (int j = 0; j < 3; j++)
{
Vec3 axis;
Vec3::cross(getFaceDirection(i), box.getFaceDirection(j), &axis);
Vec3::cross(getEdgeDirection(i), box.getEdgeDirection(j), &axis);
getInterval(*this, axis, min1, max1);
getInterval(box, axis, min2, max2);
if (max1 < min2 || max2 < min1) return false;

View File

@ -31,8 +31,8 @@
#include "3d/CCMesh.h"
#include "base/CCDirector.h"
#include "base/CCLight.h"
#include "base/CCCamera.h"
#include "2d/CCLight.h"
#include "2d/CCCamera.h"
#include "base/ccMacros.h"
#include "platform/CCPlatformMacros.h"
#include "platform/CCFileUtils.h"

View File

@ -24,6 +24,7 @@ cocos2d.cpp \
2d/CCAnimation.cpp \
2d/CCAnimationCache.cpp \
2d/CCAtlasNode.cpp \
2d/CCCamera.cpp \
2d/CCClippingNode.cpp \
2d/CCClippingRectangleNode.cpp \
2d/CCComponent.cpp \
@ -45,6 +46,7 @@ cocos2d.cpp \
2d/CCLabelTTF.cpp \
2d/CCLabelTextFormatter.cpp \
2d/CCLayer.cpp \
2d/CCLight.cpp \
2d/CCMenu.cpp \
2d/CCMenuItem.cpp \
2d/CCMotionStreak.cpp \
@ -91,7 +93,6 @@ math/Vec2.cpp \
math/Vec3.cpp \
math/Vec4.cpp \
base/CCAutoreleasePool.cpp \
base/CCCamera.cpp \
base/CCConfiguration.cpp \
base/CCConsole.cpp \
base/CCData.cpp \
@ -115,7 +116,6 @@ base/CCEventListenerTouch.cpp \
base/CCEventMouse.cpp \
base/CCEventTouch.cpp \
base/CCIMEDispatcher.cpp \
base/CCLight.cpp \
base/CCNS.cpp \
base/CCProfiling.cpp \
base/ccRandom.cpp \

View File

@ -217,7 +217,7 @@ bool AudioEngineImpl::init()
return ret;
}
int AudioEngineImpl::play2d(const std::string &fileFullPath ,bool loop ,float volume)
int AudioEngineImpl::play2d(const std::string &filePath ,bool loop ,float volume)
{
auto audioId = AudioEngine::INVAILD_AUDIO_ID;
@ -227,10 +227,10 @@ int AudioEngineImpl::play2d(const std::string &fileFullPath ,bool loop ,float vo
break;
auto& player = _audioPlayers[currentAudioID];
auto initPlayer = player.init( _engineEngine, _outputMixObject, fileFullPath, volume, loop);
auto initPlayer = player.init( _engineEngine, _outputMixObject, FileUtils::getInstance()->fullPathForFilename(filePath), volume, loop);
if (!initPlayer){
_audioPlayers.erase(currentAudioID);
log("%s,%d message:create player for %s fail", __func__, __LINE__, fileFullPath.c_str());
log("%s,%d message:create player for %s fail", __func__, __LINE__, filePath.c_str());
break;
}

View File

@ -47,7 +47,7 @@ THE SOFTWARE.
#include "renderer/CCTextureCache.h"
#include "renderer/ccGLStateCache.h"
#include "renderer/CCRenderer.h"
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "base/CCUserDefault.h"
#include "base/ccFPSImages.h"
#include "base/CCScheduler.h"

View File

@ -8,10 +8,8 @@ endif()
# todo: also base/CCController-android.cpp
set(COCOS_BASE_SRC
base/CCLight.cpp
base/ccFPSImages.c
base/CCAutoreleasePool.cpp
base/CCCamera.cpp
base/CCConfiguration.cpp
base/CCConsole.cpp
base/CCController.cpp

View File

@ -86,7 +86,7 @@ namespace utils
/**
* calculate all children's boundingBox
*/
Rect getCascadeBoundingBox(Node *node);
Rect CC_DLL getCascadeBoundingBox(Node *node);
}
NS_CC_END

View File

@ -61,8 +61,6 @@ THE SOFTWARE.
#include "base/CCIMEDelegate.h"
#include "base/CCIMEDispatcher.h"
#include "base/ccUtils.h"
#include "base/CCCamera.h"
#include "base/CCLight.h"
// EventDispatcher
#include "base/CCEventType.h"
@ -140,6 +138,9 @@ THE SOFTWARE.
#include "2d/CCGrabber.h"
#include "2d/CCGrid.h"
#include "2d/CCCamera.h"
#include "2d/CCLight.h"
// include
#include "base/CCProtocols.h"

View File

@ -47,7 +47,7 @@ static const char* FrameType_ScaleFrame = "ScaleFrame";
static const char* FrameType_RotationFrame = "RotationFrame";
static const char* FrameType_SkewFrame = "SkewFrame";
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
static const char* FrameType_AnchorFrame = "AnchorFrame";
static const char* FrameType_AnchorFrame = "AnchorPointFrame";
static const char* FrameType_InnerActionFrame = "InnerActionFrame";
static const char* FrameType_ColorFrame = "ColorFrame";
static const char* FrameType_TextureFrame = "TextureFrame";

View File

@ -36,6 +36,7 @@ NS_TIMELINE_BEGIN
Frame::Frame()
: _frameIndex(0)
, _tween(true)
, _enterWhenPassed(false)
, _timeline(nullptr)
, _node(nullptr)
{
@ -554,6 +555,7 @@ EventFrame* EventFrame::create()
EventFrame* frame = new (std::nothrow) EventFrame();
if (frame)
{
frame->init();
frame->autorelease();
return frame;
}
@ -561,6 +563,11 @@ EventFrame* EventFrame::create()
return nullptr;
}
void EventFrame::init()
{
_enterWhenPassed = true;
}
EventFrame::EventFrame()
: _event("")
{

View File

@ -54,6 +54,8 @@ public:
virtual void setTween(bool tween) { _tween = tween; }
virtual bool isTween() const { return _tween; }
virtual bool isEnterWhenPassed() { return _enterWhenPassed; }
virtual void onEnter(Frame *nextFrame) = 0;
virtual void apply(float percent) {}
@ -68,6 +70,7 @@ protected:
unsigned int _frameIndex;
bool _tween;
bool _enterWhenPassed;
Timeline* _timeline;
cocos2d::Node* _node;
@ -300,6 +303,7 @@ class CC_STUDIO_DLL EventFrame : public Frame
{
public:
static EventFrame* create();
void init();
EventFrame();

View File

@ -144,6 +144,13 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
if(_currentKeyFrameIndex >= _frames.at(0)->getFrameIndex())
needEnterFrame = true;
_fromIndex = 0;
if(length > 1)
_toIndex = 1;
else
_toIndex = 0;
from = to = _frames.at(0);
_currentKeyFrameIndex = 0;
_betweenDuration = _frames.at(0)->getFrameIndex();
@ -151,6 +158,9 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
}
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
{
_fromIndex = (int)(length - 1);
_toIndex = 0;
from = to = _frames.at(length - 1);
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
_betweenDuration = 0;
@ -171,9 +181,16 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
else
low=mid+1;
}
_fromIndex = (int)target;
from = _frames.at(target);
to = _frames.at(target+1);
if(length > 1)
_toIndex = (int)(target + 1);
else
_toIndex = (int)target;
from = _frames.at(_fromIndex);
to = _frames.at(_toIndex);
if(target == 0 && _currentKeyFrameIndex<from->getFrameIndex())
needEnterFrame = true;
@ -210,10 +227,10 @@ void Timeline::updateCurrentKeyFrame(int frameIndex)
}
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
{
from = to = _frames.at(length - 1);
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
_betweenDuration = 0;
break;
int lastFrameIndex = _frames.at(length - 1)->getFrameIndex();
if(_currentKeyFrameIndex >= lastFrameIndex)
return;
frameIndex = lastFrameIndex;
}
do
@ -230,19 +247,25 @@ void Timeline::updateCurrentKeyFrame(int frameIndex)
to = _frames.at(_toIndex);
if (frameIndex == from->getFrameIndex())
{
if(frameIndex == from->getFrameIndex())
break;
}
if(frameIndex > from->getFrameIndex() && frameIndex < to->getFrameIndex())
break;
if(from->isEnterWhenPassed())
from->onEnter(to);
}
while (frameIndex < from->getFrameIndex() || frameIndex >= to->getFrameIndex());
while (true);
if(_fromIndex == length-1)
to = from;
_betweenDuration = to->getFrameIndex() - from->getFrameIndex();
} while (0);
_currentKeyFrame = from;
_currentKeyFrame->onEnter(to);
}
}

View File

@ -141,7 +141,7 @@ void CSLoader::destroyInstance()
CSLoader::CSLoader()
: _recordJsonPath(true)
, _jsonPath("")
, _recordProtocolBuffersPath(true)
, _recordProtocolBuffersPath(false)
, _protocolBuffersPath("")
, _monoCocos2dxVersion("")
{

View File

@ -199,6 +199,10 @@ namespace cocostudio
std::string protocolBuffersPath = GUIReader::getInstance()->getFilePath();
bool barTextureScale9Enable = options.scale9enable();
if (barTextureScale9Enable)
{
slider->setUnifySizeEnabled(false);
}
slider->setScale9Enabled(barTextureScale9Enable);
slider->setPercent(options.percent());

View File

@ -79,27 +79,27 @@ NS_CC_BEGIN
int Device::getDPI()
{
static int dpi = -1;
if (dpi == -1)
{
Display *dpy;
char *displayname = NULL;
int scr = 0; /* Screen number */
dpy = XOpenDisplay (displayname);
/*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
double xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
((double) DisplayWidthMM(dpy,scr)));
dpi = (int) (xres + 0.5);
//printf("dpi = %d\n", dpi);
XCloseDisplay (dpy);
}
return dpi;
static int dpi = -1;
if (dpi == -1)
{
Display *dpy;
char *displayname = NULL;
int scr = 0; /* Screen number */
dpy = XOpenDisplay (displayname);
/*
* there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
*
* dpi = N pixels / (M millimeters / (25.4 millimeters / 1 inch))
* = N pixels / (M inch / 25.4)
* = N * 25.4 pixels / M inch
*/
double xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) /
((double) DisplayWidthMM(dpy,scr)));
dpi = (int) (xres + 0.5);
//printf("dpi = %d\n", dpi);
XCloseDisplay (dpy);
}
return dpi;
}
void Device::setAccelerometerEnabled(bool isEnabled)
@ -115,25 +115,25 @@ void Device::setAccelerometerInterval(float interval)
class BitmapDC
{
public:
BitmapDC() {
libError = FT_Init_FreeType( &library );
FcInit();
_data = NULL;
reset();
}
~BitmapDC() {
FT_Done_FreeType(library);
FcFini();
BitmapDC() {
libError = FT_Init_FreeType( &library );
FcInit();
_data = NULL;
reset();
}
}
void reset() {
iMaxLineWidth = 0;
iMaxLineHeight = 0;
textLines.clear();
}
~BitmapDC() {
FT_Done_FreeType(library);
FcFini();
reset();
}
void reset() {
iMaxLineWidth = 0;
iMaxLineHeight = 0;
textLines.clear();
}
int utf8(char **p)
{
@ -171,268 +171,268 @@ public:
}
bool isBreakPoint(FT_UInt currentCharacter, FT_UInt previousCharacter) {
if ( previousCharacter == '-' || previousCharacter == '/' || previousCharacter == '\\' ) {
// we can insert a line break after one of these characters
return true;
}
return false;
if ( previousCharacter == '-' || previousCharacter == '/' || previousCharacter == '\\' ) {
// we can insert a line break after one of these characters
return true;
}
return false;
}
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) {
const char* pText = sText;
textLines.clear();
iMaxLineWidth = 0;
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) {
const char* pText = sText;
textLines.clear();
iMaxLineWidth = 0;
FT_UInt unicode;
FT_UInt prevCharacter = 0;
FT_UInt glyphIndex = 0;
FT_UInt prevGlyphIndex = 0;
FT_Vector delta;
LineBreakLine currentLine;
FT_UInt unicode;
FT_UInt prevCharacter = 0;
FT_UInt glyphIndex = 0;
FT_UInt prevGlyphIndex = 0;
FT_Vector delta;
LineBreakLine currentLine;
int currentPaintPosition = 0;
int lastBreakIndex = -1;
bool hasKerning = FT_HAS_KERNING( face );
int currentPaintPosition = 0;
int lastBreakIndex = -1;
bool hasKerning = FT_HAS_KERNING( face );
while ((unicode=utf8((char**)&pText))) {
if (unicode == '\n') {
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
prevGlyphIndex = 0;
prevCharacter = 0;
lastBreakIndex = -1;
currentPaintPosition = 0;
continue;
}
if ( isBreakPoint(unicode, prevCharacter) ) {
lastBreakIndex = currentLine.glyphs.size() - 1;
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
prevGlyphIndex = 0;
prevCharacter = 0;
lastBreakIndex = -1;
currentPaintPosition = 0;
continue;
}
glyphIndex = FT_Get_Char_Index(face, unicode);
if (FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT)) {
return false;
}
if ( isBreakPoint(unicode, prevCharacter) ) {
lastBreakIndex = currentLine.glyphs.size() - 1;
}
if (iswspace(unicode)) {
currentPaintPosition += face->glyph->metrics.horiAdvance >> 6;
prevGlyphIndex = glyphIndex;
prevCharacter = unicode;
lastBreakIndex = currentLine.glyphs.size();
continue;
}
glyphIndex = FT_Get_Char_Index(face, unicode);
if (FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT)) {
return false;
}
LineBreakGlyph glyph;
glyph.glyphIndex = glyphIndex;
glyph.glyphWidth = face->glyph->metrics.width >> 6;
glyph.bearingX = face->glyph->metrics.horiBearingX >> 6;
glyph.horizAdvance = face->glyph->metrics.horiAdvance >> 6;
glyph.kerning = 0;
if (iswspace(unicode)) {
currentPaintPosition += face->glyph->metrics.horiAdvance >> 6;
prevGlyphIndex = glyphIndex;
prevCharacter = unicode;
lastBreakIndex = currentLine.glyphs.size();
continue;
}
if (prevGlyphIndex != 0 && hasKerning) {
FT_Get_Kerning(face, prevGlyphIndex, glyphIndex, FT_KERNING_DEFAULT, &delta);
glyph.kerning = delta.x >> 6;
}
LineBreakGlyph glyph;
glyph.glyphIndex = glyphIndex;
glyph.glyphWidth = face->glyph->metrics.width >> 6;
glyph.bearingX = face->glyph->metrics.horiBearingX >> 6;
glyph.horizAdvance = face->glyph->metrics.horiAdvance >> 6;
glyph.kerning = 0;
if (iMaxWidth > 0 && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth > iMaxWidth) {
if (prevGlyphIndex != 0 && hasKerning) {
FT_Get_Kerning(face, prevGlyphIndex, glyphIndex, FT_KERNING_DEFAULT, &delta);
glyph.kerning = delta.x >> 6;
}
int glyphCount = currentLine.glyphs.size();
if ( lastBreakIndex >= 0 && lastBreakIndex < glyphCount && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth - currentLine.glyphs.at(lastBreakIndex).paintPosition < iMaxWidth ) {
// we insert a line break at our last break opportunity
std::vector<LineBreakGlyph> tempGlyphs;
std::vector<LineBreakGlyph>::iterator it = currentLine.glyphs.begin();
std::advance(it, lastBreakIndex);
tempGlyphs.insert(tempGlyphs.begin(), it, currentLine.glyphs.end());
currentLine.glyphs.erase(it, currentLine.glyphs.end());
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
currentPaintPosition = 0;
for ( it = tempGlyphs.begin(); it != tempGlyphs.end(); it++ ) {
if ( currentLine.glyphs.empty() ) {
currentPaintPosition = -(*it).bearingX;
(*it).kerning = 0;
}
(*it).paintPosition = currentPaintPosition + (*it).bearingX + (*it).kerning;
currentLine.glyphs.push_back((*it));
currentPaintPosition += (*it).kerning + (*it).horizAdvance;
}
} else {
// the current word is too big to fit into one line, insert line break right here
currentPaintPosition = 0;
glyph.kerning = 0;
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
}
if (iMaxWidth > 0 && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth > iMaxWidth) {
prevGlyphIndex = 0;
prevCharacter = 0;
lastBreakIndex = -1;
} else {
prevGlyphIndex = glyphIndex;
prevCharacter = unicode;
}
int glyphCount = currentLine.glyphs.size();
if ( lastBreakIndex >= 0 && lastBreakIndex < glyphCount && currentPaintPosition + glyph.bearingX + glyph.kerning + glyph.glyphWidth - currentLine.glyphs.at(lastBreakIndex).paintPosition < iMaxWidth ) {
// we insert a line break at our last break opportunity
std::vector<LineBreakGlyph> tempGlyphs;
std::vector<LineBreakGlyph>::iterator it = currentLine.glyphs.begin();
std::advance(it, lastBreakIndex);
tempGlyphs.insert(tempGlyphs.begin(), it, currentLine.glyphs.end());
currentLine.glyphs.erase(it, currentLine.glyphs.end());
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
currentPaintPosition = 0;
for ( it = tempGlyphs.begin(); it != tempGlyphs.end(); it++ ) {
if ( currentLine.glyphs.empty() ) {
currentPaintPosition = -(*it).bearingX;
(*it).kerning = 0;
}
(*it).paintPosition = currentPaintPosition + (*it).bearingX + (*it).kerning;
currentLine.glyphs.push_back((*it));
currentPaintPosition += (*it).kerning + (*it).horizAdvance;
}
} else {
// the current word is too big to fit into one line, insert line break right here
currentPaintPosition = 0;
glyph.kerning = 0;
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
currentLine.reset();
}
if ( currentLine.glyphs.empty() ) {
currentPaintPosition = -glyph.bearingX;
}
glyph.paintPosition = currentPaintPosition + glyph.bearingX + glyph.kerning;
currentLine.glyphs.push_back(glyph);
currentPaintPosition += glyph.kerning + glyph.horizAdvance;
}
prevGlyphIndex = 0;
prevCharacter = 0;
lastBreakIndex = -1;
} else {
prevGlyphIndex = glyphIndex;
prevCharacter = unicode;
}
if ( currentLine.glyphs.empty() == false ) {
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
}
return true;
}
if ( currentLine.glyphs.empty() ) {
currentPaintPosition = -glyph.bearingX;
}
glyph.paintPosition = currentPaintPosition + glyph.bearingX + glyph.kerning;
currentLine.glyphs.push_back(glyph);
currentPaintPosition += glyph.kerning + glyph.horizAdvance;
}
/**
* compute the start pos of every line
*/
int computeLineStart(FT_Face face, Device::TextAlign eAlignMask, int line) {
int lineWidth = textLines.at(line).lineWidth;
if (eAlignMask == Device::TextAlign::CENTER || eAlignMask == Device::TextAlign::TOP || eAlignMask == Device::TextAlign::BOTTOM) {
return (iMaxLineWidth - lineWidth) / 2;
} else if (eAlignMask == Device::TextAlign::RIGHT || eAlignMask == Device::TextAlign::TOP_RIGHT || eAlignMask == Device::TextAlign::BOTTOM_RIGHT) {
return (iMaxLineWidth - lineWidth);
}
// left or other situation
return 0;
}
int computeLineStartY( FT_Face face, Device::TextAlign eAlignMask, int txtHeight, int borderHeight ){
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
if (eAlignMask == Device::TextAlign::CENTER || eAlignMask == Device::TextAlign::LEFT || eAlignMask == Device::TextAlign::RIGHT) {
//vertical center
return (borderHeight - txtHeight) / 2 + baseLinePos;
} else if (eAlignMask == Device::TextAlign::BOTTOM_RIGHT || eAlignMask == Device::TextAlign::BOTTOM || eAlignMask == Device::TextAlign::BOTTOM_LEFT) {
//vertical bottom
return borderHeight - txtHeight + baseLinePos;
}
// top alignment
return baseLinePos;
}
std::string getFontFile(const char* family_name) {
std::string fontPath = family_name;
std::map<std::string, std::string>::iterator it = fontCache.find(family_name);
if ( it != fontCache.end() ) {
return it->second;
}
// check if the parameter is a font file shipped with the application
std::string lowerCasePath = fontPath;
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
FILE *f = fopen(fontPath.c_str(), "r");
if ( f ) {
fclose(f);
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
return fontPath;
}
}
// use fontconfig to match the parameter against the fonts installed on the system
FcPattern *pattern = FcPatternBuild (0, FC_FAMILY, FcTypeString, family_name, (char *) 0);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcResult result;
FcPattern *font = FcFontMatch(0, pattern, &result);
if ( font ) {
FcChar8 *s = NULL;
if ( FcPatternGetString(font, FC_FILE, 0, &s) == FcResultMatch ) {
fontPath = (const char*)s;
FcPatternDestroy(font);
FcPatternDestroy(pattern);
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
return fontPath;
}
FcPatternDestroy(font);
}
FcPatternDestroy(pattern);
return family_name;
if ( currentLine.glyphs.empty() == false ) {
currentLine.calculateWidth();
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
textLines.push_back(currentLine);
}
return true;
}
bool getBitmap(const char *text, int nWidth, int nHeight, Device::TextAlign eAlignMask, const char * pFontName, float fontSize) {
if (libError) {
return false;
}
/**
* compute the start pos of every line
*/
int computeLineStart(FT_Face face, Device::TextAlign eAlignMask, int line) {
int lineWidth = textLines.at(line).lineWidth;
if (eAlignMask == Device::TextAlign::CENTER || eAlignMask == Device::TextAlign::TOP || eAlignMask == Device::TextAlign::BOTTOM) {
return (iMaxLineWidth - lineWidth) / 2;
} else if (eAlignMask == Device::TextAlign::RIGHT || eAlignMask == Device::TextAlign::TOP_RIGHT || eAlignMask == Device::TextAlign::BOTTOM_RIGHT) {
return (iMaxLineWidth - lineWidth);
}
FT_Face face;
std::string fontfile = getFontFile(pFontName);
if ( FT_New_Face(library, fontfile.c_str(), 0, &face) ) {
//no valid font found use default
if ( FT_New_Face(library, "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 0, &face) ) {
return false;
}
}
// left or other situation
return 0;
}
//select utf8 charmap
if ( FT_Select_Charmap(face, FT_ENCODING_UNICODE) ) {
FT_Done_Face(face);
return false;
}
int computeLineStartY( FT_Face face, Device::TextAlign eAlignMask, int txtHeight, int borderHeight ){
int baseLinePos = ceilf(FT_MulFix( face->bbox.yMax, face->size->metrics.y_scale )/64.0f);
if (eAlignMask == Device::TextAlign::CENTER || eAlignMask == Device::TextAlign::LEFT || eAlignMask == Device::TextAlign::RIGHT) {
//vertical center
return (borderHeight - txtHeight) / 2 + baseLinePos;
} else if (eAlignMask == Device::TextAlign::BOTTOM_RIGHT || eAlignMask == Device::TextAlign::BOTTOM || eAlignMask == Device::TextAlign::BOTTOM_LEFT) {
//vertical bottom
return borderHeight - txtHeight + baseLinePos;
}
if ( FT_Set_Pixel_Sizes(face, fontSize, fontSize) ) {
FT_Done_Face(face);
return false;
}
// top alignment
return baseLinePos;
}
if ( divideString(face, text, nWidth, nHeight) == false ) {
FT_Done_Face(face);
return false;
}
std::string getFontFile(const char* family_name) {
std::string fontPath = family_name;
//compute the final line width
iMaxLineWidth = MAX(iMaxLineWidth, nWidth);
std::map<std::string, std::string>::iterator it = fontCache.find(family_name);
if ( it != fontCache.end() ) {
return it->second;
}
//compute the final line height
iMaxLineHeight = ceilf(FT_MulFix( face->bbox.yMax - face->bbox.yMin, face->size->metrics.y_scale )/64.0f);
int lineHeight = face->size->metrics.height>>6;
if ( textLines.size() > 0 ) {
iMaxLineHeight += (lineHeight * (textLines.size() -1));
}
int txtHeight = iMaxLineHeight;
iMaxLineHeight = MAX(iMaxLineHeight, nHeight);
// check if the parameter is a font file shipped with the application
std::string lowerCasePath = fontPath;
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
fontPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fontPath.c_str());
_data = (unsigned char*)malloc(sizeof(unsigned char) * (iMaxLineWidth * iMaxLineHeight * 4));
memset(_data,0, iMaxLineWidth * iMaxLineHeight*4);
FILE *f = fopen(fontPath.c_str(), "r");
if ( f ) {
fclose(f);
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
return fontPath;
}
}
int iCurYCursor = computeLineStartY(face, eAlignMask, txtHeight, iMaxLineHeight);
// use fontconfig to match the parameter against the fonts installed on the system
FcPattern *pattern = FcPatternBuild (0, FC_FAMILY, FcTypeString, family_name, (char *) 0);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
int lineCount = textLines.size();
for (int line = 0; line < lineCount; line++) {
int iCurXCursor = computeLineStart(face, eAlignMask, line);
FcResult result;
FcPattern *font = FcFontMatch(0, pattern, &result);
if ( font ) {
FcChar8 *s = NULL;
if ( FcPatternGetString(font, FC_FILE, 0, &s) == FcResultMatch ) {
fontPath = (const char*)s;
int glyphCount = textLines.at(line).glyphs.size();
for (int i = 0; i < glyphCount; i++) {
LineBreakGlyph glyph = textLines.at(line).glyphs.at(i);
FcPatternDestroy(font);
FcPatternDestroy(pattern);
if (FT_Load_Glyph(face, glyph.glyphIndex, FT_LOAD_RENDER)) {
continue;
}
fontCache.insert(std::pair<std::string, std::string>(family_name, fontPath));
return fontPath;
}
FcPatternDestroy(font);
}
FcPatternDestroy(pattern);
FT_Bitmap& bitmap = face->glyph->bitmap;
int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6);
int xoffset = iCurXCursor + glyph.paintPosition;
return family_name;
}
for (int y = 0; y < bitmap.rows; ++y) {
bool getBitmap(const char *text, const FontDefinition& textDefinition, Device::TextAlign eAlignMask) {
if (libError) {
return false;
}
FT_Face face;
std::string fontfile = getFontFile(textDefinition._fontName.c_str());
if ( FT_New_Face(library, fontfile.c_str(), 0, &face) ) {
//no valid font found use default
if ( FT_New_Face(library, "/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 0, &face) ) {
return false;
}
}
//select utf8 charmap
if ( FT_Select_Charmap(face, FT_ENCODING_UNICODE) ) {
FT_Done_Face(face);
return false;
}
if ( FT_Set_Pixel_Sizes(face, textDefinition._fontSize, textDefinition._fontSize) ) {
FT_Done_Face(face);
return false;
}
if ( divideString(face, text, textDefinition._dimensions.width, textDefinition._dimensions.height) == false ) {
FT_Done_Face(face);
return false;
}
//compute the final line width
iMaxLineWidth = MAX(iMaxLineWidth, textDefinition._dimensions.width);
//compute the final line height
iMaxLineHeight = ceilf(FT_MulFix( face->bbox.yMax - face->bbox.yMin, face->size->metrics.y_scale )/64.0f);
int lineHeight = face->size->metrics.height>>6;
if ( textLines.size() > 0 ) {
iMaxLineHeight += (lineHeight * (textLines.size() -1));
}
int txtHeight = iMaxLineHeight;
iMaxLineHeight = MAX(iMaxLineHeight, textDefinition._dimensions.height);
_data = (unsigned char*)malloc(sizeof(unsigned char) * (iMaxLineWidth * iMaxLineHeight * 4));
memset(_data,0, iMaxLineWidth * iMaxLineHeight*4);
int iCurYCursor = computeLineStartY(face, eAlignMask, txtHeight, iMaxLineHeight);
int lineCount = textLines.size();
for (int line = 0; line < lineCount; line++) {
int iCurXCursor = computeLineStart(face, eAlignMask, line);
int glyphCount = textLines.at(line).glyphs.size();
for (int i = 0; i < glyphCount; i++) {
LineBreakGlyph glyph = textLines.at(line).glyphs.at(i);
if (FT_Load_Glyph(face, glyph.glyphIndex, FT_LOAD_RENDER)) {
continue;
}
FT_Bitmap& bitmap = face->glyph->bitmap;
int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6);
int xoffset = iCurXCursor + glyph.paintPosition;
for (int y = 0; y < bitmap.rows; ++y) {
int iY = yoffset + y;
if (iY>=iMaxLineHeight) {
//exceed the height truncate
@ -442,42 +442,42 @@ public:
int bitmap_y = y * bitmap.width;
for (int x = 0; x < bitmap.width; ++x) {
unsigned char cTemp = bitmap.buffer[bitmap_y + x];
if (cTemp == 0) {
continue;
}
for (int x = 0; x < bitmap.width; ++x) {
unsigned char cTemp = bitmap.buffer[bitmap_y + x];
if (cTemp == 0) {
continue;
}
int iX = xoffset + x;
int iX = xoffset + x;
//FIXME:wrong text color
int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp;
*(int*) &_data[(iY + iX) * 4 + 0] = iTemp;
}
}
}
// step to next line
iCurYCursor += lineHeight;
}
int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp;
*(int*) &_data[(iY + iX) * 4 + 0] = iTemp;
}
}
}
// step to next line
iCurYCursor += lineHeight;
}
// free face
FT_Done_Face(face);
return true;
}
// free face
FT_Done_Face(face);
return true;
}
public:
FT_Library library;
FT_Library library;
unsigned char *_data;
int libError;
std::vector<LineBreakLine> textLines;
int iMaxLineWidth;
int iMaxLineHeight;
unsigned char *_data;
int libError;
std::vector<LineBreakLine> textLines;
int iMaxLineWidth;
int iMaxLineHeight;
};
static BitmapDC& sharedBitmapDC()
{
static BitmapDC s_BmpDC;
return s_BmpDC;
static BitmapDC s_BmpDC;
return s_BmpDC;
}
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
@ -487,7 +487,7 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
{
BitmapDC &dc = sharedBitmapDC();
CC_BREAK_IF(! dc.getBitmap(text, textDefinition._dimensions.width, textDefinition._dimensions.height, align, textDefinition._fontName.c_str(), textDefinition._fontSize));
CC_BREAK_IF(! dc.getBitmap(text, textDefinition, align));
CC_BREAK_IF(! dc._data);
width = dc.iMaxLineWidth;
height = dc.iMaxLineHeight;

View File

@ -131,7 +131,7 @@ static bool _initWithString(const char * text, Device::TextAlign align, const ch
if ([@"!?.,-= " rangeOfString:character].location != NSNotFound) {
lastBreakLocation = i + insertCount;
}
//textSize = [lineBreak sizeWithAttributes:tokenAttributesDict];
textSize = [lineBreak sizeWithAttributes:tokenAttributesDict];
if(textSize.height > info->height)
break;
if (textSize.width > info->width) {

View File

@ -431,7 +431,7 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
GetDIBits(dc.getDC(), dc.getBitmap(), 0, height, dataBuf,
(LPBITMAPINFO)&bi, DIB_RGB_COLORS);
// change pixel's alpha value to 255, when it's RGB != 0
COLORREF textColor = (textDefinition._fontFillColor.b << 16 | textDefinition._fontFillColor.g << 8 | textDefinition._fontFillColor.r) & 0x00ffffff;
COLORREF * pPixel = nullptr;
for (int y = 0; y < height; ++y)
{
@ -439,7 +439,7 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
for (int x = 0; x < width; ++x)
{
COLORREF& clr = *pPixel;
clr = (0xffffff | (GetRValue(clr) << 24));
clr = (GetRValue(clr) << 24) | textColor;
++pPixel;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
#include "base/CCEventDispatcher.h"
#include "base/CCEventType.h"
#include "base/CCConfiguration.h"
#include "base/CCLight.h"
#include "2d/CCLight.h"
#include "renderer/ccGLStateCache.h"
#include "renderer/CCGLProgramState.h"
#include "renderer/CCRenderer.h"

View File

@ -40,7 +40,7 @@
#include "base/CCEventDispatcher.h"
#include "base/CCEventListenerCustom.h"
#include "base/CCEventType.h"
#include "base/CCCamera.h"
#include "2d/CCCamera.h"
#include "2d/CCScene.h"
NS_CC_BEGIN

View File

@ -406,6 +406,7 @@ Texture2D* TextureCache::addImage(Image *image, const std::string &key)
bool TextureCache::reloadTexture(const std::string& fileName)
{
Texture2D * texture = nullptr;
Image * image = nullptr;
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(fileName);
if (fullpath.size() == 0)
@ -426,7 +427,7 @@ bool TextureCache::reloadTexture(const std::string& fileName)
else
{
do {
Image* image = new (std::nothrow) Image();
image = new (std::nothrow) Image();
CC_BREAK_IF(nullptr == image);
bool bRet = image->initWithImageFile(fullpath);
@ -435,6 +436,8 @@ bool TextureCache::reloadTexture(const std::string& fileName)
ret = texture->initWithImage(image);
} while (0);
}
CC_SAFE_RELEASE(image);
return ret;
}

View File

@ -10,6 +10,11 @@
-- @param self
-- @param #string event
--------------------------------
--
-- @function [parent=#EventFrame] init
-- @param self
--------------------------------
--
-- @function [parent=#EventFrame] getEvent

View File

@ -22,6 +22,12 @@
-- @param self
-- @param #ccs.Timeline timeline
--------------------------------
--
-- @function [parent=#Frame] isEnterWhenPassed
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#Frame] getFrameIndex

View File

@ -76,36 +76,6 @@
-- @field [parent=#cc] UserDefault#UserDefault UserDefault preloaded module
--------------------------------------------------------
-- the cc Camera
-- @field [parent=#cc] Camera#Camera Camera preloaded module
--------------------------------------------------------
-- the cc BaseLight
-- @field [parent=#cc] BaseLight#BaseLight BaseLight preloaded module
--------------------------------------------------------
-- the cc DirectionLight
-- @field [parent=#cc] DirectionLight#DirectionLight DirectionLight preloaded module
--------------------------------------------------------
-- the cc PointLight
-- @field [parent=#cc] PointLight#PointLight PointLight preloaded module
--------------------------------------------------------
-- the cc SpotLight
-- @field [parent=#cc] SpotLight#SpotLight SpotLight preloaded module
--------------------------------------------------------
-- the cc AmbientLight
-- @field [parent=#cc] AmbientLight#AmbientLight AmbientLight preloaded module
--------------------------------------------------------
-- the cc EventListener
-- @field [parent=#cc] EventListener#EventListener EventListener preloaded module
@ -1161,6 +1131,36 @@
-- @field [parent=#cc] TiledGrid3D#TiledGrid3D TiledGrid3D preloaded module
--------------------------------------------------------
-- the cc Camera
-- @field [parent=#cc] Camera#Camera Camera preloaded module
--------------------------------------------------------
-- the cc BaseLight
-- @field [parent=#cc] BaseLight#BaseLight BaseLight preloaded module
--------------------------------------------------------
-- the cc DirectionLight
-- @field [parent=#cc] DirectionLight#DirectionLight DirectionLight preloaded module
--------------------------------------------------------
-- the cc PointLight
-- @field [parent=#cc] PointLight#PointLight PointLight preloaded module
--------------------------------------------------------
-- the cc SpotLight
-- @field [parent=#cc] SpotLight#SpotLight SpotLight preloaded module
--------------------------------------------------------
-- the cc AmbientLight
-- @field [parent=#cc] AmbientLight#AmbientLight AmbientLight preloaded module
--------------------------------------------------------
-- the cc GLProgram
-- @field [parent=#cc] GLProgram#GLProgram GLProgram preloaded module

File diff suppressed because it is too large Load Diff

View File

@ -14954,6 +14954,50 @@ int lua_cocos2dx_studio_Frame_setTimeline(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Frame_isEnterWhenPassed(lua_State* tolua_S)
{
int argc = 0;
cocostudio::timeline::Frame* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.Frame",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::timeline::Frame*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Frame_isEnterWhenPassed'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
bool ret = cobj->isEnterWhenPassed();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccs.Frame:isEnterWhenPassed",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Frame_isEnterWhenPassed'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_Frame_getFrameIndex(lua_State* tolua_S)
{
int argc = 0;
@ -15283,6 +15327,7 @@ int lua_register_cocos2dx_studio_Frame(lua_State* tolua_S)
tolua_function(tolua_S,"clone",lua_cocos2dx_studio_Frame_clone);
tolua_function(tolua_S,"setNode",lua_cocos2dx_studio_Frame_setNode);
tolua_function(tolua_S,"setTimeline",lua_cocos2dx_studio_Frame_setTimeline);
tolua_function(tolua_S,"isEnterWhenPassed",lua_cocos2dx_studio_Frame_isEnterWhenPassed);
tolua_function(tolua_S,"getFrameIndex",lua_cocos2dx_studio_Frame_getFrameIndex);
tolua_function(tolua_S,"apply",lua_cocos2dx_studio_Frame_apply);
tolua_function(tolua_S,"isTween",lua_cocos2dx_studio_Frame_isTween);
@ -17677,6 +17722,49 @@ int lua_cocos2dx_studio_EventFrame_setEvent(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_EventFrame_init(lua_State* tolua_S)
{
int argc = 0;
cocostudio::timeline::EventFrame* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.EventFrame",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::timeline::EventFrame*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_EventFrame_init'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
cobj->init();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccs.EventFrame:init",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_EventFrame_init'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_EventFrame_getEvent(lua_State* tolua_S)
{
int argc = 0;
@ -17800,6 +17888,7 @@ int lua_register_cocos2dx_studio_EventFrame(lua_State* tolua_S)
tolua_beginmodule(tolua_S,"EventFrame");
tolua_function(tolua_S,"new",lua_cocos2dx_studio_EventFrame_constructor);
tolua_function(tolua_S,"setEvent",lua_cocos2dx_studio_EventFrame_setEvent);
tolua_function(tolua_S,"init",lua_cocos2dx_studio_EventFrame_init);
tolua_function(tolua_S,"getEvent",lua_cocos2dx_studio_EventFrame_getEvent);
tolua_function(tolua_S,"create", lua_cocos2dx_studio_EventFrame_create);
tolua_endmodule(tolua_S);

View File

@ -482,6 +482,8 @@ int register_all_cocos2dx_studio(lua_State* tolua_S);

View File

@ -33,12 +33,25 @@
using namespace cocos2d;
using namespace std;
LuaMinXmlHttpRequest::LuaMinXmlHttpRequest():_isNetwork(true)
LuaMinXmlHttpRequest::LuaMinXmlHttpRequest()
:_isNetwork(true),
_url(""),
_meth(""),
_type(""),
_dataSize(0),
_readyState(UNSENT),
_status(0),
_statusText(""),
_responseType(ResponseType::STRING),
_timeout(0),
_isAsync(false),
_withCredentialsValue(true),
_errorFlag(false),
_isAborted(false)
{
_httpHeader.clear();
_requestHeader.clear();
_withCredentialsValue = true;
_httpRequest = new network::HttpRequest();
_httpRequest = new (std::nothrow)cocos2d::network::HttpRequest();
}
LuaMinXmlHttpRequest::~LuaMinXmlHttpRequest()
@ -182,6 +195,9 @@ void LuaMinXmlHttpRequest::_setHttpRequestHeader()
void LuaMinXmlHttpRequest::_sendRequest()
{
_httpRequest->setResponseCallback([this](cocos2d::network::HttpClient* sender, cocos2d::network::HttpResponse* response){
if (_isAborted)
return ;
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLOG("%s completed", response->getHttpRequest()->getTag());
@ -193,8 +209,23 @@ void LuaMinXmlHttpRequest::_sendRequest()
if (!response->isSucceed())
{
CCLOG("response failed");
CCLOG("error buffer: %s", response->getErrorBuffer());
CCLOG("Response failed, error buffer: %s", response->getErrorBuffer());
if(statusCode == 0)
{
_errorFlag = true;
_status = 0;
_statusText.clear();
}
// TODO: call back lua function
int handler = cocos2d::ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, cocos2d::ScriptHandlerMgr::HandlerType::XMLHTTPREQUEST_READY_STATE_CHANGE );
if (0 != handler)
{
CCLOG("come in handler, handler is %d", handler);
cocos2d::CommonScriptData data(handler,"");
cocos2d::ScriptEvent event(cocos2d::ScriptEventType::kCommonEvent,(void*)&data);
cocos2d::ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
return;
}
@ -244,7 +275,7 @@ void LuaMinXmlHttpRequest::_sendRequest()
}
release();
});
network::HttpClient::getInstance()->send(_httpRequest);
network::HttpClient::getInstance()->sendImmediate(_httpRequest);
_httpRequest->release();
retain();
}
@ -641,11 +672,17 @@ static int lua_get_XMLHttpRequest_response(lua_State* L)
if (self->getResponseType() == LuaMinXmlHttpRequest::ResponseType::JSON)
{
if (self->getReadyState() != LuaMinXmlHttpRequest::DONE || self->getErrorFlag())
return 0;
lua_pushstring(L, self->getDataStr().c_str());
return 1;
}
else if(self->getResponseType() == LuaMinXmlHttpRequest::ResponseType::ARRAY_BUFFER)
{
if (self->getReadyState() != LuaMinXmlHttpRequest::DONE || self->getErrorFlag())
return 0;
LuaStack *pStack = LuaEngine::getInstance()->getLuaStack();
if (NULL == pStack) {
return 0;
@ -747,10 +784,22 @@ static int lua_cocos2dx_XMLHttpRequest_open(lua_State* L)
{
self->getHttpRequest()->setRequestType(network::HttpRequest::Type::POST);
}
else
else if(method.compare("get") == 0 || method.compare("GET") == 0)
{
self->getHttpRequest()->setRequestType(network::HttpRequest::Type::GET);
}
else if(method.compare("put") == 0 || method.compare("PUT") == 0)
{
self->getHttpRequest()->setRequestType(network::HttpRequest::Type::PUT);
}
else if(method.compare("delete") == 0 || method.compare("DELETE") == 0)
{
self->getHttpRequest()->setRequestType(network::HttpRequest::Type::DELETE);
}
else
{
self->getHttpRequest()->setRequestType(network::HttpRequest::Type::UNKNOWN);
}
self->getHttpRequest()->setUrl(url.c_str());
@ -758,6 +807,8 @@ static int lua_cocos2dx_XMLHttpRequest_open(lua_State* L)
self->setIsNetWork(true);
self->setReadyState(LuaMinXmlHttpRequest::OPENED);
self->setStatus(0);
self->setAborted(false);
return 0;
}
@ -793,6 +844,8 @@ static int lua_cocos2dx_XMLHttpRequest_send(lua_State* L)
return 0;
}
#endif
self->getHttpHeader().clear();
self->setErrorFlag(false);
argc = lua_gettop(L) - 1;
@ -807,7 +860,8 @@ static int lua_cocos2dx_XMLHttpRequest_send(lua_State* L)
}
if (size > 0 &&
(self->getMethod().compare("post") == 0 || self->getMethod().compare("POST") == 0) &&
(self->getMethod().compare("post") == 0 || self->getMethod().compare("POST") == 0
|| self->getMethod().compare("put") == 0 || self->getMethod().compare("PUT") == 0 )&&
nullptr != self->getHttpRequest())
{
self->getHttpRequest()->setRequestData(data,size);
@ -829,7 +883,37 @@ tolua_lerror:
*/
static int lua_cocos2dx_XMLHttpRequest_abort(lua_State* L)
{
int argc = 0;
LuaMinXmlHttpRequest* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror;
#endif
self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (nullptr == self)
{
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_XMLHttpRequest_send'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if ( 0 == argc )
{
self->setAborted(true);
self->setReadyState(LuaMinXmlHttpRequest::UNSENT);
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_XMLHttpRequest_send'.",&tolua_err);
return 0;
#endif
}
static int lua_cocos2dx_XMLHttpRequest_setRequestHeader(lua_State* L)

View File

@ -72,8 +72,10 @@ public:
inline int getReadyState() { return _readyState ;}
inline cocos2d::network::HttpRequest* getHttpRequest() { return _httpRequest; }
inline int getStatus() { return _status; }
inline std::string getStatusText() { return _statusText ;}
inline void setStatus(int status) { _status = status; }
inline int getStatus() { return _status; }
inline std::string getUrl(){return _url;}
inline void setUrl(std::string url) { _url = url ;}
@ -96,6 +98,12 @@ public:
inline size_t getDataSize() { return _dataSize; }
inline void setErrorFlag(bool errorFlag) { _errorFlag = errorFlag; }
inline bool getErrorFlag() { return _errorFlag; }
inline void setAborted(bool isAborted) { _isAborted = isAborted; }
inline bool getAborted() { return _isAborted; }
private:
void _gotHeader(std::string header);
@ -116,6 +124,8 @@ private:
bool _withCredentialsValue;
std::map<std::string, std::string> _httpHeader;
std::map<std::string, std::string> _requestHeader;
bool _errorFlag;
bool _isAborted;
};
TOLUA_API int register_xml_http_request(lua_State* L);

View File

@ -88,7 +88,8 @@ static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L)
self->addTouchEventListener([=](cocos2d::Ref* ref,Widget::TouchEventType eventType){
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -149,6 +150,7 @@ static int lua_cocos2dx_CheckBox_addEventListener(lua_State* L)
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -210,6 +212,7 @@ static int lua_cocos2dx_Slider_addEventListener(lua_State* L)
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -271,6 +274,7 @@ static int lua_cocos2dx_TextField_addEventListener(lua_State* L)
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -332,6 +336,7 @@ static int lua_cocos2dx_PageView_addEventListener(lua_State* L)
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -393,6 +398,7 @@ static int lua_cocos2dx_ScrollView_addEventListener(lua_State* L)
handleUIEvent(handler, ref, (int)eventType);
});
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -455,6 +461,7 @@ static int lua_cocos2dx_ListView_addEventListener(lua_State* L)
};
self->addEventListener((ui::ListView::ccListViewCallback)listViewCallback);
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}
@ -506,6 +513,7 @@ static int lua_cocos2dx_ListView_addScrollViewEventListener(lua_State* L)
};
self->addEventListener((ui::ScrollView::ccScrollViewCallback)scrollViewCallback);
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
return 0;
}

View File

@ -8,11 +8,11 @@ local dp_pointSize = 1.0
local SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor"
local targetPlatform = CCApplication:getInstance():getTargetPlatform()
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
local function lazy_init()
if not dp_initialized then
dp_shader = CCShaderCache:getInstance():getProgram(SHADER_NAME_POSITION_U_COLOR)
dp_shader = cc.ShaderCache:getInstance():getProgram(SHADER_NAME_POSITION_U_COLOR)
--dp_shader:retain()
if nil ~= dp_shader then
dp_colorLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_color")
@ -52,7 +52,7 @@ function ccDrawColor4f(r,g,b,a)
end
function ccPointSize(pointSize)
dp_pointSize = pointSize * CCDirector:getInstance():getContentScaleFactor()
dp_pointSize = pointSize * cc.Director:getInstance():getContentScaleFactor()
end
function ccDrawColor4B(r,g,b,a)

View File

@ -3,6 +3,7 @@ require "cocos.cocos2d.Cocos2d"
require "cocos.cocos2d.Cocos2dConstants"
require "cocos.cocos2d.extern"
require "cocos.cocos2d.bitExtend"
require "cocos.cocos2d.DrawPrimitives"
-- opengl
require "cocos.cocos2d.Opengl"
@ -27,11 +28,15 @@ require "cocos.extension.ExtensionConstants"
-- network
require "cocos.network.NetworkConstants"
-- Spine
require "cocos.spine.SpineConstants"
if CC_USE_DEPRECATED_API then
-- CCLuaEngine
require "cocos.cocos2d.DeprecatedCocos2dClass"
require "cocos.cocos2d.DeprecatedCocos2dEnum"
require "cocos.cocos2d.DeprecatedCocos2dFunc"
require "cocos.cocos2d.DeprecatedOpenglEnum"
-- register_cocostudio_module
require "cocos.cocostudio.DeprecatedCocoStudioClass"

View File

@ -62,7 +62,7 @@ namespace ui {
}
//Size
const Vec2& LayoutComponent::getOwnerContentSize()const
Vec2 LayoutComponent::getOwnerContentSize()const
{
return this->getOwner()->getContentSize();
}

View File

@ -68,7 +68,7 @@ NS_CC_BEGIN
const Vec2& getOwnerPosition()const;
void setOwnerPosition(const Vec2& point);
const Vec2& getOwnerContentSize()const;
Vec2 getOwnerContentSize()const;
void setOwnerContentSize(const Vec2& size);
const Vec2& getPercentContentSize()const;

View File

@ -13,8 +13,15 @@
- [Windows](#user-content-windows)
- [Linux](#user-content-linux)
- [How to start a new game](#user-content-how-to-start-a-new-game)
- [Notes of v3.3rc0](#user-content-notes-of-v33rc0)
- [Highlights of v3.3rc0](#user-content-highlights-of-v33rc0)
- [Features in detail](#user-content-features-in-detail)
- [Light](#user-content-light)
- [Spine runtime](#user-content-spine-runtime)
- [AssetsManagerEx](#user-content-assetsmanagerex)
- [Application::openURL](#user-content-applicationopenurl)
- [ClippingRectangleNode](#user-content-clippingrectanglenode)
- [Facebook platform support](#user-content-facebook-platform-support)
- [Highlights of v3.3beta0](#user-content-highlights-of-v33beta0)
- [Features in detail](#user-content-features-in-detail-1)
- [BillBoard](#user-content-billboard)
@ -125,9 +132,52 @@ Run
Please refer to this document: [ReadMe](../README.md)
# Notes of v3.3rc0
**wp8**
You need to use `VS2013 with update 3` to use `Cocos2dShaderCompiler` used to compile precompiled shaders for WP8.
**lua**
All internal lua files are copied into `src/cocos` when creating a new lua project. And we added `cocos/init.lua` to load all these internal lua files. `cocos/init.lua` is loaded by default which means you don't have to load these lua files by yourself. So you have to remove all these codes in your lua codes:
* require "Cocos2d"
* require "Cocos2dConstants"
* require "bitExtend"
* require "DrawPrimitives"
* require "extern"
* require "json"
* require "Opengl"
* require "OpenglConstants"
* require "CCBReaderLoad"
* require "AudioEngine"
* require “CocoStudio”
* require “StudioConstants”
* require “ControllerConstants”
* require “ExtensionConstants”
* require “NetworkConstants”
* require “GuiConstants”
* require “experimentalUIConstants”
`luaj` and `luaoc` are special. They can not be loaded in `cocos/init.lua` because they will return an object to be used in codes. So you have to replace the codes like this:
* require "luaj" -> require "cocos.cocos2d.luaj"
* require "luaoc" -> require "cocos.cocos2d.luaoc"
All lua files used for deprecated API are not loaded by default. If you want to use deprecated API, you should uncomment a line in `src/main.lua` like this:
```
-- uncomment this line to use deprecated API
-- CC_USE_DEPRECATED_API = true
require "cocos.init"
```
# Highlights of v3.3rc0
* 3d: added light support: including direction light, point light, spot light and ambient light
* 3d: added light support: including directional light, point light, spot light and ambient light
* New audio: more platfroms supported(Mac OS X and Windows)
* Spine runtime: updated to v2.0.18
* Application: added openURL()
@ -135,12 +185,53 @@ Please refer to this document: [ReadMe](../README.md)
* TileMap: supported staggered tile map
* Added `ClippingRectangNode`, it is more effecient for renctangle clipping
* Node: schedule/unschedule lambda functions
* Facebook platform support in `plugin` on iOS and Android, all features has been added, but the API needs to be polished with Facebook guys
# Features in detail
## Light
TBD
To make 3d objects looks realistic, we add lights to this version. cocos2d-x supports four types of lights, directional light, point light, spot light and ambient light.
`DirectionLight` is meant to represent an extremely distant light source (like the sun or moon). Rays cast from directional lights run parallel in a single direction from every point in the sky, and are typically used to simulate the sun light.
The following code can add a directional light to the scene,
```c++
auto directionalLight = DirectionLight::create(Vec3(-1.0f, -1.0f, 0.0f), Color3B(200, 200, 200));
addChild(directionalLight);
```
The light is enabled by default. And it can be disabled using the following code,
```c++
directionalLight->setEnabled(false);
```
You can also set a light flag to the light.
```c++
directionalLight->setLightFlag(LightFlag::LIGHT0);
```
Then the 3d sprite whose light mask AND light flag is none zero can effect by the light.
`PointLight` casts illumination outward in every direction from a single, infinitely small point in 3D space. It is useful for simulating any omnidirectional light source.
`SpotLight` emits a cone shaped light field from a single point in space. It can be used to simulate desk lamps, overhead cone lighting, etc. Note that `SpotLight` will take more GPU time.
`AmbientLight` casts soft rays in every direction.
Note that we use forward render method, the number of lights can effect the performance. You can set the max number of lights supported in the shader in a the configuration file.
```c++
<key>cocos2d.x.3d.max_dir_light_in_shader</key>
<integer>1</integer>
<key>cocos2d.x.3d.max_point_light_in_shader</key>
<integer>1</integer>
<key>cocos2d.x.3d.max_spot_light_in_shader</key>
<integer>1</integer>
```
## Spine runtime
@ -152,9 +243,13 @@ Please refer to `tests/cpp-tests/Classes/SpineTest/SpineTest.cpp` for usage.
## AssetsManagerEx
`AssetsMangerEx` is an enhancement version of `AssetsManager`.
`AssetsMangerEx` is an enhancement version of `AssetsManager`. Compared to `AssetsManager`, there are some pros using `AssetsManagerEx`:
TBD
* complex update package support with manifest file
* multi-thread downloading support
* continue transferring from breakpoint
Please refer to [this document](http://cocos2d-x.org/wiki/Assets_manager) for detail information.
## Application::openURL
@ -185,6 +280,16 @@ auto content = Sprite::create("MyPicture.png");
clipper->addChild(content);
```
## Facebook platform support
All features has been added, but the API needs to be polished with Facebook guys. There is a test case in `plugin` for it. Steps to run test case
* open `plugin/pluing-x_ios.xcworkspace`
* select `HelloPlugins` to run
* there are `Test Facebook User` and `Test Facebook Share` items
You can refer to [this document](http://www.cocos2d-x.org/wiki/Integrate_the_Facebook_SDK_for_Cocos2d-x) for detail information.
# Highlights of v3.3beta0
* 3d: `BillBoard`
@ -230,6 +335,7 @@ The step to use Triangle Command is very simple.
To improve performance, `Triangles` will hold a weak reference to the vertices and indices data to be rendered, which is the same like `QuadCommand`. The userer should not release any rendered data before the `Command` is executed by `Renderer`.
## WebView
WebView is an new widget type which allows you to display web content inside Cocos2D-X. We only provide iOS and Android implementation currently, more platform might be added in the future.
The class is under `cocos2d::ui::experimental` namespace.
@ -304,7 +410,7 @@ Full test case please refer to `tests/cpp-tests/Classes/NewAudioEngineTest/NewAu
## Camera
This version of camera is powerful then previous one. And you can add it as a child anywhere. If you want to let a Node to be visited by a camera, Node's camera mask should include Camera's flag:
This version of camera is powerful than previous one. And you can add it as a child anywhere. If you want to let a Node to be visited by a camera, Node's camera mask should include Camera's flag:
```c++
// let sprite to be visited by a camera

View File

@ -1,6 +1,6 @@
{
"version":"v3-deps-19",
"zip_file_size":"88112898",
"version":"v3-deps-20",
"zip_file_size":"87419231",
"repo_name":"cocos2d-x-3rd-party-libs-bin",
"repo_parent":"https://github.com/cocos2d/",
"move_dirs":{

View File

@ -85,6 +85,8 @@
"cocos/2d/CCAnimationCache.h",
"cocos/2d/CCAtlasNode.cpp",
"cocos/2d/CCAtlasNode.h",
"cocos/2d/CCCamera.cpp",
"cocos/2d/CCCamera.h",
"cocos/2d/CCClippingNode.cpp",
"cocos/2d/CCClippingNode.h",
"cocos/2d/CCClippingRectangleNode.cpp",
@ -131,6 +133,8 @@
"cocos/2d/CCLabelTextFormatter.h",
"cocos/2d/CCLayer.cpp",
"cocos/2d/CCLayer.h",
"cocos/2d/CCLight.cpp",
"cocos/2d/CCLight.h",
"cocos/2d/CCMenu.cpp",
"cocos/2d/CCMenu.h",
"cocos/2d/CCMenuItem.cpp",
@ -322,8 +326,6 @@
"cocos/audio/wp8/SimpleAudioEngine.cpp",
"cocos/base/CCAutoreleasePool.cpp",
"cocos/base/CCAutoreleasePool.h",
"cocos/base/CCCamera.cpp",
"cocos/base/CCCamera.h",
"cocos/base/CCConfiguration.cpp",
"cocos/base/CCConfiguration.h",
"cocos/base/CCConsole.cpp",
@ -377,8 +379,6 @@
"cocos/base/CCIMEDelegate.h",
"cocos/base/CCIMEDispatcher.cpp",
"cocos/base/CCIMEDispatcher.h",
"cocos/base/CCLight.cpp",
"cocos/base/CCLight.h",
"cocos/base/CCMap.h",
"cocos/base/CCNS.cpp",
"cocos/base/CCNS.h",

View File

@ -1,4 +1,4 @@
{
"templateVersion":"1.4",
"runtimeVersion":"1.4"
"templateVersion":"1.5",
"runtimeVersion":"1.5"
}

View File

@ -68,7 +68,7 @@ extern string getIPAddress();
const char* getRuntimeVersion()
{
return "1.4";
return "1.5";
}
static string& replaceAll(string& str, const string& old_value, const string& new_value)

View File

@ -1,6 +1,6 @@
{
"version":"v3-lua-runtime-1.3.1",
"zip_file_size":"24660780",
"version":"v3-lua-runtime-1.5",
"zip_file_size":"30660780",
"repo_name":"cocos-runtime-bin",
"repo_parent":"https://github.com/chukong/"
}

View File

@ -25,7 +25,6 @@
#include "BillBoardTest.h"
#include "3d/CCBillBoard.h"
#include "base/CCCamera.h"
#include <algorithm>
#include "../testResource.h"

View File

@ -28,7 +28,6 @@ THE SOFTWARE.
#include "../testBasic.h"
#include "../BaseTest.h"
#include <string>
#include "base/CCCamera.h"
namespace cocos2d {
class Sprite3D;
class Delay;

View File

@ -105,7 +105,6 @@ void ConfigurationLoadConfig::onEnter()
Configuration::getInstance()->loadConfigFile("configs/config-test-ok.plist");
std::string config = Configuration::getInstance()->getInfo();
log("%s\n", config.c_str());
}
std::string ConfigurationLoadConfig::subtitle() const
@ -122,8 +121,8 @@ void ConfigurationQuery::onEnter()
{
ConfigurationBase::onEnter();
CCLOG("cocos2d version: %s", Configuration::getInstance()->getValue("cocos2d.x.version").asString().c_str() );
CCLOG("OpenGL version: %s", Configuration::getInstance()->getValue("gl.version").asString().c_str() );
log("cocos2d version: %s", Configuration::getInstance()->getValue("cocos2d.x.version").asString().c_str() );
log("OpenGL version: %s", Configuration::getInstance()->getValue("gl.version").asString().c_str() );
}
std::string ConfigurationQuery::subtitle() const
@ -159,21 +158,21 @@ void ConfigurationDefault::onEnter()
std::string c_value = Configuration::getInstance()->getValue("invalid.key", Value("no key")).asString();
if( c_value != "no key" )
CCLOG("1. Test failed!");
log("1. Test failed!");
else
CCLOG("1. Test OK!");
log("1. Test OK!");
bool b_value = Configuration::getInstance()->getValue("invalid.key", Value(true)).asBool();
if( ! b_value )
CCLOG("2. Test failed!");
log("2. Test failed!");
else
CCLOG("2. Test OK!");
log("2. Test OK!");
double d_value = Configuration::getInstance()->getValue("invalid.key", Value(42.42)).asDouble();
if( d_value != 42.42 )
CCLOG("3. Test failed!");
log("3. Test failed!");
else
CCLOG("3. Test OK!");
log("3. Test OK!");
}

View File

@ -4,7 +4,7 @@
const char* sceneManifests[] = {"AMTestScene1/project.manifest", "AMTestScene2/project.manifest", "AMTestScene3/project.manifest"};
const char* storagePaths[] = {"CppTests/AssetsManagerExTest/scene1/", "CppTests/AssetsManagerExTest/scene2/", "CppTests/AssetsManagerExTest/scene3"};
const char* backgroundPaths[] = {"Images/background1.jpg", "Images/background2.jpg", "Images/background3.png"};
const char* backgroundPaths[] = {"Images/assetMgrBackground1.jpg", "Images/assetMgrBackground2.png", "Images/assetMgrBackground3.png"};
AssetsManagerExTestLayer::AssetsManagerExTestLayer(const std::string& spritePath)
: _spritePath(spritePath)

View File

@ -68,7 +68,7 @@ static std::function<Layer*()> createFunctions[] =
CL(LabelTTFChinese),
CL(LabelBMFontChinese),
CL(BitmapFontMultiLineAlignment),
CL(LabelTTFA8Test),
CL(LabelTTFOpacityTest),
CL(BMFontOneAtlas),
CL(BMFontUnicode),
CL(BMFontInit),
@ -1325,18 +1325,17 @@ void BitmapFontMultiLineAlignment::snapArrowsToEdge()
this->_labelShouldRetain->getPosition().y));
}
/// LabelTTFA8Test
LabelTTFA8Test::LabelTTFA8Test()
/// LabelTTFOpacityTest
LabelTTFOpacityTest::LabelTTFOpacityTest()
{
auto s = Director::getInstance()->getWinSize();
auto layer = LayerColor::create(Color4B(128, 128, 128, 255));
addChild(layer, -10);
// LabelBMFont
auto label1 = LabelTTF::create("Testing A8 Format", "Marker Felt", 48);
auto label1 = LabelTTF::create("Testing opacity", "Marker Felt", 48);
addChild(label1);
label1->setColor(Color3B::RED);
label1->setFontFillColor(Color3B::RED);
label1->setPosition(Vec2(s.width/2, s.height/2));
auto fadeOut = FadeOut::create(2);
@ -1346,12 +1345,12 @@ LabelTTFA8Test::LabelTTFA8Test()
label1->runAction(forever);
}
std::string LabelTTFA8Test::title() const
std::string LabelTTFOpacityTest::title() const
{
return "Testing A8 Format";
return "Testing opacity";
}
std::string LabelTTFA8Test::subtitle() const
std::string LabelTTFOpacityTest::subtitle() const
{
return "RED label, fading In and Out in the center of the screen";
}

View File

@ -293,12 +293,12 @@ public:
bool _drag;
};
class LabelTTFA8Test : public AtlasDemo
class LabelTTFOpacityTest : public AtlasDemo
{
public:
CREATE_FUNC(LabelTTFA8Test);
CREATE_FUNC(LabelTTFOpacityTest);
LabelTTFA8Test();
LabelTTFOpacityTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;

View File

@ -27,7 +27,6 @@
#include "../testBasic.h"
#include "../BaseTest.h"
#include "base/CCLight.h"
class LightTest : public BaseTest
{

View File

@ -29,7 +29,6 @@
#include "3d/CCAttachNode.h"
#include "3d/CCRay.h"
#include "3d/CCSprite3D.h"
#include "base/CCLight.h"
#include "renderer/CCVertexIndexBuffer.h"
#include "DrawNode3D.h"
@ -1273,7 +1272,7 @@ void Sprite3DWithOBBPerfromanceTest::onTouchesBegan(const std::vector<Touch*>& t
{
if(ray.intersects(_obb[i]))
{
_intersetList.insert(i);
_intersetList.insert((int)i);
return;
}
}
@ -1295,7 +1294,7 @@ void Sprite3DWithOBBPerfromanceTest::onTouchesMoved(const std::vector<Touch*>& t
for(decltype(obbSize) i = 0; i < obbSize; i++)
{
if(_intersetList.find(i) != _intersetList.end())
if(_intersetList.find((int)i) != _intersetList.end())
_obb[i]._center = Vec3(location.x,location.y,0);
}
}

View File

@ -145,7 +145,7 @@ g_guisTests[] =
}
},
{
"TextAtalsTest",
"TextAtlasTest",
[](Ref* sender)
{
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();

View File

@ -1,6 +1,8 @@
#include "GUIEditorTest.h"
#include "cocostudio/ActionTimeline/CSLoader.h"
#include "CocoStudioGUITest.h"
#include "UISceneManager_Editor.h"
@ -119,7 +121,7 @@ g_guisTests[] =
},
*/
{
"gui TextAtals Editor Test",
"gui TextAtlas Editor Test",
[](Ref* sender)
{
UISceneManager_Editor* pManager = UISceneManager_Editor::sharedUISceneManager_Editor();
@ -270,6 +272,8 @@ void GUIEditorMainLayer::onEnter()
{
Layer::onEnter();
CSLoader::getInstance()->setRecordProtocolBuffersPath(true);
auto s = Director::getInstance()->getWinSize();
_itemMenu = Menu::create();

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -14,7 +14,6 @@ local sceneManifests =
"Manifests/AMTestScene3/project.manifest"
}
--UNCHECK
local storagePaths =
{
"LuaTests/AssetsManagerExTest/scene1",
@ -24,9 +23,9 @@ local storagePaths =
local backgroundPaths =
{
"Images/background1.jpg",
"Images/background2.jpg",
"Images/background3.png"
"Images/assetMgrBackground1.jpg",
"Images/assetMgrBackground2.png",
"Images/assetMgrBackground3.png"
}
-------------------------------------
@ -57,12 +56,12 @@ function AMTestScene1.create()
local progress = cc.Label:createWithTTF(ttfConfig, "0%", cc.VERTICAL_TEXT_ALIGNMENT_CENTER)
progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50))
layer:addChild(progress)
am = cc.AssetsManagerEx:create("Manifests/AMTestScene1/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene1")
am = cc.AssetsManagerEx:create(sceneManifests[1], cc.FileUtils:getInstance():getWritablePath() .. storagePaths[1])
am:retain()
if not am:getLocalManifest():isLoaded() then
print("Fail to update assets, step skipped.")
local background = cc.Sprite:create("Images/background1.jpg")
local background = cc.Sprite:create(backgroundPaths[1])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
else
@ -70,7 +69,7 @@ function AMTestScene1.create()
local eventCode = event:getEventCode()
if eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_NO_LOCAL_MANIFEST then
print("No local manifest file found, skip assets update.")
local background = cc.Sprite:create("Images/background1.jpg")
local background = cc.Sprite:create(backgroundPaths[1])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_PROGRESSION then
@ -89,18 +88,18 @@ function AMTestScene1.create()
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_DOWNLOAD_MANIFEST or
eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_PARSE_MANIFEST then
print("Fail to download manifest file, update skipped.")
local background = cc.Sprite:create("Images/background1.jpg")
local background = cc.Sprite:create(backgroundPaths[1])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ALREADY_UP_TO_DATE or
eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_FINISHED then
print("Update finished.")
local background = cc.Sprite:create("Images/background1.jpg")
local background = cc.Sprite:create(backgroundPaths[1])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_UPDATING then
print("Asset ", event:getAssetId(), ", ", event:getMessage())
local background = cc.Sprite:create("Images/background1.jpg")
local background = cc.Sprite:create(backgroundPaths[1])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
end
@ -154,12 +153,12 @@ function AMTestScene2.create()
progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50))
layer:addChild(progress)
am = cc.AssetsManagerEx:create("Manifests/AMTestScene2/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene2")
am = cc.AssetsManagerEx:create(sceneManifests[2], cc.FileUtils:getInstance():getWritablePath() .. storagePaths[2])
am:retain()
if not am:getLocalManifest():isLoaded() then
print("Fail to update assets, step skipped.")
local background = cc.Sprite:create("Images/background2.jpg")
local background = cc.Sprite:create(backgroundPaths[2])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
else
@ -167,7 +166,7 @@ function AMTestScene2.create()
local eventCode = event:getEventCode()
if eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_NO_LOCAL_MANIFEST then
print("No local manifest file found, skip assets update.")
local background = cc.Sprite:create("Images/background2.jpg")
local background = cc.Sprite:create(backgroundPaths[2])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_PROGRESSION then
@ -186,18 +185,18 @@ function AMTestScene2.create()
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_DOWNLOAD_MANIFEST or
eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_PARSE_MANIFEST then
print("Fail to download manifest file, update skipped.")
local background = cc.Sprite:create("Images/background2.jpg")
local background = cc.Sprite:create(backgroundPaths[2])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ALREADY_UP_TO_DATE or
eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_FINISHED then
print("Update finished.")
local background = cc.Sprite:create("Images/background2.jpg")
local background = cc.Sprite:create(backgroundPaths[2])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_UPDATING then
print("Asset ", event:getAssetId(), ", ", event:getMessage())
local background = cc.Sprite:create("Images/background2.jpg")
local background = cc.Sprite:create(backgroundPaths[2])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
end
@ -250,7 +249,7 @@ function AMTestScene3.create()
progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50))
layer:addChild(progress)
am = cc.AssetsManagerEx:create("Manifests/AMTestScene3/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene3")
am = cc.AssetsManagerEx:create(sceneManifests[3], cc.FileUtils:getInstance():getWritablePath() .. storagePaths[3])
am:retain()
if not am:getLocalManifest():isLoaded() then
@ -263,7 +262,7 @@ function AMTestScene3.create()
local eventCode = event:getEventCode()
if eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_NO_LOCAL_MANIFEST then
print("No local manifest file found, skip assets update.")
local background = cc.Sprite:create("Images/background3.png")
local background = cc.Sprite:create(backgroundPaths[3])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_PROGRESSION then
@ -282,18 +281,18 @@ function AMTestScene3.create()
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_DOWNLOAD_MANIFEST or
eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_PARSE_MANIFEST then
print("Fail to download manifest file, update skipped.")
local background = cc.Sprite:create("Images/background3.png")
local background = cc.Sprite:create(backgroundPaths[3])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ALREADY_UP_TO_DATE or
eventCode == cc.EventAssetsManagerEx.EventCode.UPDATE_FINISHED then
print("Update finished.")
local background = cc.Sprite:create("Images/background3.png")
local background = cc.Sprite:create(backgroundPaths[3])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
elseif eventCode == cc.EventAssetsManagerEx.EventCode.ERROR_UPDATING then
print("Asset ", event:getAssetId(), ", ", event:getMessage())
local background = cc.Sprite:create("Images/background3.png")
local background = cc.Sprite:create(backgroundPaths[3])
layer:addChild(background, 1)
background:setPosition( cc.p(VisibleRect:center().x, VisibleRect:center().y ))
end

View File

@ -1278,8 +1278,8 @@ local LabelCrashTest = {}
function LabelCrashTest.create()
local layer = cc.Layer:create()
Helper.initWithLayer(layer)
Helper.titleLabel:setString("New Label + .TTF")
Helper.subtitleLabel:setString("Testing rendering base on DistanceField")
Helper.titleLabel:setString("New Label Crash Test")
Helper.subtitleLabel:setString("Not crash and show [Test123] when using unknown character.")
local ttfConfig = {}
ttfConfig.fontFilePath = "fonts/arial.ttf"

View File

@ -62,7 +62,7 @@ local function LuaBridgeLayer()
if (cc.PLATFORM_OS_ANDROID == targetPlatform) then
local args = { 2 , 3}
local sigs = "(II)I"
local luaj = require "luaj"
local luaj = require "cocos.cocos2d.luaj"
local className = "com/cocos2dx/sample/LuaJavaBridgeTest/LuaJavaBridgeTest"
local ok,ret = luaj.callStaticMethod(className,"addTwoNumbers",args,sigs)
if not ok then
@ -101,7 +101,7 @@ local function LuaBridgeLayer()
subtitleLabel:setString("See the console.")
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_MAC == targetPlatform) then
local args = { num1 = 2 , num2 = 3 }
local luaoc = require "luaoc"
local luaoc = require "cocos.cocos2d.luaoc"
local className = "LuaObjectCBridgeTest"
local ok,ret = luaoc.callStaticMethod(className,"addTwoNumbers",args)
if not ok then

View File

@ -29,9 +29,13 @@ local function XMLHttpRequestLayer()
xhr:open("GET", "http://httpbin.org/get")
local function onReadyStateChange()
local statusString = "Http Status Code:"..xhr.statusText
labelStatusCode:setString(statusString)
print(xhr.response)
if xhr.readyState == 4 and (xhr.status >= 200 and xhr.status < 207) then
local statusString = "Http Status Code:"..xhr.statusText
labelStatusCode:setString(statusString)
print(xhr.response)
else
print("xhr.readyState is:", xhr.readyState, "xhr.status is: ",xhr.status)
end
end
xhr:registerScriptHandler(onReadyStateChange)
@ -53,8 +57,12 @@ local function XMLHttpRequestLayer()
xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_STRING
xhr:open("POST", "http://httpbin.org/post")
local function onReadyStateChange()
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
print(xhr.response)
if xhr.readyState == 4 and (xhr.status >= 200 and xhr.status < 207) then
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
print(xhr.response)
else
print("xhr.readyState is:", xhr.readyState, "xhr.status is: ",xhr.status)
end
end
xhr:registerScriptHandler(onReadyStateChange)
xhr:send()
@ -76,19 +84,23 @@ local function XMLHttpRequestLayer()
xhr:open("POST", "http://httpbin.org/post")
local function onReadyStateChange()
local response = xhr.response
local size = table.getn(response)
local strInfo = ""
for i = 1,size do
if 0 == response[i] then
strInfo = strInfo.."\'\\0\'"
else
strInfo = strInfo..string.char(response[i])
end
if xhr.readyState == 4 and (xhr.status >= 200 and xhr.status < 207) then
local response = xhr.response
local size = table.getn(response)
local strInfo = ""
for i = 1,size do
if 0 == response[i] then
strInfo = strInfo.."\'\\0\'"
else
strInfo = strInfo..string.char(response[i])
end
end
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
print(strInfo)
else
print("xhr.readyState is:", xhr.readyState, "xhr.status is: ",xhr.status)
end
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
print(strInfo)
end
xhr:registerScriptHandler(onReadyStateChange)
@ -112,12 +124,16 @@ local function XMLHttpRequestLayer()
xhr:open("POST", "http://httpbin.org/post")
local function onReadyStateChange()
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
local response = xhr.response
local output = json.decode(response,1)
table.foreach(output,function(i, v) print (i, v) end)
print("headers are")
table.foreach(output.headers,print)
if xhr.readyState == 4 and (xhr.status >= 200 and xhr.status < 207) then
labelStatusCode:setString("Http Status Code:"..xhr.statusText)
local response = xhr.response
local output = json.decode(response,1)
table.foreach(output,function(i, v) print (i, v) end)
print("headers are")
table.foreach(output.headers,print)
else
print("xhr.readyState is:", xhr.readyState, "xhr.status is: ",xhr.status)
end
end
xhr:registerScriptHandler(onReadyStateChange)

View File

@ -150,13 +150,9 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
ProgressTimer::[setReverseProgress=setReverseDirection],
AnimationCache::[addAnimationsWithFile=addAnimations],
LayerGradient::[initWithColor=init],
LayerColor::[initWithColor=init],
GLProgram::[initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init setUniformLocationWith1i=setUniformLocationI32],
GLProgram::[setUniformLocationWith1i=setUniformLocationI32],
Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
LabelAtlas::[create=_create],
Sprite::[initWithFile=init],
SpriteBatchNode::[initWithFile=init],
Touch::[getID=getId],
FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup],
Director::[end=endToLua]

View File

@ -54,8 +54,7 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*
BaseData::[copy subtract],
ActionTimelineCache::[getInstance loadActionTimelineFromXML]
rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance],
ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
SceneReader::[purgeSceneReader=destroyInstance]