mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocoscodeide/cocos2d-x into v3
This commit is contained in:
commit
14298dce6a
|
@ -33,6 +33,11 @@ script:
|
|||
before_install:
|
||||
- tools/travis-scripts/before-install.sh
|
||||
|
||||
notifications:
|
||||
email:
|
||||
- xiaoming.zhang@cocos2d-x.org
|
||||
- jianhua.chen@cocos2d-x.org
|
||||
|
||||
# whitelist
|
||||
branches:
|
||||
only:
|
||||
|
|
6
AUTHORS
6
AUTHORS
|
@ -673,6 +673,7 @@ Developers:
|
|||
xhcnb
|
||||
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
|
||||
Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder.
|
||||
Correct TotalTime of ActionObject
|
||||
|
||||
bopohaa
|
||||
Fixed a bug that Webp test crashes.
|
||||
|
@ -818,6 +819,7 @@ Developers:
|
|||
Fixed a bug that HTTPClient reports 2xx status codes as errors
|
||||
Added missing Text Font and Placeholder feature of EditBox for Mac platform
|
||||
HttpRequest uses std::function as callback
|
||||
EditBox: mac secure input
|
||||
|
||||
iSevenDays
|
||||
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
|
||||
|
@ -840,6 +842,7 @@ Developers:
|
|||
|
||||
zifter
|
||||
Fixed a bug that the effect of particle loaded from CocosBuilder is incorrectly
|
||||
Fix twice calling onExit
|
||||
|
||||
twhittock
|
||||
Fixed a bug that Application::run returns wrong value on Mac platform
|
||||
|
@ -849,6 +852,9 @@ Developers:
|
|||
|
||||
myourys
|
||||
Make cpp template support Eclipse c++ project
|
||||
|
||||
NatWeiss
|
||||
Fix compilation error using arch i386
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
|
|
13
CHANGELOG
13
CHANGELOG
|
@ -1,4 +1,16 @@
|
|||
cocos2d-x-3.1-rc0 May.16 2014
|
||||
[NEW] Cocos2dxActivity: Adds a virtual method to load native libraries.
|
||||
[NEW] EditBox: support secure input on Mac
|
||||
|
||||
[FIX] Director: twice calling of onExit
|
||||
[FIX] Math: Vector2->Vec2, Vector3->Vec3, Vector4->Vec4, Matrix->Mat4
|
||||
[FIX] GLProgram: uniform CC_Texture0 is pre-defined by cocos2d. MUST NOT be defined in shaders
|
||||
[FIX] GLProgramState: Supports multitexturing
|
||||
[FIX] Studio:ActionObject: correct TotalTime of ActionObject
|
||||
[FIX] Studio: FrameData::copy doesn't copy `isTween` property
|
||||
|
||||
cocos2d-x-3.1-alpha1 May.9 2014
|
||||
[NEW] Animate: Dispatch a custom event after an animation frame is displayed
|
||||
[NEW] GLProgram: Easy to customize uniforms and attributes by using the new class GLProgramState
|
||||
[NEW] Template: cpp project support Eclipse c++ project
|
||||
[NEW] UI: add navigation support
|
||||
|
@ -16,6 +28,7 @@ cocos2d-x-3.1-alpha1 May.9 2014
|
|||
[FIX] ParticleSystem: yFlippedCoord behavior fixed.
|
||||
Added cocos2d/tools/particle to fix particles that were based on the old (broken) behaviour
|
||||
[FIX] Setup.py: Added SDK / NDK detection based on PATH
|
||||
[FIX] UIText: support TTF
|
||||
[FIX] Value: all types share the same union to reduce memory usage
|
||||
|
||||
cocos2d-x-3.1-alpha0 May.1 2014
|
||||
|
|
|
@ -130,6 +130,8 @@ endif()
|
|||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/platform/desktop
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/platform/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/audio/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/scripting/lua-bindings/auto
|
||||
|
@ -140,8 +142,6 @@ include_directories(
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/external/unzip
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/edtaa3func
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/desktop
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER}
|
||||
|
|
10
README.md
10
README.md
|
@ -5,7 +5,7 @@ cocos2d-x
|
|||
=========
|
||||
|
||||
[![Build Status](https://travis-ci.org/cocos2d/cocos2d-x.png?branch=v3)](https://travis-ci.org/cocos2d/cocos2d-x)
|
||||
[![Build Status](https://travis-ci.org/cocos2d/cocos2d-x.png?branch=v3)](https://travis-ci.org/cocos-travis-mac/cocos2d-x)
|
||||
[![Build Status](https://travis-ci.org/cocos-travis-mac/cocos2d-x.png?branch=v3)](https://travis-ci.org/cocos-travis-mac/cocos2d-x)
|
||||
|
||||
[cocos2d-x][1] is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications.
|
||||
It is based on [cocos2d-iphone][2], but instead of using Objective-C, it uses C++.
|
||||
|
@ -18,7 +18,15 @@ cocos2d-x is:
|
|||
* Easy to use
|
||||
* Community Supported
|
||||
|
||||
Git user attention
|
||||
-----------------------
|
||||
|
||||
1. After cloning the repo, please execute `download-deps.py` to download and install some dependences.
|
||||
|
||||
$ cd cocos2d-x
|
||||
$ python download-deps.py
|
||||
|
||||
2. Please execute `download-deps.py` once you synchronize with this repo. If there aren't any updates, it will not download dependences again.
|
||||
|
||||
How to start a new game
|
||||
-----------------------
|
||||
|
|
|
@ -116,7 +116,7 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an
|
|||
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
|
||||
elif android_platform is not None:
|
||||
sdk_tool_path = os.path.join(sdk_root, "tools/android")
|
||||
cocoslib_path = os.path.join(cocos_root, "cocos/2d/platform/android/java")
|
||||
cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java")
|
||||
command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
|
||||
if os.system(command) != 0:
|
||||
raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30324.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d_wp8.vcxproj", "{B5AF91B3-64EA-44E1-84B0-D759E93758FB}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.wp8\libSpine.vcxproj", "{7D4FC6EB-9497-4804-98F3-3EAEDC896154}"
|
||||
|
@ -44,6 +46,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cpp-tests", "..\tests\cpp-t
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-testsComponent", "..\tests\cpp-tests\proj.wp8-xaml\cpp-testsComponent\cpp-testsComponent.vcxproj", "{86B2C23C-3A6C-4C4E-AB0E-16A8CC1523E9}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1} = {271FEE84-9198-4C26-8567-4247C563B0B1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos\network\proj.wp8\libNetwork.vcxproj", "{7DAA99E7-8E07-4FEF-8374-8EC04E395D2E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
@ -58,13 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cpp-empty-test", "..\tests\
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-empty-testComponent", "..\tests\cpp-empty-test\proj-wp8-xaml\cpp-empty-testComponent\cpp-empty-testComponent.vcxproj", "{F5D665F8-AE19-4F3F-99A7-230A1E8305D2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyTemplateFiles", "..\cocos\2d\platform\wp8-xaml\CopyTemplateFiles.vcxproj", "{271FEE84-9198-4C26-8567-4247C563B0B1}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{5921FE12-7EF3-4847-8453-42EF286DDBE7} = {5921FE12-7EF3-4847-8453-42EF286DDBE7}
|
||||
{60D53713-1675-4466-81DC-D67A031C3D21} = {60D53713-1675-4466-81DC-D67A031C3D21}
|
||||
{86B2C23C-3A6C-4C4E-AB0E-16A8CC1523E9} = {86B2C23C-3A6C-4C4E-AB0E-16A8CC1523E9}
|
||||
{F5D665F8-AE19-4F3F-99A7-230A1E8305D2} = {F5D665F8-AE19-4F3F-99A7-230A1E8305D2}
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1} = {271FEE84-9198-4C26-8567-4247C563B0B1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos\ui\proj.wp8\libGUI.vcxproj", "{08FB23E4-1517-4EDC-B682-DA238CDAA83D}"
|
||||
|
@ -72,6 +72,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos\ui\proj.
|
|||
{B5AF91B3-64EA-44E1-84B0-D759E93758FB} = {B5AF91B3-64EA-44E1-84B0-D759E93758FB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyTemplateFiles", "..\cocos\platform\wp8-xaml\CopyTemplateFiles.vcxproj", "{271FEE84-9198-4C26-8567-4247C563B0B1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -392,26 +394,6 @@ Global
|
|||
{F5D665F8-AE19-4F3F-99A7-230A1E8305D2}.Release|x64.ActiveCfg = Release|Win32
|
||||
{F5D665F8-AE19-4F3F-99A7-230A1E8305D2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F5D665F8-AE19-4F3F-99A7-230A1E8305D2}.Release|x86.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x86.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|ARM.Build.0 = Release|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Win32.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x64.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x86.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x86.Build.0 = Release|Win32
|
||||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Debug|ARM.Build.0 = Debug|ARM
|
||||
|
@ -432,6 +414,26 @@ Global
|
|||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Release|x64.ActiveCfg = Release|Win32
|
||||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Release|x86.ActiveCfg = Release|Win32
|
||||
{08FB23E4-1517-4EDC-B682-DA238CDAA83D}.Release|x86.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Debug|x86.Build.0 = Debug|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|ARM.Build.0 = Release|ARM
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|Win32.Build.0 = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x64.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x86.ActiveCfg = Release|Win32
|
||||
{271FEE84-9198-4C26-8567-4247C563B0B1}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -815,6 +815,8 @@
|
|||
3EA0FB5E191B92F100B170C8 /* cocosvideo.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */; };
|
||||
3EA0FB66191B933000B170C8 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */; };
|
||||
3EA0FB72191C844400B170C8 /* UIVideoPlayerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB70191C844400B170C8 /* UIVideoPlayerTest.cpp */; };
|
||||
59620E8F1921E5CF002021B6 /* Bug-Child.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59620E8D1921E5CF002021B6 /* Bug-Child.cpp */; };
|
||||
59620E901921E5CF002021B6 /* Bug-Child.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59620E8D1921E5CF002021B6 /* Bug-Child.cpp */; };
|
||||
A05FCACA177C124500BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; };
|
||||
A07A521E1783A1D20073F6A7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; };
|
||||
A07A521F1783A1D20073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; };
|
||||
|
@ -1852,6 +1854,8 @@
|
|||
3EA0FB70191C844400B170C8 /* UIVideoPlayerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIVideoPlayerTest.cpp; sourceTree = "<group>"; };
|
||||
3EA0FB71191C844400B170C8 /* UIVideoPlayerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayerTest.h; sourceTree = "<group>"; };
|
||||
46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = "<group>"; };
|
||||
59620E8D1921E5CF002021B6 /* Bug-Child.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-Child.cpp"; sourceTree = "<group>"; };
|
||||
59620E8E1921E5CF002021B6 /* Bug-Child.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-Child.h"; sourceTree = "<group>"; };
|
||||
70A7F72D191D3E4900F0F206 /* shaderTest.psh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shaderTest.psh.h; sourceTree = "<group>"; };
|
||||
70A7F730191D421B00F0F206 /* ShaderTest.vsh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTest.vsh.h; sourceTree = "<group>"; };
|
||||
A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
|
||||
|
@ -2425,6 +2429,8 @@
|
|||
1AC3598B18CECF0B00F37B72 /* Bug-914.h */,
|
||||
1AC3598C18CECF0B00F37B72 /* BugsTest.cpp */,
|
||||
1AC3598D18CECF0B00F37B72 /* BugsTest.h */,
|
||||
59620E8D1921E5CF002021B6 /* Bug-Child.cpp */,
|
||||
59620E8E1921E5CF002021B6 /* Bug-Child.h */,
|
||||
);
|
||||
path = BugsTest;
|
||||
sourceTree = "<group>";
|
||||
|
@ -4588,6 +4594,7 @@
|
|||
1AC35C3118CECF0C00F37B72 /* PerformanceRendererTest.cpp in Sources */,
|
||||
1AC35C4518CECF0C00F37B72 /* SceneTest.cpp in Sources */,
|
||||
1AC35B6F18CECF0C00F37B72 /* MenuTestLayer.cpp in Sources */,
|
||||
59620E8F1921E5CF002021B6 /* Bug-Child.cpp in Sources */,
|
||||
29080DCD191B595E0066F8DF /* UIScrollViewTest_Editor.cpp in Sources */,
|
||||
1AC35B5118CECF0C00F37B72 /* ClippingNodeTest.cpp in Sources */,
|
||||
1AC35C1318CECF0C00F37B72 /* LayerTest.cpp in Sources */,
|
||||
|
@ -4880,6 +4887,7 @@
|
|||
1AC35B3018CECF0C00F37B72 /* Box2dView.cpp in Sources */,
|
||||
29080DAE191B595E0066F8DF /* UIImageViewTest.cpp in Sources */,
|
||||
1AC35C1018CECF0C00F37B72 /* LabelTest.cpp in Sources */,
|
||||
59620E901921E5CF002021B6 /* Bug-Child.cpp in Sources */,
|
||||
29080DC8191B595E0066F8DF /* UISceneManager.cpp in Sources */,
|
||||
1AC35C6A18CECF0C00F37B72 /* VisibleRect.cpp in Sources */,
|
||||
1AC35C4018CECF0C00F37B72 /* ReleasePoolTest.cpp in Sources */,
|
||||
|
@ -5213,26 +5221,28 @@
|
|||
1A0EE2B018CDF6DA004CD58F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-empty-test/proj.mac/Info.plist";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1A0EE2B118CDF6DA004CD58F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-empty-test/proj.mac/Info.plist";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5240,6 +5250,7 @@
|
|||
1A0EE31218CDF733004CD58F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
|
@ -5251,13 +5262,14 @@
|
|||
"-image_base",
|
||||
100000000,
|
||||
);
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1A0EE31318CDF733004CD58F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
|
@ -5269,7 +5281,7 @@
|
|||
"-image_base",
|
||||
100000000,
|
||||
);
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5286,7 +5298,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -5302,7 +5314,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5319,7 +5331,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -5335,7 +5347,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5343,6 +5355,7 @@
|
|||
1ABCA2B318CD91520087CE3A /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
|
@ -5354,13 +5367,14 @@
|
|||
"-image_base",
|
||||
100000000,
|
||||
);
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1ABCA2B418CD91520087CE3A /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
|
@ -5372,7 +5386,7 @@
|
|||
"-image_base",
|
||||
100000000,
|
||||
);
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5391,7 +5405,7 @@
|
|||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -5409,7 +5423,7 @@
|
|||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5417,24 +5431,26 @@
|
|||
1D6058940D05DD3E006BFB54 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.mac/Info.plist";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1D6058950D05DD3E006BFB54 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.mac/Info.plist";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -5481,7 +5497,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -5497,7 +5513,7 @@
|
|||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/2d/platform/ios $(SRCROOT)/../cocos/2d/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
|
|
@ -215,7 +215,7 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*
|
|||
_boundaryFullyCovered = false;
|
||||
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
_fullScreenSize = Vector2(winSize.width, winSize.height);
|
||||
_fullScreenSize = Vec2(winSize.width, winSize.height);
|
||||
_halfScreenSize = _fullScreenSize * 0.5f;
|
||||
|
||||
if (_boundarySet)
|
||||
|
@ -257,9 +257,9 @@ void Follow::step(float dt)
|
|||
if(_boundaryFullyCovered)
|
||||
return;
|
||||
|
||||
Vector2 tempPos = _halfScreenSize - _followedNode->getPosition();
|
||||
Vec2 tempPos = _halfScreenSize - _followedNode->getPosition();
|
||||
|
||||
_target->setPosition(Vector2(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
_target->setPosition(Vec2(clampf(tempPos.x, _leftBoundary, _rightBoundary),
|
||||
clampf(tempPos.y, _bottomBoundary, _topBoundary)));
|
||||
}
|
||||
else
|
||||
|
|
|
@ -277,8 +277,8 @@ protected:
|
|||
bool _boundaryFullyCovered;
|
||||
|
||||
// fast access to the screen dimensions
|
||||
Vector2 _halfScreenSize;
|
||||
Vector2 _fullScreenSize;
|
||||
Vec2 _halfScreenSize;
|
||||
Vec2 _fullScreenSize;
|
||||
|
||||
// world boundaries
|
||||
float _leftBoundary;
|
||||
|
|
|
@ -60,12 +60,12 @@ ActionCamera * ActionCamera::reverse() const
|
|||
|
||||
void ActionCamera::restore()
|
||||
{
|
||||
_center = Vector3(0, 0, 0);
|
||||
_eye = Vector3(0, 0, FLT_EPSILON);
|
||||
_up = Vector3(0, 1, 0);
|
||||
_center = Vec3(0, 0, 0);
|
||||
_eye = Vec3(0, 0, FLT_EPSILON);
|
||||
_up = Vec3(0, 1, 0);
|
||||
}
|
||||
|
||||
void ActionCamera::setEye(const Vector3& eye)
|
||||
void ActionCamera::setEye(const Vec3& eye)
|
||||
{
|
||||
_eye = eye;
|
||||
updateTransform();
|
||||
|
@ -73,17 +73,17 @@ void ActionCamera::setEye(const Vector3& eye)
|
|||
|
||||
void ActionCamera::setEye(float x, float y, float z)
|
||||
{
|
||||
_eye = Vector3(x, y, z);
|
||||
_eye = Vec3(x, y, z);
|
||||
updateTransform();
|
||||
}
|
||||
|
||||
void ActionCamera::setCenter(const Vector3& center)
|
||||
void ActionCamera::setCenter(const Vec3& center)
|
||||
{
|
||||
_center = center;
|
||||
updateTransform();
|
||||
}
|
||||
|
||||
void ActionCamera::setUp(const Vector3& up)
|
||||
void ActionCamera::setUp(const Vec3& up)
|
||||
{
|
||||
_up = up;
|
||||
updateTransform();
|
||||
|
@ -91,18 +91,18 @@ void ActionCamera::setUp(const Vector3& up)
|
|||
|
||||
void ActionCamera::updateTransform()
|
||||
{
|
||||
Matrix lookupMatrix;
|
||||
Matrix::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix);
|
||||
Mat4 lookupMatrix;
|
||||
Mat4::createLookAt(_eye.x, _eye.y, _eye.z, _center.x, _center.y, _center.z, _up.x, _up.y, _up.z, &lookupMatrix);
|
||||
|
||||
Vector2 anchorPoint = _target->getAnchorPointInPoints();
|
||||
Vec2 anchorPoint = _target->getAnchorPointInPoints();
|
||||
|
||||
bool needsTranslation = !anchorPoint.equals(Vector2::ZERO);
|
||||
bool needsTranslation = !anchorPoint.equals(Vec2::ZERO);
|
||||
|
||||
Matrix mv = Matrix::identity();
|
||||
Mat4 mv = Mat4::IDENTITY;
|
||||
|
||||
if(needsTranslation) {
|
||||
Matrix t;
|
||||
Matrix::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t);
|
||||
Mat4 t;
|
||||
Mat4::createTranslation(anchorPoint.x, anchorPoint.y, 0, &t);
|
||||
mv = mv * t;
|
||||
}
|
||||
|
||||
|
@ -110,8 +110,8 @@ void ActionCamera::updateTransform()
|
|||
|
||||
if(needsTranslation) {
|
||||
|
||||
Matrix t;
|
||||
Matrix::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t);
|
||||
Mat4 t;
|
||||
Mat4::createTranslation(-anchorPoint.x, -anchorPoint.y, 0, &t);
|
||||
mv = mv * t;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
class Camera;
|
||||
|
||||
/**
|
||||
|
@ -65,27 +63,27 @@ public:
|
|||
virtual ActionCamera *clone() const override;
|
||||
|
||||
/* sets the Eye value of the Camera */
|
||||
void setEye(const Vector3 &eye);
|
||||
void setEye(const Vec3 &eye);
|
||||
void setEye(float x, float y, float z);
|
||||
/* returns the Eye value of the Camera */
|
||||
const Vector3& getEye() const { return _eye; }
|
||||
const Vec3& getEye() const { return _eye; }
|
||||
/* sets the Center value of the Camera */
|
||||
void setCenter(const Vector3 ¢er);
|
||||
void setCenter(const Vec3 ¢er);
|
||||
/* returns the Center value of the Camera */
|
||||
const Vector3& getCenter() const { return _center; }
|
||||
const Vec3& getCenter() const { return _center; }
|
||||
/* sets the Up value of the Camera */
|
||||
void setUp(const Vector3 &up);
|
||||
void setUp(const Vec3 &up);
|
||||
/* Returns the Up value of the Camera */
|
||||
const Vector3& getUp() const { return _up; }
|
||||
const Vec3& getUp() const { return _up; }
|
||||
|
||||
protected:
|
||||
|
||||
void restore();
|
||||
void updateTransform();
|
||||
|
||||
Vector3 _center;
|
||||
Vector3 _eye;
|
||||
Vector3 _up;
|
||||
Vec3 _center;
|
||||
Vec3 _eye;
|
||||
Vec3 _up;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,18 +62,18 @@ PointArray* PointArray::create(ssize_t capacity)
|
|||
|
||||
bool PointArray::initWithCapacity(ssize_t capacity)
|
||||
{
|
||||
_controlPoints = new vector<Vector2*>();
|
||||
_controlPoints = new vector<Vec2*>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PointArray* PointArray::clone() const
|
||||
{
|
||||
vector<Vector2*> *newArray = new vector<Vector2*>();
|
||||
vector<Vector2*>::iterator iter;
|
||||
vector<Vec2*> *newArray = new vector<Vec2*>();
|
||||
vector<Vec2*>::iterator iter;
|
||||
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
|
||||
{
|
||||
newArray->push_back(new Vector2((*iter)->x, (*iter)->y));
|
||||
newArray->push_back(new Vec2((*iter)->x, (*iter)->y));
|
||||
}
|
||||
|
||||
PointArray *points = new PointArray();
|
||||
|
@ -88,7 +88,7 @@ PointArray::~PointArray()
|
|||
{
|
||||
CCLOGINFO("deallocing PointArray: %p", this);
|
||||
|
||||
vector<Vector2*>::iterator iter;
|
||||
vector<Vec2*>::iterator iter;
|
||||
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
|
||||
{
|
||||
delete *iter;
|
||||
|
@ -98,17 +98,17 @@ PointArray::~PointArray()
|
|||
|
||||
PointArray::PointArray() :_controlPoints(nullptr){}
|
||||
|
||||
const std::vector<Vector2*>* PointArray::getControlPoints() const
|
||||
const std::vector<Vec2*>* PointArray::getControlPoints() const
|
||||
{
|
||||
return _controlPoints;
|
||||
}
|
||||
|
||||
void PointArray::setControlPoints(vector<Vector2*> *controlPoints)
|
||||
void PointArray::setControlPoints(vector<Vec2*> *controlPoints)
|
||||
{
|
||||
CCASSERT(controlPoints != nullptr, "control points should not be nullptr");
|
||||
|
||||
// delete old points
|
||||
vector<Vector2*>::iterator iter;
|
||||
vector<Vec2*>::iterator iter;
|
||||
for (iter = _controlPoints->begin(); iter != _controlPoints->end(); ++iter)
|
||||
{
|
||||
delete *iter;
|
||||
|
@ -118,35 +118,35 @@ void PointArray::setControlPoints(vector<Vector2*> *controlPoints)
|
|||
_controlPoints = controlPoints;
|
||||
}
|
||||
|
||||
void PointArray::addControlPoint(Vector2 controlPoint)
|
||||
void PointArray::addControlPoint(Vec2 controlPoint)
|
||||
{
|
||||
_controlPoints->push_back(new Vector2(controlPoint.x, controlPoint.y));
|
||||
_controlPoints->push_back(new Vec2(controlPoint.x, controlPoint.y));
|
||||
}
|
||||
|
||||
void PointArray::insertControlPoint(Vector2 &controlPoint, ssize_t index)
|
||||
void PointArray::insertControlPoint(Vec2 &controlPoint, ssize_t index)
|
||||
{
|
||||
Vector2 *temp = new Vector2(controlPoint.x, controlPoint.y);
|
||||
Vec2 *temp = new Vec2(controlPoint.x, controlPoint.y);
|
||||
_controlPoints->insert(_controlPoints->begin() + index, temp);
|
||||
}
|
||||
|
||||
Vector2 PointArray::getControlPointAtIndex(ssize_t index)
|
||||
Vec2 PointArray::getControlPointAtIndex(ssize_t index)
|
||||
{
|
||||
index = MIN(static_cast<ssize_t>(_controlPoints->size())-1, MAX(index, 0));
|
||||
return *(_controlPoints->at(index));
|
||||
}
|
||||
|
||||
void PointArray::replaceControlPoint(cocos2d::Vector2 &controlPoint, ssize_t index)
|
||||
void PointArray::replaceControlPoint(cocos2d::Vec2 &controlPoint, ssize_t index)
|
||||
{
|
||||
|
||||
Vector2 *temp = _controlPoints->at(index);
|
||||
Vec2 *temp = _controlPoints->at(index);
|
||||
temp->x = controlPoint.x;
|
||||
temp->y = controlPoint.y;
|
||||
}
|
||||
|
||||
void PointArray::removeControlPointAtIndex(ssize_t index)
|
||||
{
|
||||
vector<Vector2*>::iterator iter = _controlPoints->begin() + index;
|
||||
Vector2* removedPoint = *iter;
|
||||
vector<Vec2*>::iterator iter = _controlPoints->begin() + index;
|
||||
Vec2* removedPoint = *iter;
|
||||
_controlPoints->erase(iter);
|
||||
delete removedPoint;
|
||||
}
|
||||
|
@ -158,13 +158,13 @@ ssize_t PointArray::count() const
|
|||
|
||||
PointArray* PointArray::reverse() const
|
||||
{
|
||||
vector<Vector2*> *newArray = new vector<Vector2*>();
|
||||
vector<Vector2*>::reverse_iterator iter;
|
||||
Vector2 *point = nullptr;
|
||||
vector<Vec2*> *newArray = new vector<Vec2*>();
|
||||
vector<Vec2*>::reverse_iterator iter;
|
||||
Vec2 *point = nullptr;
|
||||
for (iter = _controlPoints->rbegin(); iter != _controlPoints->rend(); ++iter)
|
||||
{
|
||||
point = *iter;
|
||||
newArray->push_back(new Vector2(point->x, point->y));
|
||||
newArray->push_back(new Vec2(point->x, point->y));
|
||||
}
|
||||
PointArray *config = PointArray::create(0);
|
||||
config->setControlPoints(newArray);
|
||||
|
@ -175,8 +175,8 @@ PointArray* PointArray::reverse() const
|
|||
void PointArray::reverseInline()
|
||||
{
|
||||
size_t l = _controlPoints->size();
|
||||
Vector2 *p1 = nullptr;
|
||||
Vector2 *p2 = nullptr;
|
||||
Vec2 *p1 = nullptr;
|
||||
Vec2 *p2 = nullptr;
|
||||
float x, y;
|
||||
for (size_t i = 0; i < l/2; ++i)
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ void PointArray::reverseInline()
|
|||
}
|
||||
|
||||
// CatmullRom Spline formula:
|
||||
Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t)
|
||||
Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t)
|
||||
{
|
||||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
|
@ -213,7 +213,7 @@ Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, f
|
|||
float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4);
|
||||
float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4);
|
||||
|
||||
return Vector2(x,y);
|
||||
return Vec2(x,y);
|
||||
}
|
||||
|
||||
/* Implementation of CardinalSplineTo
|
||||
|
@ -274,7 +274,7 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *target)
|
|||
_deltaT = (float) 1 / (_points->count() - 1);
|
||||
|
||||
_previousPosition = target->getPosition();
|
||||
_accumulatedDiff = Vector2::ZERO;
|
||||
_accumulatedDiff = Vec2::ZERO;
|
||||
}
|
||||
|
||||
CardinalSplineTo* CardinalSplineTo::clone() const
|
||||
|
@ -307,17 +307,17 @@ void CardinalSplineTo::update(float time)
|
|||
}
|
||||
|
||||
// Interpolate
|
||||
Vector2 pp0 = _points->getControlPointAtIndex(p-1);
|
||||
Vector2 pp1 = _points->getControlPointAtIndex(p+0);
|
||||
Vector2 pp2 = _points->getControlPointAtIndex(p+1);
|
||||
Vector2 pp3 = _points->getControlPointAtIndex(p+2);
|
||||
Vec2 pp0 = _points->getControlPointAtIndex(p-1);
|
||||
Vec2 pp1 = _points->getControlPointAtIndex(p+0);
|
||||
Vec2 pp2 = _points->getControlPointAtIndex(p+1);
|
||||
Vec2 pp3 = _points->getControlPointAtIndex(p+2);
|
||||
|
||||
Vector2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
|
||||
Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, _tension, lt);
|
||||
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
// Support for stacked actions
|
||||
Node *node = _target;
|
||||
Vector2 diff = node->getPosition() - _previousPosition;
|
||||
Vec2 diff = node->getPosition() - _previousPosition;
|
||||
if( diff.x !=0 || diff.y != 0 ) {
|
||||
_accumulatedDiff = _accumulatedDiff + diff;
|
||||
newPos = newPos + _accumulatedDiff;
|
||||
|
@ -327,7 +327,7 @@ void CardinalSplineTo::update(float time)
|
|||
this->updatePosition(newPos);
|
||||
}
|
||||
|
||||
void CardinalSplineTo::updatePosition(cocos2d::Vector2 &newPos)
|
||||
void CardinalSplineTo::updatePosition(cocos2d::Vec2 &newPos)
|
||||
{
|
||||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
|
@ -365,9 +365,9 @@ CardinalSplineBy::CardinalSplineBy() : _startPosition(0,0)
|
|||
{
|
||||
}
|
||||
|
||||
void CardinalSplineBy::updatePosition(cocos2d::Vector2 &newPos)
|
||||
void CardinalSplineBy::updatePosition(cocos2d::Vec2 &newPos)
|
||||
{
|
||||
Vector2 p = newPos + _startPosition;
|
||||
Vec2 p = newPos + _startPosition;
|
||||
_target->setPosition(p);
|
||||
_previousPosition = p;
|
||||
}
|
||||
|
@ -379,11 +379,11 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Vector2 p = copyConfig->getControlPointAtIndex(0);
|
||||
Vec2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Vector2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vector2 diff = current - p;
|
||||
Vec2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vec2 diff = current - p;
|
||||
copyConfig->replaceControlPoint(diff, i);
|
||||
|
||||
p = current;
|
||||
|
@ -404,9 +404,9 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
|
||||
for (ssize_t i = 1; i < pReverse->count(); ++i)
|
||||
{
|
||||
Vector2 current = pReverse->getControlPointAtIndex(i);
|
||||
Vec2 current = pReverse->getControlPointAtIndex(i);
|
||||
current = -current;
|
||||
Vector2 abs = current + p;
|
||||
Vec2 abs = current + p;
|
||||
pReverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
@ -524,11 +524,11 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Vector2 p = copyConfig->getControlPointAtIndex(0);
|
||||
Vec2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
Vector2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vector2 diff = current - p;
|
||||
Vec2 current = copyConfig->getControlPointAtIndex(i);
|
||||
Vec2 diff = current - p;
|
||||
copyConfig->replaceControlPoint(diff, i);
|
||||
|
||||
p = current;
|
||||
|
@ -549,9 +549,9 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
|
||||
for (ssize_t i = 1; i < reverse->count(); ++i)
|
||||
{
|
||||
Vector2 current = reverse->getControlPointAtIndex(i);
|
||||
Vec2 current = reverse->getControlPointAtIndex(i);
|
||||
current = -current;
|
||||
Vector2 abs = current + p;
|
||||
Vec2 abs = current + p;
|
||||
reverse->replaceControlPoint(abs, i);
|
||||
|
||||
p = abs;
|
||||
|
|
|
@ -80,22 +80,22 @@ public:
|
|||
/** appends a control point
|
||||
* @js NA
|
||||
*/
|
||||
void addControlPoint(Vector2 controlPoint);
|
||||
void addControlPoint(Vec2 controlPoint);
|
||||
|
||||
/** inserts a controlPoint at index
|
||||
* @js NA
|
||||
*/
|
||||
void insertControlPoint(Vector2 &controlPoint, ssize_t index);
|
||||
void insertControlPoint(Vec2 &controlPoint, ssize_t index);
|
||||
|
||||
/** replaces an existing controlPoint at index
|
||||
* @js NA
|
||||
*/
|
||||
void replaceControlPoint(Vector2 &controlPoint, ssize_t index);
|
||||
void replaceControlPoint(Vec2 &controlPoint, ssize_t index);
|
||||
|
||||
/** get the value of a controlPoint at a given index
|
||||
* @js NA
|
||||
*/
|
||||
Vector2 getControlPointAtIndex(ssize_t index);
|
||||
Vec2 getControlPointAtIndex(ssize_t index);
|
||||
|
||||
/** deletes a control point at a given index
|
||||
* @js NA
|
||||
|
@ -124,14 +124,14 @@ public:
|
|||
/**
|
||||
* @js NA
|
||||
*/
|
||||
const std::vector<Vector2*>* getControlPoints() const;
|
||||
const std::vector<Vec2*>* getControlPoints() const;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
void setControlPoints(std::vector<Vector2*> *controlPoints);
|
||||
void setControlPoints(std::vector<Vec2*> *controlPoints);
|
||||
private:
|
||||
/** Array that contains the control points */
|
||||
std::vector<Vector2*> *_controlPoints;
|
||||
std::vector<Vec2*> *_controlPoints;
|
||||
};
|
||||
|
||||
/** Cardinal Spline path.
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
/** initializes the action with a duration and an array of points */
|
||||
bool initWithDuration(float duration, PointArray* points, float tension);
|
||||
|
||||
virtual void updatePosition(Vector2 &newPos);
|
||||
virtual void updatePosition(Vec2 &newPos);
|
||||
|
||||
inline PointArray* getPoints() { return _points; }
|
||||
/**
|
||||
|
@ -189,8 +189,8 @@ protected:
|
|||
PointArray *_points;
|
||||
float _deltaT;
|
||||
float _tension;
|
||||
Vector2 _previousPosition;
|
||||
Vector2 _accumulatedDiff;
|
||||
Vec2 _previousPosition;
|
||||
Vec2 _accumulatedDiff;
|
||||
};
|
||||
|
||||
/** Cardinal Spline path.
|
||||
|
@ -214,12 +214,12 @@ public:
|
|||
|
||||
// Overrides
|
||||
virtual void startWithTarget(Node *target) override;
|
||||
virtual void updatePosition(Vector2 &newPos) override;
|
||||
virtual void updatePosition(Vec2 &newPos) override;
|
||||
virtual CardinalSplineBy *clone() const override;
|
||||
virtual CardinalSplineBy* reverse() const override;
|
||||
|
||||
protected:
|
||||
Vector2 _startPosition;
|
||||
Vec2 _startPosition;
|
||||
};
|
||||
|
||||
/** An action that moves the target with a CatmullRom curve to a destination point.
|
||||
|
@ -275,7 +275,7 @@ public:
|
|||
};
|
||||
|
||||
/** Returns the Cardinal Spline position for a given set of control points, tension and time */
|
||||
extern CC_DLL Vector2 ccCardinalSplineAt(Vector2 &p0, Vector2 &p1, Vector2 &p2, Vector2 &p3, float tension, float t);
|
||||
extern CC_DLL Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, float t);
|
||||
|
||||
// end of actions group
|
||||
/// @}
|
||||
|
|
|
@ -23,10 +23,12 @@ 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 "2d/CCActionGrid.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
#include "2d/CCGrid.h"
|
||||
#include "2d/CCNodeGrid.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
// implementation of GridAction
|
||||
|
@ -103,19 +105,19 @@ GridBase* Grid3DAction::getGrid()
|
|||
return Grid3D::create(_gridSize);
|
||||
}
|
||||
|
||||
Vector3 Grid3DAction::getVertex(const Vector2& position) const
|
||||
Vec3 Grid3DAction::getVertex(const Vec2& position) const
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getVertex(position);
|
||||
}
|
||||
|
||||
Vector3 Grid3DAction::getOriginalVertex(const Vector2& position) const
|
||||
Vec3 Grid3DAction::getOriginalVertex(const Vec2& position) const
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getOriginalVertex(position);
|
||||
}
|
||||
|
||||
void Grid3DAction::setVertex(const Vector2& position, const Vector3& vertex)
|
||||
void Grid3DAction::setVertex(const Vec2& position, const Vec3& vertex)
|
||||
{
|
||||
Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid();
|
||||
g->setVertex(position, vertex);
|
||||
|
@ -128,19 +130,19 @@ GridBase* TiledGrid3DAction::getGrid(void)
|
|||
return TiledGrid3D::create(_gridSize);
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3DAction::getTile(const Vector2& pos) const
|
||||
Quad3 TiledGrid3DAction::getTile(const Vec2& pos) const
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getTile(pos);
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3DAction::getOriginalTile(const Vector2& pos) const
|
||||
Quad3 TiledGrid3DAction::getOriginalTile(const Vec2& pos) const
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->getOriginalTile(pos);
|
||||
}
|
||||
|
||||
void TiledGrid3DAction::setTile(const Vector2& pos, const Quad3& coords)
|
||||
void TiledGrid3DAction::setTile(const Vec2& pos, const Quad3& coords)
|
||||
{
|
||||
TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid();
|
||||
return g->setTile(pos, coords);
|
||||
|
|
|
@ -82,31 +82,31 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Vector3 getVertex(const Vector2& position) const;
|
||||
Vec3 getVertex(const Vec2& position) const;
|
||||
|
||||
/** @deprecated Use getVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE inline Vector3 vertex(const Vector2& position) { return getVertex(position); }
|
||||
CC_DEPRECATED_ATTRIBUTE inline Vec3 vertex(const Vec2& position) { return getVertex(position); }
|
||||
|
||||
/** returns the non-transformed vertex than belongs to certain position in the grid
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Vector3 getOriginalVertex(const Vector2& position) const;
|
||||
Vec3 getOriginalVertex(const Vec2& position) const;
|
||||
|
||||
/** @deprecated Use getOriginalVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE inline Vector3 originalVertex(const Vector2& position) { return getOriginalVertex(position); }
|
||||
CC_DEPRECATED_ATTRIBUTE inline Vec3 originalVertex(const Vec2& position) { return getOriginalVertex(position); }
|
||||
|
||||
/** sets a new vertex to a certain position of the grid
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setVertex(const Vector2& position, const Vector3& vertex);
|
||||
void setVertex(const Vec2& position, const Vec3& vertex);
|
||||
|
||||
// Overrides
|
||||
virtual Grid3DAction * clone() const override = 0;
|
||||
|
@ -126,31 +126,31 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Quad3 getTile(const Vector2& position) const;
|
||||
Quad3 getTile(const Vec2& position) const;
|
||||
|
||||
/** @deprecated Use getTile() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& position) { return getTile(position); }
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& position) { return getTile(position); }
|
||||
|
||||
/** returns the non-transformed tile that belongs to a certain position of the grid
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Quad3 getOriginalTile(const Vector2& position) const;
|
||||
Quad3 getOriginalTile(const Vec2& position) const;
|
||||
|
||||
/** @deprecated Use getOriginalTile() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& position) { return getOriginalTile(position); }
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& position) { return getOriginalTile(position); }
|
||||
|
||||
/** sets a new tile to a certain position of the grid
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setTile(const Vector2& position, const Quad3& coords);
|
||||
void setTile(const Vec2& position, const Quad3& coords);
|
||||
|
||||
/** returns the grid */
|
||||
virtual GridBase* getGrid();
|
||||
|
|
|
@ -79,10 +79,10 @@ void Waves3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i ,j));
|
||||
Vec3 v = getOriginalVertex(Vec2(i ,j));
|
||||
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
|
||||
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,32 +142,32 @@ void FlipX3D::update(float time)
|
|||
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
||||
float mx = cosf(angle);
|
||||
|
||||
Vector3 v0, v1, v, diff;
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vector2(1, 1));
|
||||
v1 = getOriginalVertex(Vector2(0, 0));
|
||||
v0 = getOriginalVertex(Vec2(1, 1));
|
||||
v1 = getOriginalVertex(Vec2(0, 0));
|
||||
|
||||
float x0 = v0.x;
|
||||
float x1 = v1.x;
|
||||
float x;
|
||||
Vector2 a, b, c, d;
|
||||
Vec2 a, b, c, d;
|
||||
|
||||
if ( x0 > x1 )
|
||||
{
|
||||
// Normal Grid
|
||||
a = Vector2(0,0);
|
||||
b = Vector2(0,1);
|
||||
c = Vector2(1,0);
|
||||
d = Vector2(1,1);
|
||||
a = Vec2(0,0);
|
||||
b = Vec2(0,1);
|
||||
c = Vec2(1,0);
|
||||
d = Vec2(1,1);
|
||||
x = x0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
c = Vector2(0,0);
|
||||
d = Vector2(0,1);
|
||||
a = Vector2(1,0);
|
||||
b = Vector2(1,1);
|
||||
c = Vec2(0,0);
|
||||
d = Vec2(0,1);
|
||||
a = Vec2(1,0);
|
||||
b = Vec2(1,1);
|
||||
x = x1;
|
||||
}
|
||||
|
||||
|
@ -236,32 +236,32 @@ void FlipY3D::update(float time)
|
|||
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
||||
float my = cosf(angle);
|
||||
|
||||
Vector3 v0, v1, v, diff;
|
||||
Vec3 v0, v1, v, diff;
|
||||
|
||||
v0 = getOriginalVertex(Vector2(1, 1));
|
||||
v1 = getOriginalVertex(Vector2(0, 0));
|
||||
v0 = getOriginalVertex(Vec2(1, 1));
|
||||
v1 = getOriginalVertex(Vec2(0, 0));
|
||||
|
||||
float y0 = v0.y;
|
||||
float y1 = v1.y;
|
||||
float y;
|
||||
Vector2 a, b, c, d;
|
||||
Vec2 a, b, c, d;
|
||||
|
||||
if (y0 > y1)
|
||||
{
|
||||
// Normal Grid
|
||||
a = Vector2(0,0);
|
||||
b = Vector2(0,1);
|
||||
c = Vector2(1,0);
|
||||
d = Vector2(1,1);
|
||||
a = Vec2(0,0);
|
||||
b = Vec2(0,1);
|
||||
c = Vec2(1,0);
|
||||
d = Vec2(1,1);
|
||||
y = y0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reversed Grid
|
||||
b = Vector2(0,0);
|
||||
a = Vector2(0,1);
|
||||
d = Vector2(1,0);
|
||||
c = Vector2(1,1);
|
||||
b = Vec2(0,0);
|
||||
a = Vec2(0,1);
|
||||
d = Vec2(1,0);
|
||||
c = Vec2(1,1);
|
||||
y = y1;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ void FlipY3D::update(float time)
|
|||
|
||||
// implementation of Lens3D
|
||||
|
||||
Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& position, float radius)
|
||||
Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vec2& position, float radius)
|
||||
{
|
||||
Lens3D *action = new Lens3D();
|
||||
|
||||
|
@ -315,11 +315,11 @@ Lens3D* Lens3D::create(float duration, const Size& gridSize, const Vector2& posi
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius)
|
||||
bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
_position = Vector2(-1, -1);
|
||||
_position = Vec2(-1, -1);
|
||||
setPosition(position);
|
||||
_radius = radius;
|
||||
_lensEffect = 0.7f;
|
||||
|
@ -341,7 +341,7 @@ Lens3D* Lens3D::clone() const
|
|||
return a;
|
||||
}
|
||||
|
||||
void Lens3D::setPosition(const Vector2& pos)
|
||||
void Lens3D::setPosition(const Vec2& pos)
|
||||
{
|
||||
if( !pos.equals(_position))
|
||||
{
|
||||
|
@ -361,8 +361,8 @@ void Lens3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vector2 vect = _position - Vector2(v.x, v.y);
|
||||
Vec3 v = getOriginalVertex(Vec2(i, j));
|
||||
Vec2 vect = _position - Vec2(v.x, v.y);
|
||||
float r = vect.getLength();
|
||||
|
||||
if (r < _radius)
|
||||
|
@ -380,12 +380,12 @@ void Lens3D::update(float time)
|
|||
if (vect.getLength() > 0)
|
||||
{
|
||||
vect.normalize();
|
||||
Vector2 new_vect = vect * new_r;
|
||||
Vec2 new_vect = vect * new_r;
|
||||
v.z += (_concave ? -1.0f : 1.0f) * new_vect.getLength() * _lensEffect;
|
||||
}
|
||||
}
|
||||
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ void Lens3D::update(float time)
|
|||
|
||||
// implementation of Ripple3D
|
||||
|
||||
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude)
|
||||
Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
|
||||
{
|
||||
Ripple3D *action = new Ripple3D();
|
||||
|
||||
|
@ -414,7 +414,7 @@ Ripple3D* Ripple3D::create(float duration, const Size& gridSize, const Vector2&
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude)
|
||||
bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
|
@ -430,7 +430,7 @@ bool Ripple3D::initWithDuration(float duration, const Size& gridSize, const Vect
|
|||
return false;
|
||||
}
|
||||
|
||||
void Ripple3D::setPosition(const Vector2& position)
|
||||
void Ripple3D::setPosition(const Vec2& position)
|
||||
{
|
||||
_position = position;
|
||||
}
|
||||
|
@ -453,8 +453,8 @@ void Ripple3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vector2 vect = _position - Vector2(v.x,v.y);
|
||||
Vec3 v = getOriginalVertex(Vec2(i, j));
|
||||
Vec2 vect = _position - Vec2(v.x,v.y);
|
||||
float r = vect.getLength();
|
||||
|
||||
if (r < _radius)
|
||||
|
@ -464,7 +464,7 @@ void Ripple3D::update(float time)
|
|||
v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
|
||||
}
|
||||
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ void Shaky3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i ,j));
|
||||
Vec3 v = getOriginalVertex(Vec2(i ,j));
|
||||
v.x += (rand() % (_randrange*2)) - _randrange;
|
||||
v.y += (rand() % (_randrange*2)) - _randrange;
|
||||
if (_shakeZ)
|
||||
|
@ -529,7 +529,7 @@ void Shaky3D::update(float time)
|
|||
v.z += (rand() % (_randrange*2)) - _randrange;
|
||||
}
|
||||
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -586,10 +586,10 @@ void Liquid::update(float time)
|
|||
{
|
||||
for (j = 1; j < _gridSize.height; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vec3 v = getOriginalVertex(Vec2(i, j));
|
||||
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
||||
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ void Waves::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i, j));
|
||||
Vec3 v = getOriginalVertex(Vec2(i, j));
|
||||
|
||||
if (_vertical)
|
||||
{
|
||||
|
@ -660,14 +660,14 @@ void Waves::update(float time)
|
|||
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
||||
}
|
||||
|
||||
setVertex(Vector2(i, j), v);
|
||||
setVertex(Vec2(i, j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implementation of Twirl
|
||||
|
||||
Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude)
|
||||
Twirl* Twirl::create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude)
|
||||
{
|
||||
Twirl *action = new Twirl();
|
||||
|
||||
|
@ -686,7 +686,7 @@ Twirl* Twirl::create(float duration, const Size& gridSize, Vector2 position, uns
|
|||
return action;
|
||||
}
|
||||
|
||||
bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude)
|
||||
bool Twirl::initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude)
|
||||
{
|
||||
if (Grid3DAction::initWithDuration(duration, gridSize))
|
||||
{
|
||||
|
@ -701,7 +701,7 @@ bool Twirl::initWithDuration(float duration, const Size& gridSize, Vector2 posit
|
|||
return false;
|
||||
}
|
||||
|
||||
void Twirl::setPosition(const Vector2& position)
|
||||
void Twirl::setPosition(const Vec2& position)
|
||||
{
|
||||
_position = position;
|
||||
}
|
||||
|
@ -718,28 +718,28 @@ Twirl *Twirl::clone() const
|
|||
void Twirl::update(float time)
|
||||
{
|
||||
int i, j;
|
||||
Vector2 c = _position;
|
||||
Vec2 c = _position;
|
||||
|
||||
for (i = 0; i < (_gridSize.width+1); ++i)
|
||||
{
|
||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||
{
|
||||
Vector3 v = getOriginalVertex(Vector2(i ,j));
|
||||
Vec3 v = getOriginalVertex(Vec2(i ,j));
|
||||
|
||||
Vector2 avg = Vector2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
Vec2 avg = Vec2(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||
float r = avg.getLength();
|
||||
|
||||
float amp = 0.1f * _amplitude * _amplitudeRate;
|
||||
float a = r * cosf( (float)M_PI/2.0f + time * (float)M_PI * _twirls * 2 ) * amp;
|
||||
|
||||
Vector2 d = Vector2(
|
||||
Vec2 d = Vec2(
|
||||
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
|
||||
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
|
||||
|
||||
v.x = c.x + d.x;
|
||||
v.y = c.y + d.y;
|
||||
|
||||
setVertex(Vector2(i ,j), v);
|
||||
setVertex(Vec2(i ,j), v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ class CC_DLL Lens3D : public Grid3DAction
|
|||
{
|
||||
public:
|
||||
/** creates the action with center position, radius, a grid size and duration */
|
||||
static Lens3D* create(float duration, const Size& gridSize, const Vector2& position, float radius);
|
||||
static Lens3D* create(float duration, const Size& gridSize, const Vec2& position, float radius);
|
||||
|
||||
/** Get lens center position */
|
||||
inline float getLensEffect() const { return _lensEffect; }
|
||||
|
@ -129,8 +129,8 @@ public:
|
|||
/** Set whether lens is concave */
|
||||
inline void setConcave(bool concave) { _concave = concave; }
|
||||
|
||||
inline const Vector2& getPosition() const { return _position; }
|
||||
void setPosition(const Vector2& position);
|
||||
inline const Vec2& getPosition() const { return _position; }
|
||||
void setPosition(const Vec2& position);
|
||||
|
||||
// Overrides
|
||||
virtual Lens3D* clone() const override;
|
||||
|
@ -141,11 +141,11 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~Lens3D() {}
|
||||
|
||||
/** initializes the action with center position, radius, a grid size and duration */
|
||||
bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius);
|
||||
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius);
|
||||
|
||||
protected:
|
||||
/* lens center position */
|
||||
Vector2 _position;
|
||||
Vec2 _position;
|
||||
float _radius;
|
||||
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
|
||||
float _lensEffect;
|
||||
|
@ -163,12 +163,12 @@ class CC_DLL Ripple3D : public Grid3DAction
|
|||
{
|
||||
public:
|
||||
/** creates the action with radius, number of waves, amplitude, a grid size and duration */
|
||||
static Ripple3D* create(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude);
|
||||
static Ripple3D* create(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
|
||||
|
||||
/** get center position */
|
||||
inline const Vector2& getPosition() const { return _position; }
|
||||
inline const Vec2& getPosition() const { return _position; }
|
||||
/** set center position */
|
||||
void setPosition(const Vector2& position);
|
||||
void setPosition(const Vec2& position);
|
||||
|
||||
inline float getAmplitude() const { return _amplitude; }
|
||||
inline void setAmplitude(float fAmplitude) { _amplitude = fAmplitude; }
|
||||
|
@ -185,11 +185,11 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~Ripple3D() {}
|
||||
|
||||
/** initializes the action with radius, number of waves, amplitude, a grid size and duration */
|
||||
bool initWithDuration(float duration, const Size& gridSize, const Vector2& position, float radius, unsigned int waves, float amplitude);
|
||||
bool initWithDuration(float duration, const Size& gridSize, const Vec2& position, float radius, unsigned int waves, float amplitude);
|
||||
|
||||
protected:
|
||||
/* center position */
|
||||
Vector2 _position;
|
||||
Vec2 _position;
|
||||
float _radius;
|
||||
unsigned int _waves;
|
||||
float _amplitude;
|
||||
|
@ -298,12 +298,12 @@ class CC_DLL Twirl : public Grid3DAction
|
|||
{
|
||||
public:
|
||||
/** creates the action with center position, number of twirls, amplitude, a grid size and duration */
|
||||
static Twirl* create(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude);
|
||||
static Twirl* create(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
|
||||
|
||||
/** get twirl center */
|
||||
inline const Vector2& getPosition() const { return _position; }
|
||||
inline const Vec2& getPosition() const { return _position; }
|
||||
/** set twirl center */
|
||||
void setPosition(const Vector2& position);
|
||||
void setPosition(const Vec2& position);
|
||||
|
||||
inline float getAmplitude() const { return _amplitude; }
|
||||
inline void setAmplitude(float amplitude) { _amplitude = amplitude; }
|
||||
|
@ -321,11 +321,11 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~Twirl() {}
|
||||
|
||||
/** initializes the action with center position, number of twirls, amplitude, a grid size and duration */
|
||||
bool initWithDuration(float duration, const Size& gridSize, Vector2 position, unsigned int twirls, float amplitude);
|
||||
bool initWithDuration(float duration, const Size& gridSize, Vec2 position, unsigned int twirls, float amplitude);
|
||||
|
||||
protected:
|
||||
/* twirl center */
|
||||
Vector2 _position;
|
||||
Vec2 _position;
|
||||
unsigned int _twirls;
|
||||
float _amplitude;
|
||||
float _amplitudeRate;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "2d/CCActionInstant.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
@ -278,7 +278,7 @@ FlipY * FlipY::clone() const
|
|||
// Place
|
||||
//
|
||||
|
||||
Place* Place::create(const Vector2& pos)
|
||||
Place* Place::create(const Vec2& pos)
|
||||
{
|
||||
Place *ret = new Place();
|
||||
|
||||
|
@ -291,7 +291,7 @@ Place* Place::create(const Vector2& pos)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool Place::initWithPosition(const Vector2& pos) {
|
||||
bool Place::initWithPosition(const Vec2& pos) {
|
||||
_position = pos;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ class CC_DLL Place : public ActionInstant //<NSCopying>
|
|||
public:
|
||||
|
||||
/** creates a Place action with a position */
|
||||
static Place * create(const Vector2& pos);
|
||||
static Place * create(const Vec2& pos);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -242,10 +242,10 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~Place(){}
|
||||
|
||||
/** Initializes a Place action with a position */
|
||||
bool initWithPosition(const Vector2& pos);
|
||||
bool initWithPosition(const Vec2& pos);
|
||||
|
||||
protected:
|
||||
Vector2 _position;
|
||||
Vec2 _position;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Place);
|
||||
|
|
|
@ -30,6 +30,9 @@ THE SOFTWARE.
|
|||
#include "2d/CCNode.h"
|
||||
#include "CCStdC.h"
|
||||
#include "2d/CCActionInstant.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -856,7 +859,7 @@ RotateBy* RotateBy::create(float duration, float deltaAngleX, float deltaAngleY)
|
|||
return rotateBy;
|
||||
}
|
||||
|
||||
RotateBy* RotateBy::create(float duration, const Vector3& deltaAngle3D)
|
||||
RotateBy* RotateBy::create(float duration, const Vec3& deltaAngle3D)
|
||||
{
|
||||
RotateBy *rotateBy = new RotateBy();
|
||||
rotateBy->initWithDuration(duration, deltaAngle3D);
|
||||
|
@ -893,7 +896,7 @@ bool RotateBy::initWithDuration(float duration, float deltaAngleX, float deltaAn
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RotateBy::initWithDuration(float duration, const Vector3& deltaAngle3D)
|
||||
bool RotateBy::initWithDuration(float duration, const Vec3& deltaAngle3D)
|
||||
{
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
|
@ -939,7 +942,7 @@ void RotateBy::update(float time)
|
|||
{
|
||||
if(_is3D)
|
||||
{
|
||||
Vector3 v;
|
||||
Vec3 v;
|
||||
v.x = _startAngle3D.x + _angle3D.x * time;
|
||||
v.y = _startAngle3D.y + _angle3D.y * time;
|
||||
v.z = _startAngle3D.z + _angle3D.z * time;
|
||||
|
@ -957,7 +960,7 @@ RotateBy* RotateBy::reverse() const
|
|||
{
|
||||
if(_is3D)
|
||||
{
|
||||
Vector3 v;
|
||||
Vec3 v;
|
||||
v.x = - _angle3D.x;
|
||||
v.y = - _angle3D.y;
|
||||
v.z = - _angle3D.z;
|
||||
|
@ -970,7 +973,7 @@ RotateBy* RotateBy::reverse() const
|
|||
// MoveBy
|
||||
//
|
||||
|
||||
MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition)
|
||||
MoveBy* MoveBy::create(float duration, const Vec2& deltaPosition)
|
||||
{
|
||||
MoveBy *ret = new MoveBy();
|
||||
ret->initWithDuration(duration, deltaPosition);
|
||||
|
@ -979,7 +982,7 @@ MoveBy* MoveBy::create(float duration, const Vector2& deltaPosition)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool MoveBy::initWithDuration(float duration, const Vector2& deltaPosition)
|
||||
bool MoveBy::initWithDuration(float duration, const Vec2& deltaPosition)
|
||||
{
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
|
@ -1007,7 +1010,7 @@ void MoveBy::startWithTarget(Node *target)
|
|||
|
||||
MoveBy* MoveBy::reverse() const
|
||||
{
|
||||
return MoveBy::create(_duration, Vector2( -_positionDelta.x, -_positionDelta.y));
|
||||
return MoveBy::create(_duration, Vec2( -_positionDelta.x, -_positionDelta.y));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1016,10 +1019,10 @@ void MoveBy::update(float t)
|
|||
if (_target)
|
||||
{
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
Vector2 diff = currentPos - _previousPosition;
|
||||
Vec2 currentPos = _target->getPosition();
|
||||
Vec2 diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
Vector2 newPos = _startPosition + (_positionDelta * t);
|
||||
Vec2 newPos = _startPosition + (_positionDelta * t);
|
||||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
|
@ -1032,7 +1035,7 @@ void MoveBy::update(float t)
|
|||
// MoveTo
|
||||
//
|
||||
|
||||
MoveTo* MoveTo::create(float duration, const Vector2& position)
|
||||
MoveTo* MoveTo::create(float duration, const Vec2& position)
|
||||
{
|
||||
MoveTo *ret = new MoveTo();
|
||||
ret->initWithDuration(duration, position);
|
||||
|
@ -1041,7 +1044,7 @@ MoveTo* MoveTo::create(float duration, const Vector2& position)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool MoveTo::initWithDuration(float duration, const Vector2& position)
|
||||
bool MoveTo::initWithDuration(float duration, const Vec2& position)
|
||||
{
|
||||
if (ActionInterval::initWithDuration(duration))
|
||||
{
|
||||
|
@ -1249,7 +1252,7 @@ SkewBy* SkewBy::reverse() const
|
|||
// JumpBy
|
||||
//
|
||||
|
||||
JumpBy* JumpBy::create(float duration, const Vector2& position, float height, int jumps)
|
||||
JumpBy* JumpBy::create(float duration, const Vec2& position, float height, int jumps)
|
||||
{
|
||||
JumpBy *jumpBy = new JumpBy();
|
||||
jumpBy->initWithDuration(duration, position, height, jumps);
|
||||
|
@ -1258,7 +1261,7 @@ JumpBy* JumpBy::create(float duration, const Vector2& position, float height, in
|
|||
return jumpBy;
|
||||
}
|
||||
|
||||
bool JumpBy::initWithDuration(float duration, const Vector2& position, float height, int jumps)
|
||||
bool JumpBy::initWithDuration(float duration, const Vec2& position, float height, int jumps)
|
||||
{
|
||||
CCASSERT(jumps>=0, "Number of jumps must be >= 0");
|
||||
|
||||
|
@ -1300,24 +1303,24 @@ void JumpBy::update(float t)
|
|||
|
||||
float x = _delta.x * t;
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
Vec2 currentPos = _target->getPosition();
|
||||
|
||||
Vector2 diff = currentPos - _previousPos;
|
||||
Vec2 diff = currentPos - _previousPos;
|
||||
_startPosition = diff + _startPosition;
|
||||
|
||||
Vector2 newPos = _startPosition + Vector2(x,y);
|
||||
Vec2 newPos = _startPosition + Vec2(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPos = newPos;
|
||||
#else
|
||||
_target->setPosition(_startPosition + Vector2(x,y));
|
||||
_target->setPosition(_startPosition + Vec2(x,y));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
||||
JumpBy* JumpBy::reverse() const
|
||||
{
|
||||
return JumpBy::create(_duration, Vector2(-_delta.x, -_delta.y),
|
||||
return JumpBy::create(_duration, Vec2(-_delta.x, -_delta.y),
|
||||
_height, _jumps);
|
||||
}
|
||||
|
||||
|
@ -1325,7 +1328,7 @@ JumpBy* JumpBy::reverse() const
|
|||
// JumpTo
|
||||
//
|
||||
|
||||
JumpTo* JumpTo::create(float duration, const Vector2& position, float height, int jumps)
|
||||
JumpTo* JumpTo::create(float duration, const Vec2& position, float height, int jumps)
|
||||
{
|
||||
JumpTo *jumpTo = new JumpTo();
|
||||
jumpTo->initWithDuration(duration, position, height, jumps);
|
||||
|
@ -1352,7 +1355,7 @@ JumpTo* JumpTo::reverse() const
|
|||
void JumpTo::startWithTarget(Node *target)
|
||||
{
|
||||
JumpBy::startWithTarget(target);
|
||||
_delta = Vector2(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
_delta = Vec2(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
}
|
||||
|
||||
// Bezier cubic formula:
|
||||
|
@ -1424,16 +1427,16 @@ void BezierBy::update(float time)
|
|||
float y = bezierat(ya, yb, yc, yd, time);
|
||||
|
||||
#if CC_ENABLE_STACKABLE_ACTIONS
|
||||
Vector2 currentPos = _target->getPosition();
|
||||
Vector2 diff = currentPos - _previousPosition;
|
||||
Vec2 currentPos = _target->getPosition();
|
||||
Vec2 diff = currentPos - _previousPosition;
|
||||
_startPosition = _startPosition + diff;
|
||||
|
||||
Vector2 newPos = _startPosition + Vector2(x,y);
|
||||
Vec2 newPos = _startPosition + Vec2(x,y);
|
||||
_target->setPosition(newPos);
|
||||
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition( _startPosition + Vector2(x,y));
|
||||
_target->setPosition( _startPosition + Vec2(x,y));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
@ -2137,6 +2140,7 @@ Animate::Animate()
|
|||
, _origFrame(nullptr)
|
||||
, _executedLoops(0)
|
||||
, _animation(nullptr)
|
||||
, _frameDisplayedEvent(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2146,6 +2150,7 @@ Animate::~Animate()
|
|||
CC_SAFE_RELEASE(_animation);
|
||||
CC_SAFE_RELEASE(_origFrame);
|
||||
CC_SAFE_DELETE(_splitTimes);
|
||||
CC_SAFE_RELEASE(_frameDisplayedEvent);
|
||||
}
|
||||
|
||||
bool Animate::initWithAnimation(Animation* animation)
|
||||
|
@ -2256,7 +2261,13 @@ void Animate::update(float t)
|
|||
const ValueMap& dict = frame->getUserInfo();
|
||||
if ( !dict.empty() )
|
||||
{
|
||||
//TODO: [[NSNotificationCenter defaultCenter] postNotificationName:AnimationFrameDisplayedNotification object:target_ userInfo:dict];
|
||||
if (_frameDisplayedEvent == nullptr)
|
||||
_frameDisplayedEvent = new EventCustom(AnimationFrameDisplayedNotification);
|
||||
|
||||
_frameDisplayedEventInfo.target = _target;
|
||||
_frameDisplayedEventInfo.userInfo = &dict;
|
||||
_frameDisplayedEvent->setUserData(&_frameDisplayedEventInfo);
|
||||
Director::getInstance()->getEventDispatcher()->dispatchEvent(_frameDisplayedEvent);
|
||||
}
|
||||
_nextFrame = i+1;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,14 @@ THE SOFTWARE.
|
|||
#ifndef __ACTION_CCINTERVAL_ACTION_H__
|
||||
#define __ACTION_CCINTERVAL_ACTION_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCAction.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCAnimation.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "base/CCVector.h"
|
||||
#include <vector>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -370,7 +371,7 @@ public:
|
|||
/** creates the action */
|
||||
static RotateBy* create(float duration, float deltaAngle);
|
||||
static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
||||
static RotateBy* create(float duration, const Vector3& deltaAngle3D);
|
||||
static RotateBy* create(float duration, const Vec3& deltaAngle3D);
|
||||
|
||||
//
|
||||
// Override
|
||||
|
@ -387,7 +388,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
/** initializes the action */
|
||||
bool initWithDuration(float duration, float deltaAngle);
|
||||
bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
||||
bool initWithDuration(float duration, const Vector3& deltaAngle3D);
|
||||
bool initWithDuration(float duration, const Vec3& deltaAngle3D);
|
||||
|
||||
protected:
|
||||
float _angleZ_X;
|
||||
|
@ -396,8 +397,8 @@ protected:
|
|||
float _startAngleZ_Y;
|
||||
|
||||
bool _is3D;
|
||||
Vector3 _angle3D;
|
||||
Vector3 _startAngle3D;
|
||||
Vec3 _angle3D;
|
||||
Vec3 _startAngle3D;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(RotateBy);
|
||||
|
@ -413,7 +414,7 @@ class CC_DLL MoveBy : public ActionInterval
|
|||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static MoveBy* create(float duration, const Vector2& deltaPosition);
|
||||
static MoveBy* create(float duration, const Vec2& deltaPosition);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -428,12 +429,12 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~MoveBy() {}
|
||||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vector2& deltaPosition);
|
||||
bool initWithDuration(float duration, const Vec2& deltaPosition);
|
||||
|
||||
protected:
|
||||
Vector2 _positionDelta;
|
||||
Vector2 _startPosition;
|
||||
Vector2 _previousPosition;
|
||||
Vec2 _positionDelta;
|
||||
Vec2 _startPosition;
|
||||
Vec2 _previousPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(MoveBy);
|
||||
|
@ -448,7 +449,7 @@ class CC_DLL MoveTo : public MoveBy
|
|||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static MoveTo* create(float duration, const Vector2& position);
|
||||
static MoveTo* create(float duration, const Vec2& position);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -461,10 +462,10 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~MoveTo() {}
|
||||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vector2& position);
|
||||
bool initWithDuration(float duration, const Vec2& position);
|
||||
|
||||
protected:
|
||||
Vector2 _endPosition;
|
||||
Vec2 _endPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(MoveTo);
|
||||
|
@ -539,7 +540,7 @@ class CC_DLL JumpBy : public ActionInterval
|
|||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static JumpBy* create(float duration, const Vector2& position, float height, int jumps);
|
||||
static JumpBy* create(float duration, const Vec2& position, float height, int jumps);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
|
@ -554,14 +555,14 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual ~JumpBy() {}
|
||||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vector2& position, float height, int jumps);
|
||||
bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
|
||||
|
||||
protected:
|
||||
Vector2 _startPosition;
|
||||
Vector2 _delta;
|
||||
Vec2 _startPosition;
|
||||
Vec2 _delta;
|
||||
float _height;
|
||||
int _jumps;
|
||||
Vector2 _previousPos;
|
||||
Vec2 _previousPos;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(JumpBy);
|
||||
|
@ -573,7 +574,7 @@ class CC_DLL JumpTo : public JumpBy
|
|||
{
|
||||
public:
|
||||
/** creates the action */
|
||||
static JumpTo* create(float duration, const Vector2& position, float height, int jumps);
|
||||
static JumpTo* create(float duration, const Vec2& position, float height, int jumps);
|
||||
|
||||
//
|
||||
// Override
|
||||
|
@ -592,11 +593,11 @@ private:
|
|||
*/
|
||||
typedef struct _ccBezierConfig {
|
||||
//! end position of the bezier
|
||||
Vector2 endPosition;
|
||||
Vec2 endPosition;
|
||||
//! Bezier control point 1
|
||||
Vector2 controlPoint_1;
|
||||
Vec2 controlPoint_1;
|
||||
//! Bezier control point 2
|
||||
Vector2 controlPoint_2;
|
||||
Vec2 controlPoint_2;
|
||||
} ccBezierConfig;
|
||||
|
||||
/** @brief An action that moves the target with a cubic Bezier curve by a certain distance.
|
||||
|
@ -630,8 +631,8 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
protected:
|
||||
ccBezierConfig _config;
|
||||
Vector2 _startPosition;
|
||||
Vector2 _previousPosition;
|
||||
Vec2 _startPosition;
|
||||
Vec2 _previousPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(BezierBy);
|
||||
|
@ -1037,6 +1038,8 @@ protected:
|
|||
unsigned int _executedLoops;
|
||||
Animation* _animation;
|
||||
|
||||
EventCustom* _frameDisplayedEvent;
|
||||
AnimationFrame::DisplayedEventInfo _frameDisplayedEventInfo;
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Animate);
|
||||
};
|
||||
|
|
|
@ -30,8 +30,8 @@ THE SOFTWARE.
|
|||
#include "2d/CCNode.h"
|
||||
#include "base/CCScheduler.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "2d/ccCArray.h"
|
||||
#include "2d/uthash.h"
|
||||
#include "base/ccCArray.h"
|
||||
#include "base/uthash.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
//
|
||||
|
|
|
@ -76,7 +76,7 @@ void PageTurn3D::update(float time)
|
|||
for (int j = 0; j <= _gridSize.height; ++j)
|
||||
{
|
||||
// Get original vertex
|
||||
Vector3 p = getOriginalVertex(Vector2(i ,j));
|
||||
Vec3 p = getOriginalVertex(Vec2(i ,j));
|
||||
|
||||
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
|
||||
float r = R * sinTheta;
|
||||
|
@ -111,7 +111,7 @@ void PageTurn3D::update(float time)
|
|||
}
|
||||
|
||||
// Set new coords
|
||||
setVertex(Vector2(i, j), p);
|
||||
setVertex(Vec2(i, j), p);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ NS_CC_BEGIN
|
|||
|
||||
struct Tile
|
||||
{
|
||||
Vector2 position;
|
||||
Vector2 startPosition;
|
||||
Vec2 position;
|
||||
Vec2 startPosition;
|
||||
Size delta;
|
||||
};
|
||||
|
||||
|
@ -91,7 +91,7 @@ void ShakyTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(i, j));
|
||||
Quad3 coords = getOriginalTile(Vec2(i, j));
|
||||
|
||||
// X
|
||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||
|
@ -113,7 +113,7 @@ void ShakyTiles3D::update(float time)
|
|||
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
|
||||
}
|
||||
|
||||
setTile(Vector2(i, j), coords);
|
||||
setTile(Vec2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void ShatteredTiles3D::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(i ,j));
|
||||
Quad3 coords = getOriginalTile(Vec2(i ,j));
|
||||
|
||||
// X
|
||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||
|
@ -195,7 +195,7 @@ void ShatteredTiles3D::update(float time)
|
|||
coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
|
||||
}
|
||||
|
||||
setTile(Vector2(i, j), coords);
|
||||
setTile(Vec2(i, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ void ShuffleTiles::shuffle(unsigned int *array, unsigned int len)
|
|||
|
||||
Size ShuffleTiles::getDelta(const Size& pos) const
|
||||
{
|
||||
Vector2 pos2;
|
||||
Vec2 pos2;
|
||||
|
||||
unsigned int idx = pos.width * _gridSize.height + pos.height;
|
||||
|
||||
|
@ -277,11 +277,11 @@ Size ShuffleTiles::getDelta(const Size& pos) const
|
|||
return Size((int)(pos2.x - pos.width), (int)(pos2.y - pos.height));
|
||||
}
|
||||
|
||||
void ShuffleTiles::placeTile(const Vector2& pos, Tile *t)
|
||||
void ShuffleTiles::placeTile(const Vec2& pos, Tile *t)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
|
||||
Vector2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vec2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
coords.bl.x += (int)(t->position.x * step.x);
|
||||
coords.bl.y += (int)(t->position.y * step.y);
|
||||
|
||||
|
@ -329,8 +329,8 @@ void ShuffleTiles::startWithTarget(Node *target)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
tileArray->position = Vector2((float)i, (float)j);
|
||||
tileArray->startPosition = Vector2((float)i, (float)j);
|
||||
tileArray->position = Vec2((float)i, (float)j);
|
||||
tileArray->startPosition = Vec2((float)i, (float)j);
|
||||
tileArray->delta = getDelta(Size(i, j));
|
||||
++tileArray;
|
||||
}
|
||||
|
@ -347,8 +347,8 @@ void ShuffleTiles::update(float time)
|
|||
{
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
tileArray->position = Vector2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
|
||||
placeTile(Vector2(i, j), tileArray);
|
||||
tileArray->position = Vec2((float)tileArray->delta.width, (float)tileArray->delta.height) * time;
|
||||
placeTile(Vec2(i, j), tileArray);
|
||||
++tileArray;
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ FadeOutTRTiles* FadeOutTRTiles::clone() const
|
|||
|
||||
float FadeOutTRTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
if ((n.x + n.y) == 0.0f)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -395,22 +395,22 @@ float FadeOutTRTiles::testFunc(const Size& pos, float time)
|
|||
return powf((pos.width + pos.height) / (n.x + n.y), 6);
|
||||
}
|
||||
|
||||
void FadeOutTRTiles::turnOnTile(const Vector2& pos)
|
||||
void FadeOutTRTiles::turnOnTile(const Vec2& pos)
|
||||
{
|
||||
setTile(pos, getOriginalTile(pos));
|
||||
}
|
||||
|
||||
void FadeOutTRTiles::turnOffTile(const Vector2& pos)
|
||||
void FadeOutTRTiles::turnOffTile(const Vec2& pos)
|
||||
{
|
||||
Quad3 coords;
|
||||
memset(&coords, 0, sizeof(Quad3));
|
||||
setTile(pos, coords);
|
||||
}
|
||||
|
||||
void FadeOutTRTiles::transformTile(const Vector2& pos, float distance)
|
||||
void FadeOutTRTiles::transformTile(const Vec2& pos, float distance)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
Vector2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vec2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
|
||||
coords.bl.x += (step.x / 2) * (1.0f - distance);
|
||||
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
||||
|
@ -438,15 +438,15 @@ void FadeOutTRTiles::update(float time)
|
|||
float distance = testFunc(Size(i, j), time);
|
||||
if ( distance == 0 )
|
||||
{
|
||||
turnOffTile(Vector2(i, j));
|
||||
turnOffTile(Vec2(i, j));
|
||||
} else
|
||||
if (distance < 1)
|
||||
{
|
||||
transformTile(Vector2(i, j), distance);
|
||||
transformTile(Vec2(i, j), distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
turnOnTile(Vector2(i, j));
|
||||
turnOnTile(Vec2(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ FadeOutBLTiles* FadeOutBLTiles::clone() const
|
|||
|
||||
float FadeOutBLTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
if ((pos.width + pos.height) == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -525,7 +525,7 @@ FadeOutUpTiles* FadeOutUpTiles::clone() const
|
|||
|
||||
float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * time;
|
||||
if (n.y == 0.0f)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -534,10 +534,10 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
|||
return powf(pos.height / n.y, 6);
|
||||
}
|
||||
|
||||
void FadeOutUpTiles::transformTile(const Vector2& pos, float distance)
|
||||
void FadeOutUpTiles::transformTile(const Vec2& pos, float distance)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(pos);
|
||||
Vector2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
Vec2 step = _gridNodeTarget->getGrid()->getStep();
|
||||
|
||||
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
||||
coords.br.y += (step.y / 2) * (1.0f - distance);
|
||||
|
@ -579,7 +579,7 @@ FadeOutDownTiles* FadeOutDownTiles::clone() const
|
|||
|
||||
float FadeOutDownTiles::testFunc(const Size& pos, float time)
|
||||
{
|
||||
Vector2 n = Vector2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
Vec2 n = Vec2((float)_gridSize.width, (float)_gridSize.height) * (1.0f - time);
|
||||
if (pos.height == 0)
|
||||
{
|
||||
return 1.0f;
|
||||
|
@ -662,12 +662,12 @@ void TurnOffTiles::shuffle(unsigned int *array, unsigned int len)
|
|||
}
|
||||
}
|
||||
|
||||
void TurnOffTiles::turnOnTile(const Vector2& pos)
|
||||
void TurnOffTiles::turnOnTile(const Vec2& pos)
|
||||
{
|
||||
setTile(pos, getOriginalTile(pos));
|
||||
}
|
||||
|
||||
void TurnOffTiles::turnOffTile(const Vector2& pos)
|
||||
void TurnOffTiles::turnOffTile(const Vec2& pos)
|
||||
{
|
||||
Quad3 coords;
|
||||
|
||||
|
@ -706,7 +706,7 @@ void TurnOffTiles::update(float time)
|
|||
for( i = 0; i < _tilesCount; i++ )
|
||||
{
|
||||
t = _tilesOrder[i];
|
||||
Vector2 tilePos = Vector2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
Vec2 tilePos = Vec2( (unsigned int)(t / _gridSize.height), t % (unsigned int)_gridSize.height );
|
||||
|
||||
if ( i < l )
|
||||
{
|
||||
|
@ -771,7 +771,7 @@ void WavesTiles3D::update(float time)
|
|||
{
|
||||
for( j = 0; j < _gridSize.height; j++ )
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(i, j));
|
||||
Quad3 coords = getOriginalTile(Vec2(i, j));
|
||||
|
||||
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
|
||||
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
|
||||
|
@ -779,7 +779,7 @@ void WavesTiles3D::update(float time)
|
|||
coords.tl.z = coords.bl.z;
|
||||
coords.tr.z = coords.bl.z;
|
||||
|
||||
setTile(Vector2(i, j), coords);
|
||||
setTile(Vec2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ void JumpTiles3D::update(float time)
|
|||
{
|
||||
for( j = 0; j < _gridSize.height; j++ )
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(i, j));
|
||||
Quad3 coords = getOriginalTile(Vec2(i, j));
|
||||
|
||||
if ( ((i+j) % 2) == 0 )
|
||||
{
|
||||
|
@ -856,7 +856,7 @@ void JumpTiles3D::update(float time)
|
|||
coords.tr.z += sinz2;
|
||||
}
|
||||
|
||||
setTile(Vector2(i, j), coords);
|
||||
setTile(Vec2(i, j), coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ void SplitRows::update(float time)
|
|||
|
||||
for (j = 0; j < _gridSize.height; ++j)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(0, j));
|
||||
Quad3 coords = getOriginalTile(Vec2(0, j));
|
||||
float direction = 1;
|
||||
|
||||
if ( (j % 2 ) == 0 )
|
||||
|
@ -923,7 +923,7 @@ void SplitRows::update(float time)
|
|||
coords.tl.x += direction * _winSize.width * time;
|
||||
coords.tr.x += direction * _winSize.width * time;
|
||||
|
||||
setTile(Vector2(0, j), coords);
|
||||
setTile(Vec2(0, j), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,7 +975,7 @@ void SplitCols::update(float time)
|
|||
|
||||
for (i = 0; i < _gridSize.width; ++i)
|
||||
{
|
||||
Quad3 coords = getOriginalTile(Vector2(i, 0));
|
||||
Quad3 coords = getOriginalTile(Vec2(i, 0));
|
||||
float direction = 1;
|
||||
|
||||
if ( (i % 2 ) == 0 )
|
||||
|
@ -988,7 +988,7 @@ void SplitCols::update(float time)
|
|||
coords.tl.y += direction * _winSize.height * time;
|
||||
coords.tr.y += direction * _winSize.height * time;
|
||||
|
||||
setTile(Vector2(i, 0), coords);
|
||||
setTile(Vec2(i, 0), coords);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
void shuffle(unsigned int *array, unsigned int len);
|
||||
Size getDelta(const Size& pos) const;
|
||||
void placeTile(const Vector2& pos, Tile *t);
|
||||
void placeTile(const Vec2& pos, Tile *t);
|
||||
|
||||
// Overrides
|
||||
virtual void startWithTarget(Node *target) override;
|
||||
|
@ -134,9 +134,9 @@ public:
|
|||
static FadeOutTRTiles* create(float duration, const Size& gridSize);
|
||||
|
||||
virtual float testFunc(const Size& pos, float time);
|
||||
void turnOnTile(const Vector2& pos);
|
||||
void turnOffTile(const Vector2& pos);
|
||||
virtual void transformTile(const Vector2& pos, float distance);
|
||||
void turnOnTile(const Vec2& pos);
|
||||
void turnOffTile(const Vec2& pos);
|
||||
virtual void transformTile(const Vec2& pos, float distance);
|
||||
|
||||
// Overrides
|
||||
virtual void update(float time) override;
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
/** creates the action with the grid size and the duration */
|
||||
static FadeOutUpTiles* create(float duration, const Size& gridSize);
|
||||
|
||||
virtual void transformTile(const Vector2& pos, float distance);
|
||||
virtual void transformTile(const Vec2& pos, float distance);
|
||||
|
||||
// Overrides
|
||||
virtual FadeOutUpTiles* clone() const override;
|
||||
|
@ -227,8 +227,8 @@ public:
|
|||
static TurnOffTiles* create(float duration, const Size& gridSize, unsigned int seed);
|
||||
|
||||
void shuffle(unsigned int *array, unsigned int len);
|
||||
void turnOnTile(const Vector2& pos);
|
||||
void turnOffTile(const Vector2& pos);
|
||||
void turnOnTile(const Vec2& pos);
|
||||
void turnOffTile(const Vec2& pos);
|
||||
|
||||
// Overrides
|
||||
virtual TurnOffTiles* clone() const override;
|
||||
|
|
|
@ -25,10 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "2d/CCAnimation.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -57,6 +57,13 @@ class SpriteFrame;
|
|||
class CC_DLL AnimationFrame : public Ref, public Clonable
|
||||
{
|
||||
public:
|
||||
|
||||
struct DisplayedEventInfo
|
||||
{
|
||||
Node* target;
|
||||
const ValueMap* userInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the animation frame with a spriteframe, number of delay units and a notification user info
|
||||
* @since 3.0
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#include "2d/CCAnimation.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCSpriteFrameCache.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -174,7 +174,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
|
|||
float delayUnits = entry["delayUnits"].asFloat();
|
||||
Value& userInfo = entry["notification"];
|
||||
|
||||
AnimationFrame *animFrame = AnimationFrame::create(spriteFrame, delayUnits, userInfo.asValueMap());
|
||||
AnimationFrame *animFrame = AnimationFrame::create(spriteFrame, delayUnits, userInfo.getType() == Value::Type::MAP ? userInfo.asValueMap() : ValueMapNull);
|
||||
|
||||
array.pushBack(animFrame);
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCAtlasNode.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
|
@ -133,7 +133,7 @@ void AtlasNode::updateAtlasValues()
|
|||
}
|
||||
|
||||
// AtlasNode - draw
|
||||
void AtlasNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void AtlasNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_quadCommand.init(
|
||||
_globalZOrder,
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#define __CCATLAS_NODE_H__
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "renderer/CCQuadCommand.h"
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual Texture2D* getTexture() const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
|
|
|
@ -196,14 +196,14 @@ void ClippingNode::drawFullScreenQuadClearStencil()
|
|||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
|
||||
DrawPrimitives::drawSolidRect(Vector2(-1,-1), Vector2(1,1), Color4F(1, 1, 1, 1));
|
||||
DrawPrimitives::drawSolidRect(Vec2(-1,-1), Vec2(1,1), Color4F(1, 1, 1, 1));
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
}
|
||||
|
||||
void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if(!_visible)
|
||||
return;
|
||||
|
@ -214,7 +214,7 @@ void ClippingNode::visit(Renderer *renderer, const Matrix &parentTransform, bool
|
|||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
@ -382,7 +382,7 @@ void ClippingNode::onBeforeVisit()
|
|||
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
||||
|
||||
// draw a fullscreen solid rectangle to clear the stencil buffer
|
||||
//ccDrawSolidRect(Vector2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
//ccDrawSolidRect(Vec2::ZERO, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||
drawFullScreenQuadClearStencil();
|
||||
|
||||
///////////////////////////////////
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
ClippingNode();
|
||||
|
|
|
@ -23,7 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "2d/CCComponent.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -26,7 +26,7 @@ THE SOFTWARE.
|
|||
#define __CC_FRAMEWORK_COMPONENT_H__
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
#include <string>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -34,67 +34,67 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
// Vector2 == CGPoint in 32-bits, but not in 64-bits (OS X)
|
||||
// Vec2 == CGPoint in 32-bits, but not in 64-bits (OS X)
|
||||
// that's why the "v2f" functions are needed
|
||||
static Vector2 v2fzero(0.0f,0.0f);
|
||||
static Vec2 v2fzero(0.0f,0.0f);
|
||||
|
||||
static inline Vector2 v2f(float x, float y)
|
||||
static inline Vec2 v2f(float x, float y)
|
||||
{
|
||||
Vector2 ret(x, y);
|
||||
Vec2 ret(x, y);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline Vector2 v2fadd(const Vector2 &v0, const Vector2 &v1)
|
||||
static inline Vec2 v2fadd(const Vec2 &v0, const Vec2 &v1)
|
||||
{
|
||||
return v2f(v0.x+v1.x, v0.y+v1.y);
|
||||
}
|
||||
|
||||
static inline Vector2 v2fsub(const Vector2 &v0, const Vector2 &v1)
|
||||
static inline Vec2 v2fsub(const Vec2 &v0, const Vec2 &v1)
|
||||
{
|
||||
return v2f(v0.x-v1.x, v0.y-v1.y);
|
||||
}
|
||||
|
||||
static inline Vector2 v2fmult(const Vector2 &v, float s)
|
||||
static inline Vec2 v2fmult(const Vec2 &v, float s)
|
||||
{
|
||||
return v2f(v.x * s, v.y * s);
|
||||
}
|
||||
|
||||
static inline Vector2 v2fperp(const Vector2 &p0)
|
||||
static inline Vec2 v2fperp(const Vec2 &p0)
|
||||
{
|
||||
return v2f(-p0.y, p0.x);
|
||||
}
|
||||
|
||||
static inline Vector2 v2fneg(const Vector2 &p0)
|
||||
static inline Vec2 v2fneg(const Vec2 &p0)
|
||||
{
|
||||
return v2f(-p0.x, - p0.y);
|
||||
}
|
||||
|
||||
static inline float v2fdot(const Vector2 &p0, const Vector2 &p1)
|
||||
static inline float v2fdot(const Vec2 &p0, const Vec2 &p1)
|
||||
{
|
||||
return p0.x * p1.x + p0.y * p1.y;
|
||||
}
|
||||
|
||||
static inline Vector2 v2fforangle(float _a_)
|
||||
static inline Vec2 v2fforangle(float _a_)
|
||||
{
|
||||
return v2f(cosf(_a_), sinf(_a_));
|
||||
}
|
||||
|
||||
static inline Vector2 v2fnormalize(const Vector2 &p)
|
||||
static inline Vec2 v2fnormalize(const Vec2 &p)
|
||||
{
|
||||
Vector2 r = Vector2(p.x, p.y).getNormalized();
|
||||
Vec2 r = Vec2(p.x, p.y).getNormalized();
|
||||
return v2f(r.x, r.y);
|
||||
}
|
||||
|
||||
static inline Vector2 __v2f(const Vector2 &v)
|
||||
static inline Vec2 __v2f(const Vec2 &v)
|
||||
{
|
||||
//#ifdef __LP64__
|
||||
return v2f(v.x, v.y);
|
||||
// #else
|
||||
// return * ((Vector2*) &v);
|
||||
// return * ((Vec2*) &v);
|
||||
// #endif
|
||||
}
|
||||
|
||||
static inline Tex2F __t(const Vector2 &v)
|
||||
static inline Tex2F __t(const Vec2 &v)
|
||||
{
|
||||
return *(Tex2F*)&v;
|
||||
}
|
||||
|
@ -205,14 +205,14 @@ bool DrawNode::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void DrawNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void DrawNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this, transform, transformUpdated);
|
||||
renderer->addCommand(&_customCommand);
|
||||
}
|
||||
|
||||
void DrawNode::onDraw(const Matrix &transform, bool transformUpdated)
|
||||
void DrawNode::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
auto glProgram = getGLProgram();
|
||||
glProgram->use();
|
||||
|
@ -252,15 +252,15 @@ void DrawNode::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
}
|
||||
|
||||
void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color)
|
||||
void DrawNode::drawDot(const Vec2 &pos, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
V2F_C4B_T2F a = {Vector2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
|
||||
V2F_C4B_T2F b = {Vector2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
|
||||
V2F_C4B_T2F c = {Vector2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
|
||||
V2F_C4B_T2F d = {Vector2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
|
||||
V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
|
||||
V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
|
||||
V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
|
||||
V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
|
||||
|
@ -273,28 +273,28 @@ void DrawNode::drawDot(const Vector2 &pos, float radius, const Color4F &color)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color)
|
||||
void DrawNode::drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 6*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
Vector2 a = __v2f(from);
|
||||
Vector2 b = __v2f(to);
|
||||
Vec2 a = __v2f(from);
|
||||
Vec2 b = __v2f(to);
|
||||
|
||||
|
||||
Vector2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
||||
Vector2 t = v2fperp(n);
|
||||
Vec2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
||||
Vec2 t = v2fperp(n);
|
||||
|
||||
Vector2 nw = v2fmult(n, radius);
|
||||
Vector2 tw = v2fmult(t, radius);
|
||||
Vector2 v0 = v2fsub(b, v2fadd(nw, tw));
|
||||
Vector2 v1 = v2fadd(b, v2fsub(nw, tw));
|
||||
Vector2 v2 = v2fsub(b, nw);
|
||||
Vector2 v3 = v2fadd(b, nw);
|
||||
Vector2 v4 = v2fsub(a, nw);
|
||||
Vector2 v5 = v2fadd(a, nw);
|
||||
Vector2 v6 = v2fsub(a, v2fsub(nw, tw));
|
||||
Vector2 v7 = v2fadd(a, v2fadd(nw, tw));
|
||||
Vec2 nw = v2fmult(n, radius);
|
||||
Vec2 tw = v2fmult(t, radius);
|
||||
Vec2 v0 = v2fsub(b, v2fadd(nw, tw));
|
||||
Vec2 v1 = v2fadd(b, v2fsub(nw, tw));
|
||||
Vec2 v2 = v2fsub(b, nw);
|
||||
Vec2 v3 = v2fadd(b, nw);
|
||||
Vec2 v4 = v2fsub(a, nw);
|
||||
Vec2 v5 = v2fadd(a, nw);
|
||||
Vec2 v6 = v2fsub(a, v2fsub(nw, tw));
|
||||
Vec2 v7 = v2fadd(a, v2fadd(nw, tw));
|
||||
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
|
@ -346,24 +346,24 @@ void DrawNode::drawSegment(const Vector2 &from, const Vector2 &to, float radius,
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
void DrawNode::drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
{
|
||||
CCASSERT(count >= 0, "invalid count value");
|
||||
|
||||
struct ExtrudeVerts {Vector2 offset, n;};
|
||||
struct ExtrudeVerts {Vec2 offset, n;};
|
||||
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
|
||||
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Vector2 v0 = __v2f(verts[(i-1+count)%count]);
|
||||
Vector2 v1 = __v2f(verts[i]);
|
||||
Vector2 v2 = __v2f(verts[(i+1)%count]);
|
||||
Vec2 v0 = __v2f(verts[(i-1+count)%count]);
|
||||
Vec2 v1 = __v2f(verts[i]);
|
||||
Vec2 v2 = __v2f(verts[(i+1)%count]);
|
||||
|
||||
Vector2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
|
||||
Vector2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
|
||||
Vec2 n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
|
||||
Vec2 n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
|
||||
|
||||
Vector2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
|
||||
Vec2 offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
|
||||
struct ExtrudeVerts tmp = {offset, n2};
|
||||
extrude[i] = tmp;
|
||||
}
|
||||
|
@ -380,9 +380,9 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
|
|||
float inset = (outline == false ? 0.5 : 0.0);
|
||||
for (int i = 0; i < count-2; i++)
|
||||
{
|
||||
Vector2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
|
||||
Vector2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
|
||||
Vector2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
|
||||
Vec2 v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
|
||||
Vec2 v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
|
||||
Vec2 v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
|
||||
|
||||
V2F_C4B_T2F_Triangle tmp = {
|
||||
{v0, Color4B(fillColor), __t(v2fzero)},
|
||||
|
@ -396,20 +396,20 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
|
|||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
int j = (i+1)%count;
|
||||
Vector2 v0 = __v2f(verts[i]);
|
||||
Vector2 v1 = __v2f(verts[j]);
|
||||
Vec2 v0 = __v2f(verts[i]);
|
||||
Vec2 v1 = __v2f(verts[j]);
|
||||
|
||||
Vector2 n0 = extrude[i].n;
|
||||
Vec2 n0 = extrude[i].n;
|
||||
|
||||
Vector2 offset0 = extrude[i].offset;
|
||||
Vector2 offset1 = extrude[j].offset;
|
||||
Vec2 offset0 = extrude[i].offset;
|
||||
Vec2 offset1 = extrude[j].offset;
|
||||
|
||||
if(outline)
|
||||
{
|
||||
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
|
||||
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
|
||||
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
|
||||
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
|
||||
Vec2 inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
|
||||
Vec2 inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
|
||||
Vec2 outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
|
||||
Vec2 outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
|
||||
|
||||
V2F_C4B_T2F_Triangle tmp1 = {
|
||||
{inner0, Color4B(borderColor), __t(v2fneg(n0))},
|
||||
|
@ -426,10 +426,10 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
|
|||
*cursor++ = tmp2;
|
||||
}
|
||||
else {
|
||||
Vector2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
|
||||
Vector2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
|
||||
Vector2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
|
||||
Vector2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
|
||||
Vec2 inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
|
||||
Vec2 inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
|
||||
Vec2 outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
|
||||
Vec2 outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
|
||||
|
||||
V2F_C4B_T2F_Triangle tmp1 = {
|
||||
{inner0, Color4B(fillColor), __t(v2fzero)},
|
||||
|
@ -454,15 +454,15 @@ void DrawNode::drawPolygon(Vector2 *verts, int count, const Color4F &fillColor,
|
|||
free(extrude);
|
||||
}
|
||||
|
||||
void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color)
|
||||
void DrawNode::drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
Color4B col = Color4B(color);
|
||||
V2F_C4B_T2F a = {Vector2(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
|
||||
V2F_C4B_T2F b = {Vector2(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
|
||||
V2F_C4B_T2F c = {Vector2(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
|
||||
V2F_C4B_T2F a = {Vec2(p1.x, p1.y), col, Tex2F(0.0, 0.0) };
|
||||
V2F_C4B_T2F b = {Vec2(p2.x, p2.y), col, Tex2F(0.0, 0.0) };
|
||||
V2F_C4B_T2F c = {Vec2(p3.x, p3.y), col, Tex2F(0.0, 0.0) };
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
V2F_C4B_T2F_Triangle triangle = {a, b, c};
|
||||
|
@ -472,23 +472,23 @@ void DrawNode::drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color)
|
||||
void DrawNode::drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = (segments + 1) * 3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
Tex2F texCoord = Tex2F(0.0, 0.0);
|
||||
Color4B col = Color4B(color);
|
||||
Vector2 vertex;
|
||||
Vector2 firstVertex = Vector2(from.x, from.y);
|
||||
Vector2 lastVertex = Vector2(to.x, to.y);
|
||||
Vec2 vertex;
|
||||
Vec2 firstVertex = Vec2(from.x, from.y);
|
||||
Vec2 lastVertex = Vec2(to.x, to.y);
|
||||
|
||||
float t = 0;
|
||||
for(unsigned int i = segments + 1; i > 0; i--)
|
||||
{
|
||||
float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x;
|
||||
float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y;
|
||||
vertex = Vector2(x, y);
|
||||
vertex = Vec2(x, y);
|
||||
|
||||
V2F_C4B_T2F a = {firstVertex, col, texCoord };
|
||||
V2F_C4B_T2F b = {lastVertex, col, texCoord };
|
||||
|
@ -503,23 +503,23 @@ void DrawNode::drawCubicBezier(const Vector2& from, const Vector2& control1, con
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color)
|
||||
void DrawNode::drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = (segments + 1) * 3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
Tex2F texCoord = Tex2F(0.0, 0.0);
|
||||
Color4B col = Color4B(color);
|
||||
Vector2 vertex;
|
||||
Vector2 firstVertex = Vector2(from.x, from.y);
|
||||
Vector2 lastVertex = Vector2(to.x, to.y);
|
||||
Vec2 vertex;
|
||||
Vec2 firstVertex = Vec2(from.x, from.y);
|
||||
Vec2 lastVertex = Vec2(to.x, to.y);
|
||||
|
||||
float t = 0;
|
||||
for(unsigned int i = segments + 1; i > 0; i--)
|
||||
{
|
||||
float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x;
|
||||
float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y;
|
||||
vertex = Vector2(x, y);
|
||||
vertex = Vec2(x, y);
|
||||
|
||||
V2F_C4B_T2F a = {firstVertex, col, texCoord };
|
||||
V2F_C4B_T2F b = {lastVertex, col, texCoord };
|
||||
|
|
|
@ -50,10 +50,10 @@ public:
|
|||
static DrawNode* create();
|
||||
|
||||
/** draw a dot at a position, with a given radius and color */
|
||||
void drawDot(const Vector2 &pos, float radius, const Color4F &color);
|
||||
void drawDot(const Vec2 &pos, float radius, const Color4F &color);
|
||||
|
||||
/** draw a segment with a radius and color */
|
||||
void drawSegment(const Vector2 &from, const Vector2 &to, float radius, const Color4F &color);
|
||||
void drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color);
|
||||
|
||||
/** draw a polygon with a fill color and line color
|
||||
* @code
|
||||
|
@ -62,16 +62,16 @@ public:
|
|||
* In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor)
|
||||
* @endcode
|
||||
*/
|
||||
void drawPolygon(Vector2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||
void drawPolygon(Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||
|
||||
/** draw a triangle with color */
|
||||
void drawTriangle(const Vector2 &p1, const Vector2 &p2, const Vector2 &p3, const Color4F &color);
|
||||
void drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color);
|
||||
|
||||
/** draw a cubic bezier curve with color and number of segments */
|
||||
void drawCubicBezier(const Vector2& from, const Vector2& control1, const Vector2& control2, const Vector2& to, unsigned int segments, const Color4F &color);
|
||||
void drawCubicBezier(const Vec2& from, const Vec2& control1, const Vec2& control2, const Vec2& to, unsigned int segments, const Color4F &color);
|
||||
|
||||
/** draw a quadratic bezier curve with color and number of segments */
|
||||
void drawQuadraticBezier(const Vector2& from, const Vector2& control, const Vector2& to, unsigned int segments, const Color4F &color);
|
||||
void drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color);
|
||||
|
||||
/** Clear the geometry in the node's buffer. */
|
||||
void clear();
|
||||
|
@ -89,10 +89,10 @@ public:
|
|||
*/
|
||||
void setBlendFunc(const BlendFunc &blendFunc);
|
||||
|
||||
void onDraw(const Matrix &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
DrawNode();
|
||||
|
|
|
@ -123,11 +123,11 @@ void free()
|
|||
s_initialized = false;
|
||||
}
|
||||
|
||||
void drawPoint( const Vector2& point )
|
||||
void drawPoint( const Vec2& point )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
Vector2 p;
|
||||
Vec2 p;
|
||||
p.x = point.x;
|
||||
p.y = point.y;
|
||||
|
||||
|
@ -150,7 +150,7 @@ void drawPoint( const Vector2& point )
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1);
|
||||
}
|
||||
|
||||
void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
||||
void drawPoints( const Vec2 *points, unsigned int numberOfPoints )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -161,13 +161,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
|||
s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize);
|
||||
|
||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||
Vector2* newPoints = new Vector2[numberOfPoints];
|
||||
Vec2* newPoints = new Vec2[numberOfPoints];
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
if( sizeof(Vec2) == sizeof(Vec2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) points, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData((void*) points, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);
|
||||
|
@ -183,7 +183,7 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
|||
#ifdef EMSCRIPTEN
|
||||
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
|
||||
// but want to make sure this continues to work even if they do.
|
||||
setGLBufferData(newPoints, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData(newPoints, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
|
||||
|
@ -198,13 +198,13 @@ void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
|||
}
|
||||
|
||||
|
||||
void drawLine( const Vector2& origin, const Vector2& destination )
|
||||
void drawLine( const Vec2& origin, const Vec2& destination )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
Vector2 vertices[2] = {
|
||||
Vector2(origin.x, origin.y),
|
||||
Vector2(destination.x, destination.y)
|
||||
Vec2 vertices[2] = {
|
||||
Vec2(origin.x, origin.y),
|
||||
Vec2(destination.x, destination.y)
|
||||
};
|
||||
|
||||
s_shader->use();
|
||||
|
@ -223,27 +223,27 @@ void drawLine( const Vector2& origin, const Vector2& destination )
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2);
|
||||
}
|
||||
|
||||
void drawRect( Vector2 origin, Vector2 destination )
|
||||
void drawRect( Vec2 origin, Vec2 destination )
|
||||
{
|
||||
drawLine(Vector2(origin.x, origin.y), Vector2(destination.x, origin.y));
|
||||
drawLine(Vector2(destination.x, origin.y), Vector2(destination.x, destination.y));
|
||||
drawLine(Vector2(destination.x, destination.y), Vector2(origin.x, destination.y));
|
||||
drawLine(Vector2(origin.x, destination.y), Vector2(origin.x, origin.y));
|
||||
drawLine(Vec2(origin.x, origin.y), Vec2(destination.x, origin.y));
|
||||
drawLine(Vec2(destination.x, origin.y), Vec2(destination.x, destination.y));
|
||||
drawLine(Vec2(destination.x, destination.y), Vec2(origin.x, destination.y));
|
||||
drawLine(Vec2(origin.x, destination.y), Vec2(origin.x, origin.y));
|
||||
}
|
||||
|
||||
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color )
|
||||
void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color )
|
||||
{
|
||||
Vector2 vertices[] = {
|
||||
Vec2 vertices[] = {
|
||||
origin,
|
||||
Vector2(destination.x, origin.y),
|
||||
Vec2(destination.x, origin.y),
|
||||
destination,
|
||||
Vector2(origin.x, destination.y)
|
||||
Vec2(origin.x, destination.y)
|
||||
};
|
||||
|
||||
drawSolidPoly(vertices, 4, color );
|
||||
}
|
||||
|
||||
void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolygon )
|
||||
void drawPoly( const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -254,10 +254,10 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
|
|||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
if( sizeof(Vec2) == sizeof(Vec2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
|
@ -272,13 +272,13 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
|
|||
{
|
||||
// Mac on 64-bit
|
||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||
Vector2* newPoli = new Vector2[numberOfPoints];
|
||||
Vec2* newPoli = new Vec2[numberOfPoints];
|
||||
for( unsigned int i=0; i<numberOfPoints;i++) {
|
||||
newPoli[i].x = poli[i].x;
|
||||
newPoli[i].y = poli[i].y;
|
||||
}
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
|
@ -295,7 +295,7 @@ void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolyg
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
|
||||
}
|
||||
|
||||
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color )
|
||||
void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -306,13 +306,13 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
|
|||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||
Vector2* newPoli = new Vector2[numberOfPoints];
|
||||
Vec2* newPoli = new Vec2[numberOfPoints];
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Vector2) == sizeof(Vector2) )
|
||||
if( sizeof(Vec2) == sizeof(Vec2) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
|
@ -323,10 +323,10 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
|
|||
// Mac on 64-bit
|
||||
for( unsigned int i=0; i<numberOfPoints;i++)
|
||||
{
|
||||
newPoli[i] = Vector2( poli[i].x, poli[i].y );
|
||||
newPoli[i] = Vec2( poli[i].x, poli[i].y );
|
||||
}
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(newPoli, numberOfPoints * sizeof(Vector2));
|
||||
setGLBufferData(newPoli, numberOfPoints * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
|
@ -339,7 +339,7 @@ void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F co
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
|
||||
}
|
||||
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
|
||||
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -383,12 +383,12 @@ void drawCircle( const Vector2& center, float radius, float angle, unsigned int
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+additionalSegment);
|
||||
}
|
||||
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
{
|
||||
drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -429,16 +429,16 @@ void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
|
||||
}
|
||||
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments)
|
||||
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments)
|
||||
{
|
||||
drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments)
|
||||
void drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
Vector2* vertices = new Vector2[segments + 1];
|
||||
Vec2* vertices = new Vec2[segments + 1];
|
||||
|
||||
float t = 0.0f;
|
||||
for(unsigned int i = 0; i < segments; i++)
|
||||
|
@ -457,7 +457,7 @@ void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2
|
|||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
|
@ -477,7 +477,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
{
|
||||
lazy_init();
|
||||
|
||||
Vector2* vertices = new Vector2[segments + 1];
|
||||
Vec2* vertices = new Vec2[segments + 1];
|
||||
|
||||
ssize_t p;
|
||||
float lt;
|
||||
|
@ -497,12 +497,12 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
}
|
||||
|
||||
// Interpolate
|
||||
Vector2 pp0 = config->getControlPointAtIndex(p-1);
|
||||
Vector2 pp1 = config->getControlPointAtIndex(p+0);
|
||||
Vector2 pp2 = config->getControlPointAtIndex(p+1);
|
||||
Vector2 pp3 = config->getControlPointAtIndex(p+2);
|
||||
Vec2 pp0 = config->getControlPointAtIndex(p-1);
|
||||
Vec2 pp1 = config->getControlPointAtIndex(p+0);
|
||||
Vec2 pp2 = config->getControlPointAtIndex(p+1);
|
||||
Vec2 pp3 = config->getControlPointAtIndex(p+2);
|
||||
|
||||
Vector2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);
|
||||
Vec2 newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt);
|
||||
vertices[i].x = newPos.x;
|
||||
vertices[i].y = newPos.y;
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
|
@ -525,11 +525,11 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
|
||||
}
|
||||
|
||||
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments)
|
||||
void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
Vector2* vertices = new Vector2[segments + 1];
|
||||
Vec2* vertices = new Vec2[segments + 1];
|
||||
|
||||
float t = 0;
|
||||
for(unsigned int i = 0; i < segments; i++)
|
||||
|
@ -548,7 +548,7 @@ void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vecto
|
|||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vector2));
|
||||
setGLBufferData(vertices, (segments + 1) * sizeof(Vec2));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
|
|
|
@ -63,14 +63,12 @@ THE SOFTWARE.
|
|||
- ccPointSize()
|
||||
- glLineWidth()
|
||||
|
||||
@warning These functions draws the Line, Vector2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode
|
||||
@warning These functions draws the Line, Vec2, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. Instead you should use DrawNode
|
||||
|
||||
*/
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
/**
|
||||
* @addtogroup global
|
||||
* @{
|
||||
|
@ -87,52 +85,52 @@ namespace DrawPrimitives
|
|||
void free();
|
||||
|
||||
/** draws a point given x and y coordinate measured in points */
|
||||
void drawPoint( const Vector2& point );
|
||||
void drawPoint( const Vec2& point );
|
||||
|
||||
/** draws an array of points.
|
||||
@since v0.7.2
|
||||
*/
|
||||
void drawPoints( const Vector2 *points, unsigned int numberOfPoints );
|
||||
void drawPoints( const Vec2 *points, unsigned int numberOfPoints );
|
||||
|
||||
/** draws a line given the origin and destination point measured in points */
|
||||
void drawLine( const Vector2& origin, const Vector2& destination );
|
||||
void drawLine( const Vec2& origin, const Vec2& destination );
|
||||
|
||||
/** draws a rectangle given the origin and destination point measured in points. */
|
||||
void drawRect( Vector2 origin, Vector2 destination );
|
||||
void drawRect( Vec2 origin, Vec2 destination );
|
||||
|
||||
/** draws a solid rectangle given the origin and destination point measured in points.
|
||||
@since 1.1
|
||||
*/
|
||||
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color );
|
||||
void drawSolidRect( Vec2 origin, Vec2 destination, Color4F color );
|
||||
|
||||
/** draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
|
||||
The polygon can be closed or open
|
||||
*/
|
||||
void drawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon );
|
||||
void drawPoly( const Vec2 *vertices, unsigned int numOfVertices, bool closePolygon );
|
||||
|
||||
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
|
||||
*/
|
||||
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color );
|
||||
void drawSolidPoly( const Vec2 *poli, unsigned int numberOfPoints, Color4F color );
|
||||
|
||||
/** draws a circle given the center, radius and number of segments. */
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
|
||||
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
||||
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
|
||||
|
||||
/** draws a solid circle given the center, radius and number of segments. */
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments);
|
||||
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
|
||||
void drawSolidCircle( const Vec2& center, float radius, float angle, unsigned int segments);
|
||||
|
||||
/** draws a quad bezier path
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
@since v0.8
|
||||
*/
|
||||
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments);
|
||||
void drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments);
|
||||
|
||||
/** draws a cubic bezier path
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
@since v0.8
|
||||
*/
|
||||
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments);
|
||||
void drawCubicBezier(const Vec2& origin, const Vec2& control1, const Vec2& control2, const Vec2& destination, unsigned int segments);
|
||||
|
||||
/** draws a Catmull Rom path.
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCFont.h"
|
||||
#include "ccUTF8.h"
|
||||
#include "2d/CCFont.h"
|
||||
#include "base/ccUTF8.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "2d/CCFontFreeType.h"
|
||||
#include "ccUTF8.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
|
@ -33,8 +33,8 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
const int FontAtlas::CacheTextureWidth = 1024;
|
||||
const int FontAtlas::CacheTextureHeight = 1024;
|
||||
const int FontAtlas::CacheTextureWidth = 512;
|
||||
const int FontAtlas::CacheTextureHeight = 512;
|
||||
const char* FontAtlas::EVENT_PURGE_TEXTURES = "__cc_FontAtlasPurgeTextures";
|
||||
|
||||
FontAtlas::FontAtlas(Font &theFont)
|
||||
|
|
|
@ -90,7 +90,7 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
|
||||
auto it = _atlasMap.find(atlasName);
|
||||
|
|
|
@ -38,7 +38,7 @@ class CC_DLL FontAtlasCache
|
|||
{
|
||||
public:
|
||||
static FontAtlas * getFontAtlasTTF(const TTFConfig & config);
|
||||
static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vector2& imageOffset = Vector2::ZERO);
|
||||
static FontAtlas * getFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset = Vec2::ZERO);
|
||||
|
||||
static FontAtlas * getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||
static FontAtlas * getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
|
||||
#include "CCFontCharMap.h"
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "ccUTF8.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -24,15 +24,16 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "2d/CCFontFNT.h"
|
||||
#include "2d/uthash.h"
|
||||
#include "base/uthash.h"
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCFontAtlas.h"
|
||||
#include "base/CCMap.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
|
||||
#include "deprecated/CCString.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "ccUTF8.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
|
||||
using namespace std;
|
||||
NS_CC_BEGIN
|
||||
|
@ -665,7 +666,7 @@ void BMFontConfiguration::parseKerningEntry(std::string line)
|
|||
HASH_ADD_INT(_kerningDictionary,key, element);
|
||||
}
|
||||
|
||||
FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
FontFNT * FontFNT::create(const std::string& fntFilePath, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
BMFontConfiguration *newConf = FNTConfigLoadFile(fntFilePath);
|
||||
if (!newConf)
|
||||
|
@ -690,7 +691,7 @@ FontFNT * FontFNT::create(const std::string& fntFilePath, const Vector2& imageOf
|
|||
return tempFont;
|
||||
}
|
||||
|
||||
FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
:_configuration(theContfig)
|
||||
,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset))
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ class FontFNT : public Font
|
|||
|
||||
public:
|
||||
|
||||
static FontFNT * create(const std::string& fntFilePath, const Vector2& imageOffset = Vector2::ZERO);
|
||||
static FontFNT * create(const std::string& fntFilePath, const Vec2& imageOffset = Vec2::ZERO);
|
||||
/** Purges the cached data.
|
||||
Removes from memory the cached configurations and the atlas name dictionary.
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
FontFNT(BMFontConfiguration *theContfig, const Vector2& imageOffset = Vector2::ZERO);
|
||||
FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -59,7 +59,7 @@ private:
|
|||
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
|
||||
|
||||
BMFontConfiguration * _configuration;
|
||||
Vector2 _imageOffset;
|
||||
Vec2 _imageOffset;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "2d/CCFontFreeType.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ccUTF8.h"
|
||||
#include "2d/CCFontFreeType.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "edtaa3func.h"
|
||||
#include FT_BBOX_H
|
||||
|
||||
|
@ -563,4 +564,4 @@ void FontFreeType::renderCharAt(unsigned char *dest,int posX, int posY, unsigned
|
|||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "CCGrabber.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCGrabber.h"
|
||||
#include "2d/ccUtils.h"
|
||||
#include "base/ccUtils.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/CCGLProgramCache.h"
|
||||
|
@ -186,8 +186,8 @@ void GridBase::set2DProjection()
|
|||
glViewport(0, 0, (GLsizei)(size.width), (GLsizei)(size.height) );
|
||||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
|
||||
Matrix orthoMatrix;
|
||||
Matrix::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix);
|
||||
Mat4 orthoMatrix;
|
||||
Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1, 1, &orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
|
||||
|
||||
director->loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
@ -217,7 +217,7 @@ void GridBase::afterDraw(cocos2d::Node *target)
|
|||
|
||||
// if (target->getCamera()->isDirty())
|
||||
// {
|
||||
// Vector2 offset = target->getAnchorPointInPoints();
|
||||
// Vec2 offset = target->getAnchorPointInPoints();
|
||||
//
|
||||
// //
|
||||
// // XXX: Camera should be applied in the AnchorPoint
|
||||
|
@ -326,11 +326,11 @@ void Grid3D::blit(void)
|
|||
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
||||
|
||||
// position
|
||||
setGLBufferData(_vertices, numOfPoints * sizeof(Vector3), 0);
|
||||
setGLBufferData(_vertices, numOfPoints * sizeof(Vec3), 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
// texCoords
|
||||
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vector2), 1);
|
||||
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vec2), 1);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
setGLIndexData(_indices, n * 12, 0);
|
||||
|
@ -361,9 +361,9 @@ void Grid3D::calculateVertexPoints(void)
|
|||
|
||||
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
||||
|
||||
_vertices = malloc(numOfPoints * sizeof(Vector3));
|
||||
_originalVertices = malloc(numOfPoints * sizeof(Vector3));
|
||||
_texCoordinates = malloc(numOfPoints * sizeof(Vector2));
|
||||
_vertices = malloc(numOfPoints * sizeof(Vec3));
|
||||
_originalVertices = malloc(numOfPoints * sizeof(Vec3));
|
||||
_texCoordinates = malloc(numOfPoints * sizeof(Vec2));
|
||||
_indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6);
|
||||
|
||||
GLfloat *vertArray = (GLfloat*)_vertices;
|
||||
|
@ -391,15 +391,15 @@ void Grid3D::calculateVertexPoints(void)
|
|||
memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
|
||||
|
||||
int l1[4] = {a*3, b*3, c*3, d*3};
|
||||
Vector3 e(x1, y1, 0);
|
||||
Vector3 f(x2, y1, 0);
|
||||
Vector3 g(x2, y2, 0);
|
||||
Vector3 h(x1, y2, 0);
|
||||
Vec3 e(x1, y1, 0);
|
||||
Vec3 f(x2, y1, 0);
|
||||
Vec3 g(x2, y2, 0);
|
||||
Vec3 h(x1, y2, 0);
|
||||
|
||||
Vector3 l2[4] = {e, f, g, h};
|
||||
Vec3 l2[4] = {e, f, g, h};
|
||||
|
||||
int tex1[4] = {a*2, b*2, c*2, d*2};
|
||||
Vector2 Tex2F[4] = {Vector2(x1, y1), Vector2(x2, y1), Vector2(x2, y2), Vector2(x1, y2)};
|
||||
Vec2 Tex2F[4] = {Vec2(x1, y1), Vec2(x2, y1), Vec2(x2, y2), Vec2(x1, y2)};
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
|
@ -420,34 +420,34 @@ void Grid3D::calculateVertexPoints(void)
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3));
|
||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
|
||||
}
|
||||
|
||||
Vector3 Grid3D::getVertex(const Vector2& pos) const
|
||||
Vec3 Grid3D::getVertex(const Vec2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
|
||||
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
||||
float *vertArray = (float*)_vertices;
|
||||
|
||||
Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||
Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||
|
||||
return vert;
|
||||
}
|
||||
|
||||
Vector3 Grid3D::getOriginalVertex(const Vector2& pos) const
|
||||
Vec3 Grid3D::getOriginalVertex(const Vec2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
|
||||
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
||||
float *vertArray = (float*)_originalVertices;
|
||||
|
||||
Vector3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||
Vec3 vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||
|
||||
return vert;
|
||||
}
|
||||
|
||||
void Grid3D::setVertex(const Vector2& pos, const Vector3& vertex)
|
||||
void Grid3D::setVertex(const Vec2& pos, const Vec3& vertex)
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
|
||||
|
@ -461,7 +461,7 @@ void Grid3D::reuse(void)
|
|||
{
|
||||
if (_reuseGrid > 0)
|
||||
{
|
||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vector3));
|
||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vec3));
|
||||
--_reuseGrid;
|
||||
}
|
||||
}
|
||||
|
@ -541,11 +541,11 @@ void TiledGrid3D::blit(void)
|
|||
int numQuads = _gridSize.width * _gridSize.height;
|
||||
|
||||
// position
|
||||
setGLBufferData(_vertices, (numQuads*4*sizeof(Vector3)), 0);
|
||||
setGLBufferData(_vertices, (numQuads*4*sizeof(Vec3)), 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
// texCoords
|
||||
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vector2)), 1);
|
||||
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vec2)), 1);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
setGLIndexData(_indices, n * 12, 0);
|
||||
|
@ -576,9 +576,9 @@ void TiledGrid3D::calculateVertexPoints(void)
|
|||
CC_SAFE_FREE(_texCoordinates);
|
||||
CC_SAFE_FREE(_indices);
|
||||
|
||||
_vertices = malloc(numQuads*4*sizeof(Vector3));
|
||||
_originalVertices = malloc(numQuads*4*sizeof(Vector3));
|
||||
_texCoordinates = malloc(numQuads*4*sizeof(Vector2));
|
||||
_vertices = malloc(numQuads*4*sizeof(Vec3));
|
||||
_originalVertices = malloc(numQuads*4*sizeof(Vec3));
|
||||
_texCoordinates = malloc(numQuads*4*sizeof(Vec2));
|
||||
_indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort));
|
||||
|
||||
GLfloat *vertArray = (GLfloat*)_vertices;
|
||||
|
@ -643,7 +643,7 @@ void TiledGrid3D::calculateVertexPoints(void)
|
|||
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords)
|
||||
void TiledGrid3D::setTile(const Vec2& pos, const Quad3& coords)
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||
|
@ -651,7 +651,7 @@ void TiledGrid3D::setTile(const Vector2& pos, const Quad3& coords)
|
|||
memcpy(&vertArray[idx], &coords, sizeof(Quad3));
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const
|
||||
Quad3 TiledGrid3D::getOriginalTile(const Vec2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||
|
@ -663,7 +663,7 @@ Quad3 TiledGrid3D::getOriginalTile(const Vector2& pos) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
Quad3 TiledGrid3D::getTile(const Vector2& pos) const
|
||||
Quad3 TiledGrid3D::getTile(const Vec2& pos) const
|
||||
{
|
||||
CCASSERT( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include "base/ccTypes.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#ifdef EMSCRIPTEN
|
||||
#include "CCGLBufferedNode.h"
|
||||
#endif // EMSCRIPTEN
|
||||
|
@ -77,8 +77,8 @@ public:
|
|||
inline void setGridSize(const Size& gridSize) { _gridSize = gridSize; }
|
||||
|
||||
/** pixels between the grids */
|
||||
inline const Vector2& getStep(void) const { return _step; }
|
||||
inline void setStep(const Vector2& step) { _step = step; }
|
||||
inline const Vec2& getStep(void) const { return _step; }
|
||||
inline void setStep(const Vec2& step) { _step = step; }
|
||||
|
||||
/** is texture flipped */
|
||||
inline bool isTextureFlipped(void) const { return _isTextureFlipped; }
|
||||
|
@ -97,7 +97,7 @@ protected:
|
|||
int _reuseGrid;
|
||||
Size _gridSize;
|
||||
Texture2D *_texture;
|
||||
Vector2 _step;
|
||||
Vec2 _step;
|
||||
Grabber *_grabber;
|
||||
bool _isTextureFlipped;
|
||||
GLProgram* _shaderProgram;
|
||||
|
@ -131,28 +131,28 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Vector3 getVertex(const Vector2& pos) const;
|
||||
Vec3 getVertex(const Vec2& pos) const;
|
||||
/** @deprecated Use getVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Vector3 vertex(const Vector2& pos) const { return getVertex(pos); }
|
||||
CC_DEPRECATED_ATTRIBUTE Vec3 vertex(const Vec2& pos) const { return getVertex(pos); }
|
||||
/** returns the original (non-transformed) vertex at a given position
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Vector3 getOriginalVertex(const Vector2& pos) const;
|
||||
Vec3 getOriginalVertex(const Vec2& pos) const;
|
||||
/** @deprecated Use getOriginalVertex() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Vector3 originalVertex(const Vector2& pos) const { return getOriginalVertex(pos); }
|
||||
CC_DEPRECATED_ATTRIBUTE Vec3 originalVertex(const Vec2& pos) const { return getOriginalVertex(pos); }
|
||||
|
||||
/** sets a new vertex at a given position
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setVertex(const Vector2& pos, const Vector3& vertex);
|
||||
void setVertex(const Vec2& pos, const Vec3& vertex);
|
||||
|
||||
// Overrides
|
||||
virtual void blit() override;
|
||||
|
@ -194,28 +194,28 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Quad3 getTile(const Vector2& pos) const;
|
||||
Quad3 getTile(const Vec2& pos) const;
|
||||
/** returns the tile at the given position
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vector2& pos) const { return getTile(pos); }
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Vec2& pos) const { return getTile(pos); }
|
||||
/** returns the original tile (untransformed) at the given position
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Quad3 getOriginalTile(const Vector2& pos) const;
|
||||
Quad3 getOriginalTile(const Vec2& pos) const;
|
||||
/** returns the original tile (untransformed) at the given position
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vector2& pos) const { return getOriginalTile(pos); }
|
||||
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Vec2& pos) const { return getOriginalTile(pos); }
|
||||
|
||||
/** sets a new tile
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setTile(const Vector2& pos, const Quad3& coords);
|
||||
void setTile(const Vec2& pos, const Quad3& coords);
|
||||
|
||||
// Overrides
|
||||
virtual void blit() override;
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include "2d/CCFontAtlasCache.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCLabelTextFormatter.h"
|
||||
#include "2d/ccUTF8.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "2d/CCFont.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
|
@ -129,7 +129,7 @@ Label* Label::createWithTTF(const TTFConfig& ttfConfig, const std::string& text,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
Label* Label::createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
auto ret = new Label(nullptr,alignment);
|
||||
|
||||
|
@ -260,8 +260,9 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
, _shadowDirty(false)
|
||||
, _compatibleMode(false)
|
||||
, _insideBounds(true)
|
||||
, _effectColorF(Color4F::BLACK)
|
||||
{
|
||||
setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
reset();
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||
|
@ -348,20 +349,20 @@ void Label::updateShaderProgram()
|
|||
break;
|
||||
case cocos2d::LabelEffect::OUTLINE:
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_OUTLINE));
|
||||
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor");
|
||||
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_effectColor");
|
||||
break;
|
||||
case cocos2d::LabelEffect::GLOW:
|
||||
if (_useDistanceField)
|
||||
{
|
||||
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW));
|
||||
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_effectColor");
|
||||
_uniformEffectColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_effectColor");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_uniformTextColor = glGetUniformLocation(getGLProgram()->getProgram(), "v_textColor");
|
||||
_uniformTextColor = glGetUniformLocation(getGLProgram()->getProgram(), "u_textColor");
|
||||
}
|
||||
|
||||
void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false */, bool useA8Shader /* = false */)
|
||||
|
@ -394,7 +395,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
|||
_reusedLetter = Sprite::createWithTexture(_fontAtlas->getTexture(0));
|
||||
_reusedLetter->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
_reusedLetter->retain();
|
||||
_reusedLetter->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT);
|
||||
_reusedLetter->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
_reusedLetter->setBatchNode(this);
|
||||
}
|
||||
else
|
||||
|
@ -426,6 +427,7 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
|
|||
reset();
|
||||
return false;
|
||||
}
|
||||
_systemFontDirty = false;
|
||||
|
||||
_currentLabelType = LabelType::TTF;
|
||||
setFontAtlas(newAtlas,ttfConfig.distanceFieldEnabled,true);
|
||||
|
@ -452,7 +454,7 @@ bool Label::setTTFConfig(const TTFConfig& ttfConfig)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
FontAtlas *newAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath,imageOffset);
|
||||
|
||||
|
@ -470,13 +472,16 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vector2&
|
|||
|
||||
void Label::setString(const std::string& text)
|
||||
{
|
||||
_originalUTF8String = text;
|
||||
_contentDirty = true;
|
||||
|
||||
std::u16string utf16String;
|
||||
if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String))
|
||||
if (text.compare(_originalUTF8String))
|
||||
{
|
||||
_currentUTF16String = utf16String;
|
||||
_originalUTF8String = text;
|
||||
_contentDirty = true;
|
||||
|
||||
std::u16string utf16String;
|
||||
if (StringUtils::UTF8ToUTF16(_originalUTF8String, utf16String))
|
||||
{
|
||||
_currentUTF16String = utf16String;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,8 +597,8 @@ void Label::alignText()
|
|||
for (auto index = _batchNodes.size(); index < textures.size(); ++index)
|
||||
{
|
||||
auto batchNode = SpriteBatchNode::createWithTexture(textures[index]);
|
||||
batchNode->setAnchorPoint(Vector2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vector2::ZERO);
|
||||
batchNode->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT);
|
||||
batchNode->setPosition(Vec2::ZERO);
|
||||
Node::addChild(batchNode,0,Node::INVALID_TAG);
|
||||
_batchNodes.push_back(batchNode);
|
||||
}
|
||||
|
@ -675,7 +680,7 @@ void Label::updateQuads()
|
|||
}
|
||||
}
|
||||
|
||||
bool Label::recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex)
|
||||
bool Label::recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex)
|
||||
{
|
||||
if (static_cast<std::size_t>(spriteIndex) >= _lettersInfo.size())
|
||||
{
|
||||
|
@ -804,7 +809,7 @@ void Label::setFontScale(float fontScale)
|
|||
Node::setScale(_fontScale);
|
||||
}
|
||||
|
||||
void Label::onDraw(const Matrix& transform, bool transformUpdated)
|
||||
void Label::onDraw(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
CC_PROFILER_START("Label - draw");
|
||||
|
||||
|
@ -872,7 +877,7 @@ void Label::drawShadowWithoutBlur()
|
|||
setColor(oldColor);
|
||||
}
|
||||
|
||||
void Label::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void Label::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
@ -892,7 +897,7 @@ void Label::createSpriteWithFontDefinition()
|
|||
texture->initWithString(_originalUTF8String.c_str(),_fontDefinition);
|
||||
|
||||
_textSprite = Sprite::createWithTexture(texture);
|
||||
_textSprite->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
_textSprite->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
this->setContentSize(_textSprite->getContentSize());
|
||||
texture->release();
|
||||
if (_blendFuncDirty)
|
||||
|
@ -1030,7 +1035,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
|||
{
|
||||
_shadowNode->setBlendFunc(_blendFunc);
|
||||
}
|
||||
_shadowNode->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
_shadowNode->setColor(_shadowColor);
|
||||
_shadowNode->setOpacity(_shadowOpacity * _displayedOpacity);
|
||||
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
|
||||
|
@ -1044,7 +1049,7 @@ void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
|
|||
_textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated);
|
||||
}
|
||||
|
||||
void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (! _visible || _originalUTF8String.empty())
|
||||
{
|
||||
|
@ -1083,7 +1088,7 @@ void Label::visit(Renderer *renderer, const Matrix &parentTransform, bool parent
|
|||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
@ -1156,7 +1161,7 @@ Sprite * Label::getLetter(int letterIndex)
|
|||
|
||||
sp = Sprite::createWithTexture(_fontAtlas->getTexture(letter.def.textureID),uvRect);
|
||||
sp->setBatchNode(_batchNodes[letter.def.textureID]);
|
||||
sp->setPosition(Vector2(letter.position.x + uvRect.size.width / 2,
|
||||
sp->setPosition(Vec2(letter.position.x + uvRect.size.width / 2,
|
||||
letter.position.y - uvRect.size.height / 2));
|
||||
sp->setOpacity(_realOpacity);
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
/* Creates a label with an FNT file,an initial string,horizontal alignment,max line width and the offset of image*/
|
||||
static Label* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,
|
||||
const TextHAlignment& alignment = TextHAlignment::LEFT, int maxLineWidth = 0,
|
||||
const Vector2& imageOffset = Vector2::ZERO);
|
||||
const Vec2& imageOffset = Vec2::ZERO);
|
||||
|
||||
static Label * createWithCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||
static Label * createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
virtual bool setTTFConfig(const TTFConfig& ttfConfig);
|
||||
virtual const TTFConfig& getTTFConfig() const { return _fontConfig;}
|
||||
|
||||
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vector2& imageOffset = Vector2::ZERO);
|
||||
virtual bool setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& imageOffset = Vec2::ZERO);
|
||||
const std::string& getBMFontFilePath() const { return _bmFontPath;}
|
||||
|
||||
virtual bool setCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
||||
|
@ -237,8 +237,8 @@ public:
|
|||
|
||||
virtual Rect getBoundingBox() const override;
|
||||
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) 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,
|
||||
|
@ -248,13 +248,13 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
|
||||
|
||||
protected:
|
||||
void onDraw(const Matrix& transform, bool transformUpdated);
|
||||
void onDraw(const Mat4& transform, bool transformUpdated);
|
||||
|
||||
struct LetterInfo
|
||||
{
|
||||
FontLetterDefinition def;
|
||||
|
||||
Vector2 position;
|
||||
Vec2 position;
|
||||
Size contentSize;
|
||||
int atlasIndex;
|
||||
};
|
||||
|
@ -279,7 +279,7 @@ protected:
|
|||
|
||||
virtual void setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled = false, bool useA8Shader = false);
|
||||
|
||||
bool recordLetterInfo(const cocos2d::Vector2& point,const FontLetterDefinition& letterDef, int spriteIndex);
|
||||
bool recordLetterInfo(const cocos2d::Vec2& point,const FontLetterDefinition& letterDef, int spriteIndex);
|
||||
bool recordPlaceholderInfo(int spriteIndex);
|
||||
|
||||
void setFontScale(float fontScale);
|
||||
|
@ -363,7 +363,7 @@ protected:
|
|||
bool _shadowEnabled;
|
||||
Size _shadowOffset;
|
||||
int _shadowBlurRadius;
|
||||
Matrix _shadowTransform;
|
||||
Mat4 _shadowTransform;
|
||||
Color3B _shadowColor;
|
||||
float _shadowOpacity;
|
||||
Sprite* _shadowNode;
|
||||
|
|
|
@ -25,17 +25,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "CCLabelAtlas.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "2d/CCDrawingPrimitives.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/ccConfig.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramCache.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "math/TransformUtils.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
// external
|
||||
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
|
@ -249,7 +249,7 @@ void LabelAtlas::updateColor()
|
|||
|
||||
//CCLabelAtlas - draw
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void LabelAtlas::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
AtlasNode::draw(renderer, transform, transformUpdated);
|
||||
|
||||
|
@ -258,7 +258,7 @@ void LabelAtlas::draw(Renderer *renderer, const Matrix &transform, bool transfor
|
|||
renderer->addCommand(&_customDebugDrawCommand);
|
||||
}
|
||||
|
||||
void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated)
|
||||
void LabelAtlas::drawDebugData(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
Director* director = Director::getInstance();
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
@ -266,12 +266,12 @@ void LabelAtlas::drawDebugData(const Matrix& transform, bool transformUpdated)
|
|||
|
||||
auto size = getContentSize();
|
||||
|
||||
Vector2 vertices[4]=
|
||||
Vec2 vertices[4]=
|
||||
{
|
||||
Vector2::ZERO,
|
||||
Vector2(size.width, 0),
|
||||
Vector2(size.width, size.height),
|
||||
Vector2(0, size.height)
|
||||
Vec2::ZERO,
|
||||
Vec2(size.width, 0),
|
||||
Vec2(size.width, size.height),
|
||||
Vec2(0, size.height)
|
||||
};
|
||||
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
virtual std::string getDescription() const override;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -100,7 +100,7 @@ protected:
|
|||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
CustomCommand _customDebugDrawCommand;
|
||||
void drawDebugData(const Matrix& transform, bool transformUpdated);
|
||||
void drawDebugData(const Mat4& transform, bool transformUpdated);
|
||||
#endif
|
||||
|
||||
// string to render
|
||||
|
|
|
@ -65,7 +65,7 @@ LabelBMFont * LabelBMFont::create()
|
|||
}
|
||||
|
||||
//LabelBMFont - Creation & Init
|
||||
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
LabelBMFont *ret = new LabelBMFont();
|
||||
if(ret && ret->initWithString(str, fntFile, width, alignment,imageOffset))
|
||||
|
@ -77,7 +77,7 @@ LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntF
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
bool LabelBMFont::initWithString(const std::string& str, const std::string& fntFile, float width /* = 0 */, TextHAlignment alignment /* = TextHAlignment::LEFT */,const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
if (_label->setBMFontFilePath(fntFile,imageOffset))
|
||||
{
|
||||
|
@ -95,9 +95,9 @@ bool LabelBMFont::initWithString(const std::string& str, const std::string& fntF
|
|||
LabelBMFont::LabelBMFont()
|
||||
{
|
||||
_label = Label::create();
|
||||
_label->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
_label->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
this->addChild(_label);
|
||||
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
_cascadeOpacityEnabled = true;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ void LabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace )
|
|||
}
|
||||
|
||||
// LabelBMFont - FntFile
|
||||
void LabelBMFont::setFntFile(const std::string& fntFile, const Vector2& imageOffset /* = Vector2::ZERO */)
|
||||
void LabelBMFont::setFntFile(const std::string& fntFile, const Vec2& imageOffset /* = Vec2::ZERO */)
|
||||
{
|
||||
if (_fntFile.compare(fntFile) != 0)
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ Rect LabelBMFont::getBoundingBox() const
|
|||
return _label->getBoundingBox();
|
||||
}
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void LabelBMFont::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
Node::draw(renderer, transform, transformUpdated);
|
||||
|
||||
|
@ -216,7 +216,7 @@ void LabelBMFont::draw(Renderer *renderer, const Matrix &transform, bool transfo
|
|||
renderer->addCommand(&_customDebugDrawCommand);
|
||||
}
|
||||
|
||||
void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated)
|
||||
void LabelBMFont::drawDebugData(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
Director* director = Director::getInstance();
|
||||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
@ -224,12 +224,12 @@ void LabelBMFont::drawDebugData(const Matrix& transform, bool transformUpdated)
|
|||
|
||||
auto size = getContentSize();
|
||||
|
||||
Vector2 vertices[4]=
|
||||
Vec2 vertices[4]=
|
||||
{
|
||||
Vector2::ZERO,
|
||||
Vector2(size.width, 0),
|
||||
Vector2(size.width, size.height),
|
||||
Vector2(0, size.height)
|
||||
Vec2::ZERO,
|
||||
Vec2(size.width, 0),
|
||||
Vec2(size.width, size.height),
|
||||
Vec2(0, size.height)
|
||||
};
|
||||
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
|
|
@ -85,14 +85,14 @@ public:
|
|||
virtual ~LabelBMFont();
|
||||
|
||||
/** creates a bitmap font atlas with an initial string and the FNT file */
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO);
|
||||
|
||||
/** Creates an label.
|
||||
*/
|
||||
static LabelBMFont * create();
|
||||
|
||||
/** init a bitmap font atlas with an initial string and the FNT file */
|
||||
bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vector2& imageOffset = Vector2::ZERO);
|
||||
bool initWithString(const std::string& str, const std::string& fntFile, float width = 0, TextHAlignment alignment = TextHAlignment::LEFT,const Vec2& imageOffset = Vec2::ZERO);
|
||||
|
||||
// super method
|
||||
virtual void setString(const std::string& newString) override;
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
virtual bool isOpacityModifyRGB() const;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
|
||||
void setFntFile(const std::string& fntFile, const Vector2& imageOffset = Vector2::ZERO);
|
||||
void setFntFile(const std::string& fntFile, const Vec2& imageOffset = Vec2::ZERO);
|
||||
const std::string& getFntFile() const;
|
||||
|
||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||
|
@ -124,13 +124,13 @@ public:
|
|||
|
||||
virtual std::string getDescription() const override;
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
CustomCommand _customDebugDrawCommand;
|
||||
void drawDebugData(const Matrix& transform, bool transformUpdated);
|
||||
void drawDebugData(const Mat4& transform, bool transformUpdated);
|
||||
#endif
|
||||
|
||||
// name of fntFile
|
||||
|
|
|
@ -39,9 +39,9 @@ NS_CC_BEGIN
|
|||
LabelTTF::LabelTTF()
|
||||
{
|
||||
_renderLabel = Label::create();
|
||||
_renderLabel->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
_renderLabel->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
this->addChild(_renderLabel);
|
||||
this->setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
this->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
|
||||
_contentDirty = false;
|
||||
_cascadeColorEnabled = true;
|
||||
|
@ -262,7 +262,7 @@ void LabelTTF::setFlippedY(bool flippedY)
|
|||
}
|
||||
}
|
||||
|
||||
void LabelTTF::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void LabelTTF::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (_contentDirty)
|
||||
{
|
||||
|
|
|
@ -150,7 +150,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual const Size& getContentSize() const override;
|
||||
protected:
|
||||
Label* _renderLabel;
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "2d/CCLabelTextFormatter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ccUTF8.h"
|
||||
#include "CCLabelTextFormatter.h"
|
||||
#include "base/ccUTF8.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCLabel.h"
|
||||
|
||||
|
@ -310,7 +311,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
auto strWhole = theLabel->_currentUTF16String;
|
||||
auto fontAtlas = theLabel->_fontAtlas;
|
||||
FontLetterDefinition tempDefinition;
|
||||
Vector2 letterPosition;
|
||||
Vec2 letterPosition;
|
||||
const auto& kernings = theLabel->_horizontalKernings;
|
||||
|
||||
float clipTop = 0;
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#ifndef _CCLabelTextFormatter_h_
|
||||
#define _CCLabelTextFormatter_h_
|
||||
|
||||
#include "base/CCPlatformMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Label;
|
||||
|
|
|
@ -27,8 +27,8 @@ THE SOFTWARE.
|
|||
|
||||
#include <stdarg.h>
|
||||
#include "2d/CCLayer.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "2d/platform/CCDevice.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
#include "platform/CCDevice.h"
|
||||
#include "2d/CCScene.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
|
@ -65,7 +65,7 @@ Layer::Layer()
|
|||
, _swallowsTouches(true)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Layer::~Layer()
|
||||
|
@ -584,7 +584,7 @@ void LayerColor::updateColor()
|
|||
}
|
||||
}
|
||||
|
||||
void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void LayerColor::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
_customCommand.init(_globalZOrder);
|
||||
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
|
||||
|
@ -592,15 +592,15 @@ void LayerColor::draw(Renderer *renderer, const Matrix &transform, bool transfor
|
|||
|
||||
for(int i = 0; i < 4; ++i)
|
||||
{
|
||||
Vector4 pos;
|
||||
Vec4 pos;
|
||||
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ;
|
||||
pos.w = 1;
|
||||
_modelViewTransform.transformVector(&pos);
|
||||
_noMVPVertices[i] = Vector3(pos.x,pos.y,pos.z)/pos.w;
|
||||
_noMVPVertices[i] = Vec3(pos.x,pos.y,pos.z)/pos.w;
|
||||
}
|
||||
}
|
||||
|
||||
void LayerColor::onDraw(const Matrix& transform, bool transformUpdated)
|
||||
void LayerColor::onDraw(const Mat4& transform, bool transformUpdated)
|
||||
{
|
||||
getGLProgram()->use();
|
||||
getGLProgram()->setUniformsForBuiltins(transform);
|
||||
|
@ -610,7 +610,7 @@ void LayerColor::onDraw(const Matrix& transform, bool transformUpdated)
|
|||
// Attributes
|
||||
//
|
||||
#ifdef EMSCRIPTEN
|
||||
setGLBufferData(_noMVPVertices, 4 * sizeof(Vector3), 0);
|
||||
setGLBufferData(_noMVPVertices, 4 * sizeof(Vec3), 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
|
||||
|
@ -640,7 +640,7 @@ LayerGradient::LayerGradient()
|
|||
, _endColor(Color4B::BLACK)
|
||||
, _startOpacity(255)
|
||||
, _endOpacity(255)
|
||||
, _alongVector(Vector2(0, -1))
|
||||
, _alongVector(Vec2(0, -1))
|
||||
, _compressedInterpolation(true)
|
||||
{
|
||||
|
||||
|
@ -662,7 +662,7 @@ LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vector2& v)
|
||||
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Vec2& v)
|
||||
{
|
||||
LayerGradient * layer = new LayerGradient();
|
||||
if( layer && layer->initWithColor(start, end, v))
|
||||
|
@ -695,10 +695,10 @@ bool LayerGradient::init()
|
|||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
|
||||
{
|
||||
return initWithColor(start, end, Vector2(0, -1));
|
||||
return initWithColor(start, end, Vec2(0, -1));
|
||||
}
|
||||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vector2& v)
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Vec2& v)
|
||||
{
|
||||
_endColor.r = end.r;
|
||||
_endColor.g = end.g;
|
||||
|
@ -722,7 +722,7 @@ void LayerGradient::updateColor()
|
|||
return;
|
||||
|
||||
float c = sqrtf(2.0f);
|
||||
Vector2 u = Vector2(_alongVector.x / h, _alongVector.y / h);
|
||||
Vec2 u = Vec2(_alongVector.x / h, _alongVector.y / h);
|
||||
|
||||
// Compressed Interpolation mode
|
||||
if (_compressedInterpolation)
|
||||
|
@ -812,13 +812,13 @@ GLubyte LayerGradient::getEndOpacity() const
|
|||
return _endOpacity;
|
||||
}
|
||||
|
||||
void LayerGradient::setVector(const Vector2& var)
|
||||
void LayerGradient::setVector(const Vec2& var)
|
||||
{
|
||||
_alongVector = var;
|
||||
updateColor();
|
||||
}
|
||||
|
||||
const Vector2& LayerGradient::getVector() const
|
||||
const Vec2& LayerGradient::getVector() const
|
||||
{
|
||||
return _alongVector;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#define __CCLAYER_H__
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "base/CCEventTouch.h"
|
||||
#ifdef EMSCRIPTEN
|
||||
#include "CCGLBufferedNode.h"
|
||||
|
@ -270,7 +270,7 @@ public:
|
|||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
|
||||
virtual void setContentSize(const Size & var) override;
|
||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||
|
@ -299,15 +299,15 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
bool initWithColor(const Color4B& color);
|
||||
|
||||
protected:
|
||||
void onDraw(const Matrix& transform, bool transformUpdated);
|
||||
void onDraw(const Mat4& transform, bool transformUpdated);
|
||||
|
||||
virtual void updateColor() override;
|
||||
|
||||
BlendFunc _blendFunc;
|
||||
Vector2 _squareVertices[4];
|
||||
Vec2 _squareVertices[4];
|
||||
Color4F _squareColors[4];
|
||||
CustomCommand _customCommand;
|
||||
Vector3 _noMVPVertices[4];
|
||||
Vec3 _noMVPVertices[4];
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(LayerColor);
|
||||
|
||||
|
@ -345,7 +345,7 @@ public:
|
|||
static LayerGradient* create(const Color4B& start, const Color4B& end);
|
||||
|
||||
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
|
||||
static LayerGradient* create(const Color4B& start, const Color4B& end, const Vector2& v);
|
||||
static LayerGradient* create(const Color4B& start, const Color4B& end, const Vec2& v);
|
||||
|
||||
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
|
||||
Default: true
|
||||
|
@ -376,9 +376,9 @@ public:
|
|||
/** Sets the directional vector that will be used for the gradient.
|
||||
The default value is vertical direction (0,-1).
|
||||
*/
|
||||
void setVector(const Vector2& alongVector);
|
||||
void setVector(const Vec2& alongVector);
|
||||
/** Returns the directional vector used for the gradient */
|
||||
const Vector2& getVector() const;
|
||||
const Vec2& getVector() const;
|
||||
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
|
@ -397,7 +397,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
bool initWithColor(const Color4B& start, const Color4B& end, const Vector2& v);
|
||||
bool initWithColor(const Color4B& start, const Color4B& end, const Vec2& v);
|
||||
|
||||
protected:
|
||||
virtual void updateColor() override;
|
||||
|
@ -406,7 +406,7 @@ protected:
|
|||
Color3B _endColor;
|
||||
GLubyte _startOpacity;
|
||||
GLubyte _endOpacity;
|
||||
Vector2 _alongVector;
|
||||
Vec2 _alongVector;
|
||||
bool _compressedInterpolation;
|
||||
};
|
||||
|
||||
|
|
|
@ -138,10 +138,10 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
|
|||
Size s = Director::getInstance()->getWinSize();
|
||||
|
||||
this->ignoreAnchorPointForPosition(true);
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
this->setContentSize(s);
|
||||
|
||||
setPosition(Vector2(s.width/2, s.height/2));
|
||||
setPosition(Vec2(s.width/2, s.height/2));
|
||||
|
||||
int z=0;
|
||||
|
||||
|
@ -315,7 +315,7 @@ void Menu::alignItemsVerticallyWithPadding(float padding)
|
|||
float y = height / 2.0f;
|
||||
|
||||
for(const auto &child : _children) {
|
||||
child->setPosition(Vector2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f));
|
||||
child->setPosition(Vec2(0, y - child->getContentSize().height * child->getScaleY() / 2.0f));
|
||||
y -= child->getContentSize().height * child->getScaleY() + padding;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ void Menu::alignItemsHorizontallyWithPadding(float padding)
|
|||
float x = -width / 2.0f;
|
||||
|
||||
for(const auto &child : _children) {
|
||||
child->setPosition(Vector2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0));
|
||||
child->setPosition(Vec2(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0));
|
||||
x += child->getContentSize().width * child->getScaleX() + padding;
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void Menu::alignItemsInColumnsWithArray(const ValueVector& rows)
|
|||
float tmp = child->getContentSize().height;
|
||||
rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp);
|
||||
|
||||
child->setPosition(Vector2(x - winSize.width / 2,
|
||||
child->setPosition(Vec2(x - winSize.width / 2,
|
||||
y - child->getContentSize().height / 2));
|
||||
|
||||
x += w;
|
||||
|
@ -514,7 +514,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
float tmp = child->getContentSize().width;
|
||||
columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp);
|
||||
|
||||
child->setPosition(Vector2(x + columnWidths[column] / 2,
|
||||
child->setPosition(Vec2(x + columnWidths[column] / 2,
|
||||
y - winSize.height / 2));
|
||||
|
||||
y -= child->getContentSize().height + 10;
|
||||
|
@ -533,7 +533,7 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
|
||||
MenuItem* Menu::getItemForTouch(Touch *touch)
|
||||
{
|
||||
Vector2 touchLocation = touch->getLocation();
|
||||
Vec2 touchLocation = touch->getLocation();
|
||||
|
||||
if (!_children.empty())
|
||||
{
|
||||
|
@ -542,9 +542,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch)
|
|||
MenuItem* child = dynamic_cast<MenuItem*>(*iter);
|
||||
if (child && child->isVisible() && child->isEnabled())
|
||||
{
|
||||
Vector2 local = child->convertToNodeSpace(touchLocation);
|
||||
Vec2 local = child->convertToNodeSpace(touchLocation);
|
||||
Rect r = child->rect();
|
||||
r.origin = Vector2::ZERO;
|
||||
r.origin = Vec2::ZERO;
|
||||
|
||||
if (r.containsPoint(local))
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include "2d/CCSprite.h"
|
||||
#include "CCLabelAtlas.h"
|
||||
#include "2d/CCLabel.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
#include "deprecated/CCString.h"
|
||||
#include <stdarg.h>
|
||||
#include <cstring>
|
||||
|
@ -90,7 +90,7 @@ bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector )
|
|||
|
||||
bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_callback = callback;
|
||||
_enabled = true;
|
||||
_selected = false;
|
||||
|
@ -179,7 +179,7 @@ void MenuItemLabel::setLabel(Node* var)
|
|||
{
|
||||
if (var)
|
||||
{
|
||||
var->setAnchorPoint(Vector2::ANCHOR_BOTTOM_LEFT);
|
||||
var->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
|
||||
setContentSize(var->getContentSize());
|
||||
addChild(var);
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ void MenuItemSprite::setNormalImage(Node* image)
|
|||
if (image)
|
||||
{
|
||||
addChild(image, 0, kNormalTag);
|
||||
image->setAnchorPoint(Vector2(0, 0));
|
||||
image->setAnchorPoint(Vec2(0, 0));
|
||||
}
|
||||
|
||||
if (_normalImage)
|
||||
|
@ -504,7 +504,7 @@ void MenuItemSprite::setSelectedImage(Node* image)
|
|||
if (image)
|
||||
{
|
||||
addChild(image, 0, kSelectedTag);
|
||||
image->setAnchorPoint(Vector2(0, 0));
|
||||
image->setAnchorPoint(Vec2(0, 0));
|
||||
}
|
||||
|
||||
if (_selectedImage)
|
||||
|
@ -524,7 +524,7 @@ void MenuItemSprite::setDisabledImage(Node* image)
|
|||
if (image)
|
||||
{
|
||||
addChild(image, 0, kDisableTag);
|
||||
image->setAnchorPoint(Vector2(0, 0));
|
||||
image->setAnchorPoint(Vec2(0, 0));
|
||||
}
|
||||
|
||||
if (_disabledImage)
|
||||
|
@ -935,7 +935,7 @@ void MenuItemToggle::setSelectedIndex(unsigned int index)
|
|||
this->addChild(item, 0, kCurrentItem);
|
||||
Size s = item->getContentSize();
|
||||
this->setContentSize(s);
|
||||
item->setPosition( Vector2( s.width/2, s.height/2 ) );
|
||||
item->setPosition( Vec2( s.width/2, s.height/2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ THE SOFTWARE.
|
|||
|
||||
// cocos2d includes
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -23,16 +23,17 @@ 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 "2d/CCMotionStreak.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCVertex.h"
|
||||
#include "math/CCVertex.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -41,7 +42,7 @@ MotionStreak::MotionStreak()
|
|||
, _startingPositionInitialized(false)
|
||||
, _texture(nullptr)
|
||||
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
, _positionR(Vector2::ZERO)
|
||||
, _positionR(Vec2::ZERO)
|
||||
, _stroke(0.0f)
|
||||
, _fadeDelta(0.0f)
|
||||
, _minSeg(0.0f)
|
||||
|
@ -102,12 +103,12 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
|
||||
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
||||
{
|
||||
Node::setPosition(Vector2::ZERO);
|
||||
setAnchorPoint(Vector2::ZERO);
|
||||
Node::setPosition(Vec2::ZERO);
|
||||
setAnchorPoint(Vec2::ZERO);
|
||||
ignoreAnchorPointForPosition(true);
|
||||
_startingPositionInitialized = false;
|
||||
|
||||
_positionR = Vector2::ZERO;
|
||||
_positionR = Vec2::ZERO;
|
||||
_fastMode = true;
|
||||
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
|
||||
_minSeg *= _minSeg;
|
||||
|
@ -118,9 +119,9 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
_maxPoints = (int)(fade*60.0f)+2;
|
||||
_nuPoints = 0;
|
||||
_pointState = (float *)malloc(sizeof(float) * _maxPoints);
|
||||
_pointVertexes = (Vector2*)malloc(sizeof(Vector2) * _maxPoints);
|
||||
_pointVertexes = (Vec2*)malloc(sizeof(Vec2) * _maxPoints);
|
||||
|
||||
_vertices = (Vector2*)malloc(sizeof(Vector2) * _maxPoints * 2);
|
||||
_vertices = (Vec2*)malloc(sizeof(Vec2) * _maxPoints * 2);
|
||||
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
|
||||
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
|
||||
|
||||
|
@ -137,7 +138,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
return true;
|
||||
}
|
||||
|
||||
void MotionStreak::setPosition(const Vector2& position)
|
||||
void MotionStreak::setPosition(const Vec2& position)
|
||||
{
|
||||
if (!_startingPositionInitialized) {
|
||||
_startingPositionInitialized = true;
|
||||
|
@ -154,7 +155,7 @@ void MotionStreak::setPosition(float x, float y)
|
|||
_positionR.y = y;
|
||||
}
|
||||
|
||||
const Vector2& MotionStreak::getPosition() const
|
||||
const Vec2& MotionStreak::getPosition() const
|
||||
{
|
||||
return _positionR;
|
||||
}
|
||||
|
@ -373,7 +374,7 @@ void MotionStreak::reset()
|
|||
_nuPoints = 0;
|
||||
}
|
||||
|
||||
void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated)
|
||||
void MotionStreak::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
getGLProgram()->use();
|
||||
getGLProgram()->setUniformsForBuiltins(transform);
|
||||
|
@ -385,7 +386,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
|
||||
#ifdef EMSCRIPTEN
|
||||
// Size calculations from ::initWithFade
|
||||
setGLBufferData(_vertices, (sizeof(Vector2) * _maxPoints * 2), 0);
|
||||
setGLBufferData(_vertices, (sizeof(Vec2) * _maxPoints * 2), 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
|
||||
|
@ -403,7 +404,7 @@ void MotionStreak::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
|
||||
}
|
||||
|
||||
void MotionStreak::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
if(_nuPoints <= 1)
|
||||
return;
|
||||
|
|
|
@ -26,8 +26,8 @@ THE SOFTWARE.
|
|||
#ifndef __CCMOTION_STREAK_H__
|
||||
#define __CCMOTION_STREAK_H__
|
||||
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
@ -73,9 +73,9 @@ public:
|
|||
}
|
||||
|
||||
// Overrides
|
||||
virtual void setPosition(const Vector2& position) override;
|
||||
virtual void setPosition(const Vec2& position) override;
|
||||
virtual void setPosition(float x, float y) override;
|
||||
virtual const Vector2& getPosition() const override;
|
||||
virtual const Vec2& getPosition() const override;
|
||||
virtual void getPosition(float* x, float* y) const override;
|
||||
virtual void setPositionX(float x) override;
|
||||
virtual void setPositionY(float y) override;
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -120,7 +120,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
protected:
|
||||
//renderer callback
|
||||
void onDraw(const Matrix &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
|
||||
bool _fastMode;
|
||||
bool _startingPositionInitialized;
|
||||
|
@ -128,7 +128,7 @@ protected:
|
|||
/** texture used for the motion streak */
|
||||
Texture2D* _texture;
|
||||
BlendFunc _blendFunc;
|
||||
Vector2 _positionR;
|
||||
Vec2 _positionR;
|
||||
|
||||
float _stroke;
|
||||
float _fadeDelta;
|
||||
|
@ -139,11 +139,11 @@ protected:
|
|||
unsigned int _previousNuPoints;
|
||||
|
||||
/** Pointers */
|
||||
Vector2* _pointVertexes;
|
||||
Vec2* _pointVertexes;
|
||||
float* _pointState;
|
||||
|
||||
// Opengl
|
||||
Vector2* _vertices;
|
||||
Vec2* _vertices;
|
||||
GLubyte* _colorPointer;
|
||||
Tex2F* _texCoords;
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ THE SOFTWARE.
|
|||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEvent.h"
|
||||
#include "base/CCEventTouch.h"
|
||||
#include "2d/ccCArray.h"
|
||||
#include "base/ccCArray.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "2d/CCActionManager.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
#include "2d/CCScene.h"
|
||||
#include "2d/CCComponent.h"
|
||||
#include "2d/CCComponentContainer.h"
|
||||
|
@ -81,11 +81,11 @@ Node::Node(void)
|
|||
, _scaleY(1.0f)
|
||||
, _scaleZ(1.0f)
|
||||
, _positionZ(0.0f)
|
||||
, _position(Vector2::ZERO)
|
||||
, _position(Vec2::ZERO)
|
||||
, _skewX(0.0f)
|
||||
, _skewY(0.0f)
|
||||
, _anchorPointInPoints(Vector2::ZERO)
|
||||
, _anchorPoint(Vector2::ZERO)
|
||||
, _anchorPointInPoints(Vec2::ZERO)
|
||||
, _anchorPoint(Vec2::ZERO)
|
||||
, _contentSize(Size::ZERO)
|
||||
, _useAdditionalTransform(false)
|
||||
, _transformDirty(true)
|
||||
|
@ -135,7 +135,7 @@ Node::Node(void)
|
|||
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
_scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;
|
||||
#endif
|
||||
_transform = _inverse = _additionalTransform = Matrix::identity();
|
||||
_transform = _inverse = _additionalTransform = Mat4::IDENTITY;
|
||||
}
|
||||
|
||||
Node::~Node()
|
||||
|
@ -277,7 +277,7 @@ float Node::getRotationSkewX() const
|
|||
return _rotationZ_X;
|
||||
}
|
||||
|
||||
void Node::setRotation3D(const Vector3& rotation)
|
||||
void Node::setRotation3D(const Vec3& rotation)
|
||||
{
|
||||
if (_rotationX == rotation.x &&
|
||||
_rotationY == rotation.y &&
|
||||
|
@ -301,12 +301,12 @@ void Node::setRotation3D(const Vector3& rotation)
|
|||
#endif
|
||||
}
|
||||
|
||||
Vector3 Node::getRotation3D() const
|
||||
Vec3 Node::getRotation3D() const
|
||||
{
|
||||
// rotation Z is decomposed in 2 to simulate Skew for Flash animations
|
||||
CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y");
|
||||
|
||||
return Vector3(_rotationX,_rotationY,_rotationZ_X);
|
||||
return Vec3(_rotationX,_rotationY,_rotationZ_X);
|
||||
}
|
||||
|
||||
void Node::setRotationSkewX(float rotationX)
|
||||
|
@ -410,13 +410,13 @@ void Node::setScaleY(float scaleY)
|
|||
|
||||
|
||||
/// position getter
|
||||
const Vector2& Node::getPosition() const
|
||||
const Vec2& Node::getPosition() const
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
|
||||
/// position setter
|
||||
void Node::setPosition(const Vector2& position)
|
||||
void Node::setPosition(const Vec2& position)
|
||||
{
|
||||
if (_position.equals(position))
|
||||
return;
|
||||
|
@ -441,18 +441,18 @@ void Node::getPosition(float* x, float* y) const
|
|||
|
||||
void Node::setPosition(float x, float y)
|
||||
{
|
||||
setPosition(Vector2(x, y));
|
||||
setPosition(Vec2(x, y));
|
||||
}
|
||||
|
||||
void Node::setPosition3D(const Vector3& position)
|
||||
void Node::setPosition3D(const Vec3& position)
|
||||
{
|
||||
_positionZ = position.z;
|
||||
setPosition(Vector2(position.x, position.y));
|
||||
setPosition(Vec2(position.x, position.y));
|
||||
}
|
||||
|
||||
Vector3 Node::getPosition3D() const
|
||||
Vec3 Node::getPosition3D() const
|
||||
{
|
||||
Vector3 ret;
|
||||
Vec3 ret;
|
||||
ret.x = _position.x;
|
||||
ret.y = _position.y;
|
||||
ret.z = _positionZ;
|
||||
|
@ -466,7 +466,7 @@ float Node::getPositionX() const
|
|||
|
||||
void Node::setPositionX(float x)
|
||||
{
|
||||
setPosition(Vector2(x, _position.y));
|
||||
setPosition(Vec2(x, _position.y));
|
||||
}
|
||||
|
||||
float Node::getPositionY() const
|
||||
|
@ -476,7 +476,7 @@ float Node::getPositionY() const
|
|||
|
||||
void Node::setPositionY(float y)
|
||||
{
|
||||
setPosition(Vector2(_position.x, y));
|
||||
setPosition(Vec2(_position.x, y));
|
||||
}
|
||||
|
||||
float Node::getPositionZ() const
|
||||
|
@ -519,21 +519,21 @@ void Node::setVisible(bool var)
|
|||
}
|
||||
}
|
||||
|
||||
const Vector2& Node::getAnchorPointInPoints() const
|
||||
const Vec2& Node::getAnchorPointInPoints() const
|
||||
{
|
||||
return _anchorPointInPoints;
|
||||
}
|
||||
|
||||
/// anchorPoint getter
|
||||
const Vector2& Node::getAnchorPoint() const
|
||||
const Vec2& Node::getAnchorPoint() const
|
||||
{
|
||||
return _anchorPoint;
|
||||
}
|
||||
|
||||
void Node::setAnchorPoint(const Vector2& point)
|
||||
void Node::setAnchorPoint(const Vec2& point)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr && !point.equals(Vector2::ANCHOR_MIDDLE))
|
||||
if (_physicsBody != nullptr && !point.equals(Vec2::ANCHOR_MIDDLE))
|
||||
{
|
||||
CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value.");
|
||||
return;
|
||||
|
@ -543,7 +543,7 @@ void Node::setAnchorPoint(const Vector2& point)
|
|||
if( ! point.equals(_anchorPoint))
|
||||
{
|
||||
_anchorPoint = point;
|
||||
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ void Node::setContentSize(const Size & size)
|
|||
{
|
||||
_contentSize = size;
|
||||
|
||||
_anchorPointInPoints = Vector2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_anchorPointInPoints = Vec2(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ void Node::setGLProgram(GLProgram *glProgram)
|
|||
if (_glProgramState == nullptr || (_glProgramState && _glProgramState->getGLProgram() != glProgram))
|
||||
{
|
||||
CC_SAFE_RELEASE(_glProgramState);
|
||||
_glProgramState = GLProgramState::getOrCreate(glProgram);
|
||||
_glProgramState = GLProgramState::getOrCreateWithGLProgram(glProgram);
|
||||
_glProgramState->retain();
|
||||
}
|
||||
}
|
||||
|
@ -915,6 +915,7 @@ void Node::detachChild(Node *child, ssize_t childIndex, bool doCleanup)
|
|||
// helper used by reorderChild & add
|
||||
void Node::insertChild(Node* child, int z)
|
||||
{
|
||||
_transformUpdated = true;
|
||||
_reorderChildDirty = true;
|
||||
_children.pushBack(child);
|
||||
child->_setLocalZOrder(z);
|
||||
|
@ -942,18 +943,18 @@ void Node::draw()
|
|||
draw(renderer, _modelViewTransform, true);
|
||||
}
|
||||
|
||||
void Node::draw(Renderer* renderer, const Matrix &transform, bool transformUpdated)
|
||||
void Node::draw(Renderer* renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
}
|
||||
|
||||
void Node::visit()
|
||||
{
|
||||
auto renderer = Director::getInstance()->getRenderer();
|
||||
Matrix parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
Mat4 parentTransform = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
visit(renderer, parentTransform, true);
|
||||
}
|
||||
|
||||
void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -968,7 +969,7 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT
|
|||
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
@ -1007,9 +1008,9 @@ void Node::visit(Renderer* renderer, const Matrix &parentTransform, bool parentT
|
|||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
}
|
||||
|
||||
Matrix Node::transform(const Matrix& parentTransform)
|
||||
Mat4 Node::transform(const Mat4& parentTransform)
|
||||
{
|
||||
Matrix ret = this->getNodeToParentTransform();
|
||||
Mat4 ret = this->getNodeToParentTransform();
|
||||
ret = parentTransform * ret;
|
||||
return ret;
|
||||
}
|
||||
|
@ -1337,7 +1338,7 @@ AffineTransform Node::getNodeToParentAffineTransform() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
const Matrix& Node::getNodeToParentTransform() const
|
||||
const Mat4& Node::getNodeToParentTransform() const
|
||||
{
|
||||
if (_transformDirty)
|
||||
{
|
||||
|
@ -1372,7 +1373,7 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
// optimization:
|
||||
// inline anchor point calculation if skew is not needed
|
||||
// Adjusted transform calculation for rotational skew
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vector2::ZERO))
|
||||
if (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO))
|
||||
{
|
||||
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY;
|
||||
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY;
|
||||
|
@ -1393,13 +1394,13 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
// FIX ME: Expensive operation.
|
||||
// FIX ME: It should be done together with the rotationZ
|
||||
if(_rotationY) {
|
||||
Matrix rotY;
|
||||
Matrix::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY);
|
||||
Mat4 rotY;
|
||||
Mat4::createRotationY(CC_DEGREES_TO_RADIANS(_rotationY), &rotY);
|
||||
_transform = _transform * rotY;
|
||||
}
|
||||
if(_rotationX) {
|
||||
Matrix rotX;
|
||||
Matrix::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX);
|
||||
Mat4 rotX;
|
||||
Mat4::createRotationX(CC_DEGREES_TO_RADIANS(_rotationX), &rotX);
|
||||
_transform = _transform * rotX;
|
||||
}
|
||||
|
||||
|
@ -1407,7 +1408,7 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
// If skew is needed, apply skew and then anchor point
|
||||
if (needsSkewMatrix)
|
||||
{
|
||||
Matrix skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0,
|
||||
Mat4 skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0,
|
||||
(float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1);
|
||||
|
@ -1415,9 +1416,9 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
_transform = _transform * skewMatrix;
|
||||
|
||||
// adjust anchor point
|
||||
if (!_anchorPointInPoints.equals(Vector2::ZERO))
|
||||
if (!_anchorPointInPoints.equals(Vec2::ZERO))
|
||||
{
|
||||
// XXX: Argh, Matrix needs a "translate" method.
|
||||
// XXX: Argh, Mat4 needs a "translate" method.
|
||||
// XXX: Although this is faster than multiplying a vec4 * mat4
|
||||
_transform.m[12] += _transform.m[0] * -_anchorPointInPoints.x + _transform.m[4] * -_anchorPointInPoints.y;
|
||||
_transform.m[13] += _transform.m[1] * -_anchorPointInPoints.x + _transform.m[5] * -_anchorPointInPoints.y;
|
||||
|
@ -1435,7 +1436,7 @@ const Matrix& Node::getNodeToParentTransform() const
|
|||
return _transform;
|
||||
}
|
||||
|
||||
void Node::setNodeToParentTransform(const Matrix& transform)
|
||||
void Node::setNodeToParentTransform(const Mat4& transform)
|
||||
{
|
||||
_transform = transform;
|
||||
_transformDirty = false;
|
||||
|
@ -1444,12 +1445,12 @@ void Node::setNodeToParentTransform(const Matrix& transform)
|
|||
|
||||
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
|
||||
{
|
||||
Matrix tmp;
|
||||
Mat4 tmp;
|
||||
CGAffineToGL(additionalTransform, tmp.m);
|
||||
setAdditionalTransform(&tmp);
|
||||
}
|
||||
|
||||
void Node::setAdditionalTransform(Matrix* additionalTransform)
|
||||
void Node::setAdditionalTransform(Mat4* additionalTransform)
|
||||
{
|
||||
if(additionalTransform == nullptr) {
|
||||
_useAdditionalTransform = false;
|
||||
|
@ -1464,13 +1465,13 @@ void Node::setAdditionalTransform(Matrix* additionalTransform)
|
|||
AffineTransform Node::getParentToNodeAffineTransform() const
|
||||
{
|
||||
AffineTransform ret;
|
||||
Matrix ret4 = getParentToNodeTransform();
|
||||
Mat4 ret4 = getParentToNodeTransform();
|
||||
|
||||
GLToCGAffine(ret4.m,&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Matrix& Node::getParentToNodeTransform() const
|
||||
const Mat4& Node::getParentToNodeTransform() const
|
||||
{
|
||||
if ( _inverseDirty ) {
|
||||
_inverse = _transform.getInversed();
|
||||
|
@ -1491,9 +1492,9 @@ AffineTransform Node::getNodeToWorldAffineTransform() const
|
|||
return t;
|
||||
}
|
||||
|
||||
Matrix Node::getNodeToWorldTransform() const
|
||||
Mat4 Node::getNodeToWorldTransform() const
|
||||
{
|
||||
Matrix t = this->getNodeToParentTransform();
|
||||
Mat4 t = this->getNodeToParentTransform();
|
||||
|
||||
for (Node *p = _parent; p != nullptr; p = p->getParent())
|
||||
{
|
||||
|
@ -1508,59 +1509,59 @@ AffineTransform Node::getWorldToNodeAffineTransform() const
|
|||
return AffineTransformInvert(this->getNodeToWorldAffineTransform());
|
||||
}
|
||||
|
||||
Matrix Node::getWorldToNodeTransform() const
|
||||
Mat4 Node::getWorldToNodeTransform() const
|
||||
{
|
||||
return getNodeToWorldTransform().getInversed();
|
||||
}
|
||||
|
||||
|
||||
Vector2 Node::convertToNodeSpace(const Vector2& worldPoint) const
|
||||
Vec2 Node::convertToNodeSpace(const Vec2& worldPoint) const
|
||||
{
|
||||
Matrix tmp = getWorldToNodeTransform();
|
||||
Vector3 vec3(worldPoint.x, worldPoint.y, 0);
|
||||
Vector3 ret;
|
||||
Mat4 tmp = getWorldToNodeTransform();
|
||||
Vec3 vec3(worldPoint.x, worldPoint.y, 0);
|
||||
Vec3 ret;
|
||||
tmp.transformPoint(vec3,&ret);
|
||||
return Vector2(ret.x, ret.y);
|
||||
return Vec2(ret.x, ret.y);
|
||||
}
|
||||
|
||||
Vector2 Node::convertToWorldSpace(const Vector2& nodePoint) const
|
||||
Vec2 Node::convertToWorldSpace(const Vec2& nodePoint) const
|
||||
{
|
||||
Matrix tmp = getNodeToWorldTransform();
|
||||
Vector3 vec3(nodePoint.x, nodePoint.y, 0);
|
||||
Vector3 ret;
|
||||
Mat4 tmp = getNodeToWorldTransform();
|
||||
Vec3 vec3(nodePoint.x, nodePoint.y, 0);
|
||||
Vec3 ret;
|
||||
tmp.transformPoint(vec3,&ret);
|
||||
return Vector2(ret.x, ret.y);
|
||||
return Vec2(ret.x, ret.y);
|
||||
|
||||
}
|
||||
|
||||
Vector2 Node::convertToNodeSpaceAR(const Vector2& worldPoint) const
|
||||
Vec2 Node::convertToNodeSpaceAR(const Vec2& worldPoint) const
|
||||
{
|
||||
Vector2 nodePoint = convertToNodeSpace(worldPoint);
|
||||
Vec2 nodePoint = convertToNodeSpace(worldPoint);
|
||||
return nodePoint - _anchorPointInPoints;
|
||||
}
|
||||
|
||||
Vector2 Node::convertToWorldSpaceAR(const Vector2& nodePoint) const
|
||||
Vec2 Node::convertToWorldSpaceAR(const Vec2& nodePoint) const
|
||||
{
|
||||
Vector2 pt = nodePoint + _anchorPointInPoints;
|
||||
Vec2 pt = nodePoint + _anchorPointInPoints;
|
||||
return convertToWorldSpace(pt);
|
||||
}
|
||||
|
||||
Vector2 Node::convertToWindowSpace(const Vector2& nodePoint) const
|
||||
Vec2 Node::convertToWindowSpace(const Vec2& nodePoint) const
|
||||
{
|
||||
Vector2 worldPoint = this->convertToWorldSpace(nodePoint);
|
||||
Vec2 worldPoint = this->convertToWorldSpace(nodePoint);
|
||||
return Director::getInstance()->convertToUI(worldPoint);
|
||||
}
|
||||
|
||||
// convenience methods which take a Touch instead of Vector2
|
||||
Vector2 Node::convertTouchToNodeSpace(Touch *touch) const
|
||||
// convenience methods which take a Touch instead of Vec2
|
||||
Vec2 Node::convertTouchToNodeSpace(Touch *touch) const
|
||||
{
|
||||
Vector2 point = touch->getLocation();
|
||||
Vec2 point = touch->getLocation();
|
||||
return this->convertToNodeSpace(point);
|
||||
}
|
||||
|
||||
Vector2 Node::convertTouchToNodeSpaceAR(Touch *touch) const
|
||||
Vec2 Node::convertTouchToNodeSpaceAR(Touch *touch) const
|
||||
{
|
||||
Vector2 point = touch->getLocation();
|
||||
Vec2 point = touch->getLocation();
|
||||
return this->convertToNodeSpaceAR(point);
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1608,7 @@ void Node::updatePhysicsBodyPosition(Scene* scene)
|
|||
{
|
||||
if (scene != nullptr && scene->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
Vector2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition()));
|
||||
Vec2 pos = getParent() == scene ? getPosition() : scene->convertToNodeSpace(_parent->convertToWorldSpace(getPosition()));
|
||||
_physicsBody->setPosition(pos);
|
||||
}
|
||||
else
|
||||
|
@ -1646,10 +1647,10 @@ void Node::setPhysicsBody(PhysicsBody* body)
|
|||
|
||||
// physics rotation based on body position, but node rotation based on node anthor point
|
||||
// it cann't support both of them, so I clear the anthor point to default.
|
||||
if (!getAnchorPoint().equals(Vector2::ANCHOR_MIDDLE))
|
||||
if (!getAnchorPoint().equals(Vec2::ANCHOR_MIDDLE))
|
||||
{
|
||||
CCLOG("Node warning: setPhysicsBody sets anchor point to Vector2::ANCHOR_MIDDLE.");
|
||||
setAnchorPoint(Vector2::ANCHOR_MIDDLE);
|
||||
CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE.");
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#include "base/ccMacros.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCVector.h"
|
||||
#include "base/CCScriptSupport.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "math/CCAffineTransform.h"
|
||||
#include "math/CCMath.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "2d/CCScriptSupport.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "CCGL.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -71,8 +71,6 @@ enum {
|
|||
kNodeOnCleanup
|
||||
};
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
bool nodeComparisonLess(Node* n1, Node* n2);
|
||||
|
||||
class EventListener;
|
||||
|
@ -275,37 +273,37 @@ public:
|
|||
/**
|
||||
* Sets the position (x,y) of the node in its parent's coordinate system.
|
||||
*
|
||||
* Usually we use `Vector2(x,y)` to compose Vector2 object.
|
||||
* Usually we use `Vec2(x,y)` to compose Vec2 object.
|
||||
* This code snippet sets the node in the center of screen.
|
||||
@code
|
||||
Size size = Director::getInstance()->getWinSize();
|
||||
node->setPosition( Vector2(size.width/2, size.height/2) )
|
||||
node->setPosition( Vec2(size.width/2, size.height/2) )
|
||||
@endcode
|
||||
*
|
||||
* @param position The position (x,y) of the node in OpenGL coordinates
|
||||
*/
|
||||
virtual void setPosition(const Vector2 &position);
|
||||
virtual void setPosition(const Vec2 &position);
|
||||
/**
|
||||
* Gets the position (x,y) of the node in its parent's coordinate system.
|
||||
*
|
||||
* @see setPosition(const Vector2&)
|
||||
* @see setPosition(const Vec2&)
|
||||
*
|
||||
* @return The position (x,y) of the node in OpenGL coordinates
|
||||
* @code
|
||||
* In js and lua return value is table which contains x,y
|
||||
* @endcode
|
||||
*/
|
||||
virtual const Vector2& getPosition() const;
|
||||
virtual const Vec2& getPosition() const;
|
||||
/**
|
||||
* Sets the position (x,y) of the node in its parent's coordinate system.
|
||||
*
|
||||
* Passing two numbers (x,y) is much efficient than passing Vector2 object.
|
||||
* Passing two numbers (x,y) is much efficient than passing Vec2 object.
|
||||
* This method is bound to Lua and JavaScript.
|
||||
* Passing a number is 10 times faster than passing a object from Lua to c++
|
||||
*
|
||||
@code
|
||||
// sample code in Lua
|
||||
local pos = node::getPosition() -- returns Vector2 object from C++
|
||||
local pos = node::getPosition() -- returns Vec2 object from C++
|
||||
node:setPosition(x, y) -- pass x, y coordinate to C++
|
||||
@endcode
|
||||
*
|
||||
|
@ -314,7 +312,7 @@ public:
|
|||
*/
|
||||
virtual void setPosition(float x, float y);
|
||||
/**
|
||||
* Gets position in a more efficient way, returns two number instead of a Vector2 object
|
||||
* Gets position in a more efficient way, returns two number instead of a Vec2 object
|
||||
*
|
||||
* @see `setPosition(float, float)`
|
||||
* In js,out value not return
|
||||
|
@ -332,11 +330,11 @@ public:
|
|||
/**
|
||||
* Sets the position (X, Y, and Z) in its parent's coordinate system
|
||||
*/
|
||||
virtual void setPosition3D(const Vector3& position);
|
||||
virtual void setPosition3D(const Vec3& position);
|
||||
/**
|
||||
* returns the position (X,Y,Z) in its parent's coordinate system
|
||||
*/
|
||||
virtual Vector3 getPosition3D() const;
|
||||
virtual Vec3 getPosition3D() const;
|
||||
|
||||
/**
|
||||
* Sets the 'z' coordinate in the position. It is the OpenGL Z vertex value.
|
||||
|
@ -421,15 +419,15 @@ public:
|
|||
*
|
||||
* @param anchorPoint The anchor point of node.
|
||||
*/
|
||||
virtual void setAnchorPoint(const Vector2& anchorPoint);
|
||||
virtual void setAnchorPoint(const Vec2& anchorPoint);
|
||||
/**
|
||||
* Returns the anchor point in percent.
|
||||
*
|
||||
* @see `setAnchorPoint(const Vector2&)`
|
||||
* @see `setAnchorPoint(const Vec2&)`
|
||||
*
|
||||
* @return The anchor point of node.
|
||||
*/
|
||||
virtual const Vector2& getAnchorPoint() const;
|
||||
virtual const Vec2& getAnchorPoint() const;
|
||||
/**
|
||||
* Returns the anchorPoint in absolute pixels.
|
||||
*
|
||||
|
@ -438,7 +436,7 @@ public:
|
|||
*
|
||||
* @return The anchor point in absolute pixels.
|
||||
*/
|
||||
virtual const Vector2& getAnchorPointInPoints() const;
|
||||
virtual const Vec2& getAnchorPointInPoints() const;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -500,11 +498,11 @@ public:
|
|||
* Sets the rotation (X,Y,Z) in degrees.
|
||||
* Useful for 3d rotations
|
||||
*/
|
||||
virtual void setRotation3D(const Vector3& rotation);
|
||||
virtual void setRotation3D(const Vec3& rotation);
|
||||
/**
|
||||
* returns the rotation (X,Y,Z) in degrees.
|
||||
*/
|
||||
virtual Vector3 getRotation3D() const;
|
||||
virtual Vec3 getRotation3D() const;
|
||||
|
||||
/**
|
||||
* Sets the X rotation (angle) of the node in degrees which performs a horizontal rotational skew.
|
||||
|
@ -925,13 +923,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 Matrix& transform, bool transformUpdated);
|
||||
virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated);
|
||||
virtual void draw() final;
|
||||
|
||||
/**
|
||||
* Visits this node's children and draw them recursively.
|
||||
*/
|
||||
virtual void visit(Renderer *renderer, const Matrix& parentTransform, bool parentTransformUpdated);
|
||||
virtual void visit(Renderer *renderer, const Mat4& parentTransform, bool parentTransformUpdated);
|
||||
virtual void visit() final;
|
||||
|
||||
|
||||
|
@ -1196,13 +1194,13 @@ public:
|
|||
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
|
||||
* The matrix is in Pixels.
|
||||
*/
|
||||
virtual const Matrix& getNodeToParentTransform() const;
|
||||
virtual const Mat4& getNodeToParentTransform() const;
|
||||
virtual AffineTransform getNodeToParentAffineTransform() const;
|
||||
|
||||
/**
|
||||
* Sets the Transformation matrix manually.
|
||||
*/
|
||||
virtual void setNodeToParentTransform(const Matrix& transform);
|
||||
virtual void setNodeToParentTransform(const Mat4& transform);
|
||||
|
||||
/** @deprecated use getNodeToParentTransform() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE inline virtual AffineTransform nodeToParentTransform() const { return getNodeToParentAffineTransform(); }
|
||||
|
@ -1211,7 +1209,7 @@ public:
|
|||
* Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
|
||||
* The matrix is in Pixels.
|
||||
*/
|
||||
virtual const Matrix& getParentToNodeTransform() const;
|
||||
virtual const Mat4& getParentToNodeTransform() const;
|
||||
virtual AffineTransform getParentToNodeAffineTransform() const;
|
||||
|
||||
/** @deprecated Use getParentToNodeTransform() instead */
|
||||
|
@ -1220,7 +1218,7 @@ public:
|
|||
/**
|
||||
* Returns the world affine transform matrix. The matrix is in Pixels.
|
||||
*/
|
||||
virtual Matrix getNodeToWorldTransform() const;
|
||||
virtual Mat4 getNodeToWorldTransform() const;
|
||||
virtual AffineTransform getNodeToWorldAffineTransform() const;
|
||||
|
||||
/** @deprecated Use getNodeToWorldTransform() instead */
|
||||
|
@ -1229,7 +1227,7 @@ public:
|
|||
/**
|
||||
* Returns the inverse world affine transform matrix. The matrix is in Pixels.
|
||||
*/
|
||||
virtual Matrix getWorldToNodeTransform() const;
|
||||
virtual Mat4 getWorldToNodeTransform() const;
|
||||
virtual AffineTransform getWorldToNodeAffineTransform() const;
|
||||
|
||||
|
||||
|
@ -1243,36 +1241,36 @@ public:
|
|||
/// @name Coordinate Converters
|
||||
|
||||
/**
|
||||
* Converts a Vector2 to node (local) space coordinates. The result is in Points.
|
||||
* Converts a Vec2 to node (local) space coordinates. The result is in Points.
|
||||
*/
|
||||
Vector2 convertToNodeSpace(const Vector2& worldPoint) const;
|
||||
Vec2 convertToNodeSpace(const Vec2& worldPoint) const;
|
||||
|
||||
/**
|
||||
* Converts a Vector2 to world space coordinates. The result is in Points.
|
||||
* Converts a Vec2 to world space coordinates. The result is in Points.
|
||||
*/
|
||||
Vector2 convertToWorldSpace(const Vector2& nodePoint) const;
|
||||
Vec2 convertToWorldSpace(const Vec2& nodePoint) const;
|
||||
|
||||
/**
|
||||
* Converts a Vector2 to node (local) space coordinates. The result is in Points.
|
||||
* Converts a Vec2 to node (local) space coordinates. The result is in Points.
|
||||
* treating the returned/received node point as anchor relative.
|
||||
*/
|
||||
Vector2 convertToNodeSpaceAR(const Vector2& worldPoint) const;
|
||||
Vec2 convertToNodeSpaceAR(const Vec2& worldPoint) const;
|
||||
|
||||
/**
|
||||
* Converts a local Vector2 to world space coordinates.The result is in Points.
|
||||
* Converts a local Vec2 to world space coordinates.The result is in Points.
|
||||
* treating the returned/received node point as anchor relative.
|
||||
*/
|
||||
Vector2 convertToWorldSpaceAR(const Vector2& nodePoint) const;
|
||||
Vec2 convertToWorldSpaceAR(const Vec2& nodePoint) const;
|
||||
|
||||
/**
|
||||
* convenience methods which take a Touch instead of Vector2
|
||||
* convenience methods which take a Touch instead of Vec2
|
||||
*/
|
||||
Vector2 convertTouchToNodeSpace(Touch * touch) const;
|
||||
Vec2 convertTouchToNodeSpace(Touch * touch) const;
|
||||
|
||||
/**
|
||||
* converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
|
||||
*/
|
||||
Vector2 convertTouchToNodeSpaceAR(Touch * touch) const;
|
||||
Vec2 convertTouchToNodeSpaceAR(Touch * touch) const;
|
||||
|
||||
/**
|
||||
* Sets an additional transform matrix to the node.
|
||||
|
@ -1282,7 +1280,7 @@ public:
|
|||
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
|
||||
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
|
||||
*/
|
||||
void setAdditionalTransform(Matrix* additionalTransform);
|
||||
void setAdditionalTransform(Mat4* additionalTransform);
|
||||
void setAdditionalTransform(const AffineTransform& additionalTransform);
|
||||
|
||||
/// @} end of Coordinate Converters
|
||||
|
@ -1314,7 +1312,7 @@ public:
|
|||
#if CC_USE_PHYSICS
|
||||
/**
|
||||
* set the PhysicsBody that let the sprite effect with physics
|
||||
* @note This method will set anchor point to Vector2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body.
|
||||
* @note This method will set anchor point to Vec2::ANCHOR_MIDDLE if body not null, and you cann't change anchor point if node has a physics body.
|
||||
*/
|
||||
void setPhysicsBody(PhysicsBody* body);
|
||||
|
||||
|
@ -1361,9 +1359,9 @@ protected:
|
|||
void detachChild(Node *child, ssize_t index, bool doCleanup);
|
||||
|
||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||
Vector2 convertToWindowSpace(const Vector2& nodePoint) const;
|
||||
Vec2 convertToWindowSpace(const Vec2& nodePoint) const;
|
||||
|
||||
Matrix transform(const Matrix &parentTransform);
|
||||
Mat4 transform(const Mat4 &parentTransform);
|
||||
|
||||
virtual void updateCascadeOpacity();
|
||||
virtual void disableCascadeOpacity();
|
||||
|
@ -1387,25 +1385,25 @@ protected:
|
|||
float _scaleY; ///< scaling factor on y-axis
|
||||
float _scaleZ; ///< scaling factor on z-axis
|
||||
|
||||
Vector2 _position; ///< position of the node
|
||||
Vec2 _position; ///< position of the node
|
||||
float _positionZ; ///< OpenGL real Z position
|
||||
|
||||
float _skewX; ///< skew angle on x-axis
|
||||
float _skewY; ///< skew angle on y-axis
|
||||
|
||||
Vector2 _anchorPointInPoints; ///< anchor point in points
|
||||
Vector2 _anchorPoint; ///< anchor point normalized (NOT in points)
|
||||
Vec2 _anchorPointInPoints; ///< anchor point in points
|
||||
Vec2 _anchorPoint; ///< anchor point normalized (NOT in points)
|
||||
|
||||
Size _contentSize; ///< untransformed size of the node
|
||||
|
||||
Matrix _modelViewTransform; ///< ModelView transform of the Node.
|
||||
Mat4 _modelViewTransform; ///< ModelView transform of the Node.
|
||||
|
||||
// "cache" variables are allowed to be mutable
|
||||
mutable Matrix _transform; ///< transform
|
||||
mutable Mat4 _transform; ///< transform
|
||||
mutable bool _transformDirty; ///< transform dirty flag
|
||||
mutable Matrix _inverse; ///< inverse transform
|
||||
mutable Mat4 _inverse; ///< inverse transform
|
||||
mutable bool _inverseDirty; ///< inverse transform dirty flag
|
||||
mutable Matrix _additionalTransform; ///< transform
|
||||
mutable Mat4 _additionalTransform; ///< transform
|
||||
bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty
|
||||
bool _transformUpdated; ///< Whether or not the Transform object was updated since the last frame
|
||||
|
||||
|
@ -1436,7 +1434,7 @@ protected:
|
|||
|
||||
bool _visible; ///< is this node visible
|
||||
|
||||
bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vector2 will be (0,0) when you position the Node, false otherwise.
|
||||
bool _ignoreAnchorPointForPosition; ///< true if the Anchor Vec2 will be (0,0) when you position the Node, false otherwise.
|
||||
///< Used by Layer and Scene.
|
||||
|
||||
bool _reorderChildDirty; ///< children order dirty flag
|
||||
|
|
|
@ -82,7 +82,7 @@ void NodeGrid::onGridEndDraw()
|
|||
}
|
||||
}
|
||||
|
||||
void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
|
@ -100,7 +100,7 @@ void NodeGrid::visit(Renderer *renderer, const Matrix &parentTransform, bool par
|
|||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
void setTarget(Node *target);
|
||||
|
||||
// overrides
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
|
||||
protected:
|
||||
NodeGrid();
|
||||
|
|
|
@ -25,14 +25,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "CCParallaxNode.h"
|
||||
#include "2d/ccCArray.h"
|
||||
#include "base/ccCArray.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PointObject : public Ref
|
||||
{
|
||||
public:
|
||||
static PointObject * create(Vector2 ratio, Vector2 offset)
|
||||
static PointObject * create(Vec2 ratio, Vec2 offset)
|
||||
{
|
||||
PointObject *ret = new PointObject();
|
||||
ret->initWithPoint(ratio, offset);
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool initWithPoint(Vector2 ratio, Vector2 offset)
|
||||
bool initWithPoint(Vec2 ratio, Vec2 offset)
|
||||
{
|
||||
_ratio = ratio;
|
||||
_offset = offset;
|
||||
|
@ -48,25 +48,25 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
inline const Vector2& getRatio() const { return _ratio; };
|
||||
inline void setRatio(const Vector2& ratio) { _ratio = ratio; };
|
||||
inline const Vec2& getRatio() const { return _ratio; };
|
||||
inline void setRatio(const Vec2& ratio) { _ratio = ratio; };
|
||||
|
||||
inline const Vector2& getOffset() const { return _offset; };
|
||||
inline void setOffset(const Vector2& offset) { _offset = offset; };
|
||||
inline const Vec2& getOffset() const { return _offset; };
|
||||
inline void setOffset(const Vec2& offset) { _offset = offset; };
|
||||
|
||||
inline Node* getChild() const { return _child; };
|
||||
inline void setChild(Node* child) { _child = child; };
|
||||
|
||||
private:
|
||||
Vector2 _ratio;
|
||||
Vector2 _offset;
|
||||
Vec2 _ratio;
|
||||
Vec2 _offset;
|
||||
Node *_child; // weak ref
|
||||
};
|
||||
|
||||
ParallaxNode::ParallaxNode()
|
||||
{
|
||||
_parallaxArray = ccArrayNew(5);
|
||||
_lastPosition = Vector2(-100,-100);
|
||||
_lastPosition = Vec2(-100,-100);
|
||||
}
|
||||
|
||||
ParallaxNode::~ParallaxNode()
|
||||
|
@ -93,14 +93,14 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag)
|
|||
CCASSERT(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
|
||||
}
|
||||
|
||||
void ParallaxNode::addChild(Node *child, int z, const Vector2& ratio, const Vector2& offset)
|
||||
void ParallaxNode::addChild(Node *child, int z, const Vec2& ratio, const Vec2& offset)
|
||||
{
|
||||
CCASSERT( child != nullptr, "Argument must be non-nil");
|
||||
PointObject *obj = PointObject::create(ratio, offset);
|
||||
obj->setChild(child);
|
||||
ccArrayAppendObjectWithResize(_parallaxArray, (Ref*)obj);
|
||||
|
||||
Vector2 pos = this->absolutePosition();
|
||||
Vec2 pos = this->absolutePosition();
|
||||
pos.x = -pos.x + pos.x * ratio.x + offset.x;
|
||||
pos.y = -pos.y + pos.y * ratio.y + offset.y;
|
||||
child->setPosition(pos);
|
||||
|
@ -128,9 +128,9 @@ void ParallaxNode::removeAllChildrenWithCleanup(bool cleanup)
|
|||
Node::removeAllChildrenWithCleanup(cleanup);
|
||||
}
|
||||
|
||||
Vector2 ParallaxNode::absolutePosition()
|
||||
Vec2 ParallaxNode::absolutePosition()
|
||||
{
|
||||
Vector2 ret = _position;
|
||||
Vec2 ret = _position;
|
||||
Node *cn = this;
|
||||
while (cn->getParent() != nullptr)
|
||||
{
|
||||
|
@ -145,11 +145,11 @@ 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 Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void ParallaxNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// Vector2 pos = position_;
|
||||
// Vector2 pos = [self convertToWorldSpace:Vector2::ZERO];
|
||||
Vector2 pos = this->absolutePosition();
|
||||
// Vec2 pos = position_;
|
||||
// Vec2 pos = [self convertToWorldSpace:Vec2::ZERO];
|
||||
Vec2 pos = this->absolutePosition();
|
||||
if( ! pos.equals(_lastPosition) )
|
||||
{
|
||||
for( int i=0; i < _parallaxArray->num; i++ )
|
||||
|
@ -157,7 +157,7 @@ void ParallaxNode::visit(Renderer *renderer, const Matrix &parentTransform, bool
|
|||
PointObject *point = (PointObject*)_parallaxArray->arr[i];
|
||||
float x = -pos.x + pos.x * point->getRatio().x + point->getOffset().x;
|
||||
float y = -pos.y + pos.y * point->getRatio().y + point->getOffset().y;
|
||||
point->getChild()->setPosition(Vector2(x,y));
|
||||
point->getChild()->setPosition(Vec2(x,y));
|
||||
}
|
||||
_lastPosition = pos;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
// prevents compiler warning: "Included function hides overloaded virtual functions"
|
||||
using Node::addChild;
|
||||
|
||||
void addChild(Node * child, int z, const Vector2& parallaxRatio, const Vector2& positionOffset);
|
||||
void addChild(Node * child, int z, const Vec2& parallaxRatio, const Vec2& positionOffset);
|
||||
|
||||
/** Sets an array of layers for the Parallax node */
|
||||
void setParallaxArray( struct _ccArray *parallaxArray) { _parallaxArray = parallaxArray; }
|
||||
|
@ -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 Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
|
||||
protected:
|
||||
/** Adds a child to the container with a z-order, a parallax ratio and a position offset
|
||||
|
@ -82,9 +82,9 @@ protected:
|
|||
*/
|
||||
virtual ~ParallaxNode();
|
||||
|
||||
Vector2 absolutePosition();
|
||||
Vec2 absolutePosition();
|
||||
|
||||
Vector2 _lastPosition;
|
||||
Vec2 _lastPosition;
|
||||
struct _ccArray* _parallaxArray;
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,16 +30,16 @@
|
|||
|
||||
#include "2d/CCParticleBatchNode.h"
|
||||
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "2d/CCParticleSystem.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/CCProfiling.h"
|
||||
#include "base/ccConfig.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/base64.h"
|
||||
#include "base/ZipUtils.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
|
@ -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 Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// CAREFUL:
|
||||
// This visit is almost identical to Node#visit
|
||||
|
@ -141,7 +141,7 @@ void ParticleBatchNode::visit(Renderer *renderer, const Matrix &parentTransform,
|
|||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
@ -383,7 +383,7 @@ void ParticleBatchNode::removeAllChildrenWithCleanup(bool doCleanup)
|
|||
_textureAtlas->removeAllQuads();
|
||||
}
|
||||
|
||||
void ParticleBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void ParticleBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CC_PROFILER_START("CCParticleBatchNode - draw");
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define __CCPARTICLEBATCHNODE_H__
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "renderer/CCBatchCommand.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -91,13 +91,13 @@ public:
|
|||
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
|
||||
|
||||
// Overrides
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) 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 Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual Texture2D* getTexture(void) const override;
|
||||
virtual void setTexture(Texture2D *texture) override;
|
||||
/**
|
||||
|
|
|
@ -24,11 +24,12 @@ 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 "CCParticleExamples.h"
|
||||
|
||||
#include "2d/CCParticleExamples.h"
|
||||
#include "platform/CCImage.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "firePngData.h"
|
||||
#include "2d/platform/CCImage.h"
|
||||
#include "base/firePngData.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
//
|
||||
|
@ -98,7 +99,7 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
this->_emitterMode = Mode::GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Vector2(0,0);
|
||||
this->modeA.gravity = Vec2(0,0);
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
this->modeA.radialAccel = 0;
|
||||
|
@ -114,8 +115,8 @@ bool ParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, 60));
|
||||
this->_posVar = Vector2(40, 20);
|
||||
this->setPosition(Vec2(winSize.width/2, 60));
|
||||
this->_posVar = Vec2(40, 20);
|
||||
|
||||
// life of particles
|
||||
_life = 3;
|
||||
|
@ -203,7 +204,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
|
|||
this->_emitterMode = Mode::GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Vector2(0,-90);
|
||||
this->modeA.gravity = Vec2(0,-90);
|
||||
|
||||
// Gravity Mode: radial
|
||||
this->modeA.radialAccel = 0;
|
||||
|
@ -215,7 +216,7 @@ bool ParticleFireworks::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
|
||||
// angle
|
||||
this->_angle= 90;
|
||||
|
@ -307,7 +308,7 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
|
@ -324,8 +325,8 @@ bool ParticleSun::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 1;
|
||||
|
@ -411,7 +412,7 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(60);
|
||||
|
@ -431,8 +432,8 @@ bool ParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -520,7 +521,7 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(80);
|
||||
|
@ -540,8 +541,8 @@ bool ParticleFlower::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -628,7 +629,7 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(-200,200));
|
||||
setGravity(Vec2(-200,200));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(15);
|
||||
|
@ -648,8 +649,8 @@ bool ParticleMeteor::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 2;
|
||||
|
@ -737,7 +738,7 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(150);
|
||||
|
@ -757,8 +758,8 @@ bool ParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 12;
|
||||
|
@ -845,7 +846,7 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(70);
|
||||
|
@ -865,8 +866,8 @@ bool ParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vector2::ZERO);
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height/2));
|
||||
setPosVar(Vec2::ZERO);
|
||||
|
||||
// life of particles
|
||||
_life = 5.0f;
|
||||
|
@ -954,7 +955,7 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,0));
|
||||
setGravity(Vec2(0,0));
|
||||
|
||||
// Gravity Mode: radial acceleration
|
||||
setRadialAccel(0);
|
||||
|
@ -970,8 +971,8 @@ bool ParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, 0));
|
||||
setPosVar(Vector2(20, 0));
|
||||
this->setPosition(Vec2(winSize.width/2, 0));
|
||||
setPosVar(Vec2(20, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4;
|
||||
|
@ -1059,7 +1060,7 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(0,-1));
|
||||
setGravity(Vec2(0,-1));
|
||||
|
||||
// Gravity Mode: speed of particles
|
||||
setSpeed(5);
|
||||
|
@ -1075,8 +1076,8 @@ bool ParticleSnow::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(Vector2(winSize.width/2, 0));
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height + 10));
|
||||
setPosVar(Vec2(winSize.width/2, 0));
|
||||
|
||||
// angle
|
||||
_angle = -90;
|
||||
|
@ -1166,7 +1167,7 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
|
|||
setEmitterMode(Mode::GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Vector2(10,-10));
|
||||
setGravity(Vec2(10,-10));
|
||||
|
||||
// Gravity Mode: radial
|
||||
setRadialAccel(0);
|
||||
|
@ -1187,8 +1188,8 @@ bool ParticleRain::initWithTotalParticles(int numberOfParticles)
|
|||
|
||||
// emitter position
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
this->setPosition(Vector2(winSize.width/2, winSize.height));
|
||||
setPosVar(Vector2(winSize.width/2, 0));
|
||||
this->setPosition(Vec2(winSize.width/2, winSize.height));
|
||||
setPosVar(Vec2(winSize.width/2, 0));
|
||||
|
||||
// life of particles
|
||||
_life = 4.5f;
|
||||
|
|
|
@ -42,21 +42,21 @@ THE SOFTWARE.
|
|||
// cocos2d uses a another approach, but the results are almost identical.
|
||||
//
|
||||
|
||||
#include "CCParticleSystem.h"
|
||||
#include "2d/CCParticleSystem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "CCParticleBatchNode.h"
|
||||
#include "2d/CCParticleBatchNode.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "platform/CCImage.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "base/base64.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "2d/platform/CCImage.h"
|
||||
#include "base/ZipUtils.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCProfiling.h"
|
||||
// opengl
|
||||
#include "renderer/CCTextureCache.h"
|
||||
|
||||
#include "CCGL.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -97,8 +97,8 @@ ParticleSystem::ParticleSystem()
|
|||
, _isActive(true)
|
||||
, _particleCount(0)
|
||||
, _duration(0)
|
||||
, _sourcePosition(Vector2::ZERO)
|
||||
, _posVar(Vector2::ZERO)
|
||||
, _sourcePosition(Vec2::ZERO)
|
||||
, _posVar(Vec2::ZERO)
|
||||
, _life(0)
|
||||
, _lifeVar(0)
|
||||
, _angle(0)
|
||||
|
@ -120,7 +120,7 @@ ParticleSystem::ParticleSystem()
|
|||
, _yCoordFlipped(1)
|
||||
, _positionType(PositionType::FREE)
|
||||
{
|
||||
modeA.gravity = Vector2::ZERO;
|
||||
modeA.gravity = Vec2::ZERO;
|
||||
modeA.speed = 0;
|
||||
modeA.speedVar = 0;
|
||||
modeA.tangentialAccel = 0;
|
||||
|
@ -257,7 +257,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
// position
|
||||
float x = dictionary["sourcePositionx"].asFloat();
|
||||
float y = dictionary["sourcePositiony"].asFloat();
|
||||
this->setPosition( Vector2(x,y) );
|
||||
this->setPosition( Vec2(x,y) );
|
||||
_posVar.x = dictionary["sourcePositionVariancex"].asFloat();
|
||||
_posVar.y = dictionary["sourcePositionVariancey"].asFloat();
|
||||
|
||||
|
@ -560,7 +560,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
// position
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
particle->startPos = this->convertToWorldSpace(Vector2::ZERO);
|
||||
particle->startPos = this->convertToWorldSpace(Vec2::ZERO);
|
||||
}
|
||||
else if (_positionType == PositionType::RELATIVE)
|
||||
{
|
||||
|
@ -573,7 +573,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
// Mode Gravity: A
|
||||
if (_emitterMode == Mode::GRAVITY)
|
||||
{
|
||||
Vector2 v(cosf( a ), sinf( a ));
|
||||
Vec2 v(cosf( a ), sinf( a ));
|
||||
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
|
||||
|
||||
// direction
|
||||
|
@ -679,10 +679,10 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
_particleIdx = 0;
|
||||
|
||||
Vector2 currentPosition = Vector2::ZERO;
|
||||
Vec2 currentPosition = Vec2::ZERO;
|
||||
if (_positionType == PositionType::FREE)
|
||||
{
|
||||
currentPosition = this->convertToWorldSpace(Vector2::ZERO);
|
||||
currentPosition = this->convertToWorldSpace(Vec2::ZERO);
|
||||
}
|
||||
else if (_positionType == PositionType::RELATIVE)
|
||||
{
|
||||
|
@ -702,9 +702,9 @@ void ParticleSystem::update(float dt)
|
|||
// Mode A: gravity, direction, tangential accel & radial accel
|
||||
if (_emitterMode == Mode::GRAVITY)
|
||||
{
|
||||
Vector2 tmp, radial, tangential;
|
||||
Vec2 tmp, radial, tangential;
|
||||
|
||||
radial = Vector2::ZERO;
|
||||
radial = Vec2::ZERO;
|
||||
// radial acceleration
|
||||
if (p->pos.x || p->pos.y)
|
||||
{
|
||||
|
@ -761,11 +761,11 @@ void ParticleSystem::update(float dt)
|
|||
// update values in quad
|
||||
//
|
||||
|
||||
Vector2 newPos;
|
||||
Vec2 newPos;
|
||||
|
||||
if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE)
|
||||
{
|
||||
Vector2 diff = currentPosition - p->startPos;
|
||||
Vec2 diff = currentPosition - p->startPos;
|
||||
newPos = p->pos - diff;
|
||||
}
|
||||
else
|
||||
|
@ -832,7 +832,7 @@ void ParticleSystem::updateWithNoTime(void)
|
|||
this->update(0.0f);
|
||||
}
|
||||
|
||||
void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition)
|
||||
void ParticleSystem::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition)
|
||||
{
|
||||
CC_UNUSED_PARAM(particle);
|
||||
CC_UNUSED_PARAM(newPosition);
|
||||
|
@ -967,13 +967,13 @@ bool ParticleSystem::getRotationIsDir() const
|
|||
return modeA.rotationIsDir;
|
||||
}
|
||||
|
||||
void ParticleSystem::setGravity(const Vector2& g)
|
||||
void ParticleSystem::setGravity(const Vec2& g)
|
||||
{
|
||||
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
|
||||
modeA.gravity = g;
|
||||
}
|
||||
|
||||
const Vector2& ParticleSystem::getGravity()
|
||||
const Vec2& ParticleSystem::getGravity()
|
||||
{
|
||||
CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.gravity;
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#ifndef __CCPARTICLE_SYSTEM_H__
|
||||
#define __CCPARTICLE_SYSTEM_H__
|
||||
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "base/CCValue.h"
|
||||
#include "deprecated/CCString.h"
|
||||
|
@ -45,8 +45,8 @@ class ParticleBatchNode;
|
|||
Structure that contains the values of each particle
|
||||
*/
|
||||
typedef struct sParticle {
|
||||
Vector2 pos;
|
||||
Vector2 startPos;
|
||||
Vec2 pos;
|
||||
Vec2 startPos;
|
||||
|
||||
Color4F color;
|
||||
Color4F deltaColor;
|
||||
|
@ -63,7 +63,7 @@ typedef struct sParticle {
|
|||
|
||||
//! Mode A: gravity, direction, radial accel, tangential accel
|
||||
struct {
|
||||
Vector2 dir;
|
||||
Vec2 dir;
|
||||
float radialAccel;
|
||||
float tangentialAccel;
|
||||
} modeA;
|
||||
|
@ -78,7 +78,7 @@ typedef struct sParticle {
|
|||
|
||||
}tParticle;
|
||||
|
||||
//typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vector2);
|
||||
//typedef void (*CC_UPDATE_PARTICLE_IMP)(id, SEL, tParticle*, Vec2);
|
||||
|
||||
class Texture2D;
|
||||
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
bool isFull();
|
||||
|
||||
//! should be overridden by subclasses
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition);
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition);
|
||||
//! should be overridden by subclasses
|
||||
virtual void postStep();
|
||||
|
||||
|
@ -202,8 +202,8 @@ public:
|
|||
virtual void setAutoRemoveOnFinish(bool var);
|
||||
|
||||
// mode A
|
||||
virtual const Vector2& getGravity();
|
||||
virtual void setGravity(const Vector2& g);
|
||||
virtual const Vec2& getGravity();
|
||||
virtual void setGravity(const Vec2& g);
|
||||
virtual float getSpeed() const;
|
||||
virtual void setSpeed(float speed);
|
||||
virtual float getSpeedVar() const;
|
||||
|
@ -256,12 +256,12 @@ public:
|
|||
inline void setDuration(float duration) { _duration = duration; };
|
||||
|
||||
/** sourcePosition of the emitter */
|
||||
inline const Vector2& getSourcePosition() const { return _sourcePosition; };
|
||||
inline void setSourcePosition(const Vector2& pos) { _sourcePosition = pos; };
|
||||
inline const Vec2& getSourcePosition() const { return _sourcePosition; };
|
||||
inline void setSourcePosition(const Vec2& pos) { _sourcePosition = pos; };
|
||||
|
||||
/** Position variance of the emitter */
|
||||
inline const Vector2& getPosVar() const { return _posVar; };
|
||||
inline void setPosVar(const Vector2& pos) { _posVar = pos; };
|
||||
inline const Vec2& getPosVar() const { return _posVar; };
|
||||
inline void setPosVar(const Vec2& pos) { _posVar = pos; };
|
||||
|
||||
/** life, and life variation of each particle */
|
||||
inline float getLife() const { return _life; };
|
||||
|
@ -432,7 +432,7 @@ protected:
|
|||
//! Mode A:Gravity + Tangential Accel + Radial Accel
|
||||
struct {
|
||||
/** Gravity value. Only available in 'Gravity' mode. */
|
||||
Vector2 gravity;
|
||||
Vec2 gravity;
|
||||
/** speed of each particle. Only available in 'Gravity' mode. */
|
||||
float speed;
|
||||
/** speed variance of each particle. Only available in 'Gravity' mode. */
|
||||
|
@ -503,9 +503,9 @@ protected:
|
|||
/** How many seconds the emitter will run. -1 means 'forever' */
|
||||
float _duration;
|
||||
/** sourcePosition of the emitter */
|
||||
Vector2 _sourcePosition;
|
||||
Vec2 _sourcePosition;
|
||||
/** Position variance of the emitter */
|
||||
Vector2 _posVar;
|
||||
Vec2 _posVar;
|
||||
/** life, and life variation of each particle */
|
||||
float _life;
|
||||
/** life variance of each particle */
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include "2d/CCParticleSystemQuad.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCParticleBatchNode.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
|
@ -239,7 +239,7 @@ void ParticleSystemQuad::setTexture(Texture2D* texture)
|
|||
|
||||
void ParticleSystemQuad::setDisplayFrame(SpriteFrame *spriteFrame)
|
||||
{
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().equals(Vector2::ZERO),
|
||||
CCASSERT(spriteFrame->getOffsetInPixels().equals(Vec2::ZERO),
|
||||
"QuadParticle only supports SpriteFrames with no offsets");
|
||||
|
||||
// update texture before updating texture rect
|
||||
|
@ -265,7 +265,7 @@ void ParticleSystemQuad::initIndices()
|
|||
}
|
||||
}
|
||||
|
||||
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vector2& newPosition)
|
||||
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Vec2& newPosition)
|
||||
{
|
||||
V3F_C4B_T2F_Quad *quad;
|
||||
|
||||
|
@ -368,7 +368,7 @@ void ParticleSystemQuad::postStep()
|
|||
}
|
||||
|
||||
// overriding draw method
|
||||
void ParticleSystemQuad::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void ParticleSystemQuad::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
CCASSERT( _particleIdx == 0 || _particleIdx == _particleCount, "Abnormal error in particle quad");
|
||||
//quad command
|
||||
|
@ -523,7 +523,6 @@ void ParticleSystemQuad::listenBackToForeground(EventCustom* event)
|
|||
|
||||
bool ParticleSystemQuad::allocMemory()
|
||||
{
|
||||
CCASSERT( ( !_quads && !_indices), "Memory already alloced");
|
||||
CCASSERT( !_batchNode, "Memory should not be alloced when not using batchNode");
|
||||
|
||||
CC_SAFE_FREE(_quads);
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Vector2& newPosition) override;
|
||||
virtual void updateQuadWithParticle(tParticle* particle, const Vec2& newPosition) override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
|
|
@ -27,8 +27,8 @@ THE SOFTWARE.
|
|||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCDrawingPrimitives.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
|
@ -79,11 +79,11 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
|||
_vertexData = nullptr;
|
||||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
_type = Type::RADIAL;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(Vector2(0.5f, 0.5f));
|
||||
setBarChangeRate(Vector2(1,1));
|
||||
setMidpoint(Vec2(0.5f, 0.5f));
|
||||
setBarChangeRate(Vec2(1,1));
|
||||
setSprite(sp);
|
||||
|
||||
// shader state
|
||||
|
@ -156,15 +156,15 @@ void ProgressTimer::setReverseProgress(bool reverse)
|
|||
///
|
||||
// @returns the vertex position from the texture coordinate
|
||||
///
|
||||
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha)
|
||||
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vec2 alpha)
|
||||
{
|
||||
Tex2F ret(0.0f, 0.0f);
|
||||
if (!_sprite) {
|
||||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Vector2 min = Vector2(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Vector2 max = Vector2(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
Vec2 min = Vec2(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||
Vec2 max = Vec2(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
|
||||
if (_sprite->isTextureRectRotated()) {
|
||||
CC_SWAP(alpha.x, alpha.y, float);
|
||||
|
@ -172,15 +172,15 @@ Tex2F ProgressTimer::textureCoordFromAlphaPoint(Vector2 alpha)
|
|||
return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
|
||||
}
|
||||
|
||||
Vector2 ProgressTimer::vertexFromAlphaPoint(Vector2 alpha)
|
||||
Vec2 ProgressTimer::vertexFromAlphaPoint(Vec2 alpha)
|
||||
{
|
||||
Vector2 ret(0.0f, 0.0f);
|
||||
Vec2 ret(0.0f, 0.0f);
|
||||
if (!_sprite) {
|
||||
return ret;
|
||||
}
|
||||
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||
Vector2 min = Vector2(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Vector2 max = Vector2(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
Vec2 min = Vec2(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||
Vec2 max = Vec2(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
|
||||
ret.y = min.y * (1.f - alpha.y) + max.y * alpha.y;
|
||||
return ret;
|
||||
|
@ -217,12 +217,12 @@ void ProgressTimer::updateProgress(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressTimer::setAnchorPoint(const Vector2& anchorPoint)
|
||||
void ProgressTimer::setAnchorPoint(const Vec2& anchorPoint)
|
||||
{
|
||||
Node::setAnchorPoint(anchorPoint);
|
||||
}
|
||||
|
||||
Vector2 ProgressTimer::getMidpoint() const
|
||||
Vec2 ProgressTimer::getMidpoint() const
|
||||
{
|
||||
return _midpoint;
|
||||
}
|
||||
|
@ -249,9 +249,9 @@ GLubyte ProgressTimer::getOpacity() const
|
|||
return _sprite->getOpacity();
|
||||
}
|
||||
|
||||
void ProgressTimer::setMidpoint(const Vector2& midPoint)
|
||||
void ProgressTimer::setMidpoint(const Vec2& midPoint)
|
||||
{
|
||||
_midpoint = midPoint.getClampPoint(Vector2::ZERO, Vector2(1, 1));
|
||||
_midpoint = midPoint.getClampPoint(Vec2::ZERO, Vec2(1, 1));
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -275,12 +275,12 @@ void ProgressTimer::updateRadial(void)
|
|||
// We find the vector to do a hit detection based on the percentage
|
||||
// We know the first vector is the one @ 12 o'clock (top,mid) so we rotate
|
||||
// from that by the progress angle around the _midpoint pivot
|
||||
Vector2 topMid = Vector2(_midpoint.x, 1.f);
|
||||
Vector2 percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
Vec2 topMid = Vec2(_midpoint.x, 1.f);
|
||||
Vec2 percentagePt = topMid.rotateByAngle(_midpoint, angle);
|
||||
|
||||
|
||||
int index = 0;
|
||||
Vector2 hit = Vector2::ZERO;
|
||||
Vec2 hit = Vec2::ZERO;
|
||||
|
||||
if (alpha == 0.f) {
|
||||
// More efficient since we don't always need to check intersection
|
||||
|
@ -302,8 +302,8 @@ void ProgressTimer::updateRadial(void)
|
|||
for (int i = 0; i <= kProgressTextureCoordsCount; ++i) {
|
||||
int pIndex = (i + (kProgressTextureCoordsCount - 1))%kProgressTextureCoordsCount;
|
||||
|
||||
Vector2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount);
|
||||
Vector2 edgePtB = boundaryTexCoord(pIndex);
|
||||
Vec2 edgePtA = boundaryTexCoord(i % kProgressTextureCoordsCount);
|
||||
Vec2 edgePtB = boundaryTexCoord(pIndex);
|
||||
|
||||
// Remember that the top edge is split in half for the 12 o'clock position
|
||||
// Let's deal with that here by finding the correct endpoints
|
||||
|
@ -315,7 +315,7 @@ void ProgressTimer::updateRadial(void)
|
|||
|
||||
// s and t are returned by ccpLineIntersect
|
||||
float s = 0, t = 0;
|
||||
if(Vector2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
if(Vec2::isLineIntersect(edgePtA, edgePtB, _midpoint, percentagePt, &s, &t))
|
||||
{
|
||||
|
||||
// Since our hit test is on rays we have to deal with the top edge
|
||||
|
@ -374,7 +374,7 @@ void ProgressTimer::updateRadial(void)
|
|||
_vertexData[1].vertices = vertexFromAlphaPoint(topMid);
|
||||
|
||||
for(int i = 0; i < index; ++i){
|
||||
Vector2 alphaPoint = boundaryTexCoord(i);
|
||||
Vec2 alphaPoint = boundaryTexCoord(i);
|
||||
_vertexData[i+2].texCoords = textureCoordFromAlphaPoint(alphaPoint);
|
||||
_vertexData[i+2].vertices = vertexFromAlphaPoint(alphaPoint);
|
||||
}
|
||||
|
@ -401,9 +401,9 @@ void ProgressTimer::updateBar(void)
|
|||
return;
|
||||
}
|
||||
float alpha = _percentage / 100.0f;
|
||||
Vector2 alphaOffset = Vector2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f;
|
||||
Vector2 min = _midpoint - alphaOffset;
|
||||
Vector2 max = _midpoint + alphaOffset;
|
||||
Vec2 alphaOffset = Vec2(1.0f * (1.0f - _barChangeRate.x) + alpha * _barChangeRate.x, 1.0f * (1.0f - _barChangeRate.y) + alpha * _barChangeRate.y) * 0.5f;
|
||||
Vec2 min = _midpoint - alphaOffset;
|
||||
Vec2 max = _midpoint + alphaOffset;
|
||||
|
||||
if (min.x < 0.f) {
|
||||
max.x += -min.x;
|
||||
|
@ -433,74 +433,74 @@ void ProgressTimer::updateBar(void)
|
|||
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
}
|
||||
// TOPLEFT
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y));
|
||||
|
||||
// BOTLEFT
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y));
|
||||
|
||||
// TOPRIGHT
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y));
|
||||
|
||||
// BOTRIGHT
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y));
|
||||
} else {
|
||||
if(!_vertexData) {
|
||||
_vertexDataCount = 8;
|
||||
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||
CCASSERT( _vertexData, "CCProgressTimer. Not enough memory");
|
||||
// TOPLEFT 1
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vector2(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vector2(0,1));
|
||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(Vec2(0,1));
|
||||
_vertexData[0].vertices = vertexFromAlphaPoint(Vec2(0,1));
|
||||
|
||||
// BOTLEFT 1
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vector2(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vector2(0,0));
|
||||
_vertexData[1].texCoords = textureCoordFromAlphaPoint(Vec2(0,0));
|
||||
_vertexData[1].vertices = vertexFromAlphaPoint(Vec2(0,0));
|
||||
|
||||
// TOPRIGHT 2
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vector2(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Vector2(1,1));
|
||||
_vertexData[6].texCoords = textureCoordFromAlphaPoint(Vec2(1,1));
|
||||
_vertexData[6].vertices = vertexFromAlphaPoint(Vec2(1,1));
|
||||
|
||||
// BOTRIGHT 2
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vector2(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Vector2(1,0));
|
||||
_vertexData[7].texCoords = textureCoordFromAlphaPoint(Vec2(1,0));
|
||||
_vertexData[7].vertices = vertexFromAlphaPoint(Vec2(1,0));
|
||||
}
|
||||
|
||||
// TOPRIGHT 1
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vector2(min.x,max.y));
|
||||
_vertexData[2].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,max.y));
|
||||
_vertexData[2].vertices = vertexFromAlphaPoint(Vec2(min.x,max.y));
|
||||
|
||||
// BOTRIGHT 1
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vector2(min.x,min.y));
|
||||
_vertexData[3].texCoords = textureCoordFromAlphaPoint(Vec2(min.x,min.y));
|
||||
_vertexData[3].vertices = vertexFromAlphaPoint(Vec2(min.x,min.y));
|
||||
|
||||
// TOPLEFT 2
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(Vector2(max.x,max.y));
|
||||
_vertexData[4].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,max.y));
|
||||
_vertexData[4].vertices = vertexFromAlphaPoint(Vec2(max.x,max.y));
|
||||
|
||||
// BOTLEFT 2
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(Vector2(max.x,min.y));
|
||||
_vertexData[5].texCoords = textureCoordFromAlphaPoint(Vec2(max.x,min.y));
|
||||
_vertexData[5].vertices = vertexFromAlphaPoint(Vec2(max.x,min.y));
|
||||
}
|
||||
updateColor();
|
||||
}
|
||||
|
||||
Vector2 ProgressTimer::boundaryTexCoord(char index)
|
||||
Vec2 ProgressTimer::boundaryTexCoord(char index)
|
||||
{
|
||||
if (index < kProgressTextureCoordsCount) {
|
||||
if (_reverseDirection) {
|
||||
return Vector2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
return Vec2((kProgressTextureCoords>>(7-(index<<1)))&1,(kProgressTextureCoords>>(7-((index<<1)+1)))&1);
|
||||
} else {
|
||||
return Vector2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
return Vec2((kProgressTextureCoords>>((index<<1)+1))&1,(kProgressTextureCoords>>(index<<1))&1);
|
||||
}
|
||||
}
|
||||
return Vector2::ZERO;
|
||||
return Vec2::ZERO;
|
||||
}
|
||||
|
||||
void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
|
||||
void ProgressTimer::onDraw(const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
|
||||
getGLProgram()->use();
|
||||
|
@ -518,7 +518,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
int offset = 0;
|
||||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
|
||||
|
||||
offset += sizeof(Vector2);
|
||||
offset += sizeof(Vec2);
|
||||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
|
||||
|
||||
offset += sizeof(Color4B);
|
||||
|
@ -551,7 +551,7 @@ void ProgressTimer::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressTimer::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void ProgressTimer::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
if( ! _vertexData || ! _sprite)
|
||||
return;
|
||||
|
|
|
@ -91,28 +91,28 @@ public:
|
|||
* If you're using radials type then the midpoint changes the center point
|
||||
* If you're using bar type the the midpoint changes the bar growth
|
||||
* it expands from the center but clamps to the sprites edge so:
|
||||
* you want a left to right then set the midpoint all the way to Vector2(0,y)
|
||||
* you want a right to left then set the midpoint all the way to Vector2(1,y)
|
||||
* you want a bottom to top then set the midpoint all the way to Vector2(x,0)
|
||||
* you want a top to bottom then set the midpoint all the way to Vector2(x,1)
|
||||
* you want a left to right then set the midpoint all the way to Vec2(0,y)
|
||||
* you want a right to left then set the midpoint all the way to Vec2(1,y)
|
||||
* you want a bottom to top then set the midpoint all the way to Vec2(x,0)
|
||||
* you want a top to bottom then set the midpoint all the way to Vec2(x,1)
|
||||
*/
|
||||
void setMidpoint(const Vector2& point);
|
||||
void setMidpoint(const Vec2& point);
|
||||
/** Returns the Midpoint */
|
||||
Vector2 getMidpoint() const;
|
||||
Vec2 getMidpoint() const;
|
||||
|
||||
/**
|
||||
* This allows the bar type to move the component at a specific rate
|
||||
* Set the component to 0 to make sure it stays at 100%.
|
||||
* For example you want a left to right bar but not have the height stay 100%
|
||||
* Set the rate to be Vector2(0,1); and set the midpoint to = Vector2(0,.5f);
|
||||
* Set the rate to be Vec2(0,1); and set the midpoint to = Vec2(0,.5f);
|
||||
*/
|
||||
inline void setBarChangeRate(const Vector2& barChangeRate ) { _barChangeRate = barChangeRate; }
|
||||
inline void setBarChangeRate(const Vec2& barChangeRate ) { _barChangeRate = barChangeRate; }
|
||||
/** Returns the BarChangeRate */
|
||||
inline Vector2 getBarChangeRate() const { return _barChangeRate; }
|
||||
inline Vec2 getBarChangeRate() const { return _barChangeRate; }
|
||||
|
||||
// Overrides
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void setAnchorPoint(const Vector2& anchorPoint) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void setAnchorPoint(const Vec2& anchorPoint) override;
|
||||
virtual void setColor(const Color3B &color) override;
|
||||
virtual const Color3B& getColor() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
@ -133,19 +133,19 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
bool initWithSprite(Sprite* sp);
|
||||
|
||||
protected:
|
||||
void onDraw(const Matrix &transform, bool transformUpdated);
|
||||
void onDraw(const Mat4 &transform, bool transformUpdated);
|
||||
|
||||
Tex2F textureCoordFromAlphaPoint(Vector2 alpha);
|
||||
Vector2 vertexFromAlphaPoint(Vector2 alpha);
|
||||
Tex2F textureCoordFromAlphaPoint(Vec2 alpha);
|
||||
Vec2 vertexFromAlphaPoint(Vec2 alpha);
|
||||
void updateProgress(void);
|
||||
void updateBar(void);
|
||||
void updateRadial(void);
|
||||
virtual void updateColor(void) override;
|
||||
Vector2 boundaryTexCoord(char index);
|
||||
Vec2 boundaryTexCoord(char index);
|
||||
|
||||
Type _type;
|
||||
Vector2 _midpoint;
|
||||
Vector2 _barChangeRate;
|
||||
Vec2 _midpoint;
|
||||
Vec2 _barChangeRate;
|
||||
float _percentage;
|
||||
Sprite *_sprite;
|
||||
int _vertexDataCount;
|
||||
|
|
|
@ -24,27 +24,27 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/CCConfiguration.h"
|
||||
#include "2d/CCRenderTexture.h"
|
||||
|
||||
#include "base/ccUtils.h"
|
||||
#include "platform/CCImage.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "2d/platform/CCImage.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "base/CCConfiguration.h"
|
||||
#include "2d/ccUtils.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "CCGL.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "2d/CCGrid.h"
|
||||
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "renderer/CCGroupCommand.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
||||
// extern
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "CCGL.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -306,7 +306,7 @@ void RenderTexture::setKeepMatrix(bool keepMatrix)
|
|||
_keepMatrix = keepMatrix;
|
||||
}
|
||||
|
||||
void RenderTexture::setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport)
|
||||
void RenderTexture::setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport)
|
||||
{
|
||||
_rtTextureRect.origin.x = rtBegin.x;
|
||||
_rtTextureRect.origin.y = rtBegin.y;
|
||||
|
@ -383,7 +383,7 @@ void RenderTexture::clearStencil(int stencilValue)
|
|||
glClearStencil(stencilClearValue);
|
||||
}
|
||||
|
||||
void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
// override visit.
|
||||
// Don't call visit on its children
|
||||
|
@ -401,7 +401,7 @@ void RenderTexture::visit(Renderer *renderer, const Matrix &parentTransform, boo
|
|||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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);
|
||||
|
@ -535,7 +535,7 @@ void RenderTexture::onBegin()
|
|||
director->setProjection(director->getProjection());
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
|
||||
Matrix modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
Mat4 modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
|
||||
modifiedProjection = CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection;
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION,modifiedProjection);
|
||||
#endif
|
||||
|
@ -547,8 +547,8 @@ void RenderTexture::onBegin()
|
|||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
Matrix orthoMatrix;
|
||||
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
Mat4 orthoMatrix;
|
||||
Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ void RenderTexture::onClearDepth()
|
|||
glClearDepth(depthClearValue);
|
||||
}
|
||||
|
||||
void RenderTexture::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
if (_autoDraw)
|
||||
{
|
||||
|
@ -703,8 +703,8 @@ void RenderTexture::begin()
|
|||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
Matrix orthoMatrix;
|
||||
Matrix::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
Mat4 orthoMatrix;
|
||||
Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix);
|
||||
director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/platform/CCImage.h"
|
||||
#include "platform/CCImage.h"
|
||||
#include "renderer/CCGroupCommand.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
||||
|
@ -153,8 +153,8 @@ public:
|
|||
};
|
||||
|
||||
// Overrides
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
|
||||
//flag: use stack matrix computed from scene hierarchy or generate new modelView and projection matrix
|
||||
void setKeepMatrix(bool keepMatrix);
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
//fullRect: the total size of screen
|
||||
//fullViewport: the total viewportSize
|
||||
*/
|
||||
void setVirtualViewport(const Vector2& rtBegin, const Rect& fullRect, const Rect& fullViewport);
|
||||
void setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport);
|
||||
|
||||
public:
|
||||
// XXX should be procted.
|
||||
|
@ -224,8 +224,8 @@ protected:
|
|||
|
||||
void onSaveToFile(const std::string& fileName);
|
||||
|
||||
Matrix _oldTransMatrix, _oldProjMatrix;
|
||||
Matrix _transformMatrix, _projectionMatrix;
|
||||
Mat4 _oldTransMatrix, _oldProjMatrix;
|
||||
Mat4 _transformMatrix, _projectionMatrix;
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ Scene::Scene()
|
|||
#endif
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
|
|
@ -26,14 +26,18 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "2d/CCSprite.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "2d/CCSpriteBatchNode.h"
|
||||
#include "2d/CCAnimation.h"
|
||||
#include "2d/CCAnimationCache.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCSpriteFrameCache.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCDrawingPrimitives.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
|
@ -48,8 +52,6 @@ THE SOFTWARE.
|
|||
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -234,10 +236,10 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
|||
_flippedX = _flippedY = false;
|
||||
|
||||
// default transform anchor: center
|
||||
setAnchorPoint(Vector2(0.5f, 0.5f));
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
|
||||
// zwoptex default values
|
||||
_offsetPosition = Vector2::ZERO;
|
||||
_offsetPosition = Vec2::ZERO;
|
||||
|
||||
// clean the Quad
|
||||
memset(&_quad, 0, sizeof(_quad));
|
||||
|
@ -367,7 +369,7 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
|
|||
setVertexRect(rect);
|
||||
setTextureCoords(rect);
|
||||
|
||||
Vector2 relativeOffset = _unflippedOffsetPositionFromCenter;
|
||||
Vec2 relativeOffset = _unflippedOffsetPositionFromCenter;
|
||||
|
||||
// issue #732
|
||||
if (_flippedX)
|
||||
|
@ -399,10 +401,10 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
|
|||
float y2 = y1 + _rect.size.height;
|
||||
|
||||
// Don't update Z.
|
||||
_quad.bl.vertices = Vector3(x1, y1, 0);
|
||||
_quad.br.vertices = Vector3(x2, y1, 0);
|
||||
_quad.tl.vertices = Vector3(x1, y2, 0);
|
||||
_quad.tr.vertices = Vector3(x2, y2, 0);
|
||||
_quad.bl.vertices = Vec3(x1, y1, 0);
|
||||
_quad.br.vertices = Vec3(x2, y1, 0);
|
||||
_quad.tl.vertices = Vec3(x1, y2, 0);
|
||||
_quad.tr.vertices = Vec3(x2, y2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,7 +507,7 @@ void Sprite::updateTransform(void)
|
|||
// If it is not visible, or one of its ancestors is not visible, then do nothing:
|
||||
if( !_visible || ( _parent && _parent != _batchNode && static_cast<Sprite*>(_parent)->_shouldBeHidden) )
|
||||
{
|
||||
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vector3(0,0,0);
|
||||
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vec3(0,0,0);
|
||||
_shouldBeHidden = true;
|
||||
}
|
||||
else
|
||||
|
@ -519,8 +521,8 @@ void Sprite::updateTransform(void)
|
|||
else
|
||||
{
|
||||
CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
Matrix nodeToParent = getNodeToParentTransform();
|
||||
Matrix parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
Mat4 nodeToParent = getNodeToParentTransform();
|
||||
Mat4 parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
_transformToBatch = parentTransform * nodeToParent;
|
||||
}
|
||||
|
||||
|
@ -554,10 +556,10 @@ void Sprite::updateTransform(void)
|
|||
float dx = x1 * cr - y2 * sr2 + x;
|
||||
float dy = x1 * sr + y2 * cr2 + y;
|
||||
|
||||
_quad.bl.vertices = Vector3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
|
||||
_quad.br.vertices = Vector3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
|
||||
_quad.tl.vertices = Vector3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
|
||||
_quad.tr.vertices = Vector3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
|
||||
_quad.bl.vertices = Vec3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
|
||||
_quad.br.vertices = Vec3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
|
||||
_quad.tl.vertices = Vec3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
|
||||
_quad.tr.vertices = Vec3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
|
||||
}
|
||||
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
|
@ -583,7 +585,7 @@ void Sprite::updateTransform(void)
|
|||
|
||||
// draw
|
||||
|
||||
void Sprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void Sprite::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
|
||||
|
@ -604,15 +606,15 @@ void Sprite::drawDebugData()
|
|||
{
|
||||
Director* director = Director::getInstance();
|
||||
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
|
||||
Matrix oldModelView;
|
||||
Mat4 oldModelView;
|
||||
oldModelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
// draw bounding box
|
||||
Vector2 vertices[4] = {
|
||||
Vector2( _quad.bl.vertices.x, _quad.bl.vertices.y ),
|
||||
Vector2( _quad.br.vertices.x, _quad.br.vertices.y ),
|
||||
Vector2( _quad.tr.vertices.x, _quad.tr.vertices.y ),
|
||||
Vector2( _quad.tl.vertices.x, _quad.tl.vertices.y ),
|
||||
Vec2 vertices[4] = {
|
||||
Vec2( _quad.bl.vertices.x, _quad.bl.vertices.y ),
|
||||
Vec2( _quad.br.vertices.x, _quad.br.vertices.y ),
|
||||
Vec2( _quad.tr.vertices.x, _quad.tr.vertices.y ),
|
||||
Vec2( _quad.tl.vertices.x, _quad.tl.vertices.y ),
|
||||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
|
@ -742,7 +744,7 @@ void Sprite::setDirtyRecursively(bool bValue)
|
|||
} \
|
||||
}
|
||||
|
||||
void Sprite::setPosition(const Vector2& pos)
|
||||
void Sprite::setPosition(const Vec2& pos)
|
||||
{
|
||||
Node::setPosition(pos);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
|
@ -815,7 +817,7 @@ void Sprite::setPositionZ(float fVertexZ)
|
|||
SET_DIRTY_RECURSIVELY();
|
||||
}
|
||||
|
||||
void Sprite::setAnchorPoint(const Vector2& anchor)
|
||||
void Sprite::setAnchorPoint(const Vec2& anchor)
|
||||
{
|
||||
Node::setAnchorPoint(anchor);
|
||||
SET_DIRTY_RECURSIVELY();
|
||||
|
@ -996,15 +998,15 @@ void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode)
|
|||
float y1 = _offsetPosition.y;
|
||||
float x2 = x1 + _rect.size.width;
|
||||
float y2 = y1 + _rect.size.height;
|
||||
_quad.bl.vertices = Vector3( x1, y1, 0 );
|
||||
_quad.br.vertices = Vector3( x2, y1, 0 );
|
||||
_quad.tl.vertices = Vector3( x1, y2, 0 );
|
||||
_quad.tr.vertices = Vector3( x2, y2, 0 );
|
||||
_quad.bl.vertices = Vec3( x1, y1, 0 );
|
||||
_quad.br.vertices = Vec3( x2, y1, 0 );
|
||||
_quad.tl.vertices = Vec3( x1, y2, 0 );
|
||||
_quad.tr.vertices = Vec3( x2, y2, 0 );
|
||||
|
||||
} else {
|
||||
|
||||
// using batch
|
||||
_transformToBatch = Matrix::identity();
|
||||
_transformToBatch = Mat4::IDENTITY;
|
||||
setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ THE SOFTWARE.
|
|||
#define __SPRITE_NODE_CCSPRITE_H__
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include <string>
|
||||
#ifdef EMSCRIPTEN
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
/**
|
||||
* Gets the offset position of the sprite. Calculated automatically by editors like Zwoptex.
|
||||
*/
|
||||
inline const Vector2& getOffsetPosition(void) const { return _offsetPosition; }
|
||||
inline const Vec2& getOffsetPosition(void) const { return _offsetPosition; }
|
||||
|
||||
|
||||
/**
|
||||
|
@ -402,7 +402,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setPosition(const Vector2& pos) override;
|
||||
virtual void setPosition(const Vec2& pos) override;
|
||||
virtual void setPosition(float x, float y) override;
|
||||
virtual void setRotation(float rotation) override;
|
||||
virtual void setRotationSkewX(float rotationX) override;
|
||||
|
@ -417,10 +417,10 @@ public:
|
|||
virtual void sortAllChildren() override;
|
||||
virtual void setScale(float scale) override;
|
||||
virtual void setPositionZ(float positionZ) override;
|
||||
virtual void setAnchorPoint(const Vector2& anchor) override;
|
||||
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 Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) override;
|
||||
virtual void setOpacityModifyRGB(bool modify) override;
|
||||
virtual bool isOpacityModifyRGB(void) const override;
|
||||
/// @}
|
||||
|
@ -535,7 +535,7 @@ protected:
|
|||
bool _dirty; /// Whether the sprite needs to be updated
|
||||
bool _recursiveDirty; /// Whether all of the sprite's children needs to be updated
|
||||
bool _shouldBeHidden; /// should not be drawn because one of the ancestors is not visible
|
||||
Matrix _transformToBatch;
|
||||
Mat4 _transformToBatch;
|
||||
|
||||
//
|
||||
// Data used when the sprite is self-rendered
|
||||
|
@ -556,8 +556,8 @@ protected:
|
|||
bool _rectRotated; /// Whether the texture is rotated
|
||||
|
||||
// Offset Position (used by Zwoptex)
|
||||
Vector2 _offsetPosition;
|
||||
Vector2 _unflippedOffsetPositionFromCenter;
|
||||
Vec2 _offsetPosition;
|
||||
Vec2 _unflippedOffsetPositionFromCenter;
|
||||
|
||||
// vertex coords, texture coords and color info
|
||||
V3F_C4B_T2F_Quad _quad;
|
||||
|
|
|
@ -28,15 +28,17 @@ THE SOFTWARE.
|
|||
|
||||
#include "2d/CCSpriteBatchNode.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCGrid.h"
|
||||
#include "2d/CCDrawingPrimitives.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCLayer.h"
|
||||
#include "2d/CCScene.h"
|
||||
#include "base/ccConfig.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCProfiling.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
|
@ -46,8 +48,6 @@ THE SOFTWARE.
|
|||
|
||||
#include "deprecated/CCString.h" // For StringUtils::format
|
||||
|
||||
// external
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -132,7 +132,7 @@ SpriteBatchNode::~SpriteBatchNode()
|
|||
|
||||
// override visit
|
||||
// don't call visit on it's children
|
||||
void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated)
|
||||
void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
CC_PROFILER_START_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
|
||||
|
||||
|
@ -156,7 +156,7 @@ void SpriteBatchNode::visit(Renderer *renderer, const Matrix &parentTransform, b
|
|||
_transformUpdated = false;
|
||||
|
||||
// IMPORTANT:
|
||||
// To ease the migration to v3.0, we still support the Matrix stack,
|
||||
// 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");
|
||||
|
@ -356,7 +356,7 @@ void SpriteBatchNode::reorderBatch(bool reorder)
|
|||
_reorderChildDirty=reorder;
|
||||
}
|
||||
|
||||
void SpriteBatchNode::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
|
||||
void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated)
|
||||
{
|
||||
// Optimization: Fast Dispatch
|
||||
if( _textureAtlas->getTotalQuads() == 0 )
|
||||
|
|
|
@ -32,9 +32,9 @@ THE SOFTWARE.
|
|||
#include <vector>
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "2d/CCTextureAtlas.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "renderer/CCTextureAtlas.h"
|
||||
#include "renderer/CCBatchCommand.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -134,7 +134,7 @@ public:
|
|||
*/
|
||||
virtual const BlendFunc& getBlendFunc() const override;
|
||||
|
||||
virtual void visit(Renderer *renderer, const Matrix &parentTransform, bool parentTransformUpdated) override;
|
||||
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) 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 Matrix &transform, bool transformUpdated) override;
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, bool transformUpdated) 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.
|
||||
|
|
|
@ -24,7 +24,8 @@ 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 "2d/CCTextureCache.h"
|
||||
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
|
@ -50,7 +51,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect
|
|||
return spriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *spriteFrame = new SpriteFrame();
|
||||
spriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize);
|
||||
|
@ -59,7 +60,7 @@ SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect
|
|||
return spriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *spriteFrame = new SpriteFrame();
|
||||
spriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize);
|
||||
|
@ -71,16 +72,16 @@ SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect,
|
|||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
return initWithTexture(texture, rectInPixels, false, Vector2::ZERO, rectInPixels.size);
|
||||
return initWithTexture(texture, rectInPixels, false, Vec2::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect );
|
||||
return initWithTextureFilename(filename, rectInPixels, false, Vector2::ZERO, rectInPixels.size);
|
||||
return initWithTextureFilename(filename, rectInPixels, false, Vec2::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = texture;
|
||||
|
||||
|
@ -100,7 +101,7 @@ bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rot
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = nullptr;
|
||||
_textureFilename = filename;
|
||||
|
@ -143,23 +144,23 @@ void SpriteFrame::setRectInPixels(const Rect& rectInPixels)
|
|||
_rect = CC_RECT_PIXELS_TO_POINTS(rectInPixels);
|
||||
}
|
||||
|
||||
const Vector2& SpriteFrame::getOffset() const
|
||||
const Vec2& SpriteFrame::getOffset() const
|
||||
{
|
||||
return _offset;
|
||||
}
|
||||
|
||||
void SpriteFrame::setOffset(const Vector2& offsets)
|
||||
void SpriteFrame::setOffset(const Vec2& offsets)
|
||||
{
|
||||
_offset = offsets;
|
||||
_offsetInPixels = CC_POINT_POINTS_TO_PIXELS( _offset );
|
||||
}
|
||||
|
||||
const Vector2& SpriteFrame::getOffsetInPixels() const
|
||||
const Vec2& SpriteFrame::getOffsetInPixels() const
|
||||
{
|
||||
return _offsetInPixels;
|
||||
}
|
||||
|
||||
void SpriteFrame::setOffsetInPixels(const Vector2& offsetInPixels)
|
||||
void SpriteFrame::setOffsetInPixels(const Vec2& offsetInPixels)
|
||||
{
|
||||
_offsetInPixels = offsetInPixels;
|
||||
_offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
#define __SPRITE_CCSPRITE_FRAME_H__
|
||||
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCProtocols.h"
|
||||
#include "base/CCProtocols.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "math/CCGeometry.h"
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
/** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
*/
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize);
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
/** Create a SpriteFrame with a texture, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
/** Create 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.
|
||||
*/
|
||||
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vector2& offset, const Size& originalSize);
|
||||
static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -94,14 +94,14 @@ public:
|
|||
/** 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 Vector2& offset, const Size& originalSize);
|
||||
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 Vector2& offset, const Size& originalSize);
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
|
||||
|
||||
|
||||
// attributes
|
||||
|
@ -117,9 +117,9 @@ public:
|
|||
void setRect(const Rect& rect);
|
||||
|
||||
/** get offset of the frame */
|
||||
const Vector2& getOffsetInPixels(void) const;
|
||||
const Vec2& getOffsetInPixels(void) const;
|
||||
/** set offset of the frame */
|
||||
void setOffsetInPixels(const Vector2& offsetInPixels);
|
||||
void setOffsetInPixels(const Vec2& offsetInPixels);
|
||||
|
||||
/** get original size of the trimmed image */
|
||||
inline const Size& getOriginalSizeInPixels(void) const { return _originalSizeInPixels; }
|
||||
|
@ -136,19 +136,19 @@ public:
|
|||
/** set texture of the frame, the texture is retained */
|
||||
void setTexture(Texture2D* pobTexture);
|
||||
|
||||
const Vector2& getOffset(void) const;
|
||||
void setOffset(const Vector2& offsets);
|
||||
const Vec2& getOffset(void) const;
|
||||
void setOffset(const Vec2& offsets);
|
||||
|
||||
// Overrides
|
||||
virtual SpriteFrame *clone() const override;
|
||||
|
||||
protected:
|
||||
Vector2 _offset;
|
||||
Vec2 _offset;
|
||||
Size _originalSize;
|
||||
Rect _rectInPixels;
|
||||
bool _rotated;
|
||||
Rect _rect;
|
||||
Vector2 _offsetInPixels;
|
||||
Vec2 _offsetInPixels;
|
||||
Size _originalSizeInPixels;
|
||||
Texture2D *_texture;
|
||||
std::string _textureFilename;
|
||||
|
|
|
@ -27,17 +27,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/CCNS.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/CCSpriteFrameCache.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "math/TransformUtils.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "deprecated/CCString.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/CCNS.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include <vector>
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "math/TransformUtils.h"
|
||||
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -132,7 +136,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
spriteFrame->initWithTexture(texture,
|
||||
Rect(x, y, w, h),
|
||||
false,
|
||||
Vector2(ox, oy),
|
||||
Vec2(ox, oy),
|
||||
Size((float)ow, (float)oh)
|
||||
);
|
||||
}
|
||||
|
@ -147,7 +151,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
rotated = frameDict["rotated"].asBool();
|
||||
}
|
||||
|
||||
Vector2 offset = PointFromString(frameDict["offset"].asString());
|
||||
Vec2 offset = PointFromString(frameDict["offset"].asString());
|
||||
Size sourceSize = SizeFromString(frameDict["sourceSize"].asString());
|
||||
|
||||
// create frame
|
||||
|
@ -163,7 +167,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
{
|
||||
// get values
|
||||
Size spriteSize = SizeFromString(frameDict["spriteSize"].asString());
|
||||
Vector2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Vec2 spriteOffset = PointFromString(frameDict["spriteOffset"].asString());
|
||||
Size spriteSourceSize = SizeFromString(frameDict["spriteSourceSize"].asString());
|
||||
Rect textureRect = RectFromString(frameDict["textureRect"].asString());
|
||||
bool textureRotated = frameDict["textureRotated"].asBool();
|
||||
|
|
|
@ -36,7 +36,7 @@ THE SOFTWARE.
|
|||
*/
|
||||
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include "2d/CCTexture2D.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/CCValue.h"
|
||||
#include "base/CCMap.h"
|
||||
|
|
|
@ -24,15 +24,17 @@ 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 "2d/CCTMXLayer.h"
|
||||
|
||||
#include "2d/CCTMXXMLParser.h"
|
||||
#include "2d/CCTMXTiledMap.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCTextureCache.h"
|
||||
#include "2d/ccCArray.h"
|
||||
#include "base/ccCArray.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
#include "deprecated/CCString.h" // For StringUtils::format
|
||||
|
||||
|
@ -83,7 +85,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la
|
|||
_layerOrientation = mapInfo->getOrientation();
|
||||
|
||||
// offset (after layer orientation is set);
|
||||
Vector2 offset = this->calculateLayerOffset(layerInfo->_offset);
|
||||
Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);
|
||||
this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));
|
||||
|
||||
_atlasIndexArray = ccCArrayNew(totalNumberOfTiles);
|
||||
|
@ -176,7 +178,7 @@ void TMXLayer::setupTiles()
|
|||
// XXX: gid == 0 --> empty tile
|
||||
if (gid != 0)
|
||||
{
|
||||
this->appendTileForGID(gid, Vector2(x, y));
|
||||
this->appendTileForGID(gid, Vec2(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,25 +225,25 @@ void TMXLayer::parseInternalProperties()
|
|||
}
|
||||
}
|
||||
|
||||
void TMXLayer::setupTileSprite(Sprite* sprite, Vector2 pos, int gid)
|
||||
void TMXLayer::setupTileSprite(Sprite* sprite, Vec2 pos, int gid)
|
||||
{
|
||||
sprite->setPosition(getPositionAt(pos));
|
||||
sprite->setPositionZ((float)getVertexZForPos(pos));
|
||||
sprite->setAnchorPoint(Vector2::ZERO);
|
||||
sprite->setAnchorPoint(Vec2::ZERO);
|
||||
sprite->setOpacity(_opacity);
|
||||
|
||||
//issue 1264, flip can be undone as well
|
||||
sprite->setFlippedX(false);
|
||||
sprite->setFlippedY(false);
|
||||
sprite->setRotation(0.0f);
|
||||
sprite->setAnchorPoint(Vector2(0,0));
|
||||
sprite->setAnchorPoint(Vec2(0,0));
|
||||
|
||||
// Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles.
|
||||
if (gid & kTMXTileDiagonalFlag)
|
||||
{
|
||||
// put the anchor in the middle for ease of rotation.
|
||||
sprite->setAnchorPoint(Vector2(0.5f,0.5f));
|
||||
sprite->setPosition(Vector2(getPositionAt(pos).x + sprite->getContentSize().height/2,
|
||||
sprite->setAnchorPoint(Vec2(0.5f,0.5f));
|
||||
sprite->setPosition(Vec2(getPositionAt(pos).x + sprite->getContentSize().height/2,
|
||||
getPositionAt(pos).y + sprite->getContentSize().width/2 ) );
|
||||
|
||||
int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag );
|
||||
|
@ -305,7 +307,7 @@ Sprite* TMXLayer::reusedTileWithRect(Rect rect)
|
|||
}
|
||||
|
||||
// TMXLayer - obtaining tiles/gids
|
||||
Sprite * TMXLayer::getTileAt(const Vector2& pos)
|
||||
Sprite * TMXLayer::getTileAt(const Vec2& pos)
|
||||
{
|
||||
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
|
||||
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
|
||||
|
@ -329,7 +331,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos)
|
|||
tile->setBatchNode(this);
|
||||
tile->setPosition(getPositionAt(pos));
|
||||
tile->setPositionZ((float)getVertexZForPos(pos));
|
||||
tile->setAnchorPoint(Vector2::ZERO);
|
||||
tile->setAnchorPoint(Vec2::ZERO);
|
||||
tile->setOpacity(_opacity);
|
||||
|
||||
ssize_t indexForZ = atlasIndexForExistantZ(z);
|
||||
|
@ -340,7 +342,7 @@ Sprite * TMXLayer::getTileAt(const Vector2& pos)
|
|||
return tile;
|
||||
}
|
||||
|
||||
uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = nullptr*/)
|
||||
uint32_t TMXLayer::getTileGIDAt(const Vec2& pos, TMXTileFlags* flags/* = nullptr*/)
|
||||
{
|
||||
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
|
||||
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
|
||||
|
@ -359,7 +361,7 @@ uint32_t TMXLayer::getTileGIDAt(const Vector2& pos, TMXTileFlags* flags/* = null
|
|||
}
|
||||
|
||||
// TMXLayer - adding helper methods
|
||||
Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos)
|
||||
Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vec2& pos)
|
||||
{
|
||||
if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0)
|
||||
{
|
||||
|
@ -399,7 +401,7 @@ Sprite * TMXLayer::insertTileForGID(uint32_t gid, const Vector2& pos)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos)
|
||||
Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vec2& pos)
|
||||
{
|
||||
Rect rect = _tileSet->getRectForGID(gid);
|
||||
rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor);
|
||||
|
@ -421,7 +423,7 @@ Sprite * TMXLayer::updateTileForGID(uint32_t gid, const Vector2& pos)
|
|||
|
||||
// used only when parsing the map. useless after the map was parsed
|
||||
// since lot's of assumptions are no longer true
|
||||
Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vector2& pos)
|
||||
Sprite * TMXLayer::appendTileForGID(uint32_t gid, const Vec2& pos)
|
||||
{
|
||||
if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0)
|
||||
{
|
||||
|
@ -485,12 +487,12 @@ ssize_t TMXLayer::atlasIndexForNewZ(int z)
|
|||
}
|
||||
|
||||
// TMXLayer - adding / remove tiles
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos)
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos)
|
||||
{
|
||||
setTileGID(gid, pos, (TMXTileFlags)0);
|
||||
}
|
||||
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vector2& pos, TMXTileFlags flags)
|
||||
void TMXLayer::setTileGID(uint32_t gid, const Vec2& pos, TMXTileFlags flags)
|
||||
{
|
||||
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
|
||||
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
|
||||
|
@ -564,7 +566,7 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
|
|||
SpriteBatchNode::removeChild(sprite, cleanup);
|
||||
}
|
||||
|
||||
void TMXLayer::removeTileAt(const Vector2& pos)
|
||||
void TMXLayer::removeTileAt(const Vec2& pos)
|
||||
{
|
||||
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
|
||||
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
|
||||
|
@ -606,28 +608,28 @@ void TMXLayer::removeTileAt(const Vector2& pos)
|
|||
}
|
||||
|
||||
//CCTMXLayer - obtaining positions, offset
|
||||
Vector2 TMXLayer::calculateLayerOffset(const Vector2& pos)
|
||||
Vec2 TMXLayer::calculateLayerOffset(const Vec2& pos)
|
||||
{
|
||||
Vector2 ret = Vector2::ZERO;
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
ret = Vector2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
ret = Vec2( pos.x * _mapTileSize.width, -pos.y *_mapTileSize.height);
|
||||
break;
|
||||
case TMXOrientationIso:
|
||||
ret = Vector2((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
ret = Vec2((_mapTileSize.width /2) * (pos.x - pos.y),
|
||||
(_mapTileSize.height /2 ) * (-pos.x - pos.y));
|
||||
break;
|
||||
case TMXOrientationHex:
|
||||
CCASSERT(pos.equals(Vector2::ZERO), "offset for hexagonal map not implemented yet");
|
||||
CCASSERT(pos.equals(Vec2::ZERO), "offset for hexagonal map not implemented yet");
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector2 TMXLayer::getPositionAt(const Vector2& pos)
|
||||
Vec2 TMXLayer::getPositionAt(const Vec2& pos)
|
||||
{
|
||||
Vector2 ret = Vector2::ZERO;
|
||||
Vec2 ret = Vec2::ZERO;
|
||||
switch (_layerOrientation)
|
||||
{
|
||||
case TMXOrientationOrtho:
|
||||
|
@ -644,19 +646,19 @@ Vector2 TMXLayer::getPositionAt(const Vector2& pos)
|
|||
return ret;
|
||||
}
|
||||
|
||||
Vector2 TMXLayer::getPositionForOrthoAt(const Vector2& pos)
|
||||
Vec2 TMXLayer::getPositionForOrthoAt(const Vec2& pos)
|
||||
{
|
||||
return Vector2(pos.x * _mapTileSize.width,
|
||||
return Vec2(pos.x * _mapTileSize.width,
|
||||
(_layerSize.height - pos.y - 1) * _mapTileSize.height);
|
||||
}
|
||||
|
||||
Vector2 TMXLayer::getPositionForIsoAt(const Vector2& pos)
|
||||
Vec2 TMXLayer::getPositionForIsoAt(const Vec2& pos)
|
||||
{
|
||||
return Vector2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1),
|
||||
return Vec2(_mapTileSize.width /2 * (_layerSize.width + pos.x - pos.y - 1),
|
||||
_mapTileSize.height /2 * ((_layerSize.height * 2 - pos.x - pos.y) - 2));
|
||||
}
|
||||
|
||||
Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos)
|
||||
Vec2 TMXLayer::getPositionForHexAt(const Vec2& pos)
|
||||
{
|
||||
float diffY = 0;
|
||||
if ((int)pos.x % 2 == 1)
|
||||
|
@ -664,12 +666,12 @@ Vector2 TMXLayer::getPositionForHexAt(const Vector2& pos)
|
|||
diffY = -_mapTileSize.height/2 ;
|
||||
}
|
||||
|
||||
Vector2 xy = Vector2(pos.x * _mapTileSize.width*3/4,
|
||||
Vec2 xy = Vec2(pos.x * _mapTileSize.width*3/4,
|
||||
(_layerSize.height - pos.y - 1) * _mapTileSize.height + diffY);
|
||||
return xy;
|
||||
}
|
||||
|
||||
int TMXLayer::getVertexZForPos(const Vector2& pos)
|
||||
int TMXLayer::getVertexZForPos(const Vec2& pos)
|
||||
{
|
||||
int ret = 0;
|
||||
int maxVal = 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
#include "CCAtlasNode.h"
|
||||
#include "2d/CCSpriteBatchNode.h"
|
||||
#include "CCTMXXMLParser.h"
|
||||
#include "2d/ccCArray.h"
|
||||
#include "base/ccCArray.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
class TMXMapInfo;
|
||||
|
@ -102,16 +102,16 @@ public:
|
|||
The Sprite can be treated like any other Sprite: rotated, scaled, translated, opacity, color, etc.
|
||||
You can remove either by calling:
|
||||
- layer->removeChild(sprite, cleanup);
|
||||
- or layer->removeTileAt(Vector2(x,y));
|
||||
- or layer->removeTileAt(Vec2(x,y));
|
||||
*/
|
||||
Sprite* getTileAt(const Vector2& tileCoordinate);
|
||||
CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vector2& tileCoordinate) { return getTileAt(tileCoordinate); };
|
||||
Sprite* getTileAt(const Vec2& tileCoordinate);
|
||||
CC_DEPRECATED_ATTRIBUTE Sprite* tileAt(const Vec2& tileCoordinate) { return getTileAt(tileCoordinate); };
|
||||
|
||||
/** returns the tile gid at a given tile coordinate. It also returns the tile flags.
|
||||
This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap])
|
||||
*/
|
||||
uint32_t getTileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr);
|
||||
CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vector2& tileCoordinate, TMXTileFlags* flags = nullptr){
|
||||
uint32_t getTileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr);
|
||||
CC_DEPRECATED_ATTRIBUTE uint32_t tileGIDAt(const Vec2& tileCoordinate, TMXTileFlags* flags = nullptr){
|
||||
return getTileGIDAt(tileCoordinate, flags);
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1.
|
||||
If a tile is already placed at that position, then it will be removed.
|
||||
*/
|
||||
void setTileGID(uint32_t gid, const Vector2& tileCoordinate);
|
||||
void setTileGID(uint32_t gid, const Vec2& tileCoordinate);
|
||||
|
||||
/** sets the tile gid (gid = tile global id) at a given tile coordinate.
|
||||
The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1.
|
||||
|
@ -128,14 +128,14 @@ public:
|
|||
Use withFlags if the tile flags need to be changed as well
|
||||
*/
|
||||
|
||||
void setTileGID(uint32_t gid, const Vector2& tileCoordinate, TMXTileFlags flags);
|
||||
void setTileGID(uint32_t gid, const Vec2& tileCoordinate, TMXTileFlags flags);
|
||||
|
||||
/** removes a tile at given tile coordinate */
|
||||
void removeTileAt(const Vector2& tileCoordinate);
|
||||
void removeTileAt(const Vec2& tileCoordinate);
|
||||
|
||||
/** returns the position in points of a given tile coordinate */
|
||||
Vector2 getPositionAt(const Vector2& tileCoordinate);
|
||||
CC_DEPRECATED_ATTRIBUTE Vector2 positionAt(const Vector2& tileCoordinate) { return getPositionAt(tileCoordinate); };
|
||||
Vec2 getPositionAt(const Vec2& tileCoordinate);
|
||||
CC_DEPRECATED_ATTRIBUTE Vec2 positionAt(const Vec2& tileCoordinate) { return getPositionAt(tileCoordinate); };
|
||||
|
||||
/** return the value for the specific property name */
|
||||
Value getProperty(const std::string& propertyName) const;
|
||||
|
@ -193,22 +193,22 @@ public:
|
|||
virtual std::string getDescription() const override;
|
||||
|
||||
private:
|
||||
Vector2 getPositionForIsoAt(const Vector2& pos);
|
||||
Vector2 getPositionForOrthoAt(const Vector2& pos);
|
||||
Vector2 getPositionForHexAt(const Vector2& pos);
|
||||
Vec2 getPositionForIsoAt(const Vec2& pos);
|
||||
Vec2 getPositionForOrthoAt(const Vec2& pos);
|
||||
Vec2 getPositionForHexAt(const Vec2& pos);
|
||||
|
||||
Vector2 calculateLayerOffset(const Vector2& offset);
|
||||
Vec2 calculateLayerOffset(const Vec2& offset);
|
||||
|
||||
/* optimization methods */
|
||||
Sprite* appendTileForGID(uint32_t gid, const Vector2& pos);
|
||||
Sprite* insertTileForGID(uint32_t gid, const Vector2& pos);
|
||||
Sprite* updateTileForGID(uint32_t gid, const Vector2& pos);
|
||||
Sprite* appendTileForGID(uint32_t gid, const Vec2& pos);
|
||||
Sprite* insertTileForGID(uint32_t gid, const Vec2& pos);
|
||||
Sprite* updateTileForGID(uint32_t gid, const Vec2& pos);
|
||||
|
||||
/* The layer recognizes some special properties, like cc_vertez */
|
||||
void parseInternalProperties();
|
||||
void setupTileSprite(Sprite* sprite, Vector2 pos, int gid);
|
||||
void setupTileSprite(Sprite* sprite, Vec2 pos, int gid);
|
||||
Sprite* reusedTileWithRect(Rect rect);
|
||||
int getVertexZForPos(const Vector2& pos);
|
||||
int getVertexZForPos(const Vec2& pos);
|
||||
|
||||
// index
|
||||
ssize_t atlasIndexForExistantZ(int z);
|
||||
|
|
|
@ -34,7 +34,7 @@ NS_CC_BEGIN
|
|||
|
||||
TMXObjectGroup::TMXObjectGroup()
|
||||
: _groupName("")
|
||||
, _positionOffset(Vector2::ZERO)
|
||||
, _positionOffset(Vec2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -71,10 +71,10 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); };
|
||||
|
||||
/** Gets the offset position of child objects */
|
||||
inline const Vector2& getPositionOffset() const { return _positionOffset; };
|
||||
inline const Vec2& getPositionOffset() const { return _positionOffset; };
|
||||
|
||||
/** Sets the offset position of child objects */
|
||||
inline void setPositionOffset(const Vector2& offset) { _positionOffset = offset; };
|
||||
inline void setPositionOffset(const Vec2& offset) { _positionOffset = offset; };
|
||||
|
||||
/** Gets the list of properties stored in a dictionary */
|
||||
inline const ValueMap& getProperties() const { return _properties; };
|
||||
|
@ -98,7 +98,7 @@ protected:
|
|||
/** name of the group */
|
||||
std::string _groupName;
|
||||
/** offset position of child objects */
|
||||
Vector2 _positionOffset;
|
||||
Vec2 _positionOffset;
|
||||
/** list of properties stored in a dictionary */
|
||||
ValueMap _properties;
|
||||
/** array of the objects */
|
||||
|
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
#include "CCTMXXMLParser.h"
|
||||
#include "CCTMXTiledMap.h"
|
||||
#include "base/ccMacros.h"
|
||||
#include "2d/platform/CCFileUtils.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "base/ZipUtils.h"
|
||||
#include "base/base64.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
@ -45,7 +45,7 @@ TMXLayerInfo::TMXLayerInfo()
|
|||
: _name("")
|
||||
, _tiles(nullptr)
|
||||
, _ownTiles(true)
|
||||
, _offset(Vector2::ZERO)
|
||||
, _offset(Vec2::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
|
||||
float x = attributeDict["x"].asFloat();
|
||||
float y = attributeDict["y"].asFloat();
|
||||
layer->_offset = Vector2(x,y);
|
||||
layer->_offset = Vec2(x,y);
|
||||
|
||||
tmxMapInfo->getLayers().pushBack(layer);
|
||||
layer->release();
|
||||
|
@ -361,7 +361,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
{
|
||||
TMXObjectGroup *objectGroup = new TMXObjectGroup();
|
||||
objectGroup->setGroupName(attributeDict["name"].asString());
|
||||
Vector2 positionOffset;
|
||||
Vec2 positionOffset;
|
||||
positionOffset.x = attributeDict["x"].asFloat() * tmxMapInfo->getTileSize().width;
|
||||
positionOffset.y = attributeDict["y"].asFloat() * tmxMapInfo->getTileSize().height;
|
||||
objectGroup->setPositionOffset(positionOffset);
|
||||
|
@ -452,7 +452,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
// Y
|
||||
int y = attributeDict["y"].asInt();
|
||||
|
||||
Vector2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt());
|
||||
Vec2 p(x + objectGroup->getPositionOffset().x, _mapSize.height * _tileSize.height - y - objectGroup->getPositionOffset().x - attributeDict["height"].asInt());
|
||||
p = CC_POINT_PIXELS_TO_POINTS(p);
|
||||
dict["x"] = Value(p.x);
|
||||
dict["y"] = Value(p.y);
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#define __CC_TM_XML_PARSER__
|
||||
|
||||
#include "math/CCGeometry.h"
|
||||
#include "2d/platform/CCSAXParser.h"
|
||||
#include "platform/CCSAXParser.h"
|
||||
#include "base/CCVector.h"
|
||||
#include "base/CCValue.h"
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
bool _visible;
|
||||
unsigned char _opacity;
|
||||
bool _ownTiles;
|
||||
Vector2 _offset;
|
||||
Vec2 _offset;
|
||||
};
|
||||
|
||||
/** @brief TMXTilesetInfo contains the information about the tilesets like:
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue