зеркало из https://github.com/microsoft/cocos2d-x.git
Merge branch 'v3' into v3Animation
This commit is contained in:
Коммит
65acec013b
12
AUTHORS
12
AUTHORS
|
@ -716,6 +716,7 @@ Developers:
|
|||
kicktheken (Kenneth Chan)
|
||||
Fixed a bug that the setBlendFunc method of some classes wasn't exposed to LUA.
|
||||
Fix lua project template crash on iOS5.1 device
|
||||
Fix layout constant syntax error in lua-binding
|
||||
|
||||
andyque
|
||||
Fixed a bug that missing to check self assignment of Vector<T>, Map<K,V>, Value and String.
|
||||
|
@ -830,6 +831,7 @@ Developers:
|
|||
Fixed incompatible pointer conversion in external/chipmunk/src/cpArray.c
|
||||
Fixed memory leak in 'Image'
|
||||
Fixed loosing precision when using 'recv' in 'Console'
|
||||
Fixed link error with Xcode 6 when building with 32-bit architecture
|
||||
|
||||
ololomax
|
||||
Fixed a potential crash in SceneReader::createNodeWithSceneFile
|
||||
|
@ -869,6 +871,16 @@ Developers:
|
|||
|
||||
uqtimes
|
||||
Fix NSNotificationCenter and NSTimer leaks
|
||||
|
||||
ntotani
|
||||
fix building error in lua-binding in release mode
|
||||
|
||||
kezhuw
|
||||
AutoReleasePool manager improvement
|
||||
|
||||
zhouxiaoxiaoxujian
|
||||
Added TextField::getStringLength()
|
||||
Add shadow, outline, glow filter support for UIText
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
|
|
31
CHANGELOG
31
CHANGELOG
|
@ -1,11 +1,40 @@
|
|||
cocos2d-x-3.2 ???
|
||||
[NEW] Console: add a command to show engine version
|
||||
[NEW] Node: added setter/getter for NormalizedPosition(). Allows to set positions in normalized values (between 0 and 1)
|
||||
[NEW] Scene: Added createWithSize() method
|
||||
[NEW] TextField: added getStringLength()
|
||||
[NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync()
|
||||
[NEW] utils: added captureScreen()
|
||||
[NEW] UIText: added shadow, outline, glow filter support
|
||||
|
||||
[FIX] Application.mk: not output debug message in releae mode on Android
|
||||
[FIX] Application.mk: not output debug message in release mode on Android
|
||||
[FIX] Android: 3d model will be black when coming from background
|
||||
[FIX] Android: don't trigger EVENT_COME_TO_BACKGROUND event when go to background
|
||||
[FIX] Cocos2dxGLSurfaceView.java: prevent flickering when opening another activity
|
||||
[FIX] GLProgramState: sampler can not be changed
|
||||
[FIX] Image: Set jpeg save quality to 90
|
||||
[FIX] Image: premultiply alpha when loading png file to resolve black border issue
|
||||
[FIX] Label: label is unsharp if it's created by smaller font
|
||||
[FIX] Label: Label's display may go bonkers if invoking Label::setString() with outline feature enabled
|
||||
[FIX] Lua-binding: compiling error on release mode
|
||||
[FIX] Lua-binding: Add xxtea encrypt support
|
||||
[FIX] Node: setPhysicsBody() can not work correctly if it is added to a Node
|
||||
[FIX] Node: state of _transformUpdated, _transformDirty and _inverseDirty are wrong in setParent()
|
||||
[FIX] Node: _orderOfArrival is set to 0 after visit
|
||||
[FIX] Other: link error with Xcode 6 when building with 32-bit architecture
|
||||
[FIX] Repeat: will run one more over in rare situations
|
||||
[FIX] Scale9Sprite: support culling
|
||||
[FIX] Schedule: schedulePerFrame() can not be called twice
|
||||
[FIX] SpriteFrameCache: fix memory leak
|
||||
[FIX] Texture2D: use image's pixel format to create texture
|
||||
[FIX] WP8: will restart if app goes to background, then touches icon to go to foreground
|
||||
[FIX] WP8: will be black if: 1. 3rd pops up a view; 2. go to background; 3. come to foreground
|
||||
[FIX] WP8: project name of new project created by console is wrong
|
||||
|
||||
[3RD] curl: will crash if use https request on iOS simulator
|
||||
|
||||
cocos2d-x-3.1.1 May.31 2014
|
||||
[FIX] GLProgramState: restores states after coming from background
|
||||
|
||||
cocos2d-x-3.1 May.24 2014
|
||||
[FIX] EventKeyboard::KeyCode: key code for back button changed from KEY_BACKSPACE to KEY_ESCAPE
|
||||
|
|
|
@ -151,6 +151,7 @@ include_directories(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/xxtea
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
|
@ -258,6 +259,9 @@ add_subdirectory(external/lua/tolua)
|
|||
|
||||
# luabinding
|
||||
add_subdirectory(cocos/scripting/lua-bindings)
|
||||
|
||||
# xxtea
|
||||
add_subdirectory(external/xxtea)
|
||||
endif(BUILD_LIBS_LUA)
|
||||
|
||||
# build tests
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; };
|
||||
06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */; };
|
||||
06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
|
||||
06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
|
||||
06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; };
|
||||
|
@ -54,8 +52,6 @@
|
|||
06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABD186AD63B0012A414 /* TriggerBase.h */; };
|
||||
06CAAACF186AD7FC0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; };
|
||||
06CAAAD0186AD7FE0012A414 /* TriggerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAABC186AD63B0012A414 /* TriggerBase.cpp */; };
|
||||
06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; };
|
||||
06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAABB186AD63B0012A414 /* ObjectFactory.h */; };
|
||||
1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; };
|
||||
1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A01C67618F57BE800EFE3A6 /* CCArray.cpp */; };
|
||||
1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A01C67718F57BE800EFE3A6 /* CCArray.h */; };
|
||||
|
@ -973,12 +969,14 @@
|
|||
2905FA8E18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; };
|
||||
2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; };
|
||||
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; };
|
||||
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 299754F2193EC95400A54AC3 /* ObjectFactory.cpp */; };
|
||||
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
|
||||
299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 299754F3193EC95400A54AC3 /* ObjectFactory.h */; };
|
||||
29CB8F4C1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
|
||||
29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
|
||||
29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
|
||||
29CB8F4F1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
|
||||
29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; };
|
||||
29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; };
|
||||
2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; };
|
||||
2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; };
|
||||
2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; };
|
||||
|
@ -1887,8 +1885,6 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFactory.cpp; sourceTree = "<group>"; };
|
||||
06CAAABB186AD63B0012A414 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFactory.h; sourceTree = "<group>"; };
|
||||
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerBase.cpp; sourceTree = "<group>"; };
|
||||
06CAAABD186AD63B0012A414 /* TriggerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerBase.h; sourceTree = "<group>"; };
|
||||
06CAAABE186AD63B0012A414 /* TriggerMng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerMng.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2274,9 +2270,10 @@
|
|||
29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = "<group>"; };
|
||||
2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = "<group>"; };
|
||||
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
|
||||
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFactory.cpp; path = ../base/ObjectFactory.cpp; sourceTree = "<group>"; };
|
||||
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
|
||||
29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = "<group>"; };
|
||||
29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = "<group>"; };
|
||||
29CB8F541929D7A900C841D6 /* UIScrollInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollInterface.h; sourceTree = "<group>"; };
|
||||
2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundingBoxAttachment.cpp; sourceTree = "<group>"; };
|
||||
2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundingBoxAttachment.h; sourceTree = "<group>"; };
|
||||
2AC795D51862867D005EC8E1 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3071,6 +3068,8 @@
|
|||
1A5700A2180BC5E60088DEC7 /* base */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
299754F2193EC95400A54AC3 /* ObjectFactory.cpp */,
|
||||
299754F3193EC95400A54AC3 /* ObjectFactory.h */,
|
||||
50ABBDC11925AB6E00A911A9 /* atitc.cpp */,
|
||||
50ABBDC21925AB6E00A911A9 /* atitc.h */,
|
||||
50ABBDC31925AB6E00A911A9 /* base64.cpp */,
|
||||
|
@ -3590,8 +3589,6 @@
|
|||
children = (
|
||||
50FCEB6818C72017004AD434 /* WidgetReader */,
|
||||
06CAAAC1186AD63B0012A414 /* TriggerObj.h */,
|
||||
06CAAABA186AD63B0012A414 /* ObjectFactory.cpp */,
|
||||
06CAAABB186AD63B0012A414 /* ObjectFactory.h */,
|
||||
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */,
|
||||
06CAAABD186AD63B0012A414 /* TriggerBase.h */,
|
||||
06CAAABE186AD63B0012A414 /* TriggerMng.cpp */,
|
||||
|
@ -4003,7 +4000,6 @@
|
|||
2905FA0518CF08D000240AA3 /* UIRichText.h */,
|
||||
2905FA0718CF08D000240AA3 /* UIScrollView.cpp */,
|
||||
2905FA0818CF08D000240AA3 /* UIScrollView.h */,
|
||||
29CB8F541929D7A900C841D6 /* UIScrollInterface.h */,
|
||||
2905FA0918CF08D000240AA3 /* UISlider.cpp */,
|
||||
2905FA0A18CF08D100240AA3 /* UISlider.h */,
|
||||
2905FA0B18CF08D100240AA3 /* UIText.cpp */,
|
||||
|
@ -4921,7 +4917,6 @@
|
|||
1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */,
|
||||
50FCEBB518C72017004AD434 /* SliderReader.h in Headers */,
|
||||
5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */,
|
||||
06CAAAD1186AD8010012A414 /* ObjectFactory.h in Headers */,
|
||||
1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */,
|
||||
1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */,
|
||||
1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
||||
|
@ -5007,6 +5002,7 @@
|
|||
1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */,
|
||||
50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */,
|
||||
2905FA6418CF08D100240AA3 /* UIListView.h in Headers */,
|
||||
299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */,
|
||||
50FCEBB918C72017004AD434 /* TextAtlasReader.h in Headers */,
|
||||
50ABBD991925AB4100A911A9 /* CCGLProgramStateCache.h in Headers */,
|
||||
5034CA3D191D591100CE6051 /* ccShader_PositionColor.frag in Headers */,
|
||||
|
@ -5153,7 +5149,6 @@
|
|||
50ABBD9D1925AB4100A911A9 /* ccGLStateCache.h in Headers */,
|
||||
50ABBEB91925AB6F00A911A9 /* ccUTF8.h in Headers */,
|
||||
1AAF536E180E3374000584C8 /* HttpRequest.h in Headers */,
|
||||
29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */,
|
||||
1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */,
|
||||
50ABBE671925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */,
|
||||
1AAF5374180E3374000584C8 /* SocketIO.h in Headers */,
|
||||
|
@ -5440,6 +5435,7 @@
|
|||
2905FA7118CF08D100240AA3 /* UIRichText.h in Headers */,
|
||||
503DD8E41926736A00CD74DD /* CCDirectorCaller.h in Headers */,
|
||||
50ABBD8A1925AB4100A911A9 /* CCCustomCommand.h in Headers */,
|
||||
299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */,
|
||||
2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */,
|
||||
50ABBE881925AB6F00A911A9 /* ccMacros.h in Headers */,
|
||||
50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */,
|
||||
|
@ -5523,7 +5519,6 @@
|
|||
50ABBDB81925AB4100A911A9 /* CCTexture2D.h in Headers */,
|
||||
50ABBE341925AB6F00A911A9 /* CCConfiguration.h in Headers */,
|
||||
1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */,
|
||||
06CAAAD2186AD8030012A414 /* ObjectFactory.h in Headers */,
|
||||
50ABBEAA1925AB6F00A911A9 /* CCTouch.h in Headers */,
|
||||
2905FA6918CF08D100240AA3 /* UILoadingBar.h in Headers */,
|
||||
50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
|
||||
|
@ -5611,7 +5606,6 @@
|
|||
50ABBD921925AB4100A911A9 /* CCGLProgramCache.h in Headers */,
|
||||
1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */,
|
||||
B29594C91926D61F003EEF37 /* CCObjLoader.h in Headers */,
|
||||
29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */,
|
||||
1AD71E98180E26E600808F54 /* Animation.h in Headers */,
|
||||
1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */,
|
||||
50ABBE961925AB6F00A911A9 /* CCProfiling.h in Headers */,
|
||||
|
@ -6153,7 +6147,6 @@
|
|||
1A57011B180BC90D0088DEC7 /* CCGrabber.cpp in Sources */,
|
||||
1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */,
|
||||
50FCEBA718C72017004AD434 /* LoadingBarReader.cpp in Sources */,
|
||||
06C0F2EF186AD822003594D5 /* ObjectFactory.cpp in Sources */,
|
||||
1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */,
|
||||
1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */,
|
||||
1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */,
|
||||
|
@ -6345,6 +6338,7 @@
|
|||
2905FA5218CF08D100240AA3 /* UIImageView.cpp in Sources */,
|
||||
50ABBDBD1925AB4100A911A9 /* CCTextureCache.cpp in Sources */,
|
||||
B29594CE1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */,
|
||||
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */,
|
||||
2905FA7C18CF08D100240AA3 /* UIText.cpp in Sources */,
|
||||
50FCEB9F18C72017004AD434 /* LayoutReader.cpp in Sources */,
|
||||
50ABC0211926664800A911A9 /* CCGLView.cpp in Sources */,
|
||||
|
@ -6598,7 +6592,6 @@
|
|||
1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */,
|
||||
1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */,
|
||||
1A570120180BC90D0088DEC7 /* CCGrid.cpp in Sources */,
|
||||
06C0F2F0186AD824003594D5 /* ObjectFactory.cpp in Sources */,
|
||||
1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */,
|
||||
503DD8E21926736A00CD74DD /* CCCommon.mm in Sources */,
|
||||
1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */,
|
||||
|
@ -6616,6 +6609,7 @@
|
|||
B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */,
|
||||
1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */,
|
||||
1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */,
|
||||
299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */,
|
||||
1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */,
|
||||
50ABBDBE1925AB4100A911A9 /* CCTextureCache.cpp in Sources */,
|
||||
1A5701E3180BCB8C0088DEC7 /* CCScene.cpp in Sources */,
|
||||
|
@ -7117,6 +7111,7 @@
|
|||
CC_TARGET_OS_MAC,
|
||||
CC_KEYBOARD_SUPPORT,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -7143,6 +7138,7 @@
|
|||
CC_KEYBOARD_SUPPORT,
|
||||
CC_TARGET_OS_MAC,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
@ -7235,6 +7231,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac";
|
||||
};
|
||||
|
@ -7245,6 +7242,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac";
|
||||
};
|
||||
|
@ -7259,6 +7257,7 @@
|
|||
CC_TARGET_OS_MAC,
|
||||
CC_KEYBOARD_SUPPORT,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac";
|
||||
|
@ -7274,6 +7273,7 @@
|
|||
CC_TARGET_OS_MAC,
|
||||
CC_KEYBOARD_SUPPORT,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../cocos/platform/desktop $(SRCROOT)/../external/glfw3/include/mac";
|
||||
|
@ -7291,6 +7291,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
|
@ -7329,6 +7330,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
|
@ -7385,6 +7387,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
|
@ -7403,6 +7406,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
|
@ -7481,6 +7485,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -7498,6 +7503,7 @@
|
|||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
|
|
|
@ -570,8 +570,6 @@
|
|||
1AC35CD718CED84500F37B72 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */; };
|
||||
1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */; };
|
||||
1AC35CD918CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */; };
|
||||
1AC35CDC18CED84500F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; };
|
||||
1AC35CDD18CED84500F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; };
|
||||
1AC35CDE18CED84500F37B72 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB318CED84500F37B72 /* components */; };
|
||||
1AC35CDF18CED84500F37B72 /* components in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB318CED84500F37B72 /* components */; };
|
||||
1AC35CE018CED84500F37B72 /* configs in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB418CED84500F37B72 /* configs */; };
|
||||
|
@ -697,7 +695,6 @@
|
|||
1AC35DE318CEE65900F37B72 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB918CED84500F37B72 /* fileLookup.plist */; };
|
||||
1AC35DE518CEE65900F37B72 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CBD18CED84500F37B72 /* Hello.png */; };
|
||||
1AC35DE618CEE65900F37B72 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB518CED84500F37B72 /* effect1.raw */; };
|
||||
1AC35DE718CEE65900F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; };
|
||||
1AC35DE918CEE65900F37B72 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB618CED84500F37B72 /* effect1.wav */; };
|
||||
1AC35DEA18CEE65900F37B72 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */; };
|
||||
1AC35DEB18CEE65B00F37B72 /* CocosBuilderExample.ccbproj in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */; };
|
||||
|
@ -709,7 +706,6 @@
|
|||
1AC35DF118CEE65B00F37B72 /* fileLookup.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB918CED84500F37B72 /* fileLookup.plist */; };
|
||||
1AC35DF318CEE65B00F37B72 /* Hello.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CBD18CED84500F37B72 /* Hello.png */; };
|
||||
1AC35DF418CEE65B00F37B72 /* effect1.raw in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB518CED84500F37B72 /* effect1.raw */; };
|
||||
1AC35DF518CEE65B00F37B72 /* commonly_used_words.txt in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB218CED84500F37B72 /* commonly_used_words.txt */; };
|
||||
1AC35DF718CEE65B00F37B72 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CB618CED84500F37B72 /* effect1.wav */; };
|
||||
1AC35DF818CEE65B00F37B72 /* pew-pew-lei.wav in Resources */ = {isa = PBXBuildFile; fileRef = 1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */; };
|
||||
1AF152D918FD252A00A52F3D /* PerformanceCallbackTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF152D718FD252A00A52F3D /* PerformanceCallbackTest.cpp */; };
|
||||
|
@ -1668,7 +1664,6 @@
|
|||
1AC35CAE18CED84500F37B72 /* ccb */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ccb; path = "../tests/cpp-tests/Resources/ccb"; sourceTree = "<group>"; };
|
||||
1AC35CAF18CED84500F37B72 /* CocosBuilderExample.ccbproj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = CocosBuilderExample.ccbproj; path = "../tests/cpp-tests/Resources/CocosBuilderExample.ccbproj"; sourceTree = "<group>"; };
|
||||
1AC35CB018CED84500F37B72 /* CocosBuilderExample.ccbresourcelog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocosBuilderExample.ccbresourcelog; path = "../tests/cpp-tests/Resources/CocosBuilderExample.ccbresourcelog"; sourceTree = "<group>"; };
|
||||
1AC35CB218CED84500F37B72 /* commonly_used_words.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = commonly_used_words.txt; path = "../tests/cpp-tests/Resources/commonly_used_words.txt"; sourceTree = "<group>"; };
|
||||
1AC35CB318CED84500F37B72 /* components */ = {isa = PBXFileReference; lastKnownFileType = folder; name = components; path = "../tests/cpp-tests/Resources/components"; sourceTree = "<group>"; };
|
||||
1AC35CB418CED84500F37B72 /* configs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = configs; path = "../tests/cpp-tests/Resources/configs"; sourceTree = "<group>"; };
|
||||
1AC35CB518CED84500F37B72 /* effect1.raw */ = {isa = PBXFileReference; lastKnownFileType = file; name = effect1.raw; path = "../tests/cpp-tests/Resources/effect1.raw"; sourceTree = "<group>"; };
|
||||
|
@ -3273,7 +3268,6 @@
|
|||
1AC35CB918CED84500F37B72 /* fileLookup.plist */,
|
||||
1AC35CBD18CED84500F37B72 /* Hello.png */,
|
||||
1AC35CB518CED84500F37B72 /* effect1.raw */,
|
||||
1AC35CB218CED84500F37B72 /* commonly_used_words.txt */,
|
||||
1AC35CB618CED84500F37B72 /* effect1.wav */,
|
||||
1AC35CC418CED84500F37B72 /* pew-pew-lei.wav */,
|
||||
);
|
||||
|
@ -4262,7 +4256,6 @@
|
|||
1ABCA38818CD9E180087CE3A /* DeprecatedOpenglEnum.lua in Resources */,
|
||||
1AC35DE118CEE65900F37B72 /* background.ogg in Resources */,
|
||||
15C90B4B18E66C2F00D69802 /* url.lua in Resources */,
|
||||
1AC35DE718CEE65900F37B72 /* commonly_used_words.txt in Resources */,
|
||||
1ABCA37A18CD9E180087CE3A /* CCBReaderLoad.lua in Resources */,
|
||||
1AC35DDF18CEE65900F37B72 /* music.mid in Resources */,
|
||||
1AC35D7518CEE58500F37B72 /* src in Resources */,
|
||||
|
@ -4352,7 +4345,6 @@
|
|||
1ABCA39B18CD9E180087CE3A /* StudioConstants.lua in Resources */,
|
||||
1ABCA38D18CD9E180087CE3A /* extern.lua in Resources */,
|
||||
1AC35DEB18CEE65B00F37B72 /* CocosBuilderExample.ccbproj in Resources */,
|
||||
1AC35DF518CEE65B00F37B72 /* commonly_used_words.txt in Resources */,
|
||||
1AC35DCA18CEE65200F37B72 /* animations in Resources */,
|
||||
1A1645A9191B6283008C7C7F /* ccs-res in Resources */,
|
||||
1AC35DA118CEE5D100F37B72 /* Icon-72.png in Resources */,
|
||||
|
@ -4393,7 +4385,6 @@
|
|||
1AC35CFA18CED84500F37B72 /* Misc in Resources */,
|
||||
1AC35D0418CED84500F37B72 /* Shaders in Resources */,
|
||||
1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */,
|
||||
1AC35CDC18CED84500F37B72 /* commonly_used_words.txt in Resources */,
|
||||
B2507B6B192589AF00FA4972 /* Shaders3D in Resources */,
|
||||
1AC35D0618CED84500F37B72 /* spine in Resources */,
|
||||
1AC35CE818CED84500F37B72 /* extensions in Resources */,
|
||||
|
@ -4471,7 +4462,6 @@
|
|||
B2507B6C192589AF00FA4972 /* Shaders3D in Resources */,
|
||||
1AC35CED18CED84500F37B72 /* fonts in Resources */,
|
||||
1AC35CD718CED84500F37B72 /* CocosBuilderExample.ccbproj in Resources */,
|
||||
1AC35CDD18CED84500F37B72 /* commonly_used_words.txt in Resources */,
|
||||
1AC35C8918CECF1400F37B72 /* Default.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -5514,6 +5504,7 @@
|
|||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
|
@ -5540,6 +5531,7 @@
|
|||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk";
|
||||
|
|
|
@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues()
|
|||
}
|
||||
|
||||
// AtlasNode - draw
|
||||
void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
_quadCommand.init(
|
||||
_globalZOrder,
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual Texture2D* getTexture() const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
|
|
|
@ -203,15 +203,12 @@ void ClippingNode::drawFullScreenQuadClearStencil()
|
|||
|
||||
}
|
||||
|
||||
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if(!_visible)
|
||||
return;
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
|
@ -249,7 +246,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
|
|||
#endif
|
||||
|
||||
}
|
||||
_stencil->visit(renderer, _modelViewTransform, dirty);
|
||||
_stencil->visit(renderer, _modelViewTransform, flags);
|
||||
|
||||
_afterDrawStencilCmd.init(_globalZOrder);
|
||||
_afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
|
||||
|
@ -266,19 +263,19 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
|
|||
auto node = _children.at(i);
|
||||
|
||||
if ( node && node->getLocalZOrder() < 0 )
|
||||
node->visit(renderer, _modelViewTransform, dirty);
|
||||
node->visit(renderer, _modelViewTransform, flags);
|
||||
else
|
||||
break;
|
||||
}
|
||||
// self draw
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
|
||||
(*it)->visit(renderer, _modelViewTransform, dirty);
|
||||
(*it)->visit(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
_afterVisitCmd.init(_globalZOrder);
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
ClippingNode();
|
||||
|
|
|
@ -205,14 +205,14 @@ bool DrawNode::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void DrawNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
void DrawNode::onDraw(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
auto glProgram = getGLProgram();
|
||||
glProgram->use();
|
||||
|
|
|
@ -89,10 +89,10 @@ public:
|
|||
*/
|
||||
void setBlendFunc(const BlendFunc &blendFunc);
|
||||
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, uint32_t flags);
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
DrawNode();
|
||||
|
|
|
@ -264,8 +264,16 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
|
|||
_currentPageOrigY += _commonLineHeight;
|
||||
_currentPageOrigX = 0;
|
||||
if(_currentPageOrigY + _commonLineHeight >= CacheTextureHeight)
|
||||
{
|
||||
auto data = _currentPageData + CacheTextureWidth * (int)startY;
|
||||
{
|
||||
unsigned char *data = nullptr;
|
||||
if(pixelFormat == Texture2D::PixelFormat::AI88)
|
||||
{
|
||||
data = _currentPageData + CacheTextureWidth * (int)startY * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _currentPageData + CacheTextureWidth * (int)startY;
|
||||
}
|
||||
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
|
||||
CacheTextureWidth, CacheTextureHeight - startY);
|
||||
|
||||
|
@ -325,7 +333,15 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
|
|||
|
||||
if(existNewLetter)
|
||||
{
|
||||
auto data = _currentPageData + CacheTextureWidth * (int)startY;
|
||||
unsigned char *data = nullptr;
|
||||
if(pixelFormat == Texture2D::PixelFormat::AI88)
|
||||
{
|
||||
data = _currentPageData + CacheTextureWidth * (int)startY * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _currentPageData + CacheTextureWidth * (int)startY;
|
||||
}
|
||||
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
|
||||
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
|
||||
}
|
||||
|
|
|
@ -877,14 +877,14 @@ void Label::drawShadowWithoutBlur()
|
|||
setColor(oldColor);
|
||||
}
|
||||
|
||||
void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
||||
if(_insideBounds) {
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(Label::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
}
|
||||
|
@ -1019,7 +1019,7 @@ void Label::updateFont()
|
|||
_systemFontDirty = false;
|
||||
}
|
||||
|
||||
void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
||||
void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags)
|
||||
{
|
||||
if (_fontDefinition._fontFillColor != _textColor)
|
||||
{
|
||||
|
@ -1044,12 +1044,12 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
|||
}
|
||||
if (_shadowNode)
|
||||
{
|
||||
_shadowNode->visit(renderer, _modelViewTransform, parentTransformUpdated);
|
||||
_shadowNode->visit(renderer, _modelViewTransform, parentFlags);
|
||||
}
|
||||
_textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated);
|
||||
_textSprite->visit(renderer, _modelViewTransform, parentFlags);
|
||||
}
|
||||
|
||||
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (! _visible || _originalUTF8String.empty())
|
||||
{
|
||||
|
@ -1064,9 +1064,9 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
|
|||
updateContent();
|
||||
}
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || dirty))
|
||||
if (_shadowEnabled && _shadowBlurRadius <= 0 && (_shadowDirty || (flags & FLAGS_DIRTY_MASK)))
|
||||
{
|
||||
_position.x += _shadowOffset.width;
|
||||
_position.y += _shadowOffset.height;
|
||||
|
@ -1081,12 +1081,6 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
|
|||
_shadowDirty = false;
|
||||
}
|
||||
|
||||
if(dirty)
|
||||
{
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
}
|
||||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
|
@ -1099,11 +1093,11 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTr
|
|||
|
||||
if (_textSprite)
|
||||
{
|
||||
drawTextSprite(renderer,dirty);
|
||||
drawTextSprite(renderer, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
|
|
@ -237,8 +237,8 @@ public:
|
|||
|
||||
virtual Rect getBoundingBox() const override;
|
||||
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static Label* create(const std::string& text, const std::string& font, float fontSize,
|
||||
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
||||
|
@ -298,7 +298,7 @@ protected:
|
|||
|
||||
void drawShadowWithoutBlur();
|
||||
|
||||
void drawTextSprite(Renderer *renderer, bool parentTransformUpdated);
|
||||
void drawTextSprite(Renderer *renderer, uint32_t parentFlags);
|
||||
|
||||
void createSpriteWithFontDefinition();
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void LabelAtlas::updateColor()
|
|||
|
||||
//CCLabelAtlas - draw
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
AtlasNode::draw(renderer, transform, transformUpdated);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
virtual std::string getDescription() const override;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
|
|
@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const
|
|||
return _label->getBoundingBox();
|
||||
}
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Node::draw(renderer, transform, transformUpdated);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
|
||||
virtual std::string getDescription() const override;
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -262,14 +262,14 @@ void LabelTTF::setFlippedY(bool flippedY)
|
|||
}
|
||||
}
|
||||
|
||||
void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (_contentDirty)
|
||||
{
|
||||
this->setContentSize(_renderLabel->getContentSize());
|
||||
_contentDirty = false;
|
||||
}
|
||||
Node::visit(renderer,parentTransform,parentTransformUpdated);
|
||||
Node::visit(renderer,parentTransform, parentFlags);
|
||||
}
|
||||
|
||||
const Size& LabelTTF::getContentSize() const
|
||||
|
|
|
@ -150,7 +150,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
virtual const Size& getContentSize() const override;
|
||||
protected:
|
||||
Label* _renderLabel;
|
||||
|
|
|
@ -75,16 +75,9 @@ Layer::~Layer()
|
|||
|
||||
bool Layer::init()
|
||||
{
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
Director * director;
|
||||
CC_BREAK_IF(!(director = Director::getInstance()));
|
||||
this->setContentSize(director->getWinSize());
|
||||
// success
|
||||
ret = true;
|
||||
} while(0);
|
||||
return ret;
|
||||
Director * director = Director::getInstance();
|
||||
setContentSize(director->getWinSize());
|
||||
return true;
|
||||
}
|
||||
|
||||
Layer *Layer::create()
|
||||
|
@ -584,10 +577,10 @@ void LayerColor::updateColor()
|
|||
}
|
||||
}
|
||||
|
||||
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
|
||||
for(int i = 0; i < 4; ++i)
|
||||
|
@ -600,7 +593,7 @@ void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformU
|
|||
}
|
||||
}
|
||||
|
||||
void LayerColor::onDraw(const Mat4& transform, bool transformUpdated)
|
||||
void LayerColor::onDraw(const Mat4& transform, uint32_t flags)
|
||||
{
|
||||
getGLProgram()->use();
|
||||
getGLProgram()->setUniformsForBuiltins(transform);
|
||||
|
|
|
@ -270,7 +270,7 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
virtual void setContentSize(const Size & var) override;
|
||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||
|
@ -299,7 +299,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
bool initWithColor(const Color4B& color);
|
||||
|
||||
protected:
|
||||
void onDraw(const Mat4& transform, bool transformUpdated);
|
||||
void onDraw(const Mat4& transform, uint32_t flags);
|
||||
|
||||
virtual void updateColor() override;
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ void MotionStreak::reset()
|
|||
_nuPoints = 0;
|
||||
}
|
||||
|
||||
void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
void MotionStreak::onDraw(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
getGLProgram()->use();
|
||||
getGLProgram()->setUniformsForBuiltins(transform);
|
||||
|
@ -404,12 +404,12 @@ void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
|
||||
}
|
||||
|
||||
void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if(_nuPoints <= 1)
|
||||
return;
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
protected:
|
||||
//renderer callback
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, uint32_t flags);
|
||||
|
||||
bool _fastMode;
|
||||
bool _startingPositionInitialized;
|
||||
|
|
|
@ -121,6 +121,7 @@ Node::Node(void)
|
|||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(false)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
, _usingNormalizedPosition(false)
|
||||
{
|
||||
// set default scheduler and actionManager
|
||||
Director *director = Director::getInstance();
|
||||
|
@ -423,6 +424,7 @@ void Node::setPosition(const Vec2& position)
|
|||
|
||||
_position = position;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
_usingNormalizedPosition = false;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr && !_physicsBody->_positionResetTag)
|
||||
|
@ -498,6 +500,23 @@ void Node::setPositionZ(float positionZ)
|
|||
setGlobalZOrder(positionZ);
|
||||
}
|
||||
|
||||
/// position getter
|
||||
const Vec2& Node::getNormalizedPosition() const
|
||||
{
|
||||
return _normalizedPosition;
|
||||
}
|
||||
|
||||
/// position setter
|
||||
void Node::setNormalizedPosition(const Vec2& position)
|
||||
{
|
||||
if (_normalizedPosition.equals(position))
|
||||
return;
|
||||
|
||||
_normalizedPosition = position;
|
||||
_usingNormalizedPosition = true;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
||||
ssize_t Node::getChildrenCount() const
|
||||
{
|
||||
return _children.size();
|
||||
|
@ -561,7 +580,7 @@ void Node::setContentSize(const Size & size)
|
|||
_contentSize = size;
|
||||
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = _contentSizeDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,6 +594,7 @@ bool Node::isRunning() const
|
|||
void Node::setParent(Node * parent)
|
||||
{
|
||||
_parent = parent;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
||||
/// isRelativeAnchorPoint getter
|
||||
|
@ -943,7 +963,7 @@ void Node::draw()
|
|||
draw(renderer, _modelViewTransform, true);
|
||||
}
|
||||
|
||||
void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Node::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -954,7 +974,30 @@ void Node::visit()
|
|||
visit(renderer, parentTransform, true);
|
||||
}
|
||||
|
||||
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
uint32_t flags = parentFlags;
|
||||
flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0);
|
||||
flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0);
|
||||
|
||||
if(_usingNormalizedPosition && (flags & FLAGS_CONTENT_SIZE_DIRTY)) {
|
||||
CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes");
|
||||
auto s = _parent->getContentSize();
|
||||
_position.x = _normalizedPosition.x * s.width;
|
||||
_position.y = _normalizedPosition.y * s.height;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
||||
if(flags & FLAGS_DIRTY_MASK)
|
||||
_modelViewTransform = this->transform(parentTransform);
|
||||
|
||||
_transformUpdated = false;
|
||||
_contentSizeDirty = false;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -962,17 +1005,12 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra
|
|||
return;
|
||||
}
|
||||
|
||||
bool dirty = _transformUpdated || parentTransformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = this->transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
|
@ -987,24 +1025,21 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTra
|
|||
auto node = _children.at(i);
|
||||
|
||||
if ( node && node->_localZOrder < 0 )
|
||||
node->visit(renderer, _modelViewTransform, dirty);
|
||||
node->visit(renderer, _modelViewTransform, flags);
|
||||
else
|
||||
break;
|
||||
}
|
||||
// self draw
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
|
||||
(*it)->visit(renderer, _modelViewTransform, dirty);
|
||||
(*it)->visit(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
// reset for next frame
|
||||
_orderOfArrival = 0;
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
}
|
||||
|
||||
|
@ -1640,8 +1675,18 @@ void Node::updatePhysicsBodyRotation(Scene* scene)
|
|||
|
||||
void Node::setPhysicsBody(PhysicsBody* body)
|
||||
{
|
||||
if (_physicsBody == body)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (body != nullptr)
|
||||
{
|
||||
if (body->getNode() != nullptr)
|
||||
{
|
||||
body->getNode()->setPhysicsBody(nullptr);
|
||||
}
|
||||
|
||||
body->_node = this;
|
||||
body->retain();
|
||||
|
||||
|
@ -1683,6 +1728,11 @@ void Node::setPhysicsBody(PhysicsBody* body)
|
|||
}
|
||||
}
|
||||
|
||||
if (scene != nullptr)
|
||||
{
|
||||
scene->getPhysicsWorld()->addBody(body);
|
||||
}
|
||||
|
||||
updatePhysicsBodyPosition(scene);
|
||||
updatePhysicsBodyRotation(scene);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,12 @@ public:
|
|||
/// Default tag used for all the nodes
|
||||
static const int INVALID_TAG = -1;
|
||||
|
||||
enum {
|
||||
FLAGS_TRANSFORM_DIRTY = (1 << 0),
|
||||
FLAGS_CONTENT_SIZE_DIRTY = (1 << 1),
|
||||
|
||||
FLAGS_DIRTY_MASK = (FLAGS_TRANSFORM_DIRTY | FLAGS_CONTENT_SIZE_DIRTY),
|
||||
};
|
||||
/// @{
|
||||
/// @name Constructor, Destructor and Initializers
|
||||
|
||||
|
@ -283,6 +289,19 @@ public:
|
|||
* @param position The position (x,y) of the node in OpenGL coordinates
|
||||
*/
|
||||
virtual void setPosition(const Vec2 &position);
|
||||
|
||||
/** Sets the position (x,y) using values between 0 and 1.
|
||||
The positions in pixels is calculated like the following:
|
||||
@code
|
||||
// pseudo code
|
||||
void setNormalizedPosition(Vec2 pos) {
|
||||
Size s = getParent()->getContentSize();
|
||||
_position = pos * s;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
virtual void setNormalizedPosition(const Vec2 &position);
|
||||
|
||||
/**
|
||||
* Gets the position (x,y) of the node in its parent's coordinate system.
|
||||
*
|
||||
|
@ -294,6 +313,10 @@ public:
|
|||
* @endcode
|
||||
*/
|
||||
virtual const Vec2& getPosition() const;
|
||||
|
||||
/** returns the normalized position */
|
||||
virtual const Vec2& getNormalizedPosition() const;
|
||||
|
||||
/**
|
||||
* Sets the position (x,y) of the node in its parent's coordinate system.
|
||||
*
|
||||
|
@ -923,13 +946,13 @@ public:
|
|||
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
|
||||
* But if you enable any other GL state, you should disable it after drawing your node.
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated);
|
||||
virtual void draw(Renderer *renderer, const Mat4& transform, uint32_t flags);
|
||||
virtual void draw() final;
|
||||
|
||||
/**
|
||||
* Visits this node's children and draw them recursively.
|
||||
*/
|
||||
virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
|
||||
virtual void visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags);
|
||||
virtual void visit() final;
|
||||
|
||||
|
||||
|
@ -1362,6 +1385,7 @@ protected:
|
|||
Vec2 convertToWindowSpace(const Vec2& nodePoint) const;
|
||||
|
||||
Mat4 transform(const Mat4 &parentTransform);
|
||||
uint32_t processParentFlags(const Mat4& parentTransform, uint32_t parentFlags);
|
||||
|
||||
virtual void updateCascadeOpacity();
|
||||
virtual void disableCascadeOpacity();
|
||||
|
@ -1387,6 +1411,8 @@ protected:
|
|||
|
||||
Vec2 _position; ///< position of the node
|
||||
float _positionZ; ///< OpenGL real Z position
|
||||
Vec2 _normalizedPosition;
|
||||
bool _usingNormalizedPosition;
|
||||
|
||||
float _skewX; ///< skew angle on x-axis
|
||||
float _skewY; ///< skew angle on y-axis
|
||||
|
@ -1395,6 +1421,7 @@ protected:
|
|||
Vec2 _anchorPoint; ///< anchor point normalized (NOT in points)
|
||||
|
||||
Size _contentSize; ///< untransformed size of the node
|
||||
bool _contentSizeDirty; ///< whether or not the contentSize is dirty
|
||||
|
||||
Mat4 _modelViewTransform; ///< ModelView transform of the Node.
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw()
|
|||
}
|
||||
}
|
||||
|
||||
void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -94,7 +94,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool paren
|
|||
renderer->addCommand(&_groupCommand);
|
||||
renderer->pushGroup(_groupCommand.getRenderQueueID());
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
bool dirty = (parentFlags & FLAGS_TRANSFORM_DIRTY) || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = this->transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
void setTarget(Node *target);
|
||||
|
||||
// overrides
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
protected:
|
||||
NodeGrid();
|
||||
|
|
|
@ -145,7 +145,7 @@ The positions are updated at visit because:
|
|||
- using a timer is not guaranteed that it will called after all the positions were updated
|
||||
- overriding "draw" will only precise if the children have a z > 0
|
||||
*/
|
||||
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// Vec2 pos = position_;
|
||||
// Vec2 pos = [self convertToWorldSpace:Vec2::ZERO];
|
||||
|
@ -161,7 +161,7 @@ void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool p
|
|||
}
|
||||
_lastPosition = pos;
|
||||
}
|
||||
Node::visit(renderer, parentTransform, parentTransformUpdated);
|
||||
Node::visit(renderer, parentTransform, parentFlags);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
virtual void removeChild(Node* child, bool cleanup) override;
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
protected:
|
||||
/** Adds a child to the container with a z-order, a parallax ratio and a position offset
|
||||
|
|
|
@ -121,7 +121,7 @@ bool ParticleBatchNode::initWithFile(const std::string& fileImage, int capacity)
|
|||
|
||||
// override visit.
|
||||
// Don't call visit on it's children
|
||||
void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// CAREFUL:
|
||||
// This visit is almost identical to Node#visit
|
||||
|
@ -135,20 +135,16 @@ void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, b
|
|||
return;
|
||||
}
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
}
|
||||
|
@ -383,7 +379,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
|
|||
_textureAtlas->removeAllQuads();
|
||||
}
|
||||
|
||||
void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
CC_PROFILER_START("CCParticleBatchNode - draw");
|
||||
|
||||
|
|
|
@ -91,13 +91,13 @@ public:
|
|||
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
|
||||
|
||||
// Overrides
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
virtual void removeChild(Node* child, bool cleanup) override;
|
||||
virtual void reorderChild(Node * child, int zOrder) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual Texture2D* getTexture(void) const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
/**
|
||||
|
|
|
@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep()
|
|||
}
|
||||
|
||||
// overriding draw method
|
||||
void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad");
|
||||
//quad command
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
|
|
@ -500,7 +500,7 @@ Vec2 ProgressTimer::boundaryTexCoord(char index)
|
|||
return Vec2::ZERO;
|
||||
}
|
||||
|
||||
void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
void ProgressTimer::onDraw(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
|
||||
getGLProgram()->use();
|
||||
|
@ -551,13 +551,13 @@ void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if( ! _vertexData || ! _sprite)
|
||||
return;
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
inline Vec2 getBarChangeRate() const { return _barChangeRate; }
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual void setAnchorPoint(const Vec2& anchorPoint) override;
|
||||
virtual void setColor(const Color3B &color) override;
|
||||
virtual const Color3B& getColor() const override;
|
||||
|
@ -133,7 +133,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
bool initWithSprite(Sprite* sp);
|
||||
|
||||
protected:
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, uint32_t flags);
|
||||
|
||||
Tex2F textureCoordFromAlphaPoint(Vec2 alpha);
|
||||
Vec2 vertexFromAlphaPoint(Vec2 alpha);
|
||||
|
|
|
@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue)
|
|||
glClearStencil(stencilClearValue);
|
||||
}
|
||||
|
||||
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// override visit.
|
||||
// Don't call visit on its children
|
||||
|
@ -392,22 +392,17 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool
|
|||
return;
|
||||
}
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
Director* director = Director::getInstance();
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
_sprite->visit(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
_sprite->visit(renderer, _modelViewTransform, flags);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
|
@ -654,7 +649,7 @@ void RenderTexture::onClearDepth()
|
|||
glClearDepth(depthClearValue);
|
||||
}
|
||||
|
||||
void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if (_autoDraw)
|
||||
{
|
||||
|
@ -672,7 +667,7 @@ void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transfo
|
|||
for(const auto &child: _children)
|
||||
{
|
||||
if (child != _sprite)
|
||||
child->visit(renderer, transform, transformUpdated);
|
||||
child->visit(renderer, transform, flags);
|
||||
}
|
||||
|
||||
//End will pop the current render group
|
||||
|
|
|
@ -153,8 +153,8 @@ public:
|
|||
};
|
||||
|
||||
// Overrides
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
//flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix
|
||||
void setKeepMatrix(bool keepMatrix);
|
||||
|
|
|
@ -53,19 +53,17 @@ Scene::~Scene()
|
|||
|
||||
bool Scene::init()
|
||||
{
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
Director * director;
|
||||
CC_BREAK_IF( ! (director = Director::getInstance()) );
|
||||
this->setContentSize(director->getWinSize());
|
||||
// success
|
||||
ret = true;
|
||||
} while (0);
|
||||
return ret;
|
||||
auto size = Director::getInstance()->getWinSize();
|
||||
return initWithSize(size);
|
||||
}
|
||||
|
||||
Scene *Scene::create()
|
||||
bool Scene::initWithSize(const Size& size)
|
||||
{
|
||||
setContentSize(size);
|
||||
return true;
|
||||
}
|
||||
|
||||
Scene* Scene::create()
|
||||
{
|
||||
Scene *ret = new Scene();
|
||||
if (ret && ret->init())
|
||||
|
@ -80,6 +78,21 @@ Scene *Scene::create()
|
|||
}
|
||||
}
|
||||
|
||||
Scene* Scene::createWithSize(const Size& size)
|
||||
{
|
||||
Scene *ret = new Scene();
|
||||
if (ret && ret->initWithSize(size))
|
||||
{
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Scene::getDescription() const
|
||||
{
|
||||
return StringUtils::format("<Scene | tag = %d>", _tag);
|
||||
|
@ -106,7 +119,7 @@ void Scene::update(float delta)
|
|||
}
|
||||
}
|
||||
|
||||
Scene *Scene::createWithPhysics()
|
||||
Scene* Scene::createWithPhysics()
|
||||
{
|
||||
Scene *ret = new Scene();
|
||||
if (ret && ret->initWithPhysics())
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
/** creates a new Scene object */
|
||||
static Scene *create();
|
||||
|
||||
/** creates a new Scene object with a predefined Size */
|
||||
static Scene *createWithSize(const Size& size);
|
||||
|
||||
// Overrides
|
||||
virtual Scene *getScene() override;
|
||||
|
||||
|
@ -64,7 +67,8 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
Scene();
|
||||
virtual ~Scene();
|
||||
|
||||
virtual bool init() override;
|
||||
bool init();
|
||||
bool initWithSize(const Size& size);
|
||||
|
||||
protected:
|
||||
friend class Node;
|
||||
|
|
|
@ -585,10 +585,10 @@ void Sprite::updateTransform(void)
|
|||
|
||||
// draw
|
||||
|
||||
void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
||||
if(_insideBounds)
|
||||
{
|
||||
|
|
|
@ -420,7 +420,7 @@ public:
|
|||
virtual void setAnchorPoint(const Vec2& anchor) override;
|
||||
virtual void ignoreAnchorPointForPosition(bool value) override;
|
||||
virtual void setVisible(bool bVisible) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual void setOpacityModifyRGB(bool modify) override;
|
||||
virtual bool isOpacityModifyRGB(void) const override;
|
||||
/// @}
|
||||
|
|
|
@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode()
|
|||
|
||||
// override visit
|
||||
// don't call visit on it's children
|
||||
void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
|
||||
|
||||
|
@ -150,20 +150,16 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, boo
|
|||
|
||||
sortAllChildren();
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
setOrderOfArrival(0);
|
||||
|
@ -356,7 +352,7 @@ void SpriteBatchNode::reorderBatch(bool reorder)
|
|||
_reorderChildDirty=reorder;
|
||||
}
|
||||
|
||||
void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
// Optimization: Fast Dispatch
|
||||
if( _textureAtlas->getTotalQuads() == 0 )
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
*/
|
||||
virtual const BlendFunc& getBlendFunc() const override;
|
||||
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
using Node::addChild;
|
||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
virtual void removeChild(Node *child, bool cleanup) override;
|
||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||
virtual void sortAllChildren() override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
||||
|
|
|
@ -69,6 +69,13 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect,
|
|||
return spriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame::SpriteFrame(void)
|
||||
: _rotated(false)
|
||||
, _texture(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
|
|
|
@ -75,34 +75,6 @@ public:
|
|||
The originalSize is the size in points of the frame before being trimmed.
|
||||
*/
|
||||
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~SpriteFrame(void);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTexture(Texture2D* pobTexture, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture filename, rect in points;
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in points of the frame before being trimmed.
|
||||
*/
|
||||
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
|
||||
@since v1.1
|
||||
*/
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
|
||||
// attributes
|
||||
inline const Rect& getRectInPixels() const { return _rectInPixels; }
|
||||
|
@ -141,6 +113,39 @@ public:
|
|||
|
||||
// Overrides
|
||||
virtual SpriteFrame *clone() const override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
SpriteFrame(void);
|
||||
|
||||
/**
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~SpriteFrame(void);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTexture(Texture2D* pobTexture, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture filename, rect in points;
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in points of the frame before being trimmed.
|
||||
*/
|
||||
bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
|
||||
@since v1.1
|
||||
*/
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
protected:
|
||||
Vec2 _offset;
|
||||
|
|
|
@ -65,7 +65,7 @@ void SpriteFrameCache::destroyInstance()
|
|||
CC_SAFE_RELEASE_NULL(_sharedSpriteFrameCache);
|
||||
}
|
||||
|
||||
bool SpriteFrameCache::init(void)
|
||||
bool SpriteFrameCache::init()
|
||||
{
|
||||
_spriteFrames.reserve(20);
|
||||
_spriteFramesAliases.reserve(20);
|
||||
|
@ -73,7 +73,7 @@ bool SpriteFrameCache::init(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
SpriteFrameCache::~SpriteFrameCache(void)
|
||||
SpriteFrameCache::~SpriteFrameCache()
|
||||
{
|
||||
CC_SAFE_DELETE(_loadedFileNames);
|
||||
}
|
||||
|
@ -132,13 +132,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
ow = abs(ow);
|
||||
oh = abs(oh);
|
||||
// create frame
|
||||
spriteFrame = new SpriteFrame();
|
||||
spriteFrame->initWithTexture(texture,
|
||||
Rect(x, y, w, h),
|
||||
false,
|
||||
Vec2(ox, oy),
|
||||
Size((float)ow, (float)oh)
|
||||
);
|
||||
spriteFrame = SpriteFrame::createWithTexture(texture,
|
||||
Rect(x, y, w, h),
|
||||
false,
|
||||
Vec2(ox, oy),
|
||||
Size((float)ow, (float)oh)
|
||||
);
|
||||
}
|
||||
else if(format == 1 || format == 2)
|
||||
{
|
||||
|
@ -155,13 +154,12 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
Size sourceSize = SizeFromString(frameDict["sourceSize"].asString());
|
||||
|
||||
// create frame
|
||||
spriteFrame = new SpriteFrame();
|
||||
spriteFrame->initWithTexture(texture,
|
||||
frame,
|
||||
rotated,
|
||||
offset,
|
||||
sourceSize
|
||||
);
|
||||
spriteFrame = SpriteFrame::createWithTexture(texture,
|
||||
frame,
|
||||
rotated,
|
||||
offset,
|
||||
sourceSize
|
||||
);
|
||||
}
|
||||
else if (format == 3)
|
||||
{
|
||||
|
@ -186,26 +184,30 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
}
|
||||
|
||||
// create frame
|
||||
spriteFrame = new SpriteFrame();
|
||||
spriteFrame->initWithTexture(texture,
|
||||
Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height),
|
||||
textureRotated,
|
||||
spriteOffset,
|
||||
spriteSourceSize);
|
||||
spriteFrame = SpriteFrame::createWithTexture(texture,
|
||||
Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height),
|
||||
textureRotated,
|
||||
spriteOffset,
|
||||
spriteSourceSize);
|
||||
}
|
||||
|
||||
// add sprite frame
|
||||
_spriteFrames.insert(spriteFrameName, spriteFrame);
|
||||
spriteFrame->release();
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, Texture2D *texture)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
if (_loadedFileNames->find(plist) != _loadedFileNames->end())
|
||||
{
|
||||
return; // We already added it
|
||||
}
|
||||
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
|
||||
addSpriteFramesWithDictionary(dict, pobTexture);
|
||||
addSpriteFramesWithDictionary(dict, texture);
|
||||
_loadedFileNames->insert(plist);
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName)
|
||||
|
@ -223,13 +225,13 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const s
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist)
|
||||
{
|
||||
CCASSERT(pszPlist.size()>0, "plist filename should not be nullptr");
|
||||
CCASSERT(plist.size()>0, "plist filename should not be nullptr");
|
||||
|
||||
if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end())
|
||||
if (_loadedFileNames->find(plist) == _loadedFileNames->end())
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
|
||||
string texturePath("");
|
||||
|
@ -244,12 +246,12 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
|||
if (!texturePath.empty())
|
||||
{
|
||||
// build texture path relative to plist file
|
||||
texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), pszPlist);
|
||||
texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), plist);
|
||||
}
|
||||
else
|
||||
{
|
||||
// build texture path by replacing file extension
|
||||
texturePath = pszPlist;
|
||||
texturePath = plist;
|
||||
|
||||
// remove .xxx
|
||||
size_t startPos = texturePath.find_last_of(".");
|
||||
|
@ -266,7 +268,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
|||
if (texture)
|
||||
{
|
||||
addSpriteFramesWithDictionary(dict, texture);
|
||||
_loadedFileNames->insert(pszPlist);
|
||||
_loadedFileNames->insert(plist);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ class CC_DLL SpriteFrameCache : public Ref
|
|||
{
|
||||
public:
|
||||
/** Returns the shared instance of the Sprite Frame cache */
|
||||
static SpriteFrameCache* getInstance(void);
|
||||
static SpriteFrameCache* getInstance();
|
||||
|
||||
/** @deprecated Use getInstance() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE static SpriteFrameCache* sharedSpriteFrameCache() { return SpriteFrameCache::getInstance(); }
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual ~SpriteFrameCache();
|
||||
bool init(void);
|
||||
bool init();
|
||||
|
||||
public:
|
||||
/** Adds multiple Sprite Frames from a plist file.
|
||||
|
|
|
@ -263,13 +263,13 @@ void TextFieldTTF::setTextColor(const Color4B &color)
|
|||
Label::setTextColor(_colorText);
|
||||
}
|
||||
|
||||
void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void TextFieldTTF::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentTransformUpdated))
|
||||
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentFlags))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Label::visit(renderer,parentTransform,parentTransformUpdated);
|
||||
Label::visit(renderer,parentTransform,parentFlags);
|
||||
}
|
||||
|
||||
const Color4B& TextFieldTTF::getColorSpaceHolder()
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
/**
|
||||
@brief If the sender doesn't want to draw, return true.
|
||||
*/
|
||||
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
virtual bool onVisit(TextFieldTTF * sender,Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
CC_UNUSED_PARAM(sender);
|
||||
return false;
|
||||
|
@ -165,7 +165,7 @@ public:
|
|||
virtual void setSecureTextEntry(bool value);
|
||||
virtual bool isSecureTextEntry();
|
||||
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -103,16 +103,16 @@ void TransitionScene::sceneOrder()
|
|||
_isInSceneOnTop = true;
|
||||
}
|
||||
|
||||
void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionScene::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Scene::draw(renderer, transform, transformUpdated);
|
||||
Scene::draw(renderer, transform, flags);
|
||||
|
||||
if( _isInSceneOnTop ) {
|
||||
_outScene->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outScene->visit(renderer, transform, flags);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
} else {
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outScene->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
_outScene->visit(renderer, transform, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1261,7 @@ TransitionCrossFade* TransitionCrossFade::create(float t, Scene* scene)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionCrossFade::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
// override draw since both scenes (textures) are rendered in 1 scene
|
||||
}
|
||||
|
@ -1410,19 +1410,19 @@ void TransitionTurnOffTiles::onExit()
|
|||
TransitionScene::onExit();
|
||||
}
|
||||
|
||||
void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionTurnOffTiles::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Scene::draw(renderer, transform, transformUpdated);
|
||||
Scene::draw(renderer, transform, flags);
|
||||
|
||||
if( _isInSceneOnTop )
|
||||
{
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1490,10 +1490,10 @@ void TransitionSplitCols::switchTargetToInscene()
|
|||
_gridProxy->setTarget(_inScene);
|
||||
}
|
||||
|
||||
void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionSplitCols::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Scene::draw(renderer, transform, transformUpdated);
|
||||
_gridProxy->visit(renderer, transform, transformUpdated);
|
||||
Scene::draw(renderer, transform, flags);
|
||||
_gridProxy->visit(renderer, transform, flags);
|
||||
}
|
||||
|
||||
void TransitionSplitCols::onExit()
|
||||
|
@ -1606,19 +1606,19 @@ void TransitionFadeTR::onExit()
|
|||
TransitionScene::onExit();
|
||||
}
|
||||
|
||||
void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionFadeTR::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Scene::draw(renderer, transform, transformUpdated);
|
||||
Scene::draw(renderer, transform, flags);
|
||||
|
||||
if( _isInSceneOnTop )
|
||||
{
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
_inScene->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inScene->visit(renderer, transform, flags);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void cleanup() override;
|
||||
|
@ -613,7 +613,7 @@ public :
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -651,7 +651,7 @@ public :
|
|||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
protected:
|
||||
TransitionTurnOffTiles();
|
||||
|
@ -684,7 +684,7 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
|
||||
virtual void onExit() override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
protected:
|
||||
TransitionSplitCols();
|
||||
virtual ~TransitionSplitCols();
|
||||
|
@ -735,7 +735,7 @@ public:
|
|||
virtual void onEnter() override;
|
||||
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
|
||||
virtual void onExit() override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
protected:
|
||||
TransitionFadeTR();
|
||||
virtual ~TransitionFadeTR();
|
||||
|
|
|
@ -92,27 +92,27 @@ void TransitionPageTurn::onDisablePolygonOffset()
|
|||
glPolygonOffset(0, 0);
|
||||
}
|
||||
|
||||
void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void TransitionPageTurn::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Scene::draw(renderer, transform, transformUpdated);
|
||||
Scene::draw(renderer, transform, flags);
|
||||
|
||||
if( _isInSceneOnTop ) {
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
renderer->addCommand(&_enableOffsetCmd);
|
||||
_inSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inSceneProxy->visit(renderer, transform, flags);
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
renderer->addCommand(&_disableOffsetCmd);
|
||||
} else {
|
||||
_inSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_inSceneProxy->visit(renderer, transform, flags);
|
||||
|
||||
_enableOffsetCmd.init(_globalZOrder);
|
||||
_enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this);
|
||||
renderer->addCommand(&_enableOffsetCmd);
|
||||
|
||||
_outSceneProxy->visit(renderer, transform, transformUpdated);
|
||||
_outSceneProxy->visit(renderer, transform, flags);
|
||||
|
||||
_disableOffsetCmd.init(_globalZOrder);
|
||||
_disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this);
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
/**
|
||||
* Creates a base transition with duration and incoming scene.
|
||||
|
|
|
@ -218,6 +218,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="..\base\ccUtils.cpp" />
|
||||
<ClCompile Include="..\base\CCValue.cpp" />
|
||||
<ClCompile Include="..\base\etc1.cpp" />
|
||||
<ClCompile Include="..\base\ObjectFactory.cpp" />
|
||||
<ClCompile Include="..\base\s3tc.cpp" />
|
||||
<ClCompile Include="..\base\TGAlib.cpp" />
|
||||
<ClCompile Include="..\base\ZipUtils.cpp" />
|
||||
|
@ -399,6 +400,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="..\base\CCVector.h" />
|
||||
<ClInclude Include="..\base\etc1.h" />
|
||||
<ClInclude Include="..\base\firePngData.h" />
|
||||
<ClInclude Include="..\base\ObjectFactory.h" />
|
||||
<ClInclude Include="..\base\s3tc.h" />
|
||||
<ClInclude Include="..\base\TGAlib.h" />
|
||||
<ClInclude Include="..\base\uthash.h" />
|
||||
|
|
|
@ -565,6 +565,9 @@
|
|||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\ObjectFactory.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -1144,6 +1147,9 @@
|
|||
<ClInclude Include="..\3d\CCSprite3DDataCache.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\ObjectFactory.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -603,7 +603,8 @@ std::string ObjLoader::LoadObj(shapes_t& shapes, const char* filename, const cha
|
|||
|
||||
std::vector<vertex_index> face;
|
||||
while (!isNewLine(token[0])) {
|
||||
vertex_index vi = parseTriple(token, v.size() / 3, vn.size() / 3, vt.size() / 2);
|
||||
// fix warning, cast to int, i think int is enough
|
||||
vertex_index vi = parseTriple(token, (int)v.size() / 3, (int)vn.size() / 3, (int)vt.size() / 2);
|
||||
face.push_back(vi);
|
||||
auto n = strspn(token, " \t\r");
|
||||
token += n;
|
||||
|
|
|
@ -279,7 +279,7 @@ void Sprite3D::setTexture(Texture2D* texture)
|
|||
}
|
||||
}
|
||||
|
||||
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
GLProgramState* programstate = getGLProgramState();
|
||||
Color4F color(getDisplayedColor());
|
||||
|
|
|
@ -73,7 +73,7 @@ protected:
|
|||
//load from .c3b or .c3t
|
||||
bool loadFromC3x(const std::string& path);
|
||||
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
virtual GLProgram* getDefaultGLProgram(bool textured = true);
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ base/ccUTF8.cpp \
|
|||
base/ccUtils.cpp \
|
||||
base/etc1.cpp \
|
||||
base/s3tc.cpp \
|
||||
base/ObjectFactory.cpp \
|
||||
renderer/CCBatchCommand.cpp \
|
||||
renderer/CCCustomCommand.cpp \
|
||||
renderer/CCGLProgram.cpp \
|
||||
|
|
|
@ -111,8 +111,7 @@ PoolManager* PoolManager::getInstance()
|
|||
{
|
||||
s_singleInstance = new PoolManager();
|
||||
// Add the first auto release pool
|
||||
s_singleInstance->_curReleasePool = new AutoreleasePool("cocos2d autorelease pool");
|
||||
s_singleInstance->_releasePoolStack.push_back(s_singleInstance->_curReleasePool);
|
||||
new AutoreleasePool("cocos2d autorelease pool");
|
||||
}
|
||||
return s_singleInstance;
|
||||
}
|
||||
|
@ -125,6 +124,7 @@ void PoolManager::destroyInstance()
|
|||
|
||||
PoolManager::PoolManager()
|
||||
{
|
||||
_releasePoolStack.reserve(10);
|
||||
}
|
||||
|
||||
PoolManager::~PoolManager()
|
||||
|
@ -134,7 +134,6 @@ PoolManager::~PoolManager()
|
|||
while (!_releasePoolStack.empty())
|
||||
{
|
||||
AutoreleasePool* pool = _releasePoolStack.back();
|
||||
_releasePoolStack.pop_back();
|
||||
|
||||
delete pool;
|
||||
}
|
||||
|
@ -143,7 +142,7 @@ PoolManager::~PoolManager()
|
|||
|
||||
AutoreleasePool* PoolManager::getCurrentPool() const
|
||||
{
|
||||
return _curReleasePool;
|
||||
return _releasePoolStack.back();
|
||||
}
|
||||
|
||||
bool PoolManager::isObjectInPools(Ref* obj) const
|
||||
|
@ -159,21 +158,12 @@ bool PoolManager::isObjectInPools(Ref* obj) const
|
|||
void PoolManager::push(AutoreleasePool *pool)
|
||||
{
|
||||
_releasePoolStack.push_back(pool);
|
||||
_curReleasePool = pool;
|
||||
}
|
||||
|
||||
void PoolManager::pop()
|
||||
{
|
||||
// Can not pop the pool that created by engine
|
||||
CC_ASSERT(_releasePoolStack.size() >= 1);
|
||||
|
||||
CC_ASSERT(!_releasePoolStack.empty());
|
||||
_releasePoolStack.pop_back();
|
||||
|
||||
// Should update _curReleasePool if a temple pool is released
|
||||
if (_releasePoolStack.size() > 1)
|
||||
{
|
||||
_curReleasePool = _releasePoolStack.back();
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -163,8 +163,7 @@ private:
|
|||
|
||||
static PoolManager* s_singleInstance;
|
||||
|
||||
std::deque<AutoreleasePool*> _releasePoolStack;
|
||||
AutoreleasePool *_curReleasePool;
|
||||
std::vector<AutoreleasePool*> _releasePoolStack;
|
||||
};
|
||||
|
||||
// end of base_nodes group
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "base/base64.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
extern const char* cocos2dVersion(void);
|
||||
//TODO: these general utils should be in a seperate class
|
||||
//
|
||||
// Trimming functions were taken from: http://stackoverflow.com/a/217605
|
||||
|
@ -295,6 +296,9 @@ Console::Console()
|
|||
{ "director", "director commands, type -h or [director help] to list supported directives", std::bind(&Console::commandDirector, this, std::placeholders::_1, std::placeholders::_2) },
|
||||
{ "touch", "simulate touch event via console, type -h or [touch help] to list supported directives", std::bind(&Console::commandTouch, this, std::placeholders::_1, std::placeholders::_2) },
|
||||
{ "upload", "upload file. Args: [filename base64_encoded_data]", std::bind(&Console::commandUpload, this, std::placeholders::_1) },
|
||||
{ "version", "print version string ", [](int fd, const std::string& args) {
|
||||
mydprintf(fd, "%s\n", cocos2dVersion());
|
||||
} },
|
||||
};
|
||||
|
||||
;
|
||||
|
|
|
@ -92,7 +92,8 @@ Director* Director::getInstance()
|
|||
{
|
||||
if (!s_SharedDirector)
|
||||
{
|
||||
s_SharedDirector = new DisplayLinkDirector();
|
||||
s_SharedDirector = new (std::nothrow) DisplayLinkDirector();
|
||||
CCASSERT(s_SharedDirector, "FATAL: Not enough memory");
|
||||
s_SharedDirector->init();
|
||||
}
|
||||
|
||||
|
@ -1091,9 +1092,9 @@ void Director::showStats()
|
|||
|
||||
Mat4 identity = Mat4::IDENTITY;
|
||||
|
||||
_drawnVerticesLabel->visit(_renderer, identity, false);
|
||||
_drawnBatchesLabel->visit(_renderer, identity, false);
|
||||
_FPSLabel->visit(_renderer, identity, false);
|
||||
_drawnVerticesLabel->visit(_renderer, identity, 0);
|
||||
_drawnBatchesLabel->visit(_renderer, identity, 0);
|
||||
_FPSLabel->visit(_renderer, identity, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -465,13 +465,28 @@ void Scheduler::schedulePerFrame(const ccSchedulerFunc& callback, void *target,
|
|||
HASH_FIND_PTR(_hashForUpdates, &target, hashElement);
|
||||
if (hashElement)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
CCASSERT(hashElement->entry->markedForDeletion,"");
|
||||
#endif
|
||||
// TODO: check if priority has changed!
|
||||
|
||||
hashElement->entry->markedForDeletion = false;
|
||||
return;
|
||||
// check if priority has changed
|
||||
if ((*hashElement->list)->priority != priority)
|
||||
{
|
||||
if (_updateHashLocked)
|
||||
{
|
||||
CCLOG("warning: you CANNOT change update priority in scheduled function");
|
||||
hashElement->entry->markedForDeletion = false;
|
||||
hashElement->entry->paused = paused;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// will be added again outside if (hashElement).
|
||||
unscheduleUpdate(target);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hashElement->entry->markedForDeletion = false;
|
||||
hashElement->entry->paused = paused;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// most of the updates are going to be 0, that's way there
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
#include "tinyxml2.h"
|
||||
#include "base/base64.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC && CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
|
||||
|
||||
// root name of xml
|
||||
#define USERDEFAULT_ROOT_NAME "userDefaultRoot"
|
||||
|
|
|
@ -41,4 +41,5 @@ set(COCOS_BASE_SRC
|
|||
base/ccUtils.cpp
|
||||
base/etc1.cpp
|
||||
base/s3tc.cpp
|
||||
base/ObjectFactory.cpp
|
||||
)
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ObjectFactory.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
ObjectFactory::TInfo::TInfo(void)
|
||||
:_class("")
|
||||
,_fun(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins)
|
||||
:_class(type)
|
||||
,_fun(ins)
|
||||
{
|
||||
ObjectFactory::getInstance()->registerType(*this);
|
||||
}
|
||||
|
||||
ObjectFactory::TInfo::TInfo(const TInfo &t)
|
||||
{
|
||||
_class = t._class;
|
||||
_fun = t._fun;
|
||||
}
|
||||
|
||||
ObjectFactory::TInfo::~TInfo(void)
|
||||
{
|
||||
_class = "";
|
||||
_fun = nullptr;
|
||||
}
|
||||
|
||||
ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t)
|
||||
{
|
||||
_class = t._class;
|
||||
_fun = t._fun;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ObjectFactory* ObjectFactory::_sharedFactory = nullptr;
|
||||
|
||||
ObjectFactory::ObjectFactory(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ObjectFactory::~ObjectFactory(void)
|
||||
{
|
||||
_typeMap.clear();
|
||||
}
|
||||
|
||||
ObjectFactory* ObjectFactory::getInstance()
|
||||
{
|
||||
if ( nullptr == _sharedFactory)
|
||||
{
|
||||
_sharedFactory = new ObjectFactory();
|
||||
}
|
||||
return _sharedFactory;
|
||||
}
|
||||
|
||||
void ObjectFactory::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(_sharedFactory);
|
||||
}
|
||||
|
||||
Ref* ObjectFactory::createObject(const std::string &name)
|
||||
{
|
||||
Ref *o = nullptr;
|
||||
do
|
||||
{
|
||||
const TInfo t = _typeMap[name];
|
||||
CC_BREAK_IF(t._fun == nullptr);
|
||||
o = t._fun();
|
||||
} while (0);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
void ObjectFactory::registerType(const TInfo &t)
|
||||
{
|
||||
_typeMap.insert(std::make_pair(t._class, t));
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -22,27 +22,47 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __UISCROLLDELEGATE_H__
|
||||
#define __UISCROLLDELEGATE_H__
|
||||
#ifndef __TRIGGERFACTORY_H__
|
||||
#define __TRIGGERFACTORY_H__
|
||||
|
||||
#include "ui/UIWidget.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "base/CCRef.h"
|
||||
#include "base/CCPlatformMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
class ScrollViewProtocol
|
||||
class ObjectFactory
|
||||
{
|
||||
public:
|
||||
virtual ~ScrollViewProtocol() {}
|
||||
typedef cocos2d::Ref* (*Instance)(void);
|
||||
struct TInfo
|
||||
{
|
||||
TInfo(void);
|
||||
TInfo(const std::string& type, Instance ins = NULL);
|
||||
TInfo(const TInfo &t);
|
||||
~TInfo(void);
|
||||
TInfo& operator= (const TInfo &t);
|
||||
std::string _class;
|
||||
Instance _fun;
|
||||
};
|
||||
typedef std::unordered_map<std::string, TInfo> FactoryMap;
|
||||
|
||||
static ObjectFactory* getInstance();
|
||||
static void destroyInstance();
|
||||
cocos2d::Ref* createObject(const std::string &name);
|
||||
|
||||
void registerType(const TInfo &t);
|
||||
void removeAll();
|
||||
|
||||
protected:
|
||||
virtual void handlePressLogic(const Vec2 &touchPoint) = 0;
|
||||
virtual void handleMoveLogic(const Vec2 &touchPoint) = 0;
|
||||
virtual void handleReleaseLogic(const Vec2 &touchPoint) = 0;
|
||||
ObjectFactory(void);
|
||||
virtual ~ObjectFactory(void);
|
||||
private:
|
||||
static ObjectFactory *_sharedFactory;
|
||||
FactoryMap _typeMap;
|
||||
};
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif /* defined(__UIScrollDelegate__) */
|
||||
#endif
|
|
@ -328,7 +328,7 @@ struct BlendFunc
|
|||
|
||||
bool operator<(const BlendFunc &a) const
|
||||
{
|
||||
return src < a.src || (src < a.src && dst < a.dst);
|
||||
return src < a.src || (src == a.src && dst < a.dst);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ THE SOFTWARE.
|
|||
#define __COCOS2D_H__
|
||||
|
||||
// 0x00 HI ME LO
|
||||
// 00 03 01 00
|
||||
#define COCOS2D_VERSION 0x00030100
|
||||
// 00 03 02 00
|
||||
#define COCOS2D_VERSION 0x00030200
|
||||
|
||||
//
|
||||
// all cocos2d include files
|
||||
|
|
|
@ -36,7 +36,6 @@ CCInputDelegate.cpp \
|
|||
DictionaryHelper.cpp \
|
||||
CCSGUIReader.cpp \
|
||||
CCSSceneReader.cpp \
|
||||
ObjectFactory.cpp \
|
||||
TriggerBase.cpp \
|
||||
TriggerMng.cpp \
|
||||
TriggerObj.cpp \
|
||||
|
|
|
@ -378,7 +378,7 @@ void Armature::update(float dt)
|
|||
_armatureTransformDirty = false;
|
||||
}
|
||||
|
||||
void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if (_parentBone == nullptr && _batchNode == nullptr)
|
||||
{
|
||||
|
@ -408,17 +408,17 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra
|
|||
{
|
||||
skin->setBlendFunc(bone->getBlendFunc());
|
||||
}
|
||||
skin->draw(renderer, transform, transformUpdated);
|
||||
skin->draw(renderer, transform, flags);
|
||||
}
|
||||
break;
|
||||
case CS_DISPLAY_ARMATURE:
|
||||
{
|
||||
node->draw(renderer, transform, transformUpdated);
|
||||
node->draw(renderer, transform, flags);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
node->visit(renderer, transform, transformUpdated);
|
||||
node->visit(renderer, transform, flags);
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
}
|
||||
break;
|
||||
|
@ -426,7 +426,7 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool tra
|
|||
}
|
||||
else if(Node *node = dynamic_cast<Node *>(object))
|
||||
{
|
||||
node->visit(renderer, transform, transformUpdated);
|
||||
node->visit(renderer, transform, flags);
|
||||
// CC_NODE_DRAW_SETUP();
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ void Armature::onExit()
|
|||
}
|
||||
|
||||
|
||||
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -453,10 +453,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b
|
|||
return;
|
||||
}
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
|
@ -468,7 +465,7 @@ void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, b
|
|||
|
||||
|
||||
sortAllChildren();
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
// reset for next frame
|
||||
_orderOfArrival = 0;
|
||||
|
|
|
@ -157,8 +157,8 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
|
||||
virtual void update(float dt) override;
|
||||
|
||||
virtual void onEnter() override;
|
||||
|
|
|
@ -101,7 +101,7 @@ void BatchNode::removeChild(Node* child, bool cleanup)
|
|||
Node::removeChild(child, cleanup);
|
||||
}
|
||||
|
||||
void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -109,21 +109,17 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare
|
|||
return;
|
||||
}
|
||||
|
||||
bool dirty = parentTransformUpdated || _transformUpdated;
|
||||
if(dirty)
|
||||
_modelViewTransform = transform(parentTransform);
|
||||
_transformUpdated = false;
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Mat4 stack,
|
||||
// but it is deprecated and your code should not rely on it
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
sortAllChildren();
|
||||
draw(renderer, _modelViewTransform, dirty);
|
||||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
// reset for next frame
|
||||
_orderOfArrival = 0;
|
||||
|
@ -131,7 +127,7 @@ void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool pare
|
|||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
}
|
||||
|
||||
void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void BatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
if (_children.empty())
|
||||
{
|
||||
|
@ -152,14 +148,14 @@ void BatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUp
|
|||
pushed = true;
|
||||
}
|
||||
|
||||
armature->visit(renderer, transform, transformUpdated);
|
||||
armature->visit(renderer, transform, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer->popGroup();
|
||||
pushed = false;
|
||||
|
||||
((Node *)object)->visit(renderer, transform, transformUpdated);
|
||||
((Node *)object)->visit(renderer, transform, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ public:
|
|||
virtual void addChild(cocos2d::Node *pChild, int zOrder) override;
|
||||
virtual void addChild(cocos2d::Node *pChild, int zOrder, int tag) override;
|
||||
virtual void removeChild(cocos2d::Node* child, bool cleanup) override;
|
||||
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
protected:
|
||||
void generateGroupCommand();
|
||||
|
|
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "cocostudio/CCComAttribute.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
@ -166,7 +167,7 @@ bool ComAttribute::serialize(void* r)
|
|||
std::string filePath;
|
||||
if (file != nullptr)
|
||||
{
|
||||
filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file));
|
||||
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
||||
}
|
||||
int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
||||
CC_BREAK_IF(resType != 0);
|
||||
|
|
|
@ -26,6 +26,8 @@ THE SOFTWARE.
|
|||
#define __CC_EXTENTIONS_CCCOMATTRIBUTE_H__
|
||||
|
||||
#include "CCComBase.h"
|
||||
#include "2d/CCComponent.h"
|
||||
#include "base/CCValue.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocostudio/CCComAudio.h"
|
||||
#include "audio/include/SimpleAudioEngine.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
@ -91,7 +92,7 @@ bool ComAudio::serialize(void* r)
|
|||
std::string filePath;
|
||||
if (file != nullptr)
|
||||
{
|
||||
filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file));
|
||||
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
||||
}
|
||||
int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
||||
CC_BREAK_IF(resType != 0);
|
||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
|||
#define __CC_EXTENTIONS_CCCOMAUDIO_H__
|
||||
|
||||
#include "CCComBase.h"
|
||||
#include "2d/CCComponent.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ THE SOFTWARE.
|
|||
#ifndef __CC_EXTENTIONS_CCCOMBASE_H__
|
||||
#define __CC_EXTENTIONS_CCCOMBASE_H__
|
||||
|
||||
#include "ObjectFactory.h"
|
||||
#include "DictionaryHelper.h"
|
||||
#include <string>
|
||||
#include "DictionaryHelper.h"
|
||||
#include "base/ObjectFactory.h"
|
||||
|
||||
|
||||
#define DECLARE_CLASS_COMPONENT_INFO \
|
||||
public: \
|
||||
static cocostudio::ObjectFactory::TInfo Type; \
|
||||
static cocos2d::ObjectFactory::TInfo Type; \
|
||||
static cocos2d::Ref* createInstance(void); \
|
||||
|
||||
#define IMPLEMENT_CLASS_COMPONENT_INFO(className) \
|
||||
|
@ -40,10 +40,10 @@ THE SOFTWARE.
|
|||
{ \
|
||||
return className::create(); \
|
||||
} \
|
||||
cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
cocos2d::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
|
||||
#define CREATE_CLASS_COMPONENT_INFO(className) \
|
||||
cocostudio::ObjectFactory::TInfo(#className, &className::createInstance)
|
||||
cocos2d::ObjectFactory::TInfo(#className, &className::createInstance)
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "cocostudio/CCComController.h"
|
||||
#include "2d/CCNode.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCComBase.h"
|
||||
#include "cocostudio/CCInputDelegate.h"
|
||||
#include "2d/CCComponent.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
|||
#define __CC_EXTENTIONS_CCCOMRENDER_H__
|
||||
|
||||
#include "CCComBase.h"
|
||||
#include "2d/CCComponent.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
|
|
@ -216,6 +216,58 @@ Widget* GUIReader::widgetFromJsonFile(const char *fileName)
|
|||
CC_SAFE_DELETE(pReader);
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string WidgetPropertiesReader::getGUIClassName(const std::string &name)
|
||||
{
|
||||
std::string convertedClassName = name;
|
||||
if (name == "Panel")
|
||||
{
|
||||
convertedClassName = "Layout";
|
||||
}
|
||||
else if (name == "TextArea")
|
||||
{
|
||||
convertedClassName = "Text";
|
||||
}
|
||||
else if (name == "TextButton")
|
||||
{
|
||||
convertedClassName = "Button";
|
||||
}
|
||||
else if (name == "Label")
|
||||
{
|
||||
convertedClassName = "Text";
|
||||
}
|
||||
else if (name == "LabelAtlas")
|
||||
{
|
||||
convertedClassName = "TextAtlas";
|
||||
}
|
||||
else if (name == "LabelBMFont")
|
||||
{
|
||||
convertedClassName = "TextBMFont";
|
||||
}
|
||||
|
||||
|
||||
return convertedClassName;
|
||||
}
|
||||
|
||||
cocos2d::ui::Widget* WidgetPropertiesReader::createGUI(const std::string &classname)
|
||||
{
|
||||
std::string name = this->getGUIClassName(classname);
|
||||
|
||||
Ref* object = ObjectFactory::getInstance()->createObject(name);
|
||||
|
||||
return dynamic_cast<ui::Widget*>(object);
|
||||
}
|
||||
|
||||
WidgetReaderProtocol* WidgetPropertiesReader::createWidgetReaderProtocol(const std::string &classname)
|
||||
{
|
||||
Ref* object = ObjectFactory::getInstance()->createObject(classname);
|
||||
|
||||
return dynamic_cast<WidgetReaderProtocol*>(object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void WidgetPropertiesReader::setAnchorPointForWidget(cocos2d::ui::Widget *widget, const rapidjson::Value &options)
|
||||
|
@ -1001,7 +1053,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
|
|||
{
|
||||
const char* classname = DICTOOL->getStringValue_json(data, "classname");
|
||||
const rapidjson::Value& uiOptions = DICTOOL->getSubDictionary_json(data, "options");
|
||||
Widget* widget = ObjectFactory::getInstance()->createGUI(classname);
|
||||
Widget* widget = this->createGUI(classname);
|
||||
|
||||
// create widget reader to parse properties of widget
|
||||
std::string readerName = classname;
|
||||
|
@ -1030,7 +1082,8 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
|
|||
readerName = "TextBMFont";
|
||||
}
|
||||
readerName.append("Reader");
|
||||
WidgetReaderProtocol* reader = ObjectFactory::getInstance()->createWidgetReaderProtocol(readerName);
|
||||
|
||||
WidgetReaderProtocol* reader = this->createWidgetReaderProtocol(readerName);
|
||||
|
||||
if (reader)
|
||||
{
|
||||
|
@ -1096,7 +1149,9 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
|
|||
{
|
||||
readerName = "WidgetReader";
|
||||
}
|
||||
reader = ObjectFactory::getInstance()->createWidgetReaderProtocol(readerName);
|
||||
|
||||
reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
|
||||
setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions);
|
||||
|
||||
// 2nd., custom widget parse with custom reader
|
||||
|
|
|
@ -28,10 +28,12 @@ THE SOFTWARE.
|
|||
#include "ui/UIWidget.h"
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
#include "WidgetReader/WidgetReaderProtocol.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "base/ObjectFactory.h"
|
||||
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
||||
#define kCCSVersion 1.0
|
||||
|
||||
typedef void (cocos2d::Ref::*SEL_ParseEvent)(const std::string&, cocos2d::Ref*, const rapidjson::Value&);
|
||||
|
@ -59,7 +61,7 @@ public:
|
|||
|
||||
const std::string& getFilePath() const { return m_strFilePath; };
|
||||
void registerTypeAndCallBack(const std::string& classType,
|
||||
ObjectFactory::Instance ins,
|
||||
cocos2d::ObjectFactory::Instance ins,
|
||||
Ref* object,
|
||||
SEL_ParseEvent callBack);
|
||||
|
||||
|
@ -94,6 +96,10 @@ public:
|
|||
protected:
|
||||
void setAnchorPointForWidget(cocos2d::ui::Widget* widget, const rapidjson::Value&options);
|
||||
|
||||
std::string getGUIClassName(const std::string& name);
|
||||
cocos2d::ui::Widget *createGUI(const std::string& classname);
|
||||
WidgetReaderProtocol* createWidgetReaderProtocol(const std::string& classname);
|
||||
|
||||
protected:
|
||||
std::string m_strFilePath;
|
||||
};
|
||||
|
|
|
@ -110,7 +110,44 @@ Node* SceneReader::nodeByTag(Node *parent, int tag)
|
|||
}
|
||||
return _retNode;
|
||||
}
|
||||
|
||||
|
||||
cocos2d::Component* SceneReader::createComponent(const std::string classname)
|
||||
{
|
||||
std::string name = this->getComponentClassName(classname);
|
||||
Ref *object = ObjectFactory::getInstance()->createObject(name);
|
||||
|
||||
return dynamic_cast<Component*>(object);
|
||||
}
|
||||
std::string SceneReader::getComponentClassName(const std::string &name)
|
||||
{
|
||||
std::string comName;
|
||||
if (name == "CCSprite" || name == "CCTMXTiledMap" || name == "CCParticleSystemQuad" || name == "CCArmature" || name == "GUIComponent")
|
||||
{
|
||||
comName = "ComRender";
|
||||
}
|
||||
else if (name == "CCComAudio" || name == "CCBackgroundAudio")
|
||||
{
|
||||
comName = "ComAudio";
|
||||
}
|
||||
else if (name == "CCComController")
|
||||
{
|
||||
comName = "ComController";
|
||||
}
|
||||
else if (name == "CCComAttribute")
|
||||
{
|
||||
comName = "ComAttribute";
|
||||
}
|
||||
else if (name == "CCScene")
|
||||
{
|
||||
comName = "Scene";
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "Unregistered Component!");
|
||||
}
|
||||
|
||||
return comName;
|
||||
}
|
||||
|
||||
Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent, AttachComponentType attachComponent)
|
||||
{
|
||||
|
@ -134,7 +171,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
|||
break;
|
||||
}
|
||||
const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
|
||||
Component *com = ObjectFactory::getInstance()->createComponent(comName);
|
||||
Component *com = this->createComponent(comName);
|
||||
if (com != nullptr)
|
||||
{
|
||||
if (com->serialize((void*)(&subDict)))
|
||||
|
|
|
@ -68,6 +68,10 @@ public:
|
|||
private:
|
||||
SceneReader(void);
|
||||
virtual ~SceneReader(void);
|
||||
std::string getComponentClassName(const std::string& name);
|
||||
|
||||
cocos2d::Component* createComponent(const std::string classname);
|
||||
|
||||
|
||||
cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent, AttachComponentType attachComponent);
|
||||
void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node);
|
||||
|
|
|
@ -219,7 +219,7 @@ Mat4 Skin::getNodeToWorldTransformAR() const
|
|||
return TransformConcat( _bone->getArmature()->getNodeToWorldTransform(),displayTransform);
|
||||
}
|
||||
|
||||
void Skin::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Skin::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
Mat4 mv = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
cocos2d::Mat4 getNodeToWorldTransform() const override;
|
||||
cocos2d::Mat4 getNodeToWorldTransformAR() const;
|
||||
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
|
|
@ -30,7 +30,6 @@ set(CS_SRC
|
|||
DictionaryHelper.cpp
|
||||
CCSGUIReader.cpp
|
||||
CCSSceneReader.cpp
|
||||
ObjectFactory.cpp
|
||||
TriggerBase.cpp
|
||||
TriggerMng.cpp
|
||||
TriggerObj.cpp
|
||||
|
|
|
@ -27,14 +27,14 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "cocostudio/CocoStudio.h"
|
||||
#include "ObjectFactory.h"
|
||||
#include "base/ObjectFactory.h"
|
||||
#include "TriggerObj.h"
|
||||
#include "TriggerMng.h"
|
||||
|
||||
|
||||
#define DECLARE_CLASS_INFO \
|
||||
public: \
|
||||
static cocostudio::ObjectFactory::TInfo Type; \
|
||||
static cocos2d::ObjectFactory::TInfo Type; \
|
||||
static cocos2d::Ref* createInstance(void); \
|
||||
|
||||
#define IMPLEMENT_CLASS_INFO(className) \
|
||||
|
@ -44,7 +44,7 @@ THE SOFTWARE.
|
|||
ret->autorelease(); \
|
||||
return ret; \
|
||||
} \
|
||||
cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
cocos2d::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \
|
||||
|
||||
|
||||
void sendEvent(unsigned int event);
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
<ClCompile Include="..\CCTween.cpp" />
|
||||
<ClCompile Include="..\CCUtilMath.cpp" />
|
||||
<ClCompile Include="..\DictionaryHelper.cpp" />
|
||||
<ClCompile Include="..\ObjectFactory.cpp" />
|
||||
<ClCompile Include="..\TriggerBase.cpp" />
|
||||
<ClCompile Include="..\TriggerMng.cpp" />
|
||||
<ClCompile Include="..\TriggerObj.cpp" />
|
||||
|
@ -207,4 +206,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -177,9 +177,6 @@
|
|||
<ClCompile Include="..\CCActionObject.cpp">
|
||||
<Filter>action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ObjectFactory.cpp">
|
||||
<Filter>trigger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TriggerBase.cpp">
|
||||
<Filter>trigger</Filter>
|
||||
</ClCompile>
|
||||
|
@ -417,4 +414,4 @@
|
|||
<Filter>reader\WidgetReader\PageViewReader</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -194,7 +194,6 @@
|
|||
<ClCompile Include="..\CCTween.cpp" />
|
||||
<ClCompile Include="..\CCUtilMath.cpp" />
|
||||
<ClCompile Include="..\DictionaryHelper.cpp" />
|
||||
<ClCompile Include="..\ObjectFactory.cpp" />
|
||||
<ClCompile Include="..\TriggerBase.cpp" />
|
||||
<ClCompile Include="..\TriggerMng.cpp" />
|
||||
<ClCompile Include="..\TriggerObj.cpp" />
|
||||
|
@ -283,4 +282,4 @@
|
|||
<ClInclude Include="..\WidgetReader\WidgetReaderProtocol.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -177,9 +177,6 @@
|
|||
<ClCompile Include="..\CCActionObject.cpp">
|
||||
<Filter>action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ObjectFactory.cpp">
|
||||
<Filter>trigger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TriggerBase.cpp">
|
||||
<Filter>trigger</Filter>
|
||||
</ClCompile>
|
||||
|
@ -419,4 +416,4 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -125,15 +125,15 @@ void Skeleton::update (float deltaTime) {
|
|||
spSkeleton_update(skeleton, deltaTime * timeScale);
|
||||
}
|
||||
|
||||
void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
void Skeleton::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, transformUpdated);
|
||||
_customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this, transform, flags);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void Skeleton::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
void Skeleton::onDraw(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
getGLProgram()->use();
|
||||
getGLProgram()->setUniformsForBuiltins(transform);
|
||||
|
|
|
@ -67,8 +67,8 @@ public:
|
|||
virtual ~Skeleton ();
|
||||
|
||||
virtual void update (float deltaTime) override;
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
|
||||
void onDraw(const cocos2d::Mat4 &transform, bool transformUpdated);
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;
|
||||
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags);
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
virtual cocos2d::Rect getBoundingBox () const override;
|
||||
|
|
|
@ -39,6 +39,26 @@ THE SOFTWARE.
|
|||
|
||||
extern "C"
|
||||
{
|
||||
// To resolve link error when building 32bits with Xcode 6.
|
||||
// More information please refer to the discussion in https://github.com/cocos2d/cocos2d-x/pull/6986
|
||||
#if defined(__APPLE__) || defined(__unix)
|
||||
#ifndef __ENABLE_COMPATIBILITY_WITH_UNIX_2003__
|
||||
#define __ENABLE_COMPATIBILITY_WITH_UNIX_2003__
|
||||
#include <stdio.h>
|
||||
FILE *fopen$UNIX2003( const char *filename, const char *mode )
|
||||
{
|
||||
return fopen(filename, mode);
|
||||
}
|
||||
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
|
||||
{
|
||||
return fwrite(a, b, c, d);
|
||||
}
|
||||
char *strerror$UNIX2003( int errnum )
|
||||
{
|
||||
return strerror(errnum);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#include "png.h"
|
||||
#include "tiffio.h"
|
||||
#include "base/etc1.h"
|
||||
|
@ -961,7 +981,15 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
|
||||
png_read_end(png_ptr, nullptr);
|
||||
|
||||
_preMulti = false;
|
||||
// premultiplied alpha for RGBA8888
|
||||
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
premultipliedAlpha();
|
||||
}
|
||||
else
|
||||
{
|
||||
_preMulti = false;
|
||||
}
|
||||
|
||||
if (row_pointers != nullptr)
|
||||
{
|
||||
|
@ -1542,7 +1570,9 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
|
|||
_data = tgaData->imageData;
|
||||
_dataLen = _width * _height * tgaData->pixelDepth / 8;
|
||||
_fileType = Format::TGA;
|
||||
|
||||
_preMulti = false;
|
||||
|
||||
ret = true;
|
||||
|
||||
}while(false);
|
||||
|
@ -2175,5 +2205,19 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
void Image::premultipliedAlpha()
|
||||
{
|
||||
CCASSERT(_renderFormat == Texture2D::PixelFormat::RGBA8888, "The pixel format should be RGBA8888!");
|
||||
|
||||
unsigned int* fourBytes = (unsigned int*)_data;
|
||||
for(int i = 0; i < _width * _height; i++)
|
||||
{
|
||||
unsigned char* p = _data + i * 4;
|
||||
fourBytes[i] = CC_RGB_PREMULTIPLY_ALPHA(p[0], p[1], p[2], p[3]);
|
||||
}
|
||||
|
||||
_preMulti = true;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -155,6 +155,8 @@ protected:
|
|||
bool saveImageToPNG(const std::string& filePath, bool isToRGB = true);
|
||||
bool saveImageToJPG(const std::string& filePath);
|
||||
|
||||
void premultipliedAlpha();
|
||||
|
||||
protected:
|
||||
/**
|
||||
@brief Determine how many mipmaps can we have.
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче