Conflicts:
	tools/bindings-generator
	web
This commit is contained in:
pandamicro 2015-06-02 10:12:22 +08:00
commit 4c6f67fd7e
813 changed files with 92181 additions and 15242 deletions

6
.gitignore vendored
View File

@ -113,9 +113,14 @@ build/build/
cocos/scripting/lua-bindings/proj.ios_mac/build/
tests/*/runtime/
tests/*/publish/
tests/*/project/proj.android-studio/app/build.xml
tests/*/project/proj.android-studio/app/proguard-project.txt
tests/*/proj.android-studio/app/build.xml
tests/*/proj.android-studio/app/proguard-project.txt
# Android
project.properties
*.iml
# Ignore prebuilt libraries folder
/external/*
@ -130,3 +135,4 @@ tests/cpp-tests/Resources/audio
/tests/lua-game-controller-test/src/cocos/
/tests/lua-tests/src/cocos/
/tests/js-tests/res/
/tools/framework-compile/

View File

@ -833,6 +833,7 @@ Developers:
flashjay
Remove deprecated code in lua tests & template
luaLoadChunksFromZip should just remove .lua or .luac extension
zukkun
Fixed incorrect function invocation in PhysicsBody::setAngularVelocityLimit
@ -1127,6 +1128,9 @@ Developers:
tankorsmash
Fixed the bug that ProgressTimer::setSprite() doesn't take effect
namezero111111
ui: TextField add `getTextColor`, `getTextHorizontalAlignment` and `getTextVerticalAlignment` API
Retired Core Developers:
WenSheng Yang
Author of windows port, CCTextField,

View File

@ -1,13 +1,32 @@
cocos2d-x-3.7 ??
[NEW] android: Add Samsung API for cocos, please refer to the release note for more details.
[NEW] 3rd: updated rapidjson to v1.0.2
[NEW] 3d: added physics3d support
[NEW] console: support build & run Android Studio project
[NEW] Audio: added support on WP8.1, now it supports wav format
[NEW] C++: added ActionFloat
[NEW] C++: support physical keyboard on WinRT
[NEW] C++: supported physical keyboard on WinRT
[NEW] C++: added Android Studio support
[NEW] FileUtils: checked filename case characters on windows
[NEW] FileUitls: added supporting loading files that which file path include utf-8 characters
[NEW] PhysicsShape: added sensor property
[NEW] Scale9Sprite: added Android 9-patch image support
[NEW] Sprite: used triangle command
[NEW] 3d: add `getFarPlane` and `getNearPlane` in `Camera` class
[NEW] 3d: add opengl version project/unproject function in camera.
[NEW] ui: button add BMFont title support
[NEW] ui: TextField add `getTextColor`, `getTextHorizontalAlignment` and `getTextVerticalAlignment` API
[NEW] audio: Added MP3 support to winrt audio
[FIX] audio: Fixed program may freeze if `AudioEngine::stop` or `AudioEngine::stopAll()` is invoked frequently on Android
[FIX] audio: Fixed audio can't resume if it is interrupted by an incoming phone call.
[FIX] audio: Fixed SimpleAudioEngine::playEffect() lagged on Android 5.0.x
[FIX] ui: TextField scale factor is wrong with multiline text.
[FIX] 3d: skybox can't move to other position except origin point in world space
[FIX] 3d: terrain can't move to other position except origin point in world space
[FIX] 3rd: fix PIE link error on iOS caused by libpng and libtiff
[FIX] AssetsManager: crashed issue
[FIX] Audio: can not play large ogg files on windows
[FIX] EaseRateAction: no way to create an `EaseRateAction` instance
[FIX] Label: crashed if invoking `setString(text` after `getLetter(letterIndex)` and `letterIndex` is greater than the length of text
[FIX] Label: position is wrong if label content is changed after invoking `getLetter(letterIndex)`
@ -15,9 +34,13 @@ cocos2d-x-3.7 ??
[FIX] Label: outline effect doesn't match characters well
[FIX] ProgressTimer: `setSprite()` doesn't take effect
[FIX] Sprite3D: setGLProgram() does not work
[FIX] Sprite3D: transition breaks when there is a Sprite3D in the scene
[FIX] Terrain: terrain is on top of particles, particles can not be seen
[FIX] TextureCache: unbindImageAsync failed to unbind all asynchronous callback for a specified bound image
[FIX] TileMap: crashed if a layer contains nothing
[FIX] WebView: memory leak on iOS
[FIX] WebView: crashed if url contains illegal characters on Android
[FIX] Lua: luaLoadChunksFromZip should just remove .lua or .luac extension
cocos2d-x-3.6 Apr.30 2015
[NEW] 3rd: update chipmunk to v 6.2.2 on Windows 8.1 Universal App

View File

@ -58,8 +58,8 @@ endif()
set(BUILD_CPP_TESTS_DEFAULT ON)
set(BUILD_LUA_LIBS_DEFAULT ON)
set(BUILD_LUA_TESTS_DEFAULT ON)
set(BUILD_JS_LIBS_DEFAULT OFF)
set(BUILD_JS_TESTS_DEFAULT OFF)
set(BUILD_JS_LIBS_DEFAULT ON)
set(BUILD_JS_TESTS_DEFAULT ON)
# TODO: fix test samples for MSVC
if(MSVC)
set(BUILD_CPP_TESTS_DEFAULT OFF)

View File

@ -186,7 +186,7 @@ $ bin/lua-empty-test/lua-empty-test
* For Windows
Open the `cocos2d-x/build/cocos2d-win32.vc2013.sln`
Open the `cocos2d-x/build/cocos2d-win32.sln`
* For Windows 8.1 Universal Apps (Phone and Store)

View File

@ -4,12 +4,12 @@
import sys
import os, os.path
import shutil
from optparse import OptionParser
CPP_SAMPLES = ['cpp-empty-test', 'cpp-tests', 'game-controller-test']
LUA_SAMPLES = ['lua-empty-test', 'lua-tests', 'lua-game-controller-test']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
JS_SAMPLES = ['js-tests']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JS_SAMPLES
def caculate_built_samples(args):
''' Compute the sampels to be built
@ -27,6 +27,9 @@ def caculate_built_samples(args):
if 'lua' in args:
targets += LUA_SAMPLES
args.remove('lua')
if 'js' in args:
targets += JS_SAMPLES
args.remove('js')
targets += args
@ -36,8 +39,8 @@ def caculate_built_samples(args):
return list(targets)
def do_build(app_android_root, build_mode):
command = 'cocos compile -p android -s %s --ndk-mode %s' % (app_android_root, build_mode)
command = 'cocos compile -p android -s %s --ndk-mode %s' % (app_android_root, build_mode)
print command
if os.system(command) != 0:
@ -49,7 +52,7 @@ def build_samples(target, build_mode):
build_mode = 'debug'
elif build_mode != 'release':
build_mode = 'debug'
build_targets = caculate_built_samples(target)
app_android_root = ''
@ -60,7 +63,8 @@ def build_samples(target, build_mode):
"cpp-tests": "tests/cpp-tests",
"lua-empty-test": "tests/lua-empty-test",
"lua-tests": "tests/lua-tests",
"lua-game-controller-test": "tests/lua-game-controller-test"
"lua-game-controller-test": "tests/lua-game-controller-test",
"js-tests": "tests/js-tests"
}
cocos_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
@ -81,7 +85,7 @@ if __name__ == '__main__':
usage = """
This script is mainy used for building tests built-in with cocos2d-x.
Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests|cpp|lua|all]
Usage: %prog [options] [cpp-empty-test|cpp-tests|lua-empty-test|lua-tests|js-tests|cpp|lua|all]
If you are new to cocos2d-x, I recommend you start with cpp-empty-test, lua-empty-test.
@ -93,13 +97,15 @@ if __name__ == '__main__':
parser = OptionParser(usage=usage)
parser.add_option("-n", "--ndk", dest="ndk_build_param",
help='It is not used anymore, because cocos console does not support it.')
help='It is not used anymore, because cocos console does not support it.')
parser.add_option("-p", "--platform", dest="android_platform",
help='This parameter is not used any more, just keep compatible.')
help='This parameter is not used any more, just keep compatible.')
parser.add_option("-b", "--build", dest="build_mode",
help='The build mode for java project,debug[default] or release. Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
help='The build mode for java project,debug[default] or release. \
Get more information, \
please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args()
if len(args) == 0:
parser.print_help()
sys.exit(1)

View File

@ -45,6 +45,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.Windows", "..\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.WindowsPhone", "..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.WindowsPhone\libjscocos2d.WindowsPhone.vcxproj", "{CA082EC4-17CE-430B-8207-D1E947A5D1E9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libbullet", "libbullet", "{9A66AB4C-057B-4675-849D-5D69B98C728C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.Shared", "..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems", "{16AF311F-74CA-45A3-A82D-6334200FB124}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.Windows", "..\external\bullet\proj.win8.1-universal\libbullet.Windows\libbullet.Windows.vcxproj", "{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.WindowsPhone", "..\external\bullet\proj.win8.1-universal\libbullet.WindowsPhone\libbullet.WindowsPhone.vcxproj", "{E35634BD-B91B-4A6D-B957-96F56DD065F9}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{ae6763f6-1549-441e-afb5-377be1c776dc}*SharedItemsImports = 9
@ -53,7 +61,10 @@ Global
..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{70914fc8-7709-4cd6-b86b-c63fde5478db}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{cc1da216-a80d-4be4-b309-acb6af313aff}*SharedItemsImports = 4
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{4a3c6ba8-c227-498b-aa21-40bda27b461f}*SharedItemsImports = 9
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{e35634bd-b91b-4a6d-b957-96f56dd065f9}*SharedItemsImports = 4
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{ec2b1292-2d8c-4feb-a84b-2550b32c1ae7}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{adafd00d-a0d6-46ef-9f0b-ea2880bfe1de}*SharedItemsImports = 9
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{16af311f-74ca-45a3-a82d-6334200fb124}*SharedItemsImports = 9
..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems*{ca082ec4-17ce-430b-8207-d1e947a5d1e9}*SharedItemsImports = 4
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{5d6f020f-7e72-4494-90a0-2df11d235df9}*SharedItemsImports = 9
..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems*{bea66276-51dd-4c53-92a8-f3d1fea50892}*SharedItemsImports = 9
@ -192,6 +203,28 @@ Global
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.ActiveCfg = Release|Win32
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.Build.0 = Release|Win32
{CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|x64.ActiveCfg = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|ARM.ActiveCfg = Debug|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|ARM.Build.0 = Debug|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|Win32.ActiveCfg = Debug|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|Win32.Build.0 = Debug|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|x64.ActiveCfg = Debug|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|x64.Build.0 = Debug|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|ARM.ActiveCfg = Release|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|ARM.Build.0 = Release|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|Win32.ActiveCfg = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|Win32.Build.0 = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|x64.ActiveCfg = Release|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|x64.Build.0 = Release|x64
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|ARM.ActiveCfg = Debug|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|ARM.Build.0 = Debug|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|Win32.ActiveCfg = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|Win32.Build.0 = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|x64.ActiveCfg = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|ARM.ActiveCfg = Release|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|ARM.Build.0 = Release|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|Win32.ActiveCfg = Release|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|Win32.Build.0 = Release|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -214,5 +247,9 @@ Global
{BEA66276-51DD-4C53-92A8-F3D1FEA50892} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5}
{BCF5546D-66A0-4998-AFD6-C5514F618930} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5}
{CA082EC4-17CE-430B-8207-D1E947A5D1E9} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5}
{9A66AB4C-057B-4675-849D-5D69B98C728C} = {85630454-74EA-4B5B-9B62-0E459B4476CB}
{16AF311F-74CA-45A3-A82D-6334200FB124} = {9A66AB4C-057B-4675-849D-5D69B98C728C}
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7} = {9A66AB4C-057B-4675-849D-5D69B98C728C}
{E35634BD-B91B-4A6D-B957-96F56DD065F9} = {9A66AB4C-057B-4675-849D-5D69B98C728C}
EndGlobalSection
EndGlobal

123
build/cocos2d-win10.sln Normal file
View File

@ -0,0 +1,123 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{17093B03-00CA-402F-981A-D8C84B2922B5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win10\libSpine.vcxproj", "{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\external\Box2D\proj-win10\libbox2d.vcxproj", "{0C32D479-46D5-46C3-9AA9-0A8FF8320516}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\libcocos2d_win10\libcocos2d.vcxproj", "{07C2895D-720C-487D-B7B4-12C293EA533F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-empty-test", "..\tests\cpp-empty-test\proj.win10\cpp-empty-test.vcxproj", "{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests", "..\tests\cpp-tests\proj.win10\cpp-tests.vcxproj", "{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet", "..\external\bullet\proj.win10\libbullet.vcxproj", "{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|ARM.ActiveCfg = Debug|ARM
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|ARM.Build.0 = Debug|ARM
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|x64.ActiveCfg = Debug|x64
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|x64.Build.0 = Debug|x64
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|x86.ActiveCfg = Debug|Win32
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Debug|x86.Build.0 = Debug|Win32
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|ARM.ActiveCfg = Release|ARM
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|ARM.Build.0 = Release|ARM
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|x64.ActiveCfg = Release|x64
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|x64.Build.0 = Release|x64
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|x86.ActiveCfg = Release|Win32
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8}.Release|x86.Build.0 = Release|Win32
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|ARM.ActiveCfg = Debug|ARM
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|ARM.Build.0 = Debug|ARM
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|x64.ActiveCfg = Debug|x64
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|x64.Build.0 = Debug|x64
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|x86.ActiveCfg = Debug|Win32
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Debug|x86.Build.0 = Debug|Win32
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|ARM.ActiveCfg = Release|ARM
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|ARM.Build.0 = Release|ARM
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|x64.ActiveCfg = Release|x64
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|x64.Build.0 = Release|x64
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|x86.ActiveCfg = Release|Win32
{0C32D479-46D5-46C3-9AA9-0A8FF8320516}.Release|x86.Build.0 = Release|Win32
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|ARM.ActiveCfg = Debug|ARM
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|ARM.Build.0 = Debug|ARM
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|x64.ActiveCfg = Debug|x64
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|x64.Build.0 = Debug|x64
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|x86.ActiveCfg = Debug|Win32
{07C2895D-720C-487D-B7B4-12C293EA533F}.Debug|x86.Build.0 = Debug|Win32
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|ARM.ActiveCfg = Release|ARM
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|ARM.Build.0 = Release|ARM
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|x64.ActiveCfg = Release|x64
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|x64.Build.0 = Release|x64
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|x86.ActiveCfg = Release|Win32
{07C2895D-720C-487D-B7B4-12C293EA533F}.Release|x86.Build.0 = Release|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|ARM.ActiveCfg = Debug|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|ARM.Build.0 = Debug|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|ARM.Deploy.0 = Debug|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x64.ActiveCfg = Debug|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x64.Build.0 = Debug|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x64.Deploy.0 = Debug|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x86.ActiveCfg = Debug|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x86.Build.0 = Debug|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Debug|x86.Deploy.0 = Debug|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|ARM.ActiveCfg = Release|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|ARM.Build.0 = Release|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|ARM.Deploy.0 = Release|ARM
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x64.ActiveCfg = Release|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x64.Build.0 = Release|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x64.Deploy.0 = Release|x64
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x86.ActiveCfg = Release|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x86.Build.0 = Release|Win32
{87ED86E7-A850-433F-88D5-D5F65CFF7BF5}.Release|x86.Deploy.0 = Release|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|ARM.ActiveCfg = Debug|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|ARM.Build.0 = Debug|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|ARM.Deploy.0 = Debug|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x64.ActiveCfg = Debug|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x64.Build.0 = Debug|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x64.Deploy.0 = Debug|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x86.ActiveCfg = Debug|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x86.Build.0 = Debug|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Debug|x86.Deploy.0 = Debug|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|ARM.ActiveCfg = Release|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|ARM.Build.0 = Release|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|ARM.Deploy.0 = Release|ARM
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x64.ActiveCfg = Release|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x64.Build.0 = Release|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x64.Deploy.0 = Release|x64
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x86.ActiveCfg = Release|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x86.Build.0 = Release|Win32
{C1307B42-D00A-4B88-BCDD-0A16A81FF4C1}.Release|x86.Deploy.0 = Release|Win32
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|ARM.ActiveCfg = Debug|ARM
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|ARM.Build.0 = Debug|ARM
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|x64.ActiveCfg = Debug|x64
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|x64.Build.0 = Debug|x64
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|x86.ActiveCfg = Debug|Win32
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Debug|x86.Build.0 = Debug|Win32
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|ARM.ActiveCfg = Release|ARM
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|ARM.Build.0 = Release|ARM
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|x64.ActiveCfg = Release|x64
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|x64.Build.0 = Release|x64
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|x86.ActiveCfg = Release|Win32
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4B3BA10A-941F-4E08-8A50-8A7FCB822BB8} = {17093B03-00CA-402F-981A-D8C84B2922B5}
{0C32D479-46D5-46C3-9AA9-0A8FF8320516} = {17093B03-00CA-402F-981A-D8C84B2922B5}
{ECEE1119-CE2E-4F7E-83A8-1932EA48E893} = {17093B03-00CA-402F-981A-D8C84B2922B5}
EndGlobalSection
EndGlobal

View File

@ -45,6 +45,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp.Windows", "..\test
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp.WindowsPhone", "..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.WindowsPhone\HelloCpp.WindowsPhone.vcxproj", "{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libbullet", "libbullet", "{0500043C-7E95-4351-97D6-0382A8C92DD3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.Shared", "..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems", "{16AF311F-74CA-45A3-A82D-6334200FB124}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.Windows", "..\external\bullet\proj.win8.1-universal\libbullet.Windows\libbullet.Windows.vcxproj", "{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet.WindowsPhone", "..\external\bullet\proj.win8.1-universal\libbullet.WindowsPhone\libbullet.WindowsPhone.vcxproj", "{E35634BD-B91B-4A6D-B957-96F56DD065F9}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{9335005f-678e-4e8e-9b84-50037216aec8}*SharedItemsImports = 4
@ -52,9 +60,12 @@ Global
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{a3ad93e4-0b2f-4c58-9181-69bed2e42e3e}*SharedItemsImports = 9
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{cc1da216-a80d-4be4-b309-acb6af313aff}*SharedItemsImports = 4
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{4a3c6ba8-c227-498b-aa21-40bda27b461f}*SharedItemsImports = 9
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{e35634bd-b91b-4a6d-b957-96f56dd065f9}*SharedItemsImports = 4
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{79a8fcda-4b12-4dd1-b676-ff148d651638}*SharedItemsImports = 4
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{ec2b1292-2d8c-4feb-a84b-2550b32c1ae7}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{adafd00d-a0d6-46ef-9f0b-ea2880bfe1de}*SharedItemsImports = 9
..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems*{be3a1791-5bce-4cea-92cd-0e2d86dde27a}*SharedItemsImports = 9
..\external\bullet\proj.win8.1-universal\libbullet.Shared\libbullet.Shared.vcxitems*{16af311f-74ca-45a3-a82d-6334200fb124}*SharedItemsImports = 9
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{5d6f020f-7e72-4494-90a0-2df11d235df9}*SharedItemsImports = 9
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{3b26a12d-3a44-47ea-82d2-282660fc844d}*SharedItemsImports = 4
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{22f3b9df-1209-4574-8331-003966f562bf}*SharedItemsImports = 4
@ -202,6 +213,28 @@ Global
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|Win32.Build.0 = Release|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|Win32.Deploy.0 = Release|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|x64.ActiveCfg = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|ARM.ActiveCfg = Debug|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|ARM.Build.0 = Debug|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|Win32.ActiveCfg = Debug|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|Win32.Build.0 = Debug|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|x64.ActiveCfg = Debug|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Debug|x64.Build.0 = Debug|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|ARM.ActiveCfg = Release|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|ARM.Build.0 = Release|ARM
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|Win32.ActiveCfg = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|Win32.Build.0 = Release|Win32
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|x64.ActiveCfg = Release|x64
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7}.Release|x64.Build.0 = Release|x64
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|ARM.ActiveCfg = Debug|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|ARM.Build.0 = Debug|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|Win32.ActiveCfg = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|Win32.Build.0 = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Debug|x64.ActiveCfg = Debug|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|ARM.ActiveCfg = Release|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|ARM.Build.0 = Release|ARM
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|Win32.ActiveCfg = Release|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|Win32.Build.0 = Release|Win32
{E35634BD-B91B-4A6D-B957-96F56DD065F9}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -224,5 +257,9 @@ Global
{A3AD93E4-0B2F-4C58-9181-69BED2E42E3E} = {B70EF25E-E352-4020-BCDF-388973E44637}
{79A8FCDA-4B12-4DD1-B676-FF148D651638} = {B70EF25E-E352-4020-BCDF-388973E44637}
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A} = {B70EF25E-E352-4020-BCDF-388973E44637}
{0500043C-7E95-4351-97D6-0382A8C92DD3} = {85630454-74EA-4B5B-9B62-0E459B4476CB}
{16AF311F-74CA-45A3-A82D-6334200FB124} = {0500043C-7E95-4351-97D6-0382A8C92DD3}
{EC2B1292-2D8C-4FEB-A84B-2550B32C1AE7} = {0500043C-7E95-4351-97D6-0382A8C92DD3}
{E35634BD-B91B-4A6D-B957-96F56DD065F9} = {0500043C-7E95-4351-97D6-0382A8C92DD3}
EndGlobalSection
EndGlobal

View File

@ -596,7 +596,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"";
shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"\ncp -r \"${SRCROOT}/../tests/js-tests/resjs/\" \"${cocos_dir}\"";
};
EDCA13EE1AEA4E7B00F445CA /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@ -609,7 +609,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"";
shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\"\ncp -r \"${SRCROOT}/../tests/js-tests/resjs/\" \"${cocos_dir}\"";
};
/* End PBXShellScriptBuildPhase section */
@ -821,7 +821,7 @@
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual";
};
name = Debug;
};
@ -845,7 +845,7 @@
HEADER_SEARCH_PATHS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual";
};
name = Release;
};

View File

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

View File

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

View File

@ -1190,6 +1190,10 @@
1AC0269D1914068200FA920D /* ConvertUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC026991914068200FA920D /* ConvertUTF.h */; };
29031E0719BFE8D400EFA1DF /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29031E0619BFE8D400EFA1DF /* libchipmunk.a */; };
29031E0919BFE8DE00EFA1DF /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 29031E0819BFE8DE00EFA1DF /* libchipmunk.a */; };
291901431B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 291901411B05895600F8B4BA /* CCNinePatchImageParser.h */; };
291901441B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 291901411B05895600F8B4BA /* CCNinePatchImageParser.h */; };
291901451B05895600F8B4BA /* CCNinePatchImageParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 291901421B05895600F8B4BA /* CCNinePatchImageParser.cpp */; };
291901461B05895600F8B4BA /* CCNinePatchImageParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 291901421B05895600F8B4BA /* CCNinePatchImageParser.cpp */; };
292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; };
292DB13E19B4574100A80320 /* UIEditBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 292DB12F19B4574100A80320 /* UIEditBox.cpp */; };
292DB13F19B4574100A80320 /* UIEditBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 292DB13019B4574100A80320 /* UIEditBox.h */; };
@ -3921,6 +3925,8 @@
2905FA1318CF08D100240AA3 /* UIWidget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidget.cpp; sourceTree = "<group>"; };
2905FA1418CF08D100240AA3 /* UIWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidget.h; sourceTree = "<group>"; };
29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = "<group>"; };
291901411B05895600F8B4BA /* CCNinePatchImageParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCNinePatchImageParser.h; path = ../base/CCNinePatchImageParser.h; sourceTree = "<group>"; };
291901421B05895600F8B4BA /* CCNinePatchImageParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCNinePatchImageParser.cpp; path = ../base/CCNinePatchImageParser.cpp; sourceTree = "<group>"; };
292DB12F19B4574100A80320 /* UIEditBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIEditBox.cpp; sourceTree = "<group>"; };
292DB13019B4574100A80320 /* UIEditBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBox.h; sourceTree = "<group>"; };
292DB13119B4574100A80320 /* UIEditBoxImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIEditBoxImpl.h; sourceTree = "<group>"; };
@ -5620,6 +5626,8 @@
1A5700A2180BC5E60088DEC7 /* base */ = {
isa = PBXGroup;
children = (
291901411B05895600F8B4BA /* CCNinePatchImageParser.h */,
291901421B05895600F8B4BA /* CCNinePatchImageParser.cpp */,
505385001B01887A00793096 /* CCProperties.h */,
505385011B01887A00793096 /* CCProperties.cpp */,
B63990CA1A490AFE00B07923 /* CCAsyncTaskPool.cpp */,
@ -9408,6 +9416,7 @@
50ABBE211925AB6F00A911A9 /* atitc.h in Headers */,
15AE19A519AAD39600C27E9E /* TextFieldReader.h in Headers */,
B665E3401AA80A6500DDB1C5 /* CCPUOnEventFlagObserverTranslator.h in Headers */,
291901431B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */,
B24AA98B195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */,
B665E3A01AA80A6500DDB1C5 /* CCPUPositionEmitter.h in Headers */,
B29594B61926D5EC003EEF37 /* CCMeshCommand.h in Headers */,
@ -10210,6 +10219,7 @@
50ABBE481925AB6F00A911A9 /* CCEvent.h in Headers */,
5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */,
15AE1A9719AAD40300C27E9E /* b2Draw.h in Headers */,
291901441B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */,
3E6176691960F89B00DE83F5 /* CCController.h in Headers */,
B6CAB43E1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */,
3823841D1A2590D2002C4610 /* ComAudioReader.h in Headers */,
@ -10682,6 +10692,7 @@
50ED2BD919BE5D5D00A0AB90 /* CCEventListenerController.cpp in Sources */,
B665E2321AA80A6500DDB1C5 /* CCPUBoxEmitter.cpp in Sources */,
B257B460198A353E00D9A687 /* CCPrimitiveCommand.cpp in Sources */,
291901451B05895600F8B4BA /* CCNinePatchImageParser.cpp in Sources */,
15AE19A419AAD39600C27E9E /* TextFieldReader.cpp in Sources */,
50ED2BDB19BE76D500A0AB90 /* UIVideoPlayer-ios.mm in Sources */,
B665E32A1AA80A6500DDB1C5 /* CCPUOnCountObserver.cpp in Sources */,
@ -11642,6 +11653,7 @@
15AE19AA19AAD39700C27E9E /* ListViewReader.cpp in Sources */,
1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */,
1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */,
291901461B05895600F8B4BA /* CCNinePatchImageParser.cpp in Sources */,
B665E39B1AA80A6500DDB1C5 /* CCPUPointEmitterTranslator.cpp in Sources */,
382384291A2590F9002C4610 /* NodeReader.cpp in Sources */,
15AE193419AAD35100C27E9E /* CCActionObject.cpp in Sources */,

View File

@ -60,6 +60,10 @@
15B3709819EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */; };
15B3709919EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */; };
15B3709A19EE5EED00ABE682 /* Manifests in Resources */ = {isa = PBXBuildFile; fileRef = 15B3709219EE5D1000ABE682 /* Manifests */; };
15B914481B156A3700C6B95B /* Materials in Resources */ = {isa = PBXBuildFile; fileRef = 5046AB5A1AF2C4180060550B /* Materials */; };
15B914491B15721400C6B95B /* Shaders3D in Resources */ = {isa = PBXBuildFile; fileRef = B2507B6A192589AF00FA4972 /* Shaders3D */; };
15B9144A1B15A18C00C6B95B /* Materials in Resources */ = {isa = PBXBuildFile; fileRef = 5046AB5A1AF2C4180060550B /* Materials */; };
15B9144B1B15A18C00C6B95B /* Shaders3D in Resources */ = {isa = PBXBuildFile; fileRef = B2507B6A192589AF00FA4972 /* Shaders3D */; };
15C64825165F3934007D4F18 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; };
15C64827165F394E007D4F18 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; };
15C64829165F396B007D4F18 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; };
@ -4438,6 +4442,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
15B914491B15721400C6B95B /* Shaders3D in Resources */,
15B914481B156A3700C6B95B /* Materials in Resources */,
1531B2501AE013DE0075DB94 /* Test.html in Resources */,
1502702E1AD3BDC90089CD03 /* TerrainTest in Resources */,
157B08EC1A90864100B7BEA4 /* Particle3D in Resources */,
@ -4485,6 +4491,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
15B9144A1B15A18C00C6B95B /* Materials in Resources */,
15B9144B1B15A18C00C6B95B /* Shaders3D in Resources */,
1531B2511AE013F00075DB94 /* Test.html in Resources */,
1502702D1AD3BDBC0089CD03 /* TerrainTest in Resources */,
157B08ED1A90865600B7BEA4 /* Particle3D in Resources */,
@ -5787,6 +5795,7 @@
"$(inherited)",
CC_TARGET_OS_MAC,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.mac/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
@ -5802,6 +5811,7 @@
"$(inherited)",
CC_TARGET_OS_MAC,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.mac/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac";
@ -5890,6 +5900,7 @@
"$(inherited)",
CC_TARGET_OS_IPHONE,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.ios/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
LIBRARY_SEARCH_PATHS = (
@ -5913,6 +5924,7 @@
"$(inherited)",
CC_TARGET_OS_IPHONE,
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INFOPLIST_FILE = "$(SRCROOT)/../tests/cpp-tests/proj.ios/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
LIBRARY_SEARCH_PATHS = (

View File

@ -125,9 +125,9 @@ public:
* @param t Duration in seconds.
* @param radius The start radius.
* @param deltaRadius The delta radius.
* @param angleZ The start Angel in Z.
* @param angleZ The start angle in Z.
* @param deltaAngleZ The delta angle in Z.
* @param angleX The start Angel in X.
* @param angleX The start angle in X.
* @param deltaAngleX The delta angle in X.
* @return An OrbitCamera.
*/

View File

@ -245,11 +245,42 @@ Vec2 Camera::project(const Vec3& src) const
return screenPos;
}
Vec2 Camera::projectGL(const Vec3& src) const
{
Vec2 screenPos;
auto viewport = Director::getInstance()->getWinSize();
Vec4 clipPos;
getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos);
CCASSERT(clipPos.w != 0.0f, "");
float ndcX = clipPos.x / clipPos.w;
float ndcY = clipPos.y / clipPos.w;
screenPos.x = (ndcX + 1.0f) * 0.5f * viewport.width;
screenPos.y = (ndcY + 1.0f) * 0.5f * viewport.height;
return screenPos;
}
Vec3 Camera::unproject(const Vec3& src) const
{
auto viewport = Director::getInstance()->getWinSize();
Vec3 dst;
unproject(Director::getInstance()->getWinSize(), &src, &dst);
return dst;
}
Vec4 screen(src.x / viewport.width, ((viewport.height - src.y)) / viewport.height, src.z, 1.0f);
Vec3 Camera::unprojectGL(const Vec3& src) const
{
Vec3 dst;
unprojectGL(Director::getInstance()->getWinSize(), &src, &dst);
return dst;
}
void Camera::unproject(const Size& viewport, const Vec3* src, Vec3* dst) const
{
CCASSERT(src && dst, "vec3 can not be null");
Vec4 screen(src->x / viewport.width, ((viewport.height - src->y)) / viewport.height, src->z, 1.0f);
screen.x = screen.x * 2.0f - 1.0f;
screen.y = screen.y * 2.0f - 1.0f;
screen.z = screen.z * 2.0f - 1.0f;
@ -262,14 +293,14 @@ Vec3 Camera::unproject(const Vec3& src) const
screen.z /= screen.w;
}
return Vec3(screen.x, screen.y, screen.z);
dst->set(screen.x, screen.y, screen.z);
}
void Camera::unproject(const Size& viewport, const Vec3* src, Vec3* dst) const
void Camera::unprojectGL(const Size& viewport, const Vec3* src, Vec3* dst) const
{
CCASSERT(src && dst, "vec3 can not be null");
Vec4 screen(src->x / viewport.width, ((viewport.height - src->y)) / viewport.height, src->z, 1.0f);
Vec4 screen(src->x / viewport.width, src->y / viewport.height, src->z, 1.0f);
screen.x = screen.x * 2.0f - 1.0f;
screen.y = screen.y * 2.0f - 1.0f;
screen.z = screen.z * 2.0f - 1.0f;

View File

@ -61,6 +61,7 @@ enum class CameraFlag
class CC_DLL Camera :public Node
{
friend class Scene;
friend class EventDispatcher;
public:
/**
* The type of camera.
@ -128,30 +129,60 @@ public:
/**get view projection matrix*/
const Mat4& getViewProjectionMatrix() const;
/* convert the specified point of viewport from world-space coordinates into the screen-space coordinates.
/* convert the specified point in 3D world-space coordinates into the screen-space coordinates.
*
* Origin point at left top corner in screen-space.
* @param src The world-space position.
* @return The screen-space position.
*/
Vec2 project(const Vec3& src) const;
/**
* Convert the specified point of viewport from screen-space coordinate into the world-space coordinate.
/* convert the specified point in 3D world-space coordinates into the GL-screen-space coordinates.
*
* Origin point at left bottom corner in GL-screen-space.
* @param src The 3D world-space position.
* @return The GL-screen-space position.
*/
Vec2 projectGL(const Vec3& src) const;
/**
* Convert the specified point of screen-space coordinate into the 3D world-space coordinate.
*
* Origin point at left top corner in screen-space.
* @param src The screen-space position.
* @return The world-space position.
* @return The 3D world-space position.
*/
Vec3 unproject(const Vec3& src) const;
/**
* Convert the specified point of viewport from screen-space coordinate into the world-space coordinate.
*
* @param viewport The viewport size to use.
* @param src The screen-space position.
* @param dst The world-space position.
*/
void unproject(const Size& viewport, const Vec3* src, Vec3* dst) const;
/**
* Convert the specified point of GL-screen-space coordinate into the 3D world-space coordinate.
*
* Origin point at left bottom corner in GL-screen-space.
* @param src The GL-screen-space position.
* @return The 3D world-space position.
*/
Vec3 unprojectGL(const Vec3& src) const;
/**
* Convert the specified point of screen-space coordinate into the 3D world-space coordinate.
*
* Origin point at left top corner in screen-space.
* @param size The window size to use.
* @param src The screen-space position.
* @param dst The 3D world-space position.
*/
void unproject(const Size& size, const Vec3* src, Vec3* dst) const;
/**
* Convert the specified point of GL-screen-space coordinate into the 3D world-space coordinate.
*
* Origin point at left bottom corner in GL-screen-space.
* @param size The window size to use.
* @param src The GL-screen-space position.
* @param dst The 3D world-space position.
*/
void unprojectGL(const Size& size, const Vec3* src, Vec3* dst) const;
/**
* Is this aabb visible in frustum
*/
@ -172,6 +203,16 @@ public:
*/
int getDepth() const { return _depth; }
/**
* Get the frustum's far plane.
*/
float getFarPlane() const { return _farPlane; }
/**
* Get the frustum's near plane.
*/
float getNearPlane() const { return _nearPlane; }
//override
virtual void onEnter() override;
virtual void onExit() override;

View File

@ -118,7 +118,7 @@ public:
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @param scaleX The scale value in x.
@ -131,7 +131,7 @@ public:
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @param color Set the circle color.
@ -216,7 +216,7 @@ public:
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param scaleX The scale value in x.
* @param scaleY The scale value in y.
@ -228,7 +228,7 @@ public:
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param color The solid circle color.
* @js NA

View File

@ -153,7 +153,7 @@ namespace DrawPrimitives
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @param scaleX The scale value in x.
@ -165,7 +165,7 @@ namespace DrawPrimitives
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
*/
@ -174,7 +174,7 @@ namespace DrawPrimitives
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @param scaleX The scale value in x.
* @param scaleY The scale value in y.
@ -185,7 +185,7 @@ namespace DrawPrimitives
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
* @param angle The circle angel.
* @param angle The circle angle.
* @param segments The number of segments.
* @js NA
*/

View File

@ -101,6 +101,9 @@ TMXTiledMap::~TMXTiledMap()
TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo);
if (tileset == nullptr)
return nullptr;
TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo);
// tell the layerinfo to release the ownership of the tiles map.
@ -170,6 +173,10 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
if (layerInfo->_visible)
{
TMXLayer *child = parseLayer(layerInfo, mapInfo);
if (child == nullptr) {
idx++;
continue;
}
addChild(child, idx, idx);
// update content size with the max size

View File

@ -40,23 +40,21 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
std::vector<char16_t> multiline_string;
multiline_string.reserve( limit );
std::vector<char16_t> last_word;
last_word.reserve( 25 );
bool isStartOfLine = false, isStartOfWord = false;
float startOfLine = -1, startOfWord = -1;
bool lineIsEmpty = true;
bool calculateLineStart = false;
float startOfLine = 0.f;
int skip = 0;
int skip = 0;
int tIndex = 0;
float scalsX = theLabel->getScaleX();
float lineWidth = theLabel->_maxLineWidth;
bool breakLineWithoutSpace = theLabel->_lineBreakWithoutSpaces;
Label::LetterInfo* info = nullptr;
for (int j = 0; j+skip < limit; j++)
{
{
info = & theLabel->_lettersInfo.at(j+skip);
unsigned int justSkipped = 0;
@ -72,10 +70,10 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
isStartOfWord = false;
isStartOfLine = false;
startOfWord = -1;
startOfLine = -1;
calculateLineStart = false;
startOfLine = 0.f;
lineIsEmpty = true;
}
if(tIndex < limit)
{
@ -90,69 +88,21 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
if (tIndex >= limit)
break;
char16_t character = strWhole[tIndex];
if (!isStartOfWord)
if (calculateLineStart)
{
startOfWord = info->position.x * scalsX;
isStartOfWord = true;
startOfLine = info->position.x - info->def.offsetX - theLabel->_horizontalKernings[tIndex];
calculateLineStart = false;
lineIsEmpty = true;
}
if (!isStartOfLine)
auto character = strWhole[tIndex];
if (breakLineWithoutSpace)
{
startOfLine = startOfWord;
isStartOfLine = true;
}
// 1) Whitespace.
// 2) This character is non-CJK, but the last character is CJK
bool isspace = StringUtils::isUnicodeSpace(character);
bool isCJK = false;
if(!isspace)
{
isCJK = StringUtils::isCJKUnicode(character);
}
if (isspace ||
(!last_word.empty() && StringUtils::isCJKUnicode(last_word.back()) && !isCJK))
{
// if current character is white space, put it into the current word
if (isspace) last_word.push_back(character);
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
isStartOfWord = false;
startOfWord = -1;
// put the CJK character in the last word
// and put the non-CJK(ASCII) character in the current word
if (!isspace) last_word.push_back(character);
continue;
}
float posRight = (info->position.x + info->contentSize.width) * scalsX;
// Out of bounds.
if (posRight - startOfLine > lineWidth)
{
if (!breakLineWithoutSpace && !isCJK)
float posRight = info->position.x + info->contentSize.width;
if (posRight - startOfLine > lineWidth)
{
last_word.push_back(character);
int found = StringUtils::getIndexOfLastNotChar16(multiline_string, ' ');
if (found != -1)
StringUtils::trimUTF16Vector(multiline_string);
else
multiline_string.clear();
if (multiline_string.size() > 0)
multiline_string.push_back('\n');
isStartOfLine = false;
startOfLine = -1;
}
else
{
StringUtils::trimUTF16Vector(last_word);
//issue #8492:endless loop if not using system font, and constrained length is less than one character width
if (isStartOfLine && last_word.size() == 0)
if (last_word.empty())
last_word.push_back(character);
else
--j;
@ -160,22 +110,102 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
isStartOfWord = false;
isStartOfLine = false;
startOfWord = -1;
startOfLine = -1;
startOfLine = 0.f;
}
else
{
last_word.push_back(character);
}
}
//Break line with space.
else
{
// Character is normal.
last_word.push_back(character);
std::vector<char16_t> nonCJKword;
int wordIndex = tIndex;
for (; wordIndex < limit; ++wordIndex)
{
auto ch = strWhole[wordIndex];
if (ch == '\n' || StringUtils::isUnicodeSpace(ch) || StringUtils::isCJKUnicode(ch))
{
break;
}
nonCJKword.push_back(ch);
}
if (!nonCJKword.empty())
{
auto wordLenth = nonCJKword.size();
auto lastCharacterInfo = &theLabel->_lettersInfo.at(tIndex + wordLenth - 1);
float posRight = lastCharacterInfo->position.x + lastCharacterInfo->contentSize.width;
if (posRight - startOfLine > lineWidth)
{
if (last_word.empty())
{
nonCJKword.push_back('\n');
multiline_string.insert(multiline_string.end(), nonCJKword.begin(), nonCJKword.end());
calculateLineStart = true;
}
else
{
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
startOfLine = info->position.x - info->def.offsetX - theLabel->_horizontalKernings[tIndex];
if (posRight - startOfLine > lineWidth)
{
nonCJKword.push_back('\n');
multiline_string.insert(multiline_string.end(), nonCJKword.begin(), nonCJKword.end());
calculateLineStart = true;
}
else
{
multiline_string.insert(multiline_string.end(), nonCJKword.begin(), nonCJKword.end());
lineIsEmpty = false;
calculateLineStart = false;
}
}
}
else
{
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
multiline_string.insert(multiline_string.end(), nonCJKword.begin(), nonCJKword.end());
lineIsEmpty = false;
}
j += wordLenth - 1;
continue;
}
float posRight = info->position.x + info->contentSize.width;
if (posRight - startOfLine > lineWidth)
{
//issue #8492:endless loop if not using system font, and constrained length is less than one character width
if (lineIsEmpty && last_word.empty())
last_word.push_back(character);
else
--j;
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
calculateLineStart = true;
}
else
{
last_word.push_back(character);
}
}
}
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
std::u16string strNew(multiline_string.begin(), multiline_string.end());
theLabel->_currentUTF16String = strNew;
@ -386,33 +416,16 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
continue;
}
nextFontPositionX += charAdvance + kernings[i];
nextFontPositionX += charAdvance + theLabel->_additionalKerning;
if (longestLine < nextFontPositionX)
auto letterRight = letterPosition.x + tempDefinition.width;
if (longestLine < letterRight)
{
longestLine = nextFontPositionX;
longestLine = letterRight;
}
// check longest line before adding additional kerning
nextFontPositionX += theLabel->_additionalKerning;
}
float lastCharWidth = tempDefinition.width * contentScaleFactor;
Size tmpSize;
// If the last character processed has an xAdvance which is less that the width of the characters image, then we need
// to adjust the width of the string to take this into account, or the character will overlap the end of the bounding
// box
if(charAdvance < lastCharWidth)
{
tmpSize.width = longestLine - charAdvance + lastCharWidth;
}
else
{
tmpSize.width = longestLine;
}
tmpSize.height = totalHeight;
Size tmpSize(longestLine * contentScaleFactor, totalHeight);
if (theLabel->_labelHeight > 0)
{
tmpSize.height = theLabel->_labelHeight * contentScaleFactor;

View File

@ -1314,9 +1314,12 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl
_normalizedPositionDirty = false;
}
}
//remove this two line given that isVisitableByVisitingCamera should not affect the calculation of transform given that we are visiting scene
//without involving view and projection matrix.
if (!isVisitableByVisitingCamera())
return parentFlags;
// if (!isVisitableByVisitingCamera())
// return parentFlags;
uint32_t flags = parentFlags;
flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0);

View File

@ -598,8 +598,8 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
if(_insideBounds)
#endif
{
_quadCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, transform, flags);
renderer->addCommand(&_quadCommand);
_trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), transform, flags);
renderer->addCommand(&_trianglesCommand);
#if CC_SPRITE_DEBUG_DRAW
_debugDrawNode->clear();
@ -614,6 +614,17 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
}
}
TrianglesCommand::Triangles Sprite::getRenderedTriangles() const
{
static unsigned short indices[6] = {0, 1, 2, 3, 2, 1};
TrianglesCommand::Triangles result;
result.indices = indices;
result.verts = (V3F_C4B_T2F*)&_quad;
result.vertCount = 4;
result.indexCount = 6;
return result;
}
// MARK: visit, draw, transform
void Sprite::addChild(Node *child, int zOrder, int tag)
@ -993,6 +1004,10 @@ bool Sprite::isFrameDisplayed(SpriteFrame *frame) const
SpriteFrame* Sprite::getSpriteFrame() const
{
if(nullptr != this->_spriteFrame)
{
return this->_spriteFrame;
}
return SpriteFrame::createWithTexture(_texture,
CC_RECT_POINTS_TO_PIXELS(_rect),
_rectRotated,

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
#include "2d/CCDrawNode.h"
#include "base/CCProtocols.h"
#include "renderer/CCTextureAtlas.h"
#include "renderer/CCQuadCommand.h"
#include "renderer/CCTrianglesCommand.h"
#include "renderer/CCCustomCommand.h"
NS_CC_BEGIN
@ -538,7 +538,8 @@ protected:
virtual void updateBlendFunc();
virtual void setReorderChildDirtyRecursively();
virtual void setDirtyRecursively(bool value);
TrianglesCommand::Triangles getRenderedTriangles() const;
//
// Data used when the sprite is rendered using a SpriteSheet
//
@ -557,7 +558,7 @@ protected:
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
Texture2D* _texture; /// Texture2D object that is used to render the sprite
SpriteFrame* _spriteFrame;
QuadCommand _quadCommand; /// quad command
TrianglesCommand _trianglesCommand; ///
#if CC_SPRITE_DEBUG_DRAW
DrawNode *_debugDrawNode;
#endif //CC_SPRITE_DEBUG_DRAW

View File

@ -39,7 +39,7 @@ THE SOFTWARE.
#include "base/CCDirector.h"
#include "renderer/CCTexture2D.h"
#include "renderer/CCTextureCache.h"
#include "base/CCNinePatchImageParser.h"
#include "deprecated/CCString.h"
@ -104,6 +104,10 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
// check the format
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
auto textureFileName = Director::getInstance()->getTextureCache()->getTextureFilePath(texture);
auto image = new Image();
image->initWithImageFile(textureFileName);
NinePatchImageParser parser;
for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter)
{
ValueMap& frameDict = iter->second.asValueMap();
@ -183,7 +187,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
_spriteFramesAliases[oneAlias] = Value(spriteFrameName);
}
// create frame
spriteFrame = SpriteFrame::createWithTexture(texture,
Rect(textureRect.origin.x, textureRect.origin.y, spriteSize.width, spriteSize.height),
@ -192,9 +196,16 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
spriteSourceSize);
}
bool flag = NinePatchImageParser::isNinePatchImage(spriteFrameName);
if(flag)
{
parser.setSpriteFrameInfo(image, spriteFrame->getRectInPixels(), spriteFrame->isRotated());
texture->addSpriteFrameCapInset(spriteFrame, parser.parseCapInset());
}
// add sprite frame
_spriteFrames.insert(spriteFrameName, spriteFrame);
}
CC_SAFE_DELETE(image);
}
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, Texture2D *texture)
@ -327,13 +338,14 @@ void SpriteFrameCache::removeUnusedSpriteFrames()
if( spriteFrame->getReferenceCount() == 1 )
{
toRemoveFrames.push_back(iter->first);
spriteFrame->getTexture()->removeSpriteFrameCapInset(spriteFrame);
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", iter->first.c_str());
removed = true;
}
}
_spriteFrames.erase(toRemoveFrames);
// FIXME:. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache
if( removed )
{

View File

@ -102,6 +102,9 @@ TMXTiledMap::~TMXTiledMap()
TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo);
if (tileset == nullptr)
return nullptr;
TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo);
// tell the layerinfo to release the ownership of the tiles map.
@ -171,9 +174,12 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
auto& layers = mapInfo->getLayers();
for(const auto &layerInfo : layers) {
if (layerInfo->_visible)
{
if (layerInfo->_visible) {
TMXLayer *child = parseLayer(layerInfo, mapInfo);
if (child == nullptr) {
idx++;
continue;
}
addChild(child, idx, idx);
// update content size with the max size

View File

@ -257,8 +257,8 @@ void MarchingSquare::marchSquare(int startx, int starty)
{
//TODO: we triangulation cannot work collineer points, so we need to modify same point a little
//TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them
points.back().x -= 0.00001;
points.back().y -= 0.00001;
points.back().x -= 0.00001f;
points.back().y -= 0.00001f;
points.push_back(Vec2((float)curx, (float)height-cury)/ scaleFactor);
}
else{

View File

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>opengl32.lib;glew32.lib;libzlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;libwebp.lib;libiconv.lib;glfw3.lib;freetype250.lib;winmm.lib;ws2_32.lib;libchipmunk.lib;libbox2d.lib;libSpine.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opengl32.lib;glew32.lib;libzlib.lib;libwebp.lib;libiconv.lib;freetype250.lib;winmm.lib;ws2_32.lib;libbox2d.lib;libSpine.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
</Link>

View File

@ -432,6 +432,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\base\CCEventTouch.cpp" />
<ClCompile Include="..\base\ccFPSImages.c" />
<ClCompile Include="..\base\CCIMEDispatcher.cpp" />
<ClCompile Include="..\base\CCNinePatchImageParser.cpp" />
<ClCompile Include="..\base\CCNS.cpp" />
<ClCompile Include="..\base\CCProfiling.cpp" />
<ClCompile Include="..\base\CCProperties.cpp" />
@ -995,6 +996,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\base\CCIMEDispatcher.h" />
<ClInclude Include="..\base\ccMacros.h" />
<ClInclude Include="..\base\CCMap.h" />
<ClInclude Include="..\base\CCNinePatchImageParser.h" />
<ClInclude Include="..\base\CCNS.h" />
<ClInclude Include="..\base\CCProfiling.h" />
<ClInclude Include="..\base\CCProperties.h" />

View File

@ -1872,6 +1872,9 @@
<ClCompile Include="..\renderer\CCVertexAttribBinding.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="..\base\CCNinePatchImageParser.cpp">
<Filter>base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h">
@ -3662,6 +3665,9 @@
<ClInclude Include="..\renderer\CCVertexAttribBinding.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="..\base\CCNinePatchImageParser.h">
<Filter>base</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\math\Mat4.inl">

View File

@ -236,6 +236,9 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\include\Export.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\include\SimpleAudioEngine.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\Audio.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioCachePlayer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioEngine-winrt.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioSourceReader.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\MediaStreamer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\allocator\CCAllocatorBase.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\allocator\CCAllocatorDiagnostics.h" />
@ -282,6 +285,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccMacros.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCMap.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.h" />
@ -442,6 +446,14 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\network\HttpResponse.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\network\SocketIO.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\network\WebSocket.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3D.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DComponent.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DObject.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DShape.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DWorld.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsBody.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsContact.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsHelper.h" />
@ -830,11 +842,15 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\3d\CCSprite3DMaterial.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\3d\CCTerrain.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\3d\CCTextureCube.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\AudioEngine.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\Audio.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioCachePlayer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioEngine-winrt.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioSourceReader.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\MediaStreamer.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<ForcedIncludeFiles>
@ -883,6 +899,7 @@
</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProperties.cpp" />
@ -892,7 +909,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCScriptSupport.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCTouch.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccTypes.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault-winrt.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccUTF8.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccUtils.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCValue.cpp" />
@ -1019,6 +1036,14 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\network\HttpClient.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\network\SocketIO.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\network\WebSocket.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3D.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DComponent.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DObject.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DShape.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DWorld.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsBody.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsContact.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsJoint.cpp" />
@ -1222,4 +1247,7 @@
<None Include="$(MSBuildThisFileDirectory)..\..\..\libcocos2d.vcxproj.filters" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\libcocos2d_wp8.vcxproj.filters" />
</ItemGroup>
<ItemGroup>
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -1791,6 +1791,43 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCVertexAttribBinding.h">
<Filter>renderer</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3D.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DComponent.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DObject.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DShape.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DWorld.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.h">
<Filter>physics3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\include\AudioEngine.h">
<Filter>audioengine</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioCachePlayer.h">
<Filter>audioengine</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioEngine-winrt.h">
<Filter>audioengine</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioSourceReader.h">
<Filter>audioengine</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp" />
@ -2776,9 +2813,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccTypes.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccUTF8.cpp">
<Filter>base</Filter>
</ClCompile>
@ -3405,6 +3439,46 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCVertexAttribBinding.cpp">
<Filter>renderer</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\AudioEngine.cpp">
<Filter>audioengine</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioCachePlayer.cpp">
<Filter>audioengine</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioEngine-winrt.cpp">
<Filter>audioengine</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\audio\winrt\AudioSourceReader.cpp">
<Filter>audioengine</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3D.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DComponent.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DConstraint.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DDebugDrawer.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DObject.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DShape.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysics3DWorld.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.cpp">
<Filter>physics3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault-winrt.cpp">
<Filter>base</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNinePatchImageParser.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="2d">
@ -3662,6 +3736,12 @@
<Filter Include="external\poly2tri\sweep">
<UniqueIdentifier>{932c5f6e-07b3-4b34-97ae-2f3d42024149}</UniqueIdentifier>
</Filter>
<Filter Include="audioengine">
<UniqueIdentifier>{bd1a6214-d6e0-4341-a1fc-79da99b55e35}</UniqueIdentifier>
</Filter>
<Filter Include="physics3d">
<UniqueIdentifier>{e6f8ab69-f66f-48be-a40f-e33c08e77516}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\..\..\cocos2d.def" />
@ -3777,4 +3857,9 @@
<Filter>3d</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CMakeLists.txt">
<Filter>physics3d</Filter>
</Text>
</ItemGroup>
</Project>

View File

@ -30,6 +30,9 @@
<ProjectReference Include="..\..\..\..\..\external\Box2D\proj.win8.1-universal\libbox2d.Windows\libbox2d.Windows.vcxproj">
<Project>{3b26a12d-3a44-47ea-82d2-282660fc844d}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\external\bullet\proj.win8.1-universal\libbullet.Windows\libbullet.Windows.vcxproj">
<Project>{ec2b1292-2d8c-4feb-a84b-2550b32c1ae7}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\editor-support\spine\proj.win8.1-universal\libSpine.Windows\libSpine.Windows.vcxproj">
<Project>{f3550fe0-c795-44f6-8feb-093eb68143ae}</Project>
</ProjectReference>
@ -157,7 +160,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -177,7 +180,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -197,7 +200,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -217,7 +220,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -237,7 +240,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -257,7 +260,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1\freetype2;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>

View File

@ -22,6 +22,9 @@
<ProjectReference Include="..\..\..\..\..\external\Box2D\proj.win8.1-universal\libbox2d.WindowsPhone\libbox2d.WindowsPhone.vcxproj">
<Project>{22f798d8-bfff-4754-996f-a5395343d5ec}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\external\bullet\proj.win8.1-universal\libbullet.WindowsPhone\libbullet.WindowsPhone.vcxproj">
<Project>{e35634bd-b91b-4a6d-b957-96f56dd065f9}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\editor-support\spine\proj.win8.1-universal\libSpine.WindowsPhone\libSpine.WindowsPhone.vcxproj">
<Project>{cc1da216-a80d-4be4-b309-acb6af313aff}</Project>
</ProjectReference>
@ -111,7 +114,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -131,7 +134,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -151,7 +154,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
@ -171,7 +174,7 @@
<AdditionalOptions>/Zm384 /bigobj %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1\freetype2;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_WINDOWS_PHONE_8_1;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>false</SDLCheck>
<DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<EngineRoot>$(MSBuildThisFileDirectory)..\..\..\</EngineRoot>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM)\freetype2;$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile>
<PreprocessorDefinitions>WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4056;4244;4251;4756;4453;28204;4099;</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<BuildMacro Include="EngineRoot">
<Value>$(EngineRoot)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="APP_DLLS">
<AngleBinPath Condition=" '$(AngleBinPath)' == '' ">$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\prebuilt\$(Platform)\</AngleBinPath>
<ZLibBinPath Condition=" '$(ZLibBinPath)' == '' ">$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform)\</ZLibBinPath>
<WebsocketsBinPath Condition=" '$(WebsocketsBinPath)' == '' ">$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\</WebsocketsBinPath>
<SQLiteBinPath Condition=" '$(SQLiteBinPath)' == '' ">$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform)\</SQLiteBinPath>
</PropertyGroup>
<ItemGroup Label="ANGLE">
<None Include="$(AngleBinPath)libEGL.dll">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="$(AngleBinPath)libGLESv2.dll">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="$(ZLibBinPath)zlib.dll">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="$(WebsocketsBinPath)libwebsockets.dll">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="$(SQLiteBinPath)sqlite3.dll">
<DeploymentContent>true</DeploymentContent>
</None>
</ItemGroup>
</Project>

View File

@ -2,6 +2,11 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="COCOS2">
<COCOS2D_PLATFORM Condition=" '$(COCOS2_PLATFORM)' == '' ">winrt_8.1</COCOS2D_PLATFORM>
<COCOS2D_PLATFORM Condition=" '$(COCOS2_PLATFORM)' == '' ">win10</COCOS2D_PLATFORM>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>msxml6.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>

View File

@ -10,12 +10,12 @@
<AdditionalIncludeDirectories>$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\angle\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM)\freetype2;$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile>
<PreprocessorDefinitions>WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4056;4244;4251;4756;4453;28204;</DisableSpecificWarnings>
<DisableSpecificWarnings>4056;4244;4251;4756;4453;28204;4099;</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;chipmunk.lib;zlib.lib;freetype.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies)</AdditionalDependencies>

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<EngineRoot>$(MSBuildThisFileDirectory)..\..\..\</EngineRoot>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)external\winrt-specific\angle\include;$(EngineRoot)external\freetype2\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\curl\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\websockets\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\platform\winrt;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\editor-support;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\sqlite3\include;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)extensions;$(EngineRoot)external;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\unzip;$(EngineRoot)external\tinyxml2;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\xxhash;$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile>
<PreprocessorDefinitions>WINRT;_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<DisableSpecificWarnings>4056;4996;4244;4251;</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>libGLESv2.lib;libEGL.lib;ws2_32.lib;libwebsockets.lib;libcurl.lib;libchipmunk.lib;zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype250.lib;sqlite3.lib;d2d1.lib;d3d11.lib;dxgi.lib;windowscodecs.lib;dwrite.lib;dxguid.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(EngineRoot)external\winrt-specific\angle\prebuilt\$(Platform);$(EngineRoot)external\curl\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\websockets\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\chipmunk\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\$(COCOS2D_PLATFORM)-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\png\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\tiff\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\jpeg\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\sqlite3\libraries\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\freetype2\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);$(EngineRoot)external\poly2tri;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<BuildMacro Include="EngineRoot">
<Value>$(EngineRoot)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
</Project>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="APP_DLLS">
<AngleBinPath Condition=" '$(AngleBinPath)' == '' ">$(EngineRoot)external\winrt-specific\angle\prebuilt\$(Platform)\</AngleBinPath>
</PropertyGroup>
<ItemGroup Label="ANGLE">
<None Include="$(AngleBinPath)libEGL.dll">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="$(AngleBinPath)libGLESv2.dll">
<DeploymentContent>true</DeploymentContent>
</None>
</ItemGroup>
</Project>

View File

@ -230,10 +230,10 @@ void BillBoard::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
//FIXME: frustum culling here
flags |= Node::FLAGS_RENDER_AS_3D;
_quadCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, _modelViewTransform, flags);
_quadCommand.setTransparent(true);
_quadCommand.set3D(true);
renderer->addCommand(&_quadCommand);
_trianglesCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), _modelViewTransform, flags);
_trianglesCommand.setTransparent(true);
_trianglesCommand.set3D(true);
renderer->addCommand(&_trianglesCommand);
}
void BillBoard::setMode( Mode mode )

View File

@ -760,18 +760,27 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
meshData->subMeshIndices.push_back(indexArray);
meshData->numIndex = (int)meshData->subMeshIndices.size();
//meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS];
if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6)
if(mesh_data.HasMember(AABBS))
{
Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble());
Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble());
meshData->subMeshAABB.push_back(AABB(min, max));
const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS];
if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6)
{
Vec3 min(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(),
mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble());
Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(),
mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble());
meshData->subMeshAABB.push_back(AABB(min, max));
}
else
{
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
}
}
else
{
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
}
}
meshdatas.meshDatas.push_back(meshData);
}

View File

@ -152,18 +152,32 @@ void Skybox::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
void Skybox::onDraw(const Mat4& transform, uint32_t flags)
{
Mat4 trans(transform);
const cocos2d::Vec3 pos(Camera::getVisitingCamera()->getPosition3D());
trans.m[12] = pos.x;
trans.m[13] = pos.y;
trans.m[14] = pos.z;
auto camera = Camera::getVisitingCamera();
/*
At beginning, we have a regular skybox at origin point.
To render the skybox, we should keep camera at the center of skybox.
So we need a translate matrix, which can transform origin point to camera pos.
Camera's node to word transform matrix don't match our requement,
because it maybe contain the scale, rotate, reflact... effects, which isn't need.
First, we transform origin point to camera position by camera's node to world matrix.
Second, we create a translate matrix with the origin point's world position.
*/
Vec3 cameraPosInNode(0, 0, 0);
Vec3 cameraPosInWorld;
Mat4 cameraModelMat = camera->getNodeToWorldTransform();
Mat4 trans = Mat4::IDENTITY;
cameraModelMat.transformPoint(cameraPosInNode, &cameraPosInWorld);
trans.translate(cameraPosInWorld);
auto state = getGLProgramState();
state->apply(trans);
Vec4 color(_displayedColor.r / 255.f, _displayedColor.g / 255.f, _displayedColor.b / 255.f, 1.f);
state->setUniformVec4("u_color", color);
float scalf = (camera->getFarPlane() + camera->getNearPlane()) / 2;
state->setUniformFloat("u_scalef", scalf);
GLboolean depthFlag = glIsEnabled(GL_DEPTH_TEST);
GLint depthFunc;
glGetIntegerv(GL_DEPTH_FUNC, &depthFunc);

View File

@ -701,7 +701,7 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
#if CC_USE_CULLING
// camera clipping
if(!Camera::getVisitingCamera()->isVisibleInFrustum(&this->getAABB()))
if(Camera::getVisitingCamera() && !Camera::getVisitingCamera()->isVisibleInFrustum(&this->getAABB()))
return;
#endif

View File

@ -33,6 +33,7 @@ USING_NS_CC;
#include "renderer/CCRenderer.h"
#include "renderer/CCGLProgramStateCache.h"
#include "renderer/ccGLStateCache.h"
#include "renderer/CCRenderState.h"
#include "base/CCDirector.h"
#include "2d/CCCamera.h"
@ -79,6 +80,12 @@ bool Terrain::initProperties()
auto state = GLProgramState::create(shader);
setGLProgramState(state);
_stateBlock->setBlend(false);
_stateBlock->setDepthWrite(true);
_stateBlock->setDepthTest(true);
_stateBlock->setCullFace(true);
setDrawWire(false);
setIsEnableFrustumCull(true);
setAnchorPoint(Vec2(0,0));
@ -93,6 +100,13 @@ void Terrain::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform,
void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
{
auto modelMatrix = getNodeToWorldTransform();
if(memcmp(&modelMatrix,&_terrainModelMatrix,sizeof(Mat4))!=0)
{
_terrainModelMatrix = modelMatrix;
_quadRoot->preCalculateAABB(_terrainModelMatrix);
}
auto glProgram = getGLProgram();
glProgram->use();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
@ -104,34 +118,16 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
}
#endif
GLboolean blendCheck = glIsEnabled(GL_BLEND);
if(blendCheck)
{
glDisable(GL_BLEND);
}
_stateBlock->bind();
GL::enableVertexAttribs(1<<_positionLocation | 1 << _texcordLocation | 1<<_normalLocation);
glProgram->setUniformsForBuiltins(transform);
GLboolean depthMaskCheck;
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMaskCheck);
if(!depthMaskCheck)
{
glDepthMask(GL_TRUE);
}
GLboolean CullFaceCheck =glIsEnabled(GL_CULL_FACE);
if(!CullFaceCheck)
{
glEnable(GL_CULL_FACE);
}
GLboolean depthTestCheck;
depthTestCheck = glIsEnabled(GL_DEPTH_TEST);
if(!depthTestCheck)
{
glEnable(GL_DEPTH_TEST);
}
if(!_alphaMap)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,_detailMapTextures[0]->getName());
GL::bindTexture2D(_detailMapTextures[0]->getName());
glUniform1i(_detailMapLocation[0],0);
glUniform1i(_alphaIsHasAlphaMapLocation,0);
}else
@ -139,7 +135,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
for(int i =0;i<_maxDetailMapValue;i++)
{
glActiveTexture(GL_TEXTURE0+i);
glBindTexture(GL_TEXTURE_2D,_detailMapTextures[i]->getName());
GL::bindTexture2D(_detailMapTextures[i]->getName());
glUniform1i(_detailMapLocation[i],i);
glUniform1f(_detailMapSizeLocation[i],_terrainData._detailMaps[i]._detailMapSize);
@ -148,7 +144,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
glUniform1i(_alphaIsHasAlphaMapLocation,1);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D,_alphaMap->getName());
GL::bindTexture2D(_alphaMap->getName());
glUniform1i(_alphaMapLocation,4);
}
@ -164,6 +160,8 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
if(_isCameraViewChanged )
{
auto camPos = camera->getPosition3D();
auto camModelMat = camera->getNodeToWorldTransform();
camModelMat.transformPoint(&camPos);
//set lod
setChunksLOD(camPos);
}
@ -180,28 +178,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
_isCameraViewChanged = false;
}
glActiveTexture(GL_TEXTURE0);
if(depthTestCheck)
{
}else
{
glDisable(GL_DEPTH_TEST);
}
if(depthMaskCheck)
{
}else
{
glDepthMask(GL_FALSE);
}
if(CullFaceCheck)
{
}else
{
glEnable(GL_CULL_FACE);
}
if(blendCheck)
{
glEnable(GL_BLEND);
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
if(_isDrawWire)//reset state.
{
@ -260,8 +237,12 @@ bool Terrain::initHeightMap(const char * heightMap)
}
Terrain::Terrain()
: _alphaMap(nullptr)
, _stateBlock(nullptr)
{
_alphaMap = nullptr;
_stateBlock = RenderState::StateBlock::create();
CC_SAFE_RETAIN(_stateBlock);
_customCommand.setTransparent(false);
_customCommand.set3D(true);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
@ -453,6 +434,8 @@ void Terrain::setIsEnableFrustumCull(bool bool_value)
Terrain::~Terrain()
{
CC_SAFE_RELEASE(_stateBlock);
_alphaMap->release();
_heightMapImage->release();
delete _quadRoot;
@ -832,7 +815,6 @@ void Terrain::reload()
}
}
CCLOG("recreate");
initTextures();
_chunkLodIndicesSet.clear();
_chunkLodIndicesSkirtSet.clear();

View File

@ -24,15 +24,18 @@ THE SOFTWARE.
#ifndef CC_TERRAIN_H
#define CC_TERRAIN_H
#include <vector>
#include "2d/CCNode.h"
#include "2d/CCCamera.h"
#include "renderer/CCTexture2D.h"
#include "renderer/CCCustomCommand.h"
#include "renderer/CCRenderState.h"
#include "3d/CCAABB.h"
#include "3d/CCRay.h"
#include <vector>
#include "base/CCEventListenerCustom.h"
#include "base/CCEventDispatcher.h"
NS_CC_BEGIN
/**
@ -81,7 +84,7 @@ NS_CC_BEGIN
* We can use ray-terrain intersection to pick a point of the terrain;
* Also we can get an arbitrary point of the terrain's height and normal vector for convenience .
**/
class CC_DLL Terrain :public Node
class CC_DLL Terrain : public Node
{
public:
@ -433,6 +436,7 @@ protected:
ChunkIndices insertIndicesLOD(int neighborLod[4], int selfLod, GLushort * indices, int size);
ChunkIndices insertIndicesLODSkirt(int selfLod, GLushort * indices, int size);
protected:
std::vector <ChunkLODIndices> _chunkLodIndicesSet;
std::vector<ChunkLODIndicesSkirt> _chunkLodIndicesSkirtSet;
@ -469,6 +473,9 @@ protected:
GLint _alphaMapLocation;
GLint _alphaIsHasAlphaMapLocation;
GLint _detailMapSizeLocation[4];
RenderState::StateBlock* _stateBlock;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
EventListenerCustom* _backToForegroundListener;
#endif

View File

@ -103,6 +103,7 @@ math/TransformUtils.cpp \
math/Vec2.cpp \
math/Vec3.cpp \
math/Vec4.cpp \
base/CCNinePatchImageParser.cpp \
base/CCAsyncTaskPool.cpp \
base/CCAutoreleasePool.cpp \
base/CCConfiguration.cpp \

View File

@ -24,7 +24,7 @@
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#include "audio/include/AudioEngine.h"
#include "platform/CCFileUtils.h"
@ -36,6 +36,8 @@
#include "apple/AudioEngine-inl.h"
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#include "win32/AudioEngine-win32.h"
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#include "winrt/AudioEngine-winrt.h"
#endif
#define TIME_DELAY_PRECISION 0.0001

View File

@ -1,23 +1,6 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cocosdenshion_static
LOCAL_MODULE_FILENAME := libcocosdenshion
LOCAL_SRC_FILES := cddSimpleAudioEngine.cpp \
ccdandroidUtils.cpp \
jni/cddandroidAndroidJavaEngine.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../.. \
$(LOCAL_PATH)/../../platform/android
include $(BUILD_STATIC_LIBRARY)
#new audio engine
#New AudioEngine
include $(CLEAR_VARS)
LOCAL_MODULE := audioengine_static
@ -36,3 +19,23 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../../platform/android
include $(BUILD_STATIC_LIBRARY)
#SimpleAudioEngine
include $(CLEAR_VARS)
LOCAL_MODULE := cocosdenshion_static
LOCAL_MODULE_FILENAME := libcocosdenshion
LOCAL_SRC_FILES := cddSimpleAudioEngine.cpp \
ccdandroidUtils.cpp \
jni/cddandroidAndroidJavaEngine.cpp
LOCAL_STATIC_LIBRARIES := audioengine_static
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
$(LOCAL_PATH)/../.. \
$(LOCAL_PATH)/../../platform/android
include $(BUILD_STATIC_LIBRARY)

View File

@ -43,6 +43,8 @@
using namespace cocos2d;
using namespace cocos2d::experimental;
#define DELAY_TIME_TO_REMOVE 0.5f
void PlayOverEvent(SLPlayItf caller, void* context, SLuint32 playEvent)
{
if (context && playEvent == SL_PLAYEVENT_HEADATEND)
@ -67,6 +69,7 @@ AudioPlayer::AudioPlayer()
, _playOver(false)
, _loop(false)
, _assetFd(0)
, _delayTimeToRemove(-1.f)
{
}
@ -276,18 +279,32 @@ int AudioEngineImpl::play2d(const std::string &filePath ,bool loop ,float volume
void AudioEngineImpl::update(float dt)
{
auto itend = _audioPlayers.end();
for (auto iter = _audioPlayers.begin(); iter != itend; ++iter)
{
if(iter->second._playOver)
{
if (iter->second._finishCallback)
iter->second._finishCallback(iter->second._audioID, *AudioEngine::_audioIDInfoMap[iter->second._audioID].filePath);
AudioPlayer* player = nullptr;
AudioEngine::remove(iter->second._audioID);
_audioPlayers.erase(iter);
break;
auto itend = _audioPlayers.end();
for (auto iter = _audioPlayers.begin(); iter != itend; )
{
player = &(iter->second);
if (player->_playOver)
{
if (player->_finishCallback)
player->_finishCallback(player->_audioID, *AudioEngine::_audioIDInfoMap[player->_audioID].filePath);
AudioEngine::remove(player->_audioID);
iter = _audioPlayers.erase(iter);
continue;
}
else if (player->_delayTimeToRemove > 0.f)
{
player->_delayTimeToRemove -= dt;
if (player->_delayTimeToRemove < 0.f)
{
iter = _audioPlayers.erase(iter);
continue;
}
}
++iter;
}
if(_audioPlayers.empty()){
@ -348,7 +365,13 @@ void AudioEngineImpl::stop(int audioID)
log("%s error:%u",__func__, result);
}
_audioPlayers.erase(audioID);
/*If destroy openSL object immediately,it may cause dead lock.
*It's a system issue.For more information:
* https://github.com/cocos2d/cocos2d-x/issues/11697
* https://groups.google.com/forum/#!msg/android-ndk/zANdS2n2cQI/AT6q1F3nNGIJ
*/
player._delayTimeToRemove = DELAY_TIME_TO_REMOVE;
//_audioPlayers.erase(audioID);
}
void AudioEngineImpl::stopAll()
@ -356,9 +379,13 @@ void AudioEngineImpl::stopAll()
auto itEnd = _audioPlayers.end();
for (auto it = _audioPlayers.begin(); it != itEnd; ++it)
{
auto result = (*it->second._fdPlayerPlay)->SetPlayState(it->second._fdPlayerPlay, SL_PLAYSTATE_STOPPED);
(*it->second._fdPlayerPlay)->SetPlayState(it->second._fdPlayerPlay, SL_PLAYSTATE_STOPPED);
if (it->second._delayTimeToRemove < 0.f)
{
//If destroy openSL object immediately,it may cause dead lock.
it->second._delayTimeToRemove = DELAY_TIME_TO_REMOVE;
}
}
_audioPlayers.clear();
}
float AudioEngineImpl::getDuration(int audioID)

View File

@ -60,6 +60,7 @@ private:
float _duration;
int _audioID;
int _assetFd;
float _delayTimeToRemove;
std::function<void (int, const std::string &)> _finishCallback;

View File

@ -1,6 +1,6 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
Copyright (c) 2013-2015 Chukong Technologies Inc.
http://www.cocos2d-x.org
@ -24,10 +24,13 @@ THE SOFTWARE.
****************************************************************************/
#include "cddandroidAndroidJavaEngine.h"
#include "platform/android/jni/JniHelper.h"
#include "ccdandroidUtils.h"
#include <stdlib.h>
#include <android/log.h>
#include <jni.h>
#include <sys/system_properties.h>
#include "platform/android/jni/JniHelper.h"
#include "ccdandroidUtils.h"
#include "audio/include/AudioEngine.h"
// logging
#define LOG_TAG "cocosdenshion::android::AndroidJavaEngine"
@ -36,282 +39,463 @@ THE SOFTWARE.
// Java class
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper"
namespace CocosDenshion {
namespace android {
using namespace cocos2d::experimental;
using namespace CocosDenshion::android;
bool AndroidJavaEngine::getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo,
const char *methodName,
const char *paramCode) {
return cocos2d::JniHelper::getStaticMethodInfo(methodinfo,
CLASS_NAME,
methodName,
paramCode);
}
static inline bool getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo,
const char *methodName,
const char *paramCode) {
return cocos2d::JniHelper::getStaticMethodInfo(methodinfo,
CLASS_NAME,
methodName,
paramCode);
}
AndroidJavaEngine::~AndroidJavaEngine() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "end", "()V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::preloadBackgroundMusic(const char* pszFilePath) {
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath);
// void playBackgroundMusic(String,boolean)
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V")) {
return;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) {
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath);
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V")) {
return;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::stopBackgroundMusic(bool bReleaseData) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::pauseBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::resumeBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::rewindBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
bool AndroidJavaEngine::willPlayBackgroundMusic() {
return true;
}
bool AndroidJavaEngine::isBackgroundMusicPlaying() {
cocos2d::JniMethodInfo methodInfo;
jboolean ret = false;
if (! getJNIStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z")) {
return ret;
}
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
float AndroidJavaEngine::getBackgroundMusicVolume() {
cocos2d::JniMethodInfo methodInfo;
jfloat ret = -1.0;
if (! getJNIStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F")) {
return ret;
}
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
void AndroidJavaEngine::setBackgroundMusicVolume(float volume) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
float AndroidJavaEngine::getEffectsVolume() {
cocos2d::JniMethodInfo methodInfo;
jfloat ret = -1.0;
if (! getJNIStaticMethodInfo(methodInfo, "getEffectsVolume", "()F")) {
return ret;
}
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
void AndroidJavaEngine::setEffectsVolume(float volume) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
unsigned int AndroidJavaEngine::playEffect(const char* pszFilePath, bool bLoop,
float pitch, float pan, float gain) {
cocos2d::JniMethodInfo methodInfo;
int ret = 0;
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath);
if (! getJNIStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;ZFFF)I")) {
return ret;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID,
methodInfo.methodID,
stringArg,
bLoop,
pitch, pan, gain);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return (unsigned int)ret;
}
void AndroidJavaEngine::pauseEffect(unsigned int nSoundId) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "pauseEffect", "(I)V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::pauseAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "pauseAllEffects", "()V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::resumeEffect(unsigned int nSoundId) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "resumeEffect", "(I)V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::resumeAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "resumeAllEffects", "()V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::stopEffect(unsigned int nSoundId) {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "stopEffect", "(I)V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::stopAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (! getJNIStaticMethodInfo(methodInfo, "stopAllEffects", "()V")) {
return ;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void loadEffect(const char* pszFilePath, char* loadEffectName) {
cocos2d::JniMethodInfo methodInfo;
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(pszFilePath);
if (! cocos2d::JniHelper::getStaticMethodInfo(methodInfo, CLASS_NAME, loadEffectName, "(Ljava/lang/String;)V")) {
return ;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::preloadEffect(const char* pszFilePath) {
loadEffect(pszFilePath, "preloadEffect");
}
void AndroidJavaEngine::unloadEffect(const char* pszFilePath) {
loadEffect(pszFilePath, "unloadEffect");
AndroidJavaEngine::AndroidJavaEngine()
: _implementBaseOnAudioEngine(false)
, _effectVolume(1.f)
{
char sdk_ver_str[PROP_VALUE_MAX] = "0";
auto len = __system_property_get("ro.build.version.sdk", sdk_ver_str);
if (len > 0)
{
auto sdk_ver = atoi(sdk_ver_str);
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d", "android build version:%d", sdk_ver);
if (sdk_ver == 21)
{
_implementBaseOnAudioEngine = true;
}
}
}
else
{
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d", "%s", "Fail to get android build version.");
}
}
AndroidJavaEngine::~AndroidJavaEngine() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "end", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::preloadBackgroundMusic(const char* filePath) {
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
// void playBackgroundMusic(String,boolean)
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V")) {
return;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::playBackgroundMusic(const char* filePath, bool loop) {
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V")) {
return;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, loop);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::stopBackgroundMusic(bool releaseData) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::pauseBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::resumeBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
void AndroidJavaEngine::rewindBackgroundMusic() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
bool AndroidJavaEngine::willPlayBackgroundMusic() {
return true;
}
bool AndroidJavaEngine::isBackgroundMusicPlaying() {
cocos2d::JniMethodInfo methodInfo;
jboolean ret = false;
if (!getJNIStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z")) {
return ret;
}
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
float AndroidJavaEngine::getBackgroundMusicVolume() {
cocos2d::JniMethodInfo methodInfo;
jfloat ret = -1.0;
if (!getJNIStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F")) {
return ret;
}
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
void AndroidJavaEngine::setBackgroundMusicVolume(float volume) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static float _jni_getEffectsVolume() {
cocos2d::JniMethodInfo methodInfo;
jfloat ret = -1.0;
if (!getJNIStaticMethodInfo(methodInfo, "getEffectsVolume", "()F")) {
return ret;
}
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return ret;
}
static void _jni_setEffectsVolume(float volume) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static unsigned int _jni_playEffect(const char* filePath, bool loop, float pitch, float pan, float gain)
{
cocos2d::JniMethodInfo methodInfo;
int ret = 0;
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
if (!getJNIStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;ZFFF)I")) {
return ret;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID,
methodInfo.methodID,
stringArg,
loop,
pitch, pan, gain);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
return (unsigned int)ret;
}
static void _jni_pauseEffect(unsigned int soundId) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "pauseEffect", "(I)V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_pauseAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "pauseAllEffects", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_resumeEffect(unsigned int soundId) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "resumeEffect", "(I)V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_resumeAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "resumeAllEffects", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_stopEffect(unsigned int soundId) {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "stopEffect", "(I)V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_stopAllEffects() {
cocos2d::JniMethodInfo methodInfo;
if (!getJNIStaticMethodInfo(methodInfo, "stopAllEffects", "()V")) {
return;
}
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void loadEffect(const char* filePath, char* loadEffectName) {
cocos2d::JniMethodInfo methodInfo;
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
if (!cocos2d::JniHelper::getStaticMethodInfo(methodInfo, CLASS_NAME, loadEffectName, "(Ljava/lang/String;)V")) {
return;
}
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
methodInfo.env->DeleteLocalRef(stringArg);
methodInfo.env->DeleteLocalRef(methodInfo.classID);
}
static void _jni_preloadEffect(const char* filePath) {
loadEffect(filePath, "preloadEffect");
}
static void _jni_unloadEffect(const char* filePath) {
loadEffect(filePath, "unloadEffect");
}
float AndroidJavaEngine::getEffectsVolume()
{
if (_implementBaseOnAudioEngine)
{
return _effectVolume;
}
else
{
return _jni_getEffectsVolume();
}
}
void AndroidJavaEngine::setEffectsVolume(float volume)
{
if (_implementBaseOnAudioEngine)
{
if (volume > 1.f)
{
volume = 1.f;
}
else if (volume < 0.f)
{
volume = 0.f;
}
if (_effectVolume != volume)
{
_effectVolume = volume;
for (auto& it : _soundIDs)
{
AudioEngine::setVolume(it.first, volume);
}
}
}
else
{
_jni_setEffectsVolume(volume);
}
}
unsigned int AndroidJavaEngine::playEffect(const char* filePath, bool loop,
float pitch, float pan, float gain)
{
if (_implementBaseOnAudioEngine)
{
auto soundID = AudioEngine::play2d(filePath, loop, _effectVolume);
if (soundID != AudioEngine::INVALID_AUDIO_ID)
{
_soundIDs[soundID] = soundID;
AudioEngine::setFinishCallback(soundID, [this](int id, const std::string& filePath){
_soundIDs.erase(id);
});
}
return soundID;
}
else
{
return _jni_playEffect(filePath, loop, pitch, pan, gain);
}
}
void AndroidJavaEngine::pauseEffect(unsigned int soundID)
{
if (_implementBaseOnAudioEngine)
{
AudioEngine::pause(soundID);
}
else
{
_jni_pauseEffect(soundID);
}
}
void AndroidJavaEngine::resumeEffect(unsigned int soundID)
{
if (_implementBaseOnAudioEngine)
{
AudioEngine::resume(soundID);
}
else
{
_jni_resumeEffect(soundID);
}
}
void AndroidJavaEngine::stopEffect(unsigned int soundID)
{
if (_implementBaseOnAudioEngine)
{
AudioEngine::stop(soundID);
_soundIDs.erase(soundID);
}
else
{
_jni_stopEffect(soundID);
}
}
void AndroidJavaEngine::pauseAllEffects()
{
if (_implementBaseOnAudioEngine)
{
for (auto& it : _soundIDs)
{
AudioEngine::pause(it.first);
}
}
else
{
_jni_pauseAllEffects();
}
}
void AndroidJavaEngine::resumeAllEffects()
{
if (_implementBaseOnAudioEngine)
{
for (auto& it : _soundIDs)
{
AudioEngine::resume(it.first);
}
}
else
{
_jni_resumeAllEffects();
}
}
void AndroidJavaEngine::stopAllEffects()
{
if (_implementBaseOnAudioEngine)
{
for (auto& it : _soundIDs)
{
AudioEngine::stop(it.first);
}
_soundIDs.clear();
}
else
{
_jni_stopAllEffects();
}
}
void AndroidJavaEngine::preloadEffect(const char* filePath)
{
if (!_implementBaseOnAudioEngine)
{
_jni_preloadEffect(filePath);
}
}
void AndroidJavaEngine::unloadEffect(const char* filePath)
{
if (!_implementBaseOnAudioEngine)
{
_jni_unloadEffect(filePath);
}
}

View File

@ -1,6 +1,6 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
Copyright (c) 2013-2015 Chukong Technologies Inc.
http://www.cocos2d-x.org
@ -27,39 +27,42 @@ THE SOFTWARE.
#include "SimpleAudioEngine.h"
#include "platform/android/jni/JniHelper.h"
#include <unordered_map>
namespace CocosDenshion {
namespace android {
class AndroidJavaEngine : public SimpleAudioEngine {
public:
AndroidJavaEngine();
~AndroidJavaEngine();
void preloadBackgroundMusic(const char* pszFilePath);
void playBackgroundMusic(const char* pszFilePath, bool bLoop);
void stopBackgroundMusic(bool bReleaseData);
void pauseBackgroundMusic();
void resumeBackgroundMusic();
void rewindBackgroundMusic();
bool willPlayBackgroundMusic();
bool isBackgroundMusicPlaying();
float getBackgroundMusicVolume();
void setBackgroundMusicVolume(float volume);
float getEffectsVolume();
void setEffectsVolume(float volume);
unsigned int playEffect(const char* pszFilePath, bool bLoop = false,
virtual void preloadBackgroundMusic(const char* filePath);
virtual void playBackgroundMusic(const char* filePath, bool loop);
virtual void stopBackgroundMusic(bool releaseData);
virtual void pauseBackgroundMusic();
virtual void resumeBackgroundMusic();
virtual void rewindBackgroundMusic();
virtual bool willPlayBackgroundMusic();
virtual bool isBackgroundMusicPlaying();
virtual float getBackgroundMusicVolume();
virtual void setBackgroundMusicVolume(float volume);
virtual float getEffectsVolume();
virtual void setEffectsVolume(float volume);
virtual unsigned int playEffect(const char* filePath, bool loop = false,
float pitch = 1.0f, float pan = 0.0f, float gain = 1.0f);
void pauseEffect(unsigned int nSoundId);
void pauseAllEffects();
void resumeEffect(unsigned int nSoundId);
void resumeAllEffects();
void stopEffect(unsigned int nSoundId);
void stopAllEffects();
void preloadEffect(const char* pszFilePath);
void unloadEffect(const char* pszFilePath);
virtual void pauseEffect(unsigned int soundId);
virtual void pauseAllEffects();
virtual void resumeEffect(unsigned int soundId);
virtual void resumeAllEffects();
virtual void stopEffect(unsigned int soundId);
virtual void stopAllEffects();
virtual void preloadEffect(const char* filePath);
virtual void unloadEffect(const char* filePath);
private :
static bool getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo,
const char *methodName,
const char *paramCode);
bool _implementBaseOnAudioEngine;
float _effectVolume;
std::unordered_map<int, int> _soundIDs;
};
}
}

View File

@ -158,10 +158,11 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio
-(id) init
{
if (self == [super init])
if (self = [super init])
{
if ([[[UIDevice currentDevice] systemVersion] intValue] > 5) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:UIApplicationDidBecomeActiveNotification object:[AVAudioSession sharedInstance]];
}
else {
AudioSessionInitialize(NULL, NULL, AudioEngineInterruptionListenerCallback, self);
@ -172,6 +173,8 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio
-(void)handleInterruption:(NSNotification*)notification
{
static bool resumeOnBecomingActive = false;
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
NSInteger reason = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] integerValue];
if (reason == AVAudioSessionInterruptionTypeBegan) {
@ -179,17 +182,35 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio
}
if (reason == AVAudioSessionInterruptionTypeEnded) {
OSStatus result = AudioSessionSetActive(true);
if (result) NSLog(@"Error setting audio session active! %d\n", result);
alcMakeContextCurrent(s_ALContext);
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
NSError *error = nil;
[[AVAudioSession sharedInstance] setActive:YES error:&error];
alcMakeContextCurrent(s_ALContext);
} else {
resumeOnBecomingActive = true;
}
}
}
if ([notification.name isEqualToString:UIApplicationDidBecomeActiveNotification] && resumeOnBecomingActive) {
resumeOnBecomingActive = false;
NSError *error = nil;
BOOL success = [[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryAmbient
error: &error];
if (!success) {
printf("Fail to set audio session.\n");
return;
}
[[AVAudioSession sharedInstance] setActive:YES error:&error];
alcMakeContextCurrent(s_ALContext);
}
}
-(void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionInterruptionNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
[super dealloc];
}
@ -239,12 +260,11 @@ bool AudioEngineImpl::init()
s_ALDevice = alcOpenDevice(nullptr);
if (s_ALDevice) {
auto alError = alGetError();
s_ALContext = alcCreateContext(s_ALDevice, nullptr);
alcMakeContextCurrent(s_ALContext);
alGenSources(MAX_AUDIOINSTANCES, _alSources);
alError = alGetError();
auto alError = alGetError();
if(alError != AL_NO_ERROR)
{
printf("%s:generating sources fail! error = %x\n", __PRETTY_FUNCTION__, alError);

View File

@ -23,7 +23,7 @@
****************************************************************************/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#ifndef __AUDIO_ENGINE_H_
#define __AUDIO_ENGINE_H_

View File

@ -38,7 +38,7 @@
#endif
#include "CCPlatformMacros.h"
#define QUEUEBUFFER_NUM 3
#define QUEUEBUFFER_NUM 5
#define QUEUEBUFFER_TIME_STEP 0.1f
NS_CC_BEGIN

View File

@ -62,6 +62,7 @@ namespace cocos2d {
for (int index = 0; index < _numThread; ++index) {
_tasks.push_back(nullptr);
_threads.push_back( std::thread( std::bind(&AudioEngineThreadPool::threadFunc,this,index) ) );
_threads[index].detach();
}
}
@ -78,7 +79,7 @@ namespace cocos2d {
if (targetIndex == -1) {
_tasks.push_back(task);
_threads.push_back( std::thread( std::bind(&AudioEngineThreadPool::threadFunc,this,_numThread) ) );
_threads[_numThread].detach();
_numThread++;
}
_taskMutex.unlock();
@ -212,16 +213,14 @@ int AudioEngineImpl::play2d(const std::string &filePath ,bool loop ,float volume
auto it = _audioCaches.find(filePath);
if (it == _audioCaches.end()) {
audioCache = &_audioCaches[filePath];
auto ext = filePath.substr(filePath.rfind('.'));
transform(ext.begin(), ext.end(), ext.begin(), tolower);
auto ext = strchr(filePath.c_str(), '.');
bool eraseCache = true;
if (ext.compare(".ogg") == 0){
if (_stricmp(ext, ".ogg") == 0){
audioCache->_fileFormat = AudioCache::FileFormat::OGG;
eraseCache = false;
}
else if (ext.compare(".mp3") == 0){
else if (_stricmp(ext, ".mp3") == 0){
audioCache->_fileFormat = AudioCache::FileFormat::MP3;
if (MPG123_LAZYINIT){
@ -239,7 +238,7 @@ int AudioEngineImpl::play2d(const std::string &filePath ,bool loop ,float volume
}
}
else{
log("unsupported media type:%s\n",ext.c_str());
log("unsupported media type:%s\n", ext);
}
if (eraseCache){
@ -380,7 +379,14 @@ bool AudioEngineImpl::stop(int audioID)
alSourcei(player._alSource, AL_BUFFER, NULL);
_alSourceUsed[player._alSource] = false;
_audioPlayers.erase(audioID);
if (player._streamingSource)
{
player.notifyExitThread();
}
else
{
_audioPlayers.erase(audioID);
}
return ret;
}
@ -394,7 +400,19 @@ void AudioEngineImpl::stopAll()
_alSourceUsed[_alSources[index]] = false;
}
_audioPlayers.clear();
for (auto it = _audioPlayers.begin(); it != _audioPlayers.end();)
{
auto& player = it->second;
if (player._streamingSource)
{
player.notifyExitThread();
++it;
}
else
{
it = _audioPlayers.erase(it);
}
}
}
float AudioEngineImpl::getDuration(int audioID)
@ -498,7 +516,11 @@ void AudioEngineImpl::update(float dt)
auto& player = it->second;
alGetSourcei(player._alSource, AL_SOURCE_STATE, &sourceState);
if (player._ready && sourceState == AL_STOPPED) {
if (player._readForRemove)
{
it = _audioPlayers.erase(it);
}
else if (player._ready && sourceState == AL_STOPPED) {
_alSourceUsed[player._alSource] = false;
if (player._finishCallbak) {
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
@ -507,7 +529,15 @@ void AudioEngineImpl::update(float dt)
AudioEngine::remove(audioID);
it = _audioPlayers.erase(it);
if (player._streamingSource)
{
player.notifyExitThread();
++it;
}
else
{
it = _audioPlayers.erase(it);
}
}
else{
++it;

View File

@ -42,6 +42,7 @@ AudioPlayer::AudioPlayer()
, _finishCallbak(nullptr)
, _ready(false)
, _audioCache(nullptr)
, _readForRemove(false)
{
}
@ -59,13 +60,17 @@ AudioPlayer::AudioPlayer(const AudioPlayer& player)
AudioPlayer::~AudioPlayer()
{
_exitThread = true;
if (_audioCache && _audioCache->_queBufferFrames > 0) {
alDeleteBuffers(QUEUEBUFFER_NUM, _bufferIds);
}
}
void AudioPlayer::notifyExitThread()
{
if (_audioCache && _audioCache->_queBufferFrames > 0) {
std::unique_lock<std::mutex> lk(_sleepMutex);
_exitThread = true;
_sleepCondition.notify_all();
if (_rotateBufferThread.joinable()) {
_rotateBufferThread.join();
}
alDeleteBuffers(3, _bufferIds);
}
}
@ -94,11 +99,9 @@ bool AudioPlayer::play2d(AudioCache* cache)
alSourcei(_alSource, AL_LOOPING, AL_FALSE);
auto alError = alGetError();
alGenBuffers(3, _bufferIds);
alGenBuffers(QUEUEBUFFER_NUM, _bufferIds);
alError = alGetError();
if (alError == AL_NO_ERROR) {
_rotateBufferThread = std::thread(&AudioPlayer::rotateBufferThread,this, _audioCache->_queBufferFrames * QUEUEBUFFER_NUM + 1);
for (int index = 0; index < QUEUEBUFFER_NUM; ++index) {
alBufferData(_bufferIds[index], _audioCache->_alBufferFormat, _audioCache->_queBuffers[index], _audioCache->_queBufferSize[index], _audioCache->_sampleRate);
}
@ -110,13 +113,22 @@ bool AudioPlayer::play2d(AudioCache* cache)
}
}
alSourcePlay(_alSource);
_ready = true;
auto alError = alGetError();
if (_streamingSource)
{
_rotateBufferThread = std::thread(&AudioPlayer::rotateBufferThread, this, _audioCache->_queBufferFrames * QUEUEBUFFER_NUM + 1);
_rotateBufferThread.detach();
}
else
{
alSourcePlay(_alSource);
if (alError != AL_NO_ERROR) {
log("%s:alSourcePlay error code:%x\n", __FUNCTION__,alError);
return false;
auto alError = alGetError();
if (alError != AL_NO_ERROR) {
log("%s:alSourcePlay error code:%x\n", __FUNCTION__, alError);
return false;
}
_ready = true;
}
return true;
@ -177,9 +189,13 @@ void AudioPlayer::rotateBufferThread(int offsetFrame)
break;
}
alSourcePlay(_alSource);
while (!_exitThread) {
alGetSourcei(_alSource, AL_SOURCE_STATE, &sourceState);
if (sourceState == AL_PLAYING) {
_ready = true;
alGetSourcei(_alSource, AL_BUFFERS_PROCESSED, &bufferProcessed);
while (bufferProcessed > 0) {
bufferProcessed--;
@ -250,11 +266,13 @@ void AudioPlayer::rotateBufferThread(int offsetFrame)
}
}
if (_exitThread){
std::unique_lock<std::mutex> lk(_sleepMutex);
if (_exitThread)
{
break;
}
std::unique_lock<std::mutex> lk(_sleepMutex);
_sleepCondition.wait_for(lk,std::chrono::milliseconds(75));
_sleepCondition.wait_for(lk,std::chrono::milliseconds(35));
}
ExitBufferThread:
switch (audioFileFormat)
@ -272,6 +290,7 @@ ExitBufferThread:
break;
}
free(tmpBuffer);
_readForRemove = true;
}
bool AudioPlayer::setLoop(bool loop)

View File

@ -37,6 +37,7 @@
#include <AL/al.h>
#endif
#include "CCPlatformMacros.h"
#include "AudioCache.h"
NS_CC_BEGIN
namespace experimental{
@ -55,7 +56,8 @@ public:
bool setTime(float time);
float getTime() { return _currTime;}
bool setLoop(bool loop);
void notifyExitThread();
protected:
void rotateBufferThread(int offsetFrame);
bool play2d(AudioCache* cache);
@ -73,11 +75,12 @@ protected:
float _currTime;
bool _timeDirty;
bool _streamingSource;
ALuint _bufferIds[3];
ALuint _bufferIds[QUEUEBUFFER_NUM];
std::thread _rotateBufferThread;
std::mutex _sleepMutex;
std::condition_variable _sleepCondition;
bool _exitThread;
bool _exitThread;
bool _readForRemove;
friend class AudioEngineImpl;
};

View File

@ -17,8 +17,8 @@
*/
#include "Audio.h"
#include "MediaStreamer.h"
//#include "CCCommon.h"
#include "CCCommon.h"
#include "AudioSourceReader.h"
inline void ThrowIfFailed(HRESULT hr)
{
@ -522,13 +522,34 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
int sound = Hash(pszFilePath);
MediaStreamer mediaStreamer;
mediaStreamer.Initialize(CCUtf8ToUnicode(pszFilePath).c_str());
m_soundEffects[sound].m_soundID = sound;
uint32 bufferLength = mediaStreamer.GetMaxStreamLengthInBytes();
m_soundEffects[sound].m_soundEffectBufferData = new byte[bufferLength];
mediaStreamer.ReadAll(m_soundEffects[sound].m_soundEffectBufferData, bufferLength, &m_soundEffects[sound].m_soundEffectBufferLength);
std::unique_ptr<cocos2d::experimental::AudioSourceReader> reader = std::make_unique<cocos2d::experimental::MP3Reader>();
if (!reader) {
return;
}
static_cast<cocos2d::experimental::MP3Reader*>(reader.get())->doLargeFileSupport(false);
if (!reader->initialize(pszFilePath)) {
return;
}
m_soundEffects[sound].m_soundID = sound;
uint32 bufferLength = reader->getTotalAudioBytes();
WAVEFORMATEX wfx = reader->getWaveFormatInfo();
cocos2d::experimental::AudioDataChunk chunk;
if (!reader->consumeChunk(chunk)) {
return;
}
m_soundEffects[sound].m_soundEffectBufferData = new (std::nothrow) BYTE[chunk._dataSize];
if (nullptr == m_soundEffects[sound].m_soundEffectBufferData) {
return;
}
m_soundEffects[sound].m_soundEffectBufferLength = chunk._dataSize;
CopyMemory(m_soundEffects[sound].m_soundEffectBufferData, chunk._data->data(), chunk._dataSize);
if (isMusic)
{
@ -541,7 +562,7 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
ThrowIfFailed(
m_musicEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&(mediaStreamer.GetOutputWaveFormatEx()), 0, 1.0f, &m_voiceContext, &sends)
&wfx, 0, 1.0f, &m_voiceContext, &sends)
);
//fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_backgroundMusicVolume);
@ -556,13 +577,13 @@ void Audio::PreloadSoundEffect(const char* pszFilePath, bool isMusic)
ThrowIfFailed(
m_soundEffectEngine->CreateSourceVoice(&m_soundEffects[sound].m_soundEffectSourceVoice,
&(mediaStreamer.GetOutputWaveFormatEx()), 0, 1.0f, &m_voiceContext, &sends, nullptr)
&wfx, 0, 1.0f, &m_voiceContext, &sends, nullptr)
);
//fix bug: set a initial volume
m_soundEffects[sound].m_soundEffectSourceVoice->SetVolume(m_soundEffctVolume);
}
m_soundEffects[sound].m_soundEffectSampleRate = mediaStreamer.GetOutputWaveFormatEx().nSamplesPerSec;
m_soundEffects[sound].m_soundEffectSampleRate = wfx.nSamplesPerSec;
// Queue in-memory buffer for playback
ZeroMemory(&m_soundEffects[sound].m_audioBuffer, sizeof(m_soundEffects[sound].m_audioBuffer));

View File

@ -0,0 +1,563 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#include "AudioCachePlayer.h"
using namespace cocos2d;
using namespace cocos2d::experimental;
inline void ThrowIfFailed(HRESULT hr)
{
if (FAILED(hr)) {
// Set a breakpoint on this line to catch XAudio2 API errors.
throw Platform::Exception::CreateException(hr);
}
}
// AudioCache
AudioCache::AudioCache()
: _isReady(false)
, _fileFullPath("")
, _srcReader(nullptr)
, _fileFormat(FileFormat::UNKNOWN)
{
_callbacks.clear();
memset(&_audInfo, 0, sizeof(AudioInfo));
}
AudioCache::~AudioCache()
{
_callbacks.clear();
if (nullptr != _srcReader) {
delete _srcReader;
_srcReader = nullptr;
}
}
void AudioCache::readDataTask()
{
std::wstring path(_fileFullPath.begin(), _fileFullPath.end());
if (nullptr != _srcReader) {
delete _srcReader;
_srcReader = nullptr;
}
switch (_fileFormat)
{
case FileFormat::WAV:
_srcReader = new (std::nothrow) WAVReader();
if (_srcReader && _srcReader->initialize(_fileFullPath)) {
_audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes();
_audInfo._wfx = _srcReader->getWaveFormatInfo();
_isReady = true;
invokeCallbacks();
}
break;
case FileFormat::OGG:
break;
case FileFormat::MP3:
_srcReader = new (std::nothrow) MP3Reader();
if (_srcReader && _srcReader->initialize(_fileFullPath)) {
_audInfo._totalAudioBytes = _srcReader->getTotalAudioBytes();
_audInfo._wfx = _srcReader->getWaveFormatInfo();
_isReady = true;
invokeCallbacks();
}
break;
case FileFormat::UNKNOWN:
default:
break;
}
}
void AudioCache::addCallback(const std::function<void()> &callback)
{
_cbMutex.lock();
if (_isReady) {
callback();
}
else {
_callbacks.push_back(callback);
}
_cbMutex.unlock();
}
void AudioCache::invokeCallbacks()
{
_cbMutex.lock();
auto cnt = _callbacks.size();
for (size_t ind = 0; ind < cnt; ind++)
{
_callbacks[ind]();
}
_callbacks.clear();
_cbMutex.unlock();
}
bool AudioCache::getChunk(AudioDataChunk& chunk)
{
bool ret = false;
if (nullptr != _srcReader) {
ret = _srcReader->consumeChunk(chunk);
}
return ret;
}
void AudioCache::doBuffering()
{
if (isStreamingSource()){
_srcReader->produceChunk();
}
}
bool AudioCache::isStreamingSource()
{
if (nullptr != _srcReader) {
return _srcReader->isStreamingSource();
}
return false;
}
void AudioCache::seek(const float ratio)
{
if (nullptr != _srcReader){
_srcReader->seekTo(ratio);
}
}
// AudioPlayer
AudioPlayer::AudioPlayer()
: _loop(false)
, _ready(false)
, _current(0.0)
, _volume(0.0)
, _duration(0.0)
, _cache(nullptr)
, _totalSamples(0)
, _samplesOffset(0)
, _criticalError(false)
, _isStreaming(false)
, _finishCallback(nullptr)
, _xaMasterVoice(nullptr)
, _xaSourceVoice(nullptr)
, _state(AudioPlayerState::INITIALZING)
{
init();
}
AudioPlayer::~AudioPlayer()
{
free();
}
void AudioPlayer::stop()
{
_stop();
}
void AudioPlayer::pause()
{
_stop(true);
}
bool AudioPlayer::update()
{
if (_criticalError){
free();
init();
}
if (_cache != nullptr) {
_cache->doBuffering();
}
//log("bufferQueued: %d, _current: %f", _cachedBufferQ.size(), _current);
return _criticalError;
}
void AudioPlayer::resume()
{
_play(true);
}
bool AudioPlayer::isInError()
{
return _criticalError;
}
float AudioPlayer::getDuration()
{
if (nullptr == _cache) {
return _duration;
}
auto fmt = _cache->_audInfo._wfx;
if (!fmt.nChannels) {
return _duration;
}
if ((int)_duration <= 0)
{
switch (fmt.wFormatTag)
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_ADPCM:
_duration = (float(_cache->_audInfo._totalAudioBytes / ((fmt.wBitsPerSample / 8) * fmt.nChannels)) / fmt.nSamplesPerSec) * 1000;
_totalSamples = fmt.nSamplesPerSec * _duration / 1000;
break;
default:
break;
}
}
return _duration;
}
float AudioPlayer::getCurrentTime()
{
_stMutex.lock();
auto samplesPlayed = getSourceVoiceState().SamplesPlayed;
//log("_samplesOffset: %lu, samplesPlayed: %lu, _current: %f", (UINT32)_samplesOffset, (UINT32)samplesPlayed, _current);
_current += ((samplesPlayed - _samplesOffset) / (float)_totalSamples) * _duration;
_current = _current > _duration ? 0.0 : _current;
_samplesOffset = samplesPlayed;
_stMutex.unlock();
return _current;
}
bool AudioPlayer::setTime(float time)
{
bool ret = true;
_stop();
if (!_isStreaming) {
auto fmt = _cache->_audInfo._wfx;
int seek = (time / _duration) * _totalSamples;
seek -= (seek % (fmt.nChannels * fmt.nBlockAlign));
_xaBuffer.LoopCount = 0;
_xaBuffer.PlayBegin = seek;
_xaBuffer.PlayLength = _totalSamples - seek;
if (_xaBuffer.PlayBegin >= _totalSamples) {
_xaBuffer.PlayBegin = _totalSamples - (fmt.nChannels * fmt.nBlockAlign);
_xaBuffer.PlayLength = (fmt.nChannels * fmt.nBlockAlign);
}
}
_stMutex.lock();
_samplesOffset = getSourceVoiceState().SamplesPlayed;
_current = time;
_stMutex.unlock();
_play();
return ret;
}
void AudioPlayer::setVolume(float volume)
{
if (_xaMasterVoice != nullptr){
if (FAILED(_xaMasterVoice->SetVolume(volume))) {
error();
}
}
}
bool AudioPlayer::play2d(AudioCache* cache)
{
bool ret = false;
if (cache != nullptr)
{
_cache = cache;
if (nullptr == _xaSourceVoice && _ready) {
XAUDIO2_SEND_DESCRIPTOR descriptors[1];
descriptors[0].pOutputVoice = _xaMasterVoice;
descriptors[0].Flags = 0;
XAUDIO2_VOICE_SENDS sends = { 0 };
sends.SendCount = 1;
sends.pSends = descriptors;
ThrowIfFailed(_xaEngine->CreateSourceVoice(&_xaSourceVoice, &cache->_audInfo._wfx, 0, 1.0, this, &sends));
}
_isStreaming = _cache->isStreamingSource();
_duration = getDuration();
ret = _play();
}
return ret;
}
void AudioPlayer::init()
{
memset(&_xaBuffer, 0, sizeof(_xaBuffer));
ThrowIfFailed(XAudio2Create(_xaEngine.ReleaseAndGetAddressOf()));
#if defined(_DEBUG)
XAUDIO2_DEBUG_CONFIGURATION debugConfig = { 0 };
debugConfig.BreakMask = XAUDIO2_LOG_ERRORS;
debugConfig.TraceMask = XAUDIO2_LOG_ERRORS;
_xaEngine->SetDebugConfiguration(&debugConfig);
#endif
_xaEngine->RegisterForCallbacks(this);
ThrowIfFailed(_xaEngine->CreateMasteringVoice(&_xaMasterVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, nullptr, nullptr, AudioCategory_GameMedia));
_ready = true;
_state = AudioPlayerState::READY;
}
void AudioPlayer::free()
{
_stop();
memset(&_xaBuffer, 0, sizeof(_xaBuffer));
if (_xaEngine) {
_xaEngine->StopEngine();
}
if (_xaSourceVoice != nullptr) {
_xaSourceVoice->DestroyVoice();
_xaSourceVoice = nullptr;
}
if (_xaMasterVoice != nullptr) {
_xaMasterVoice->DestroyVoice();
_xaMasterVoice = nullptr;
}
while (!_cachedBufferQ.empty()) {
popBuffer();
}
}
bool AudioPlayer::_play(bool resume)
{
do {
if (!resume) {
_cache->seek(_current / _duration);
submitBuffers();
}
if (_state == AudioPlayerState::PAUSED && !resume || nullptr == _xaSourceVoice) break;
if (FAILED(_xaSourceVoice->Start())) {
error();
}
else {
_state = AudioPlayerState::PLAYING;
}
} while (false);
return !_criticalError;
}
void AudioPlayer::_stop(bool pause)
{
if (_xaSourceVoice != nullptr) {
if (FAILED(_xaSourceVoice->Stop())) {
error();
}
else {
if (!pause) {
_xaSourceVoice->FlushSourceBuffers();
if (_state != AudioPlayerState::PAUSED) _state = AudioPlayerState::STOPPED;
}
else {
_state = AudioPlayerState::PAUSED;
}
}
}
}
void AudioPlayer::error()
{
_criticalError = true;
_ready = false;
_state = AudioPlayerState::ERRORED;
}
void AudioPlayer::popBuffer()
{
_bqMutex.lock();
if (!_cachedBufferQ.empty()) {
_cachedBufferQ.pop();
}
_bqMutex.unlock();
}
bool AudioPlayer::submitBuffers()
{
bool ret = false;
_bqMutex.lock();
do {
if (nullptr == _xaSourceVoice) break;
if (!_cachedBufferQ.size() || (_isStreaming && _cachedBufferQ.size() < QUEUEBUFFER_NUM)) {
AudioDataChunk chunk;
if (_cache->getChunk(chunk) && chunk._dataSize) {
_xaBuffer.AudioBytes = chunk._dataSize;
_xaBuffer.pAudioData = chunk._data->data();
_xaBuffer.Flags = chunk._endOfStream ? XAUDIO2_END_OF_STREAM : 0;
_cachedBufferQ.push(chunk);
ret = SUCCEEDED(_xaSourceVoice->SubmitSourceBuffer(&_xaBuffer));
if (!_isStreaming) break;
}
else {
break;
}
}
else if (!_isStreaming) {
ret = SUCCEEDED(_xaSourceVoice->SubmitSourceBuffer(&_xaBuffer));
break;
}
else {
break;
}
} while (ret);
_bqMutex.unlock();
return ret;
}
void AudioPlayer::updateState()
{
if (!_isStreaming) {
_stMutex.lock();
_samplesOffset = getSourceVoiceState().SamplesPlayed;
_stMutex.unlock();
}
else {
if (_cachedBufferQ.size() > getSourceVoiceState(true).BuffersQueued) {
popBuffer();
}
}
}
void AudioPlayer::onBufferRunOut()
{
_stMutex.lock();
_samplesOffset = 0;
_current = 0.0;
_xaBuffer.PlayBegin = _xaBuffer.PlayLength = 0;
_stMutex.unlock();
if (!_loop) {
_stop();
//invokeFinishCallback();
}
else {
_play();
}
}
void AudioPlayer::invokeFinishCallback()
{
if (_finishCallback) {
_finishCallback(0, "");
}
}
XAUDIO2_VOICE_STATE AudioPlayer::getSourceVoiceState(bool fast)
{
XAUDIO2_VOICE_STATE state;
memset(&state, 0, sizeof(XAUDIO2_VOICE_STATE));
if (_xaSourceVoice != nullptr) {
_xaSourceVoice->GetState(&state, fast ? XAUDIO2_VOICE_NOSAMPLESPLAYED : 0);
}
return state;
}
// IXAudio2EngineCallback
void AudioPlayer::OnProcessingPassStart()
{
}
void AudioPlayer::OnProcessingPassEnd()
{
}
void AudioPlayer::OnCriticalError(HRESULT err)
{
UNREFERENCED_PARAMETER(err);
error();
}
// IXAudio2VoiceCallback
void AudioPlayer::OnVoiceProcessingPassStart(UINT32 uBytesRequired)
{
if (uBytesRequired && _isStreaming){
submitBuffers();
}
}
void AudioPlayer::OnVoiceProcessingPassEnd()
{
}
void AudioPlayer::OnStreamEnd()
{
onBufferRunOut();
}
void AudioPlayer::OnBufferStart(void* pBufferContext)
{
UNREFERENCED_PARAMETER(pBufferContext);
}
void AudioPlayer::OnBufferEnd(void* pBufferContext)
{
UNREFERENCED_PARAMETER(pBufferContext);
updateState();
}
void AudioPlayer::OnLoopEnd(void* pBufferContext)
{
UNREFERENCED_PARAMETER(pBufferContext);
if (!_loop) {
_stop();
}
}
void AudioPlayer::OnVoiceError(void* pBufferContext, HRESULT err)
{
UNREFERENCED_PARAMETER(pBufferContext);
UNREFERENCED_PARAMETER(err);
error();
}
#endif

View File

@ -0,0 +1,161 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#ifndef __AUDIO_CACHE_PLAYER_H_
#define __AUDIO_CACHE_PLAYER_H_
#include "AudioSourceReader.h"
NS_CC_BEGIN
namespace experimental{
typedef struct AudioInfo
{
size_t _totalAudioBytes;
WAVEFORMATEX _wfx;
} AudioInfo;
enum class AudioPlayerState
{
ERRORED = -1,
INITIALZING,
READY,
PLAYING,
PAUSED,
STOPPED
};
class AudioCache
{
public:
AudioCache();
~AudioCache();
void readDataTask();
void addCallback(const std::function<void()> &callback);
bool getChunk(AudioDataChunk& chunk);
void doBuffering();
bool isStreamingSource();
void seek(const float ratio);
protected:
void invokeCallbacks();
private:
AudioCache(const AudioCache&);
AudioCache& operator=(const AudioCache&);
private:
bool _isReady;
AudioInfo _audInfo;
std::mutex _cbMutex;
FileFormat _fileFormat;
std::string _fileFullPath;
AudioSourceReader *_srcReader;
std::vector<std::function<void()>> _callbacks;
friend class AudioPlayer;
friend class AudioEngineImpl;
};
class AudioPlayer : public IXAudio2EngineCallback, IXAudio2VoiceCallback
{
public:
AudioPlayer();
virtual ~AudioPlayer();
void stop();
void pause();
bool update();
void resume();
bool isInError();
float getDuration();
float getCurrentTime();
bool setTime(float time);
void setVolume(float volume);
bool play2d(AudioCache* cache);
AudioPlayerState getState() { return _state; }
protected:
AudioPlayer(AudioPlayer&);
AudioPlayer& operator=(AudioPlayer&);
void init();
void free();
void error();
void popBuffer();
void updateState();
bool submitBuffers();
void onBufferRunOut();
void invokeFinishCallback();
void _stop(bool pause = false);
bool _play(bool resume = false);
XAUDIO2_VOICE_STATE getSourceVoiceState(bool fast = false);
// IXAudio2EngineCallback
STDMETHOD_(void, OnProcessingPassStart) () override;
STDMETHOD_(void, OnProcessingPassEnd) () override;
STDMETHOD_(void, OnCriticalError) (HRESULT error) override;
// IXAudio2VoiceCallback
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32 uBytesRequired) override;
STDMETHOD_(void, OnVoiceProcessingPassEnd) () override;
STDMETHOD_(void, OnStreamEnd) () override;
STDMETHOD_(void, OnBufferStart) (void* pBufferContext) override;
STDMETHOD_(void, OnBufferEnd) (void* pBufferContext) override;
STDMETHOD_(void, OnLoopEnd) (void* pBufferContext) override;
STDMETHOD_(void, OnVoiceError) (void *pBufferContext, HRESULT error) override;
private:
bool _loop;
bool _ready;
float _volume;
float _current;
float _duration;
bool _criticalError;
bool _isStreaming;
UINT64 _totalSamples;
UINT64 _samplesOffset;
XAUDIO2_BUFFER _xaBuffer;
IXAudio2SourceVoice *_xaSourceVoice;
IXAudio2MasteringVoice *_xaMasterVoice;
Microsoft::WRL::ComPtr<IXAudio2> _xaEngine;
AudioCache *_cache;
std::mutex _stMutex;
std::mutex _bqMutex;
AudioPlayerState _state;
std::queue<AudioDataChunk> _cachedBufferQ;
std::function<void(int, const std::string &)> _finishCallback;
friend class AudioEngineImpl;
};
}
NS_CC_END
#endif // __AUDIO_CACHE_PLAYER_H_
#endif

View File

@ -0,0 +1,430 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#include "AudioEngine-winrt.h"
#include <condition_variable>
using namespace cocos2d;
using namespace cocos2d::experimental;
namespace cocos2d {
namespace experimental {
class AudioEngineThreadPool
{
public:
AudioEngineThreadPool()
: _running(true)
, _numThread(6)
{
_threads.reserve(_numThread);
_tasks.reserve(_numThread);
for (int index = 0; index < _numThread; ++index) {
_tasks.push_back(nullptr);
_threads.push_back(std::thread(std::bind(&AudioEngineThreadPool::threadFunc, this, index)));
}
}
void addTask(const std::function<void()> &task){
_taskMutex.lock();
int targetIndex = -1;
for (int index = 0; index < _numThread; ++index) {
if (_tasks[index] == nullptr) {
targetIndex = index;
_tasks[index] = task;
break;
}
}
if (targetIndex == -1) {
_tasks.push_back(task);
_threads.push_back(std::thread(std::bind(&AudioEngineThreadPool::threadFunc, this, _numThread)));
_numThread++;
}
_taskMutex.unlock();
_sleepCondition.notify_all();
}
void destroy()
{
_running = false;
_sleepCondition.notify_all();
for (int index = 0; index < _numThread; ++index) {
_threads[index].join();
}
}
private:
bool _running;
std::vector<std::thread> _threads;
std::vector< std::function<void()> > _tasks;
void threadFunc(int index)
{
while (_running) {
std::function<void()> task = nullptr;
_taskMutex.lock();
task = _tasks[index];
_taskMutex.unlock();
if (nullptr == task)
{
std::unique_lock<std::mutex> lk(_sleepMutex);
_sleepCondition.wait(lk);
continue;
}
task();
_taskMutex.lock();
_tasks[index] = nullptr;
_taskMutex.unlock();
}
}
int _numThread;
std::mutex _taskMutex;
std::mutex _sleepMutex;
std::condition_variable _sleepCondition;
};
}
}
AudioEngineImpl::AudioEngineImpl()
: _lazyInitLoop(true)
, _currentAudioID(0)
, _threadPool(nullptr)
{
}
AudioEngineImpl::~AudioEngineImpl()
{
_audioCaches.clear();
if (_threadPool) {
_threadPool->destroy();
delete _threadPool;
}
}
bool AudioEngineImpl::init()
{
bool ret = false;
if (nullptr == _threadPool) {
_threadPool = new (std::nothrow) AudioEngineThreadPool();
}
ret = true;
return ret;
}
int AudioEngineImpl::play2d(const std::string &filePath, bool loop, float volume)
{
AudioCache* audioCache = nullptr;
auto it = _audioCaches.find(filePath);
if (it == _audioCaches.end()) {
audioCache = &_audioCaches[filePath];
auto ext = filePath.substr(filePath.rfind('.'));
transform(ext.begin(), ext.end(), ext.begin(), tolower);
bool eraseCache = true;
if (ext.compare(".wav") == 0){
audioCache->_fileFormat = FileFormat::WAV;
eraseCache = false;
}
else if (ext.compare(".ogg") == 0){
audioCache->_fileFormat = FileFormat::OGG;
//eraseCache = false; //TODO add support for OGG
}
else if (ext.compare(".mp3") == 0){
audioCache->_fileFormat = FileFormat::MP3;
eraseCache = false;
}
else{
log("unsupported media type:%s\n", ext.c_str());
eraseCache = false;
}
if (eraseCache){
_audioCaches.erase(filePath);
return AudioEngine::INVALID_AUDIO_ID;
}
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath);
audioCache->_fileFullPath = fullPath;
_threadPool->addTask(std::bind(&AudioCache::readDataTask, audioCache));
}
else {
audioCache = &it->second;
}
auto player = &_audioPlayers[_currentAudioID];
player->_loop = loop;
player->_volume = volume;
audioCache->addCallback(std::bind(&AudioEngineImpl::_play2d, this, audioCache, _currentAudioID));
if (_lazyInitLoop) {
_lazyInitLoop = false;
auto scheduler = cocos2d::Director::getInstance()->getScheduler();
scheduler->schedule(schedule_selector(AudioEngineImpl::update), this, 0.05f, false);
}
return _currentAudioID++;
}
void AudioEngineImpl::_play2d(AudioCache *cache, int audioID)
{
if (cache->_isReady){
auto playerIt = _audioPlayers.find(audioID);
if (playerIt != _audioPlayers.end()) {
if (playerIt->second.play2d(cache)) {
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PLAYING;
}
else{
_threadMutex.lock();
_toRemoveAudioIDs.push_back(audioID);
_threadMutex.unlock();
}
}
}
else {
_threadMutex.lock();
_toRemoveCaches.push_back(cache);
_toRemoveAudioIDs.push_back(audioID);
_threadMutex.unlock();
}
}
void AudioEngineImpl::setVolume(int audioID, float volume)
{
auto& player = _audioPlayers[audioID];
if (player._ready){
player.setVolume(volume);
}
if (player.isInError()) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
}
void AudioEngineImpl::setLoop(int audioID, bool loop)
{
auto& player = _audioPlayers[audioID];
if (player._ready) {
player._loop = loop;
}
if (player.isInError()) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
}
bool AudioEngineImpl::pause(int audioID)
{
bool ret = false;
auto& player = _audioPlayers[audioID];
if (player._ready) {
player.pause();
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PAUSED;
}
ret = !player.isInError();
if (!ret) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
return ret;
}
bool AudioEngineImpl::resume(int audioID)
{
bool ret = false;
auto& player = _audioPlayers[audioID];
if (player._ready) {
player.resume();
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PLAYING;
}
ret = !player.isInError();
if (!ret) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
return ret;
}
bool AudioEngineImpl::stop(int audioID)
{
bool ret = false;
auto& player = _audioPlayers[audioID];
if (player._ready) {
player.stop();
ret = !player.isInError();
}
if (!ret) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
_audioPlayers.erase(audioID);
return ret;
}
void AudioEngineImpl::stopAll()
{
for (auto &player : _audioPlayers) {
player.second.stop();
}
_audioPlayers.clear();
}
float AudioEngineImpl::getDuration(int audioID)
{
auto& player = _audioPlayers[audioID];
if (player._ready) {
return player.getDuration();
}
else {
return AudioEngine::TIME_UNKNOWN;
}
}
float AudioEngineImpl::getCurrentTime(int audioID)
{
float ret = 0.0f;
auto& player = _audioPlayers[audioID];
if (player._ready) {
ret = player.getCurrentTime();
}
return ret;
}
bool AudioEngineImpl::setCurrentTime(int audioID, float time)
{
bool ret = false;
auto& player = _audioPlayers[audioID];
if (player._ready) {
ret = player.setTime(time);
}
if (!ret) {
log("%s: audio id = %d, error.\n", __FUNCTION__, audioID);
}
return ret;
}
void AudioEngineImpl::setFinishCallback(int audioID, const std::function<void(int, const std::string &)> &callback)
{
_audioPlayers[audioID]._finishCallback = callback;
}
void AudioEngineImpl::update(float dt)
{
int audioID;
if (_threadMutex.try_lock()) {
size_t removeAudioCount = _toRemoveAudioIDs.size();
for (size_t index = 0; index < removeAudioCount; ++index) {
audioID = _toRemoveAudioIDs[index];
auto playerIt = _audioPlayers.find(audioID);
if (playerIt != _audioPlayers.end()) {
if (playerIt->second._finishCallback) {
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
playerIt->second._finishCallback(audioID, *audioInfo.filePath);
}
_audioPlayers.erase(audioID);
AudioEngine::remove(audioID);
}
}
size_t removeCacheCount = _toRemoveCaches.size();
for (size_t index = 0; index < removeCacheCount; ++index) {
auto itEnd = _audioCaches.end();
for (auto it = _audioCaches.begin(); it != itEnd; ++it) {
if (&it->second == _toRemoveCaches[index]) {
_audioCaches.erase(it);
break;
}
}
}
_threadMutex.unlock();
}
for (auto it = _audioPlayers.begin(); it != _audioPlayers.end();) {
audioID = it->first;
auto& player = it->second;
if (player._ready && player._state == AudioPlayerState::STOPPED) {
if (player._finishCallback) {
auto& audioInfo = AudioEngine::_audioIDInfoMap[audioID];
player._finishCallback(audioID, *audioInfo.filePath);
}
AudioEngine::remove(audioID);
it = _audioPlayers.erase(it);
}
else{
player.update();
++it;
}
}
if (_audioPlayers.empty()){
_lazyInitLoop = true;
auto scheduler = cocos2d::Director::getInstance()->getScheduler();
scheduler->unschedule(schedule_selector(AudioEngineImpl::update), this);
}
}
void AudioEngineImpl::uncache(const std::string &filePath)
{
_audioCaches.erase(filePath);
}
void AudioEngineImpl::uncacheAll()
{
_audioCaches.clear();
}
#endif

View File

@ -0,0 +1,82 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#ifndef __AUDIO_ENGINE_WINRT_H_
#define __AUDIO_ENGINE_WINRT_H_
#define NEAR near
#include <unordered_map>
#include "base/CCRef.h"
#include "AudioEngine.h"
#include "AudioCachePlayer.h"
NS_CC_BEGIN
namespace experimental{
#define MAX_AUDIOINSTANCES 32
class AudioEngineThreadPool;
class CC_DLL AudioEngineImpl : public cocos2d::Ref
{
public:
AudioEngineImpl();
~AudioEngineImpl();
bool init();
int play2d(const std::string &fileFullPath, bool loop, float volume);
void setVolume(int audioID, float volume);
void setLoop(int audioID, bool loop);
bool pause(int audioID);
bool resume(int audioID);
bool stop(int audioID);
void stopAll();
float getDuration(int audioID);
float getCurrentTime(int audioID);
bool setCurrentTime(int audioID, float time);
void setFinishCallback(int audioID, const std::function<void(int, const std::string &)> &callback);
void uncache(const std::string& filePath);
void uncacheAll();
void update(float dt);
private:
void _play2d(AudioCache *cache, int audioID);
private:
std::unordered_map<int, AudioPlayer> _audioPlayers;
std::unordered_map<std::string, AudioCache> _audioCaches;
std::vector<AudioCache*> _toRemoveCaches;
std::mutex _threadMutex;
std::vector<int> _toRemoveAudioIDs;
bool _lazyInitLoop;
int _currentAudioID;
AudioEngineThreadPool* _threadPool;
};
}
NS_CC_END
#endif // __AUDIO_ENGINE_WINRT_H_
#endif

View File

@ -0,0 +1,523 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#include "CCWinRTUtils.h"
#include "AudioSourceReader.h"
using namespace cocos2d;
using namespace cocos2d::experimental;
using namespace Microsoft::WRL;
// AudioFileReader
AudioSourceReader::AudioSourceReader() :
_isStreaming(false)
, _filePath("")
, _audioSize(0)
, _bytesRead(0)
, _isDirty(false)
{
memset(&_wfx, 0, sizeof(_wfx));
}
AudioSourceReader::~AudioSourceReader()
{
flushChunks();
}
void AudioSourceReader::flushChunks()
{
_rwMutex.lock();
while (!_chnkQ.empty()) {
_chnkQ.pop();
}
_rwMutex.unlock();
}
// WAVFileReader
WAVReader::WAVReader() :
_streamer(nullptr)
{
}
WAVReader::~WAVReader()
{
}
bool WAVReader::initialize(const std::string& filePath)
{
bool ret = false;
_isStreaming = false;
_filePath = filePath;
do {
auto fileSize = FileUtils::getInstance()->getFileSize(_filePath);
if (fileSize <= 0)
break;
flushChunks();
_rwMutex.lock();
_streamer = ref new MediaStreamer;
_streamer->Initialize(std::wstring(_filePath.begin(), _filePath.end()).c_str(), true);
_rwMutex.unlock();
_wfx = _streamer->GetOutputWaveFormatEx();
UINT32 dataSize = _streamer->GetMaxStreamLengthInBytes();
if (dataSize <= 0)
break;
_audioSize = dataSize;
if (_audioSize <= PCMDATA_CACHEMAXSIZE) {
produceChunk();
}
else {
_isStreaming = true;
for (int i = 0; i < QUEUEBUFFER_NUM; i++) {
produceChunk();
}
}
ret = true;
} while (false);
return ret;
}
bool WAVReader::consumeChunk(AudioDataChunk& chunk)
{
bool ret = false;
_isDirty = true;
_rwMutex.lock();
if (_chnkQ.size() > 0) {
chunk = _chnkQ.front();
if (_isStreaming) {
_chnkQ.pop();
}
ret = true;
}
_rwMutex.unlock();
return ret;
}
void WAVReader::produceChunk()
{
_rwMutex.lock();
int chunkSize = _audioSize;
do {
if (!_isStreaming && _chnkQ.size() || _chnkQ.size() >= QUEUEBUFFER_NUM) {
break;
}
if (_isStreaming) {
chunkSize = std::min(CHUNK_SIZE_MAX, _audioSize - _bytesRead);
}
if (!chunkSize && !_chnkQ.size()) {
auto alignment = _wfx.nChannels * _wfx.nBlockAlign;
_bytesRead -= alignment;
chunkSize = alignment;
}
if (!chunkSize) {
break;
}
UINT retSize = 0;
AudioDataChunk chunk = { 0 };
chunk._data = std::make_shared<PCMBuffer>(chunkSize);
_streamer->ReadChunk(chunk._data->data(), _bytesRead, chunkSize, &retSize);
_bytesRead += retSize;
chunk._dataSize = retSize;
chunk._seqNo = ((float)_bytesRead / _audioSize) * ((float)_audioSize / CHUNK_SIZE_MAX);
chunk._endOfStream = (_bytesRead >= _audioSize);
_chnkQ.push(chunk);
} while (false);
_rwMutex.unlock();
}
void WAVReader::seekTo(const float ratio)
{
if (_isStreaming) {
auto newPos = ratio * _audioSize;
if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position
return;
_bytesRead = newPos;
flushChunks();
switch (_wfx.wFormatTag)
{
case WAVE_FORMAT_PCM:
case WAVE_FORMAT_ADPCM: {
auto alignment = _wfx.nChannels * _wfx.nBlockAlign;
_bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment);
} break;
default:
break;
}
for (int i = 0; i < QUEUEBUFFER_NUM; i++) {
produceChunk();
}
}
}
// MP3Reader
MP3Reader::MP3Reader() :
_mappedWavFile("")
, _largeFileSupport(true)
{
}
MP3Reader::~MP3Reader()
{
}
bool MP3Reader::initialize(const std::string& filePath)
{
bool ret = false;
_filePath = filePath;
HRESULT hr = S_OK;
MFStartup(MF_VERSION);
do {
ComPtr<IMFSourceReader> pReader;
ComPtr<IMFMediaType> ppDecomprsdAudioType;
if (FAILED(hr = MFCreateSourceReaderFromURL(std::wstring(_filePath.begin(), _filePath.end()).c_str(), NULL, &pReader))) {
break;
}
hr = configureSourceReader(pReader.Get(), &ppDecomprsdAudioType);
if (FAILED(hr)) {
break;
}
UINT32 cbFormat = 0;
WAVEFORMATEX *pWav = nullptr;
if (FAILED(hr = MFCreateWaveFormatExFromMFMediaType(ppDecomprsdAudioType.Get(), &pWav, &cbFormat))) {
break;
}
CopyMemory(&_wfx, pWav, sizeof(WAVEFORMATEX));
CoTaskMemFree(pWav);
if (FAILED(hr = readAudioData(pReader.Get()))) {
break;
}
ret = SUCCEEDED(hr);
} while (false);
MFShutdown();
return ret;
}
bool MP3Reader::consumeChunk(AudioDataChunk& chunk)
{
bool ret = false;
_isDirty = true;
_rwMutex.lock();
if (_chnkQ.size() > 0) {
chunk = _chnkQ.front();
if (_isStreaming) {
_chnkQ.pop();
}
ret = true;
}
_rwMutex.unlock();
return ret;
}
void MP3Reader::produceChunk()
{
_rwMutex.lock();
int chunkSize = _audioSize;
do {
if (!_isStreaming && _chnkQ.size() || _chnkQ.size() >= QUEUEBUFFER_NUM) {
break;
}
if (_isStreaming) {
chunkSize = std::min(CHUNK_SIZE_MAX, _audioSize - _bytesRead);
}
if (!chunkSize && !_chnkQ.size()) {
auto alignment = _wfx.nChannels * _wfx.nBlockAlign;
_bytesRead -= alignment;
chunkSize = alignment;
}
if (!chunkSize) {
break;
}
UINT retSize = 0;
AudioDataChunk chunk = { 0 };
chunk._data = std::make_shared<PCMBuffer>(chunkSize);
readFromMappedWavFile(chunk._data->data(), _bytesRead, chunkSize, &retSize);
_bytesRead += retSize;
chunk._dataSize = retSize;
chunk._seqNo = ((float)_bytesRead / _audioSize) * ((float)_audioSize / CHUNK_SIZE_MAX);
chunk._endOfStream = (_bytesRead >= _audioSize);
_chnkQ.push(chunk);
} while (false);
_rwMutex.unlock();
}
void MP3Reader::seekTo(const float ratio)
{
if (_isStreaming) {
auto newPos = ratio * _audioSize;
if (!newPos && !_isDirty && _chnkQ.size()) // already in 0.0 position
return;
_bytesRead = newPos;
flushChunks();
auto alignment = _wfx.nChannels * _wfx.nBlockAlign;
_bytesRead = _bytesRead >= _audioSize ? (_audioSize - alignment) : _bytesRead - (_bytesRead % alignment);
for (int i = 0; i < QUEUEBUFFER_NUM; i++) {
produceChunk();
}
}
}
HRESULT MP3Reader::configureSourceReader(IMFSourceReader* pReader, IMFMediaType** ppDecomprsdAudioType)
{
HRESULT hr = S_OK;
do {
ComPtr<IMFMediaType> pTmpMediaType;
ComPtr<IMFMediaType> pRetMediaType;
pReader->SetStreamSelection(MF_SOURCE_READER_ALL_STREAMS, FALSE);
pReader->SetStreamSelection(MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE);
if (FAILED(hr = MFCreateMediaType(&pTmpMediaType))) {
break;
}
if (FAILED(hr = pTmpMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio))) {
break;
}
if (FAILED(hr = pTmpMediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM))) {
break;
}
if (FAILED(hr = pReader->SetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, pTmpMediaType.Get()))) {
break;
}
if (FAILED(hr = pReader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, &pRetMediaType))) {
break;
}
if (FAILED(hr = pReader->SetStreamSelection(MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE))) {
break;
}
*ppDecomprsdAudioType = pRetMediaType.Get();
(*ppDecomprsdAudioType)->AddRef();
} while (false);
return hr;
}
HRESULT MP3Reader::readAudioData(IMFSourceReader* pReader)
{
HRESULT hr = S_OK;
do {
PCMBuffer buffer;
if (createMappedCacheFile(_filePath, _mappedWavFile, ".dat")) {
_isStreaming = _largeFileSupport;
_audioSize = FileUtils::getInstance()->getFileSize(_mappedWavFile);
if (!_largeFileSupport) {
buffer.resize(_audioSize);
readFromMappedWavFile(buffer.data(), 0, _audioSize, nullptr);
chunkify(buffer);
}
break;
}
buffer.reserve(PCMDATA_CACHEMAXSIZE);
while (SUCCEEDED(hr))
{
DWORD flags = 0;
DWORD cbSize = 0;
BYTE* pAudioData = nullptr;
ComPtr<IMFSample> pSample;
ComPtr<IMFMediaBuffer> pBuffer;
if (FAILED(hr = pReader->ReadSample(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &flags, NULL, &pSample))) {
break;
}
if (flags & MF_SOURCE_READERF_ENDOFSTREAM) {
break;
}
if (FAILED(hr = pSample->ConvertToContiguousBuffer(&pBuffer))) {
break;
}
if (FAILED(hr = pBuffer->Lock(&pAudioData, NULL, &cbSize))) {
break;
}
if (_largeFileSupport && _audioSize + cbSize > PCMDATA_CACHEMAXSIZE) {
if (!_isStreaming) {
_isStreaming = true;
chunkify(buffer);
appendToMappedWavFile(buffer);
buffer.clear();
}
buffer.resize(cbSize);
CopyMemory(buffer.data(), pAudioData, cbSize);
appendToMappedWavFile(buffer);
buffer.clear();
}
else {
buffer.resize(_audioSize + cbSize);
CopyMemory(&buffer[_audioSize], pAudioData, cbSize);
}
_audioSize += cbSize;
hr = pBuffer->Unlock();
pAudioData = NULL;
}
if (FAILED(hr)) {
break;
}
if (!_isStreaming) {
chunkify(buffer);
_audioSize > PCMDATA_CACHEMAXSIZE ?
appendToMappedWavFile(buffer) :
destroyMappedCacheFile(_filePath);
}
} while (false);
return hr;
}
void MP3Reader::chunkify(PCMBuffer& buffer)
{
_rwMutex.lock();
size_t offset = 0;
if (buffer.size() && _chnkQ.size() < QUEUEBUFFER_NUM)
{
AudioDataChunk chunk = { 0 };
int chunkSize = buffer.size();
chunk._data = std::make_shared<PCMBuffer>(buffer);
_bytesRead += chunkSize;
chunk._dataSize = chunkSize;
chunk._endOfStream = (!_isStreaming && _bytesRead >= _audioSize);
chunk._seqNo = ((float)_bytesRead / _audioSize) * ((float)_audioSize / CHUNK_SIZE_MAX);
_chnkQ.push(chunk);
offset += chunkSize;
}
_rwMutex.unlock();
}
bool MP3Reader::appendToMappedWavFile(PCMBuffer& buffer)
{
bool ret = false;
_rwMutex.lock();
do {
auto file = openFile(_mappedWavFile, true);
if (file.Get() == INVALID_HANDLE_VALUE) {
break;
}
LARGE_INTEGER li = { 0 };
if (!SetFilePointerEx(file.Get(), li, nullptr, FILE_END)) {
break;
}
ret = (TRUE == WriteFile(file.Get(), buffer.data(), buffer.size(), nullptr, nullptr));
} while (false);
_rwMutex.unlock();
return ret;
}
void MP3Reader::readFromMappedWavFile(BYTE *data, size_t offset, int size, UINT *pRetSize)
{
do {
auto file = openFile(_mappedWavFile);
if (file.Get() == INVALID_HANDLE_VALUE) {
break;
}
if (offset) {
LARGE_INTEGER li = { 0 };
li.QuadPart = offset;
if (!SetFilePointerEx(file.Get(), li, nullptr, FILE_BEGIN)) {
break;
}
}
ReadFile(file.Get(), data, size, (LPDWORD)pRetSize, nullptr);
} while (false);
}
Wrappers::FileHandle MP3Reader::openFile(const std::string& path, bool append)
{
CREATEFILE2_EXTENDED_PARAMETERS extParams = { 0 };
extParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
extParams.dwFileFlags = FILE_FLAG_RANDOM_ACCESS;
extParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
extParams.dwSize = sizeof(extParams);
extParams.hTemplateFile = nullptr;
extParams.lpSecurityAttributes = nullptr;
DWORD access = append ? GENERIC_WRITE : GENERIC_READ;
DWORD creation = append ? OPEN_ALWAYS : OPEN_EXISTING;
return Microsoft::WRL::Wrappers::FileHandle(CreateFile2(std::wstring(path.begin(), path.end()).c_str(), access, FILE_SHARE_READ, creation, &extParams));
}
#endif

View File

@ -0,0 +1,139 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2011 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#ifndef __AUDIO_SOURCE_READER_H_
#define __AUDIO_SOURCE_READER_H_
#define NEAR near
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
#include <queue>
#include <mutex>
#include "MediaStreamer.h"
NS_CC_BEGIN
namespace experimental{
const UINT PCMDATA_CACHEMAXSIZE = 2621440;
const UINT QUEUEBUFFER_NUM = 4;
const UINT CHUNK_SIZE_MAX = PCMDATA_CACHEMAXSIZE / QUEUEBUFFER_NUM;
typedef std::vector<BYTE> PCMBuffer;
enum class FileFormat
{
UNKNOWN,
WAV,
MP3,
OGG
};
typedef struct AudioDataChunk
{
std::shared_ptr<PCMBuffer> _data;
size_t _dataSize;
bool _endOfStream;
int _seqNo;
} AudioDataChunk;
class AudioSourceReader
{
public:
AudioSourceReader();
virtual ~AudioSourceReader();
bool isStreamingSource() { return _isStreaming; }
std::string getFilePath() { return _filePath; }
virtual size_t getTotalAudioBytes() { return _audioSize; }
virtual bool initialize(const std::string& filePath) = 0;
virtual FileFormat getFileFormat() = 0;
virtual bool consumeChunk(AudioDataChunk& chunk) = 0;
virtual void produceChunk() = 0;
virtual void seekTo(const float ratio) = 0;
virtual const WAVEFORMATEX& getWaveFormatInfo() { return _wfx; }
protected:
void flushChunks();
protected:
bool _isDirty;
size_t _bytesRead;
bool _isStreaming;
std::string _filePath;
size_t _audioSize;
WAVEFORMATEX _wfx;
std::mutex _rwMutex;
std::queue<AudioDataChunk> _chnkQ;
};
class WAVReader : public AudioSourceReader
{
public:
WAVReader();
virtual ~WAVReader();
virtual bool initialize(const std::string& filePath) override;
virtual FileFormat getFileFormat() override { return FileFormat::WAV; }
virtual bool consumeChunk(AudioDataChunk& chunk) override;
virtual void produceChunk() override;
virtual void seekTo(const float ratio) override;
private:
MediaStreamer^ _streamer;
};
class MP3Reader : public AudioSourceReader
{
public:
MP3Reader();
virtual ~MP3Reader();
virtual bool initialize(const std::string& filePath) override;
virtual FileFormat getFileFormat() override { return FileFormat::WAV; }
virtual bool consumeChunk(AudioDataChunk& chunk) override;
virtual void produceChunk() override;
virtual void seekTo(const float ratio) override;
// for backward compatibility with simple audio engine
void doLargeFileSupport(bool action) { _largeFileSupport = action; }
protected:
HRESULT configureSourceReader(IMFSourceReader* pReader, IMFMediaType** ppDecomprsdAudioType);
HRESULT readAudioData(IMFSourceReader* pReader);
void chunkify(PCMBuffer& buffer);
bool appendToMappedWavFile(PCMBuffer& buffer);
void readFromMappedWavFile(BYTE *data, size_t offset, int size, UINT *pRetSize);
Microsoft::WRL::Wrappers::FileHandle openFile(const std::string& path, bool append = false);
private:
bool _largeFileSupport;
std::string _mappedWavFile;
};
}
NS_CC_END
#endif // __AUDIO_SOURCE_READER_H_
#endif

View File

@ -39,6 +39,8 @@ using namespace Concurrency;
((uint32)(byte)(ch2) << 16) | ((uint32)(byte)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
const int FMT_CHUNK_MAX = 256;
inline void ThrowIfFailed(HRESULT hr)
{
if (FAILED(hr))
@ -50,6 +52,8 @@ inline void ThrowIfFailed(HRESULT hr)
MediaStreamer::MediaStreamer() :
m_offset(0)
, m_dataLen(0)
, m_filename(nullptr)
{
ZeroMemory(&m_waveFormat, sizeof(m_waveFormat));
m_location = Package::Current->InstalledLocation;
@ -59,39 +63,33 @@ MediaStreamer::MediaStreamer() :
MediaStreamer::~MediaStreamer()
{
}
Platform::Array<byte>^ MediaStreamer::ReadData(
_In_ Platform::String^ filename
)
Platform::Array<byte>^ MediaStreamer::ReadData(_In_ Platform::String^ filename)
{
return ReadData(filename, 0, 0);
}
Platform::Array<byte>^ MediaStreamer::ReadData(_In_ Platform::String^ filename, uint32 from, uint32 length)
{
CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0};
extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);
extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN;
extendedParams.dwFileFlags = from ? FILE_FLAG_RANDOM_ACCESS : FILE_FLAG_SEQUENTIAL_SCAN;
extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
extendedParams.lpSecurityAttributes = nullptr;
extendedParams.hTemplateFile = nullptr;
Wrappers::FileHandle file(
CreateFile2(
filename->Data(),
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
&extendedParams
)
CreateFile2(filename->Data(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, &extendedParams)
);
if (file.Get()==INVALID_HANDLE_VALUE)
{
throw ref new Platform::FailureException();
}
FILE_STANDARD_INFO fileInfo = {0};
if (!GetFileInformationByHandleEx(
file.Get(),
FileStandardInfo,
&fileInfo,
sizeof(fileInfo)
))
FILE_STANDARD_INFO fileInfo = { 0 };
if (!GetFileInformationByHandleEx(file.Get(), FileStandardInfo, &fileInfo, sizeof(fileInfo)))
{
throw ref new Platform::FailureException();
}
@ -101,15 +99,21 @@ Platform::Array<byte>^ MediaStreamer::ReadData(
throw ref new Platform::OutOfMemoryException();
}
Platform::Array<byte>^ fileData = ref new Platform::Array<byte>(fileInfo.EndOfFile.LowPart);
from += m_offset;
length = (length == 0 || from + length > fileInfo.EndOfFile.LowPart) ? fileInfo.EndOfFile.LowPart - from : length;
Platform::Array<byte>^ fileData = ref new Platform::Array<byte>(length);
if (!ReadFile(
file.Get(),
fileData->Data,
fileData->Length,
nullptr,
nullptr
) )
if (from)
{
LARGE_INTEGER pos = { 0 };
pos.QuadPart = from;
if (!SetFilePointerEx(file.Get(), pos, nullptr, FILE_BEGIN))
{
throw ref new Platform::FailureException();
}
}
if (!ReadFile(file.Get(), fileData->Data, fileData->Length, nullptr, nullptr))
{
throw ref new Platform::FailureException();
}
@ -117,9 +121,9 @@ Platform::Array<byte>^ MediaStreamer::ReadData(
return fileData;
}
void MediaStreamer::Initialize(__in const WCHAR* url)
void MediaStreamer::Initialize(__in const WCHAR* url, bool lazy)
{
m_filename = ref new Platform::String(url);
WCHAR filePath[MAX_PATH] = {0};
if ((wcslen(url) > 1 && url[1] == ':'))
{
@ -139,8 +143,7 @@ void MediaStreamer::Initialize(__in const WCHAR* url)
wcscat_s(filePath, url);
}
Platform::Array<byte>^ data = ReadData(ref new Platform::String(filePath));
Platform::Array<byte>^ data = lazy ? ReadData(ref new Platform::String(filePath), 0, FMT_CHUNK_MAX) : ReadData(ref new Platform::String(filePath));
UINT32 length = data->Length;
const byte * dataPtr = data->Data;
UINT32 offset = 0;
@ -197,22 +200,45 @@ void MediaStreamer::Initialize(__in const WCHAR* url)
// Locate the 'data' chunk and copy its contents to a buffer.
ThrowIfFailed(ReadChunk(MAKEFOURCC('d', 'a', 't', 'a'), chunkSize, chunkPos));
m_data.resize(chunkSize);
CopyMemory(m_data.data(), &dataPtr[chunkPos], chunkSize);
m_dataLen = chunkSize;
m_offset = chunkPos;
m_offset = 0;
if (!lazy)
{
m_data.resize(chunkSize);
CopyMemory(m_data.data(), &dataPtr[chunkPos], chunkSize);
m_offset = 0;
}
}
void MediaStreamer::ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength)
{
UINT32 toCopy = m_data.size() - m_offset;
if (toCopy > maxBufferSize) toCopy = maxBufferSize;
if (!m_data.size())
{
ReadChunk(buffer, 0, m_dataLen, bufferLength);
}
else
{
UINT32 toCopy = m_data.size() - m_offset;
if (toCopy > maxBufferSize) toCopy = maxBufferSize;
CopyMemory(buffer, m_data.data(), toCopy);
*bufferLength = toCopy;
CopyMemory(buffer, m_data.data(), toCopy);
*bufferLength = toCopy;
m_offset += toCopy;
if (m_offset > m_data.size()) m_offset = m_data.size();
m_offset += toCopy;
if (m_offset > m_data.size()) m_offset = m_data.size();
}
}
void MediaStreamer::ReadChunk(uint8* buffer, uint32 from, uint32 length, uint32* bytesRead)
{
Platform::Array<byte>^ data = ReadData(m_filename, from, length);
*bytesRead = data->Length;
if (*bytesRead > 0)
{
CopyMemory(buffer, (byte*)data->Data, data->Length);
}
}
void MediaStreamer::Restart()

View File

@ -29,9 +29,12 @@ private:
uint32 m_maxStreamLengthInBytes;
std::vector<byte> m_data;
UINT32 m_offset;
Platform::Array<byte>^ ReadData(
_In_ Platform::String^ filename
);
UINT32 m_dataLen;
Platform::String^ m_filename;
Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename);
Platform::Array<byte>^ ReadData(_In_ Platform::String^ filename, uint32 from, uint32 length);
internal:
Windows::Storage::StorageFolder^ m_location;
Platform::String^ m_locationPath;
@ -49,10 +52,11 @@ internal:
UINT32 GetMaxStreamLengthInBytes()
{
return m_data.size();
return m_dataLen;
}
void Initialize(_In_ const WCHAR* url);
void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
void Initialize(_In_ const WCHAR* url, bool lazy = false);
void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
void ReadChunk(uint8* buffer, uint32 from, uint32 length, uint32* bytesRead);
void Restart();
};

View File

@ -18,10 +18,12 @@
#include "SimpleAudioEngine.h"
#include "Audio.h"
#include "cocos2d.h"
#include <map>
//#include "CCCommon.h"
using namespace std;
USING_NS_CC;
namespace CocosDenshion {
@ -81,7 +83,8 @@ void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
return;
}
sharedAudioController()->PlayBackgroundMusic(pszFilePath, bLoop);
string fullPath = CCFileUtils::getInstance()->fullPathForFilename(pszFilePath);
sharedAudioController()->PlayBackgroundMusic(fullPath.c_str(), bLoop);
}
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
@ -121,8 +124,8 @@ bool SimpleAudioEngine::isBackgroundMusicPlaying()
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,float pitch, float pan, float gain)
{
unsigned int sound;
sharedAudioController()->PlaySoundEffect(pszFilePath, bLoop, sound);
// TODO: need to support playEffect parameters
string fullPath = CCFileUtils::getInstance()->fullPathForFilename(pszFilePath);
sharedAudioController()->PlaySoundEffect(fullPath.c_str(), bLoop, sound); // TODO: need to support playEffect parameters
return sound;
}
@ -133,7 +136,8 @@ void SimpleAudioEngine::stopEffect(unsigned int nSoundId)
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
sharedAudioController()->PreloadSoundEffect(pszFilePath);
string fullPath = CCFileUtils::getInstance()->fullPathForFilename(pszFilePath);
sharedAudioController()->PreloadSoundEffect(fullPath.c_str());
}
void SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
@ -168,7 +172,8 @@ void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
{
sharedAudioController()->UnloadSoundEffect(pszFilePath);
string fullPath = CCFileUtils::getInstance()->fullPathForFilename(pszFilePath);
sharedAudioController()->UnloadSoundEffect(fullPath.c_str());
}
//////////////////////////////////////////////////////////////////////////

View File

@ -354,10 +354,6 @@ bool Console::listenOnTCP(int port)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
WSADATA wsaData;
n = WSAStartup(MAKEWORD(2, 2),&wsaData);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
CCLogIPAddresses();
#endif
#endif
if ( (n = getaddrinfo(nullptr, serv, &hints, &res)) != 0) {
@ -446,7 +442,10 @@ void Console::stop()
{
if( _running ) {
_endThread = true;
_thread.join();
if (_thread.joinable())
{
_thread.join();
}
}
}
@ -1056,6 +1055,17 @@ void Console::addClient()
_maxfd = std::max(_maxfd,fd);
sendPrompt(fd);
/**
* A SIGPIPE is sent to a process if it tried to write to socket that had been shutdown for
* writing or isn't connected (anymore) on iOS.
*
* The default behaviour for this signal is to end the process.So we make the process ignore SIGPIPE.
*/
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
int set = 1;
setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int));
#endif
}
}
@ -1155,14 +1165,16 @@ void Console::loop()
/* Any message for the remote console ? send it! */
if( !_DebugStrings.empty() ) {
_DebugStringsMutex.lock();
for(const auto &str : _DebugStrings) {
for(const auto &fd : _fds) {
send(fd, str.c_str(), str.length(),0);
if (_DebugStringsMutex.try_lock())
{
for (const auto &str : _DebugStrings) {
for (auto fd : _fds) {
send(fd, str.c_str(), str.length(), 0);
}
}
_DebugStrings.clear();
_DebugStringsMutex.unlock();
}
_DebugStrings.clear();
_DebugStringsMutex.unlock();
}
}

View File

@ -81,12 +81,12 @@ public:
*
* @return The scroll data of x axis.
*/
inline float getScrollX() { return _scrollX; };
inline float getScrollX() const { return _scrollX; };
/** Get mouse scroll data of y axis.
*
* @return The scroll data of y axis.
*/
inline float getScrollY() { return _scrollY; };
inline float getScrollY() const { return _scrollY; };
/** Set the cursor position.
*
@ -118,19 +118,19 @@ public:
* @return The mouse button.
* @js getButton
*/
inline int getMouseButton() { return _mouseButton; };
inline int getMouseButton() const { return _mouseButton; };
/** Get the cursor position of x axis.
*
* @return The x coordinate of cursor position.
* @js getLocationX
*/
inline float getCursorX() { return _x; };
inline float getCursorX() const { return _x; };
/** Get the cursor position of y axis.
*
* @return The y coordinate of cursor position.
* @js getLocationY
*/
inline float getCursorY() { return _y; };
inline float getCursorY() const { return _y; };
/** Returns the current touch location in OpenGL coordinates.
*

View File

@ -0,0 +1,220 @@
/****************************************************************************
Copyright (c) 2013-2015 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCNinePatchImageParser.h"
#include "platform/CCImage.h"
#include "base/CCDirector.h"
NS_CC_BEGIN
NinePatchImageParser::~NinePatchImageParser()
{
}
NinePatchImageParser::NinePatchImageParser()
:_image(nullptr)
,_imageFrame(Rect::ZERO)
,_isRotated(false)
{
}
NinePatchImageParser::NinePatchImageParser(Image* image)
:_image(image)
,_imageFrame(Rect::ZERO)
,_isRotated(false)
{
this->_imageFrame = Rect(0,0,image->getWidth(), image->getHeight());
CCASSERT(image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888,
"unsupported format, currently only supports rgba8888");
}
NinePatchImageParser::NinePatchImageParser(Image* image, const Rect& frame, bool rotated)
:_image(image)
,_imageFrame(frame)
,_isRotated(rotated)
{
CCASSERT(image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888,
"unsupported format, currently only supports rgba8888");
}
int NinePatchImageParser::getFrameHeight()const
{
if (_isRotated)
{
return _imageFrame.size.width;
}
return _imageFrame.size.height;
}
int NinePatchImageParser::getFrameWidth()const
{
if (_isRotated)
{
return _imageFrame.size.height;
}
return _imageFrame.size.width;
}
int NinePatchImageParser::getPixelOriginOffset(Direction direction)const
{
int imageWidth = _image->getWidth();
int frameWidth = this->getFrameWidth();
int topLineLeftOffset = (int)_imageFrame.origin.y * imageWidth * 4 + (int)_imageFrame.origin.x * 4;
if(direction == Direction::HORIZONTAL)
{
return topLineLeftOffset;
}
else
{
if(_isRotated)
{
return topLineLeftOffset + (frameWidth - 1) * 4;
}
else
{
return topLineLeftOffset;
}
}
}
Vec2 NinePatchImageParser::parseHorizontalMargin()const
{
unsigned char* data = _image->getData();
data = data + this->getPixelOriginOffset(Direction::HORIZONTAL);
unsigned char lastPixel = *(data + 3);
int x1 = 0;
int x2 = 0;
int length = _imageFrame.origin.x + this->getFrameWidth();
for(int i = (int)_imageFrame.origin.x; i <= length ; i++)
{
unsigned char pixel = *(data + (i - (int)_imageFrame.origin.x) * 4 +3);
if(pixel != lastPixel)
{
if (pixel > 0)
{
x1 = (i - (int)_imageFrame.origin.x);
}
else
{
x2 = (i - (int)_imageFrame.origin.x);
break;
}
}
lastPixel = pixel;
}
return Vec2(x1,x2);
}
Vec2 NinePatchImageParser::parseVerticalMargin()const
{
unsigned char* data = _image->getData();
int imageWidth = _image->getWidth();
int y1 = 0;
int y2 = 0;
data = data + this->getPixelOriginOffset(Direction::VERTICAL);
unsigned char lastPixel = *(data + 3);
int length = (int)(_imageFrame.origin.y + this->getFrameHeight());
for(int i = _imageFrame.origin.y; i <= length; i++)
{
unsigned char pixel = *(data + (i - (int)_imageFrame.origin.y) * imageWidth * 4 + 3);
if(pixel != lastPixel)
{
if(pixel > 0)
{
y1 = (i - (int)_imageFrame.origin.y);
}
else
{
y2 = (i - (int)_imageFrame.origin.y);
break;
}
}
lastPixel = pixel;
}
return Vec2(y1,y2);
}
Rect NinePatchImageParser::parseCapInset() const
{
Rect capInsets;
Vec2 horizontalLine = this->parseHorizontalMargin();
Vec2 verticalLine = this->parseVerticalMargin();
if(_isRotated)
{
capInsets = Rect(verticalLine.y,
_imageFrame.size.height - horizontalLine.y,
verticalLine.y - verticalLine.x,
horizontalLine.y - horizontalLine.x);
}
else
{
capInsets = Rect(horizontalLine.x,
verticalLine.x,
horizontalLine.y - horizontalLine.x,
verticalLine.y - verticalLine.x);
}
capInsets = Rect(capInsets.origin.x / CC_CONTENT_SCALE_FACTOR(),
capInsets.origin.y / CC_CONTENT_SCALE_FACTOR(),
capInsets.size.width / CC_CONTENT_SCALE_FACTOR(),
capInsets.size.height / CC_CONTENT_SCALE_FACTOR());
return capInsets;
}
void NinePatchImageParser::setSpriteFrameInfo(Image* image, const cocos2d::Rect& frameRect, bool rotated )
{
this->_image = image;
CCASSERT(image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888,
"unsupported format, currently only supports rgba8888");
this->_imageFrame = frameRect;
this->_isRotated = rotated;
}
bool NinePatchImageParser::isNinePatchImage(const std::string& filepath)
{
size_t length = filepath.length();
if(length <7 )
{
return false;
}
if(filepath.compare(length-6, 6, ".9.png") == 0)
{
return true;
}
else
{
return false;
}
}
NS_CC_END

View File

@ -0,0 +1,120 @@
/****************************************************************************
Copyright (c) 2013-2015 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCPlatformMacros.h"
#include "math/CCGeometry.h"
NS_CC_BEGIN
class Image;
class SpriteFrame;
/**
* A class for paring Android .9 patch image.
* For more about Android .9 patch image format, please refer to
* http://developer.android.com/tools/help/draw9patch.html
*
* The class could parse a single .9 patch image and produce the capInsets
* as well as a sprite atlas and store all the capInsets infos in a Texture2D.
* Note:
* - Currently only PixelFormat::RGBA8888 is supported.
* - TexturePacker Trim mode is not supported at the moment.
*/
class CC_DLL NinePatchImageParser
{
public:
/**
* Determines whether a filename contains ".9.png" suffix.
* @param filename A 9-patch image name.
*
* @return If the filename contains ".9.png", then return true, otherwise false.
*/
static bool isNinePatchImage(const std::string& filename);
/**
* Default constructor.
*
*/
NinePatchImageParser();
/**
* Instantiate a NinePatchImageParser with a Image object.
*
* @param image A Image object pointer.
*
* @return A NinePatchImageParser instance.
*/
explicit NinePatchImageParser(Image* image);
/**
* Instantiate a NinePatchImageParser with a Image object and the spriteFrame info.
* The spriteFrame contains the frame rect in the image atlas and whether it
* is rotated or not.
*
* @param image A Image object pointer.
* @param frameRect The sprite frame rect in the image atlas.
* @param ratated Whether is sprite frame is rotated in the image atlas.
*
* @return
*/
NinePatchImageParser(Image* image, const Rect& frameRect, bool ratated);
/**
* Change the sprite frame info.
* It is useful when parsing multiple sprite frame with only on NinePatchImageParser.
*
* @param frameRect The sprite frame rect in the image atlas.
* @param rotated Whether is sprite frame is rotated in the image atlas.
*/
void setSpriteFrameInfo(Image* image, const Rect& frameRect, bool rotated);
/**
* Default destructor.
*/
virtual ~NinePatchImageParser();
/**
* Parsing the image data and extract the capInsets info.
* @return The capInsets Rect.
*/
Rect parseCapInset()const;
private:
enum class Direction
{
HORIZONTAL,
VERTICAL
};
int getPixelOriginOffset(Direction direction)const;
Vec2 parseHorizontalMargin()const;
Vec2 parseVerticalMargin()const;
int getFrameWidth()const;
int getFrameHeight()const;
Image* _image;
Rect _imageFrame;
bool _isRotated;
};
NS_CC_END

View File

@ -85,7 +85,7 @@ Properties::Properties(Data* data, ssize_t* dataIdx, const std::string& name, co
rewind();
}
Properties* Properties::createWithoutAutorelease(const std::string& url)
Properties* Properties::createNonRefCounted(const std::string& url)
{
if (url.size() == 0)
{
@ -419,24 +419,25 @@ signed char Properties::readChar()
char* Properties::readLine(char* output, int num)
{
int idx=0;
if (eof())
return nullptr;
// little optimization: avoid uneeded dereferences
ssize_t dataIdx = *_dataIdx;
const ssize_t dataIdx = *_dataIdx;
int i;
while (dataIdx<_data->_size && _data->_bytes[dataIdx]!='\n' && idx-1<num)
for (i=0; i<num && dataIdx+i < _data->_size; i++)
{
dataIdx++; idx++;
auto c = _data->_bytes[dataIdx+i];
if (c == '\n')
break;
output[i] = c;
}
memcpy(output, &_data->_bytes[*_dataIdx], idx);
output[idx] = '\0';
output[i] = '\0';
// restore value
*_dataIdx = dataIdx;
*_dataIdx = dataIdx+i;
return output;
}

View File

@ -105,7 +105,7 @@ class Data;
@verbatim
// Create the top-level Properties object.
Properties* properties = Properties::createWithoutAutorelease("example.properties");
Properties* properties = Properties::createNonRefCounted("example.properties");
// Retrieve the "spriteTexture" namespace.
Properties* spriteTexture = properties->getNamespace("spriteTexture");
@ -187,7 +187,7 @@ public:
* @return The created Properties or NULL if there was an error.
* @script{create}
*/
static Properties* createWithoutAutorelease(const std::string& url);
static Properties* createNonRefCounted(const std::string& url);
/**
* Destructor.
@ -579,7 +579,7 @@ private:
bool seekFromCurrent(int offset);
bool eof();
// Called after createWithoutAutorelease(); copies info from parents into derived namespaces.
// Called after createNonRefCounted(); copies info from parents into derived namespaces.
void resolveInheritance(const char* id = NULL);
// Called by resolveInheritance().

View File

@ -0,0 +1,334 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "base/CCUserDefault.h"
#include "platform/CCCommon.h"
#include "base/base64.h"
#include "base/ccUtils.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#include "CCWinRTUtils.h"
using namespace Windows::Storage;
using namespace Windows::Foundation;
using namespace std;
#define XML_FILE_NAME "UserDefault.xml"
NS_CC_BEGIN
/**
* WinRT implementation of UserDefault
*/
UserDefault* UserDefault::_userDefault = nullptr;
string UserDefault::_filePath = string("");
bool UserDefault::_isFilePathInitialized = false;
UserDefault::~UserDefault()
{
}
UserDefault::UserDefault()
{
}
Platform::Object^ getPlatformKeyValue(const char* pKey)
{
// check key
if (!pKey)
{
return nullptr;
}
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
auto key = PlatformStringFromString(pKey);
auto values = localSettings->Values;
if (values->HasKey(key))
{
return values->Lookup(key);
}
return nullptr;
}
void setPlatformKeyValue(const char* pKey, PropertyValue^ value)
{
// check key
if (!pKey)
{
return;
}
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
auto values = localSettings->Values;
values->Insert(PlatformStringFromString(pKey), value);
}
bool UserDefault::getBoolForKey(const char* pKey)
{
return getBoolForKey(pKey, false);
}
bool UserDefault::getBoolForKey(const char* pKey, bool defaultValue)
{
bool ret = defaultValue;
auto value = getPlatformKeyValue(pKey);
if (value)
{
ret = safe_cast<bool>(value);
}
return ret;
}
int UserDefault::getIntegerForKey(const char* pKey)
{
return getIntegerForKey(pKey, 0);
}
int UserDefault::getIntegerForKey(const char* pKey, int defaultValue)
{
int ret = defaultValue;
auto value = getPlatformKeyValue(pKey);
if (value)
{
ret = safe_cast<int>(value);
}
return ret;
}
float UserDefault::getFloatForKey(const char* pKey)
{
return getFloatForKey(pKey, 0.0f);
}
float UserDefault::getFloatForKey(const char* pKey, float defaultValue)
{
float ret = (float)getDoubleForKey(pKey, (double)defaultValue);
return ret;
}
double UserDefault::getDoubleForKey(const char* pKey)
{
return getDoubleForKey(pKey, 0.0);
}
double UserDefault::getDoubleForKey(const char* pKey, double defaultValue)
{
double ret = defaultValue;
auto value = getPlatformKeyValue(pKey);
if (value)
{
ret = safe_cast<double>(value);
}
return ret;
}
std::string UserDefault::getStringForKey(const char* pKey)
{
return getStringForKey(pKey, "");
}
string UserDefault::getStringForKey(const char* pKey, const std::string & defaultValue)
{
string ret = defaultValue;
auto value = getPlatformKeyValue(pKey);
if (value)
{
auto result = safe_cast<Platform::String^>(value);
ret = PlatformStringToString(result);
}
return ret;
}
Data UserDefault::getDataForKey(const char* pKey)
{
return getDataForKey(pKey, Data::Null);
}
Data UserDefault::getDataForKey(const char* pKey, const Data& defaultValue)
{
Data ret = defaultValue;
std::string encodedData = getStringForKey(pKey,"");
if (!encodedData.empty())
{
unsigned char* decodedData = nullptr;
int decodedDataLen = base64Decode((unsigned char*) encodedData.c_str(), (unsigned int) encodedData.length(), &decodedData);
if (decodedData && decodedDataLen > 0)
{
ret.fastSet(decodedData, decodedDataLen);
}
}
return ret;
}
void UserDefault::setBoolForKey(const char* pKey, bool value)
{
// check key
if (!pKey)
{
return;
}
setPlatformKeyValue(pKey, dynamic_cast<PropertyValue^>(PropertyValue::CreateBoolean(value)));
}
void UserDefault::setIntegerForKey(const char* pKey, int value)
{
// check key
if (! pKey)
{
return;
}
setPlatformKeyValue(pKey, dynamic_cast<PropertyValue^>(PropertyValue::CreateInt32(value)));
}
void UserDefault::setFloatForKey(const char* pKey, float value)
{
setDoubleForKey(pKey, value);
}
void UserDefault::setDoubleForKey(const char* pKey, double value)
{
// check key
if (! pKey)
{
return;
}
setPlatformKeyValue(pKey, dynamic_cast<PropertyValue^>(PropertyValue::CreateDouble(value)));
}
void UserDefault::setStringForKey(const char* pKey, const std::string & value)
{
// check key
if (! pKey)
{
return;
}
setPlatformKeyValue(pKey, dynamic_cast<PropertyValue^>(PropertyValue::CreateString(PlatformStringFromString(value))));
}
void UserDefault::setDataForKey(const char* pKey, const Data& value) {
// check key
if (! pKey)
{
return;
}
char *encodedData = 0;
base64Encode(value.getBytes(), static_cast<unsigned int>(value.getSize()), &encodedData);
setPlatformKeyValue(pKey, dynamic_cast<PropertyValue^>(PropertyValue::CreateString(PlatformStringFromString(encodedData))));
if (encodedData)
free(encodedData);
}
UserDefault* UserDefault::getInstance()
{
if (!_userDefault)
{
initXMLFilePath();
// only create xml file one time
// the file exists after the program exit
if ((!isXMLFileExist()) && (!createXMLFile()))
{
return nullptr;
}
_userDefault = new (std::nothrow) UserDefault();
}
return _userDefault;
}
void UserDefault::destroyInstance()
{
CC_SAFE_DELETE(_userDefault);
}
void UserDefault::setDelegate(UserDefault *delegate)
{
if (_userDefault)
delete _userDefault;
_userDefault = delegate;
}
// FIXME:: deprecated
UserDefault* UserDefault::sharedUserDefault()
{
return UserDefault::getInstance();
}
// FIXME:: deprecated
void UserDefault::purgeSharedUserDefault()
{
return UserDefault::destroyInstance();
}
bool UserDefault::isXMLFileExist()
{
//return FileUtils::getInstance()->isFileExist(_filePath);
return true;
}
void UserDefault::initXMLFilePath()
{
if (! _isFilePathInitialized)
{
_filePath += FileUtils::getInstance()->getWritablePath() + XML_FILE_NAME;
_isFilePathInitialized = true;
}
}
// create new xml file
bool UserDefault::createXMLFile()
{
return false;
}
const string& UserDefault::getXMLFilePath()
{
return _filePath;
}
void UserDefault::flush()
{
}
NS_CC_END
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)

View File

@ -237,7 +237,7 @@ public:
* @js NA
*/
static const std::string& getXMLFilePath();
/** All supported platforms other iOS & Android use xml file to save values. This function checks whether the xml file exists or not.
/** All supported platforms other iOS & Android and CC_PLATFORM_WINRT use xml file to save values. This function checks whether the xml file exists or not.
* @return True if the xml file exists, flase if not.
* @js NA
*/

View File

@ -15,6 +15,7 @@ set(COCOS_BASE_SRC
base/CCController.cpp
base/CCData.cpp
base/CCDataVisitor.cpp
base/CCNinePatchImageParser.cpp
base/CCDirector.cpp
base/CCEvent.cpp
base/CCEventAcceleration.cpp

View File

@ -254,7 +254,8 @@ THE SOFTWARE.
/** Use 3d physics integration API. */
#ifndef CC_USE_3D_PHYSICS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#define CC_USE_3D_PHYSICS 1
#define CC_USE_3D_PHYSICS 1
#endif
#endif

View File

@ -199,6 +199,9 @@ THE SOFTWARE.
#include "platform/android/CCGLViewImpl-android.h"
#include "platform/android/CCGL-android.h"
#include "platform/android/CCStdC-android.h"
//Enhance modification begin
#include "platform/android/CCEnhanceAPI-android.h"
//Enhance modification end
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)

View File

@ -183,7 +183,7 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(const std::s
doc.Parse<0>(content.c_str());
if (doc.HasParseError())
{
CCLOG("GetParseError %s\n", doc.GetParseError());
CCLOG("GetParseError %d\n", doc.GetParseError());
}
const rapidjson::Value& json = DICTOOL->getSubDictionary_json(doc, ACTION);

View File

@ -606,20 +606,20 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
void InnerActionFrame::setStartFrameIndex(int frameIndex)
{
CCASSERT(_enterWithName, " cannot setStartFrameIndex when enterWithName is set");
CCASSERT(!_enterWithName, " cannot setStartFrameIndex when enterWithName is set");
_startFrameIndex = frameIndex;
}
void InnerActionFrame::setEndFrameIndex(int frameIndex)
{
CCASSERT(_enterWithName, " cannot setEndFrameIndex when enterWithName is set");
CCASSERT(!_enterWithName, " cannot setEndFrameIndex when enterWithName is set");
_endFrameIndex = frameIndex;
}
void InnerActionFrame::setAnimationName(const std::string& animationName)
{
CCASSERT(!_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
CCASSERT(_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
_animationName = animationName;
}

View File

@ -376,7 +376,7 @@ Node* CSLoader::loadNodeWithContent(const std::string& content)
doc.Parse<0>(content.c_str());
if (doc.HasParseError())
{
CCLOG("GetParseError %s\n", doc.GetParseError());
CCLOG("GetParseError %d\n", doc.GetParseError());
}
// cocos2dx version mono editor is based on
@ -724,7 +724,7 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
customJsonDict.Parse<0>(customProperty);
if (customJsonDict.HasParseError())
{
CCLOG("GetParseError %s\n", customJsonDict.GetParseError());
CCLOG("GetParseError %d\n", customJsonDict.GetParseError());
}
widgetPropertiesReader->setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict);

View File

@ -128,14 +128,6 @@ bool ComAudio::serialize(void* r)
}
if (strcmp(className, "CCBackgroundAudio") == 0)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
std::string::size_type pos = filePath.find(".mp3");
if (pos == filePath.npos)
{
continue;
}
filePath.replace(pos, filePath.length(), ".wav");
#endif
preloadBackgroundMusic(filePath.c_str());
setLoop(loop);
playBackgroundMusic(filePath.c_str(), loop);

View File

@ -1247,7 +1247,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
json.ParseStream<0>(stream);
if (json.HasParseError()) {
CCLOG("GetParseError %s\n",json.GetParseError());
CCLOG("GetParseError %d\n",json.GetParseError());
}
dataInfo->contentScale = DICTOOL->getFloatValue_json(json, CONTENT_SCALE, 1.0f);

View File

@ -212,7 +212,7 @@ Widget* GUIReader::widgetFromJsonFile(const char *fileName)
jsonDict.Parse<0>(contentStr.c_str());
if (jsonDict.HasParseError())
{
CCLOG("GetParseError %s\n",jsonDict.GetParseError());
CCLOG("GetParseError %d\n",jsonDict.GetParseError());
}
Widget* widget = nullptr;
const char* fileVersion = DICTOOL->getStringValue_json(jsonDict, "version");
@ -1373,7 +1373,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
customJsonDict.Parse<0>(customProperty);
if (customJsonDict.HasParseError())
{
CCLOG("GetParseError %s\n", customJsonDict.GetParseError());
CCLOG("GetParseError %d\n", customJsonDict.GetParseError());
}
setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict);
}else{
@ -1474,7 +1474,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
customJsonDict.Parse<0>(customProperty);
if (customJsonDict.HasParseError())
{
CCLOG("GetParseError %s\n", customJsonDict.GetParseError());
CCLOG("GetParseError %d\n", customJsonDict.GetParseError());
}
setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict);
}else{

View File

@ -72,6 +72,7 @@ int DictionaryHelper::getIntValue_json(const rapidjson::Value& root, const char*
int nRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(key));
CC_BREAK_IF(root[key].IsNull());
nRet = root[key].GetInt();
} while (0);
@ -85,6 +86,7 @@ float DictionaryHelper::getFloatValue_json(const rapidjson::Value& root,const ch
float fRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(key));
CC_BREAK_IF(root[key].IsNull());
fRet = (float)root[key].GetDouble();
} while (0);
@ -97,6 +99,7 @@ bool DictionaryHelper::getBooleanValue_json(const rapidjson::Value& root,const c
bool bRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(key));
CC_BREAK_IF(root[key].IsNull());
bRet = root[key].GetBool();
} while (0);
@ -109,6 +112,7 @@ const char* DictionaryHelper::getStringValue_json(const rapidjson::Value& root,c
const char* sRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(key));
CC_BREAK_IF(root[key].IsNull());
sRet = root[key].GetString();
} while (0);
@ -123,6 +127,7 @@ int DictionaryHelper::getArrayCount_json(const rapidjson::Value& root, const cha
int nRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(key));
CC_BREAK_IF(root[key].IsNull());
nRet = (int)(root[key].Size());
} while (0);
@ -136,6 +141,7 @@ int DictionaryHelper::getIntValueFromArray_json(const rapidjson::Value& root,con
int nRet = def;
do {
CC_BREAK_IF(root.IsNull());
CC_BREAK_IF(!root.HasMember(arrayKey));
CC_BREAK_IF(root[arrayKey].IsNull());
CC_BREAK_IF(root[arrayKey][idx].IsNull());
nRet = root[arrayKey][idx].GetInt();

View File

@ -236,7 +236,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
{
if (str2 != nullptr)
{
action.AddMember("classname", str2, allocator);
action.AddMember("classname", rapidjson::Value(str2,allocator), allocator);
}
}
else if (key2.compare("dataitems") == 0)
@ -257,7 +257,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
{
if (str3 != nullptr)
{
dataitem.AddMember("key", str3, allocator);
dataitem.AddMember("key", rapidjson::Value(str3,allocator), allocator);
}
}
else
@ -265,7 +265,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
rapidjson::Type type = pDataItemArray[i5].GetType(pCocoLoader);
if (type == rapidjson::kStringType)
{
dataitem.AddMember("value", str3, allocator);
dataitem.AddMember("value", rapidjson::Value(str3,allocator), allocator);
}
else
{
@ -312,7 +312,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
{
if (str4 != nullptr)
{
cond.AddMember("classname", str4, allocator);
cond.AddMember("classname", rapidjson::Value(str4,allocator), allocator);
}
}
else if (key4.compare("dataitems") == 0)
@ -333,7 +333,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
{
if (str5 != nullptr)
{
dataitem.AddMember("key", str5, allocator);
dataitem.AddMember("key", rapidjson::Value(str5,allocator), allocator);
}
}
else
@ -341,7 +341,7 @@ void TriggerMng::buildJson(rapidjson::Document &document, cocostudio::CocoLoader
rapidjson::Type type = pDataItemArray[i9].GetType(pCocoLoader);
if (type == rapidjson::kStringType)
{
dataitem.AddMember("value", str5, allocator);
dataitem.AddMember("value", rapidjson::Value(str5,allocator), allocator);
}
else
{

View File

@ -154,12 +154,12 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node,
fileExist = false;
}
if (!fileExist)
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", filepath.c_str())->getCString());
custom->addChild(label);
}
//if (!fileExist)
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", filepath.c_str())->getCString());
// custom->addChild(label);
//}
}

View File

@ -706,12 +706,12 @@ namespace cocostudio
{
button->loadTextureNormal(normalTexturePath, (Widget::TextureResType)normalType);
}
else if (!normalTexturePath.empty())
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", normalErrorFilePath.c_str())->getCString());
button->addChild(label);
}
//else if (!normalTexturePath.empty())
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", normalErrorFilePath.c_str())->getCString());
// button->addChild(label);
//}
bool pressedFileExist = false;
std::string pressedErrorFilePath = "";
@ -770,12 +770,12 @@ namespace cocostudio
{
button->loadTexturePressed(pressedTexturePath, (Widget::TextureResType)pressedType);
}
else if (!pressedTexturePath.empty())
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", pressedErrorFilePath.c_str())->getCString());
button->addChild(label);
}
//else if (!pressedTexturePath.empty())
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", pressedErrorFilePath.c_str())->getCString());
// button->addChild(label);
//}
bool disabledFileExist = false;
std::string disabledErrorFilePath = "";
@ -834,12 +834,12 @@ namespace cocostudio
{
button->loadTextureDisabled(disabledTexturePath, (Widget::TextureResType)disabledType);
}
else if (!disabledTexturePath.empty())
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", disabledErrorFilePath.c_str())->getCString());
button->addChild(label);
}
//else if (!disabledTexturePath.empty())
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", disabledErrorFilePath.c_str())->getCString());
// button->addChild(label);
//}
std::string titleText = options->text()->c_str();
button->setTitleText(titleText);
@ -873,12 +873,12 @@ namespace cocostudio
{
button->setTitleFontName(path);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
button->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// button->addChild(label);
//}
}
bool displaystate = options->displaystate() != 0;

View File

@ -491,12 +491,12 @@ namespace cocostudio
{
checkBox->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", backGroundErrorFilePath.c_str())->getCString());
checkBox->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", backGroundErrorFilePath.c_str())->getCString());
// checkBox->addChild(label);
//}
//load background selected image
bool backGroundSelectedfileExist = false;
@ -556,12 +556,12 @@ namespace cocostudio
{
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (Widget::TextureResType)backGroundSelectedType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", backGroundSelectedErrorFilePath.c_str())->getCString());
checkBox->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", backGroundSelectedErrorFilePath.c_str())->getCString());
// checkBox->addChild(label);
//}
//load frontCross image
bool frontCrossFileExist = false;
@ -621,12 +621,12 @@ namespace cocostudio
{
checkBox->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", frontCrossErrorFilePath.c_str())->getCString());
checkBox->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", frontCrossErrorFilePath.c_str())->getCString());
// checkBox->addChild(label);
//}
//load backGroundBoxDisabledData
bool backGroundBoxDisabledFileExist = false;
@ -686,12 +686,12 @@ namespace cocostudio
{
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (Widget::TextureResType)backGroundDisabledType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", backGroundBoxDisabledErrorFilePath.c_str())->getCString());
checkBox->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", backGroundBoxDisabledErrorFilePath.c_str())->getCString());
// checkBox->addChild(label);
//}
///load frontCrossDisabledData
bool frontCrossDisabledFileExist = false;
@ -751,12 +751,12 @@ namespace cocostudio
{
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (Widget::TextureResType)frontCrossDisabledType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", frontCrossDisabledErrorFilePath.c_str())->getCString());
checkBox->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", frontCrossDisabledErrorFilePath.c_str())->getCString());
// checkBox->addChild(label);
//}
bool selectedstate = options->selectedState() != 0;
checkBox->setSelected(selectedstate);

View File

@ -238,15 +238,15 @@ namespace cocostudio
setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions);
}
}
else
{
Node* node = Node::create();
setPropsWithFlatBuffers(node, (Table*)gameMapOptions);
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
node->addChild(label);
return node;
}
//else
//{
// Node* node = Node::create();
// setPropsWithFlatBuffers(node, (Table*)gameMapOptions);
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// node->addChild(label);
// return node;
//}
return tmx;
}

View File

@ -353,12 +353,12 @@ namespace cocostudio
{
imageView->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
imageView->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// imageView->addChild(label);
//}
bool scale9Enabled = options->scale9Enabled() != 0;
imageView->setScale9Enabled(scale9Enabled);

View File

@ -190,12 +190,21 @@ namespace cocostudio
/* adapt screen gui */
float w = 0, h = 0;
bool adaptScrenn = DICTOOL->getBooleanValue_json(options, P_AdaptScreen);
if (adaptScrenn)
bool adaptScrennExsit = DICTOOL->checkObjectExist_json(options, P_AdaptScreen);
if (adaptScrennExsit)
{
Size screenSize = CCDirector::getInstance()->getWinSize();
w = screenSize.width;
h = screenSize.height;
bool adaptScrenn = DICTOOL->getBooleanValue_json(options, P_AdaptScreen);
if (adaptScrenn)
{
Size screenSize = Director::getInstance()->getWinSize();
w = screenSize.width;
h = screenSize.height;
}
else
{
w = DICTOOL->getFloatValue_json(options, P_Width);
h = DICTOOL->getFloatValue_json(options, P_Height);
}
}
else
{
@ -300,7 +309,11 @@ namespace cocostudio
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
}
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, P_LayoutType));
bool layoutTypeExsit = DICTOOL->checkObjectExist_json(options, P_LayoutType);
if (layoutTypeExsit)
{
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, P_LayoutType));
}
int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR,255);
int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG,255);
@ -662,12 +675,12 @@ namespace cocostudio
{
panel->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
panel->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// panel->addChild(label);
//}
}
auto widgetOptions = options->widgetOptions();

View File

@ -490,12 +490,12 @@ namespace cocostudio
{
listView->setBackGroundImage(imageFileName, (Widget::TextureResType)imageFileNameType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
listView->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// listView->addChild(label);
//}
}
auto widgetOptions = options->widgetOptions();

View File

@ -303,12 +303,12 @@ namespace cocostudio
{
loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
loadingBar->addChild(label);
}
//else
//{
// auto label = Label::create();
// label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
// loadingBar->addChild(label);
//}
int direction = options->direction();
loadingBar->setDirection(LoadingBar::Direction(direction));

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