mirror of https://github.com/axmolengine/axmol.git
Merge commit '4214ad231ed0b280a41128a4a147dc07d5e914b9' into develop
Conflicts: cocos/scripting/auto-generated
This commit is contained in:
commit
5be6ab1986
1
AUTHORS
1
AUTHORS
|
@ -93,6 +93,7 @@ Developers:
|
|||
martell
|
||||
use tinyxml2 to replace libxml2
|
||||
Added Mingw-crt Support without breaking VS SDK
|
||||
CMake support for windows.
|
||||
|
||||
mchinen
|
||||
fix emulator issue for OpenGL ES 2.0 on Android
|
||||
|
|
|
@ -2,11 +2,15 @@ cocos2d-x-3.0beta0 ?? 2013
|
|||
[All]
|
||||
[NEW] Upgrated Box2D to 2.3.0
|
||||
[NEW] Added ThreadHelper, ThreadHelper::runOnGLThread() simplify invoking engine codes and OpenGL ES commands in a thread other then gl thread.
|
||||
[NEW] Added tga format support again.
|
||||
[Android]
|
||||
[NEW] build/android-build.sh: add supporting to generate .apk file
|
||||
[FIX] XMLHttpRequest receives wrong binary array.
|
||||
[NEW] Bindings-generator supports to bind 'unsigned long'.
|
||||
[FIX] 'Test Frame Event' of TestJavascript/CocoStudioArmatureTest Crashes.
|
||||
[Windows]
|
||||
[NEW] CMake support for windows.
|
||||
|
||||
cocos2d-x-3.0alpha1 Nov.19 2013
|
||||
[all platforms]
|
||||
[DOC] Added RELEASE_NOTES and CODING_STYLE.md files
|
||||
|
|
174
CMakeLists.txt
174
CMakeLists.txt
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project (Cocos2dx)
|
||||
|
||||
# The version number
|
||||
|
@ -7,6 +7,26 @@ set(Cocos2dxSamples_VERSION_MINOR 0)
|
|||
|
||||
include(build/BuildHelpers.CMakeLists.txt)
|
||||
|
||||
if(WIN32 OR APPLE)
|
||||
|
||||
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
||||
option(USE_BOX2D "Use box2d for physics library" OFF)
|
||||
option(DEBUG_MODE "Debug or release?" ON)
|
||||
option(BUILD_LIBS_LUA "Build lua libraries" OFF)
|
||||
option(BUILD_GUI "Build GUI library" OFF)
|
||||
option(BUILD_NETWORK "Build network library" OFF)
|
||||
option(BUILD_EXTENSIONS "Build extension library" OFF)
|
||||
option(BUILD_EDITOR_SPINE "Build editor support for spine" OFF)
|
||||
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" OFF)
|
||||
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" OFF)
|
||||
|
||||
option(BUILD_HelloCpp "Only build HelloCpp sample" ON)
|
||||
option(BUILD_TestCpp "Only build TestCpp sample" OFF)
|
||||
option(BUILD_HelloLua "Only build HelloLua sample" OFF)
|
||||
option(BUILD_TestLua "Only build TestLua sample" OFF)
|
||||
|
||||
else()#temp
|
||||
|
||||
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
|
||||
option(USE_BOX2D "Use box2d for physics library" OFF)
|
||||
option(DEBUG_MODE "Debug or release?" ON)
|
||||
|
@ -24,6 +44,8 @@ option(BUILD_TestCpp "Only build TestCpp sample" ON)
|
|||
option(BUILD_HelloLua "Only build HelloLua sample" ON)
|
||||
option(BUILD_TestLua "Only build TestLua sample" ON)
|
||||
|
||||
endif()#temp
|
||||
|
||||
|
||||
if(DEBUG_MODE)
|
||||
set(CMAKE_BUILD_TYPE DEBUG)
|
||||
|
@ -31,18 +53,47 @@ else(DEBUG_MODE)
|
|||
set(CMAKE_BUILD_TYPE RELEASE)
|
||||
endif(DEBUG_MODE)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
|
||||
if(WIN32)
|
||||
ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32)
|
||||
|
||||
if(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_SCL_SECURE_NO_WARNINGS
|
||||
-wd4251 -wd4244 -wd4334
|
||||
-wd4005 -wd4820 -wd4710
|
||||
-wd4514 -wd4056 -wd4996 -wd4099)
|
||||
else(MSVC)#MINGW
|
||||
|
||||
endif(MSVC)
|
||||
elseif(APPLE)
|
||||
|
||||
|
||||
else()#Linux
|
||||
ADD_DEFINITIONS(-DLINUX)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT MSVC)# all gcc
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99")
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
endif()
|
||||
|
||||
|
||||
if(USE_CHIPMUNK)
|
||||
message("Using chipmunk ...")
|
||||
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
||||
add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
|
||||
elseif(USE_BOX2D)
|
||||
message("Using box2d ...")
|
||||
add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
|
||||
add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1)
|
||||
else(USE_CHIPMUNK)
|
||||
message(FATAL_ERROR "Must choose a physics library.")
|
||||
endif(USE_CHIPMUNK)
|
||||
|
@ -54,40 +105,93 @@ else()
|
|||
set(ARCH_DIR "32-bit")
|
||||
endif()
|
||||
|
||||
if(WIN32) # Win32
|
||||
set(PLATFORM_FOLDER win32)
|
||||
elseif(APPLE)# osx or ios
|
||||
set(PLATFORM_FOLDER mac)
|
||||
else() # Assume Linux
|
||||
set(PLATFORM_FOLDER linux)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
.
|
||||
cocos
|
||||
cocos/audio/include
|
||||
cocos/2d
|
||||
cocos/2d/platform
|
||||
cocos/2d/platform/linux
|
||||
cocos/base
|
||||
cocos/physics
|
||||
cocos/editor-support
|
||||
cocos/math/kazmath/include
|
||||
extensions
|
||||
external
|
||||
external/jpeg/include/linux
|
||||
external/tiff/include/linux
|
||||
external/webp/include/linux
|
||||
external/glfw3/include/linux
|
||||
external/curl/include/linux/${ARCH_DIR}
|
||||
external/tinyxml2
|
||||
external/unzip
|
||||
external/chipmunk/include/chipmunk
|
||||
external/freetype2/include/linux
|
||||
external/linux-specific/fmod/include/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/audio/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/base
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/physics
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/editor-support
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/math/kazmath/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extensions
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/unzip
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cocos/2d/platform/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/include/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/include/${PLATFORM_FOLDER}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
/usr/local/lib
|
||||
${CMAKE_SOURCE_DIR}/external/jpeg/prebuilt/linux/${ARCH_DIR}
|
||||
${CMAKE_SOURCE_DIR}/external/tiff/prebuilt/linux/${ARCH_DIR}
|
||||
${CMAKE_SOURCE_DIR}/external/webp/prebuilt/linux/${ARCH_DIR}
|
||||
${CMAKE_SOURCE_DIR}/external/freetype2/prebuilt/linux/${ARCH_DIR}
|
||||
${CMAKE_SOURCE_DIR}/external/curl/prebuilt/linux/${ARCH_DIR}
|
||||
${CMAKE_SOURCE_DIR}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
|
||||
)
|
||||
if(WIN32)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include
|
||||
external/curl/include/${PLATFORM_FOLDER}
|
||||
)
|
||||
elseif(APPLE)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}
|
||||
)
|
||||
else()
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
if(WIN32)
|
||||
|
||||
if(NOT MINGW)
|
||||
link_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt
|
||||
)
|
||||
endif()
|
||||
|
||||
link_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/glfw3/prebuilt/${PLATFORM_FOLDER}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/prebuilt
|
||||
)
|
||||
|
||||
elseif(APPLE)
|
||||
|
||||
else()
|
||||
|
||||
link_directories(
|
||||
/usr/local/lib
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR}
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# kazmath
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
:start
|
||||
mkdir win32-msvc-vs2010-x86
|
||||
cd win32-msvc-vs2010-x86
|
||||
cmake -G "Visual Studio 10" ../..
|
||||
pause
|
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
:start
|
||||
mkdir win32-msvc-vs2012-x86
|
||||
cd win32-msvc-vs2012-x86
|
||||
cmake -G "Visual Studio 11" ../..
|
||||
pause
|
|
@ -0,0 +1,8 @@
|
|||
@echo off
|
||||
SETLOCAL
|
||||
|
||||
:start
|
||||
mkdir win32-msvc-vs2013-x86
|
||||
cd win32-msvc-vs2013-x86
|
||||
cmake -G "Visual Studio 12" ../..
|
||||
pause
|
|
@ -1341,14 +1341,17 @@ Point Node::convertTouchToNodeSpaceAR(Touch *touch) const
|
|||
}
|
||||
|
||||
#ifdef CC_USE_PHYSICS
|
||||
void Node::updatePhysicsTransform()
|
||||
bool Node::updatePhysicsTransform()
|
||||
{
|
||||
if (_physicsBody)
|
||||
if (_physicsBody != nullptr && _physicsBody->getWorld() != nullptr && !_physicsBody->isResting())
|
||||
{
|
||||
_position = _physicsBody->getPosition();
|
||||
_rotationX = _rotationY = _physicsBody->getRotation();
|
||||
_transformDirty = _inverseDirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -627,7 +627,7 @@ public:
|
|||
/**
|
||||
* Sets the parent node
|
||||
*
|
||||
* @param parent A pointer to the parnet node
|
||||
* @param parent A pointer to the parent node
|
||||
*/
|
||||
virtual void setParent(Node* parent);
|
||||
/**
|
||||
|
@ -635,7 +635,7 @@ public:
|
|||
*
|
||||
* @see `setParent(Node*)`
|
||||
*
|
||||
* @returns A pointer to the parnet node
|
||||
* @returns A pointer to the parent node
|
||||
*/
|
||||
virtual Node* getParent() { return _parent; }
|
||||
virtual const Node* getParent() const { return _parent; }
|
||||
|
@ -1386,7 +1386,7 @@ public:
|
|||
/**
|
||||
* update rotation and position from physics body
|
||||
*/
|
||||
virtual void updatePhysicsTransform();
|
||||
virtual bool updatePhysicsTransform();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag)
|
|||
setBlendFunc(child->getBlendFunc());
|
||||
}
|
||||
|
||||
CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function");
|
||||
CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a ParticleSystem that uses a different blending function");
|
||||
|
||||
//no lazy sorting, so don't call super addChild, call helper instead
|
||||
unsigned int pos = addChildHelper(child,zOrder,tag);
|
||||
|
|
|
@ -496,8 +496,10 @@ void Sprite::updateTransform(void)
|
|||
CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode");
|
||||
|
||||
#ifdef CC_USE_PHYSICS
|
||||
updatePhysicsTransform();
|
||||
setDirty(true);
|
||||
if (updatePhysicsTransform())
|
||||
{
|
||||
setDirty(true);
|
||||
};
|
||||
#endif
|
||||
|
||||
// recalculate matrix only if it is dirty
|
||||
|
|
|
@ -1,3 +1,34 @@
|
|||
if(WIN32)
|
||||
|
||||
ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
|
||||
|
||||
set(PLATFORM_SRC
|
||||
platform/win32/CCStdC.cpp
|
||||
platform/win32/CCFileUtilsWin32.cpp
|
||||
platform/win32/CCCommon.cpp
|
||||
platform/win32/CCApplication.cpp
|
||||
platform/win32/CCEGLView.cpp
|
||||
platform/win32/CCImage.cpp
|
||||
platform/win32/CCDevice.cpp
|
||||
)
|
||||
|
||||
elseif(APPLE)
|
||||
|
||||
else()
|
||||
|
||||
set(PLATFORM_SRC
|
||||
platform/linux/CCStdC.cpp
|
||||
platform/linux/CCFileUtilsLinux.cpp
|
||||
platform/linux/CCCommon.cpp
|
||||
platform/linux/CCApplication.cpp
|
||||
platform/linux/CCEGLView.cpp
|
||||
platform/linux/CCImage.cpp
|
||||
platform/linux/CCDevice.cpp
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
set(COCOS2D_SRC
|
||||
CCAction.cpp
|
||||
CCActionCamera.cpp
|
||||
|
@ -107,27 +138,56 @@ set(COCOS2D_SRC
|
|||
platform/CCThread.cpp
|
||||
platform/CCEGLViewProtocol.cpp
|
||||
platform/CCFileUtils.cpp
|
||||
platform/linux/CCStdC.cpp
|
||||
platform/linux/CCFileUtilsLinux.cpp
|
||||
platform/linux/CCCommon.cpp
|
||||
platform/linux/CCApplication.cpp
|
||||
platform/linux/CCEGLView.cpp
|
||||
platform/linux/CCImage.cpp
|
||||
platform/linux/CCDevice.cpp
|
||||
)
|
||||
|
||||
include(../physics/CMakeLists.txt)
|
||||
|
||||
add_library(cocos2d STATIC
|
||||
${COCOS2D_SRC}
|
||||
${PLATFORM_SRC}
|
||||
${COCOS_PHYSICS_SRC}
|
||||
)
|
||||
target_link_libraries(cocos2d
|
||||
cocosbase
|
||||
chipmunk_static
|
||||
tinyxml2
|
||||
kazmath
|
||||
unzip
|
||||
|
||||
if(WIN32)
|
||||
|
||||
if(MINGW)
|
||||
|
||||
set(COCOS_LINK
|
||||
z
|
||||
jpeg
|
||||
png
|
||||
webp
|
||||
tiff
|
||||
glfw3
|
||||
glew32
|
||||
opengl32
|
||||
iconv
|
||||
freetype
|
||||
bz2
|
||||
)
|
||||
|
||||
else()
|
||||
|
||||
|
||||
set(COCOS_LINK
|
||||
libjpeg
|
||||
libpng
|
||||
libwebp
|
||||
libtiff
|
||||
freetype250
|
||||
glfw3
|
||||
glew32
|
||||
opengl32
|
||||
libiconv
|
||||
libzlib
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
elseif(APPLE)
|
||||
|
||||
else()
|
||||
set(COCOS_LINK
|
||||
jpeg
|
||||
webp
|
||||
tiff
|
||||
|
@ -142,6 +202,16 @@ target_link_libraries(cocos2d
|
|||
rt
|
||||
z
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(cocos2d
|
||||
cocosbase
|
||||
chipmunk_static
|
||||
tinyxml2
|
||||
kazmath
|
||||
unzip
|
||||
${COCOS_LINK}
|
||||
)
|
||||
|
||||
set_target_properties(cocos2d
|
||||
PROPERTIES
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
#include "TGAlib.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
namespace cocos2d {
|
||||
NS_CC_BEGIN
|
||||
|
||||
static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *psInfo);
|
||||
void tgaFlipImage( tImageTGA *info );
|
||||
|
@ -192,22 +192,18 @@ void tgaFlipImage( tImageTGA *psInfo )
|
|||
psInfo->flipped = 0;
|
||||
}
|
||||
|
||||
// this is the function to call when we want to load an image
|
||||
tImageTGA * tgaLoad(const char *filename)
|
||||
tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size)
|
||||
{
|
||||
int mode,total;
|
||||
tImageTGA *info = NULL;
|
||||
|
||||
long size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
tImageTGA *info = nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(! pBuffer);
|
||||
CC_BREAK_IF(! buffer);
|
||||
info = (tImageTGA *)malloc(sizeof(tImageTGA));
|
||||
|
||||
// get the file header info
|
||||
if (! tgaLoadHeader(pBuffer, size, info))
|
||||
if (! tgaLoadHeader(buffer, size, info))
|
||||
{
|
||||
info->status = TGA_ERROR_MEMORY;
|
||||
break;
|
||||
|
@ -245,11 +241,11 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
// finally load the image pixels
|
||||
if ( info->type == 10 )
|
||||
{
|
||||
bLoadImage = tgaLoadRLEImageData(pBuffer, size, info);
|
||||
bLoadImage = tgaLoadRLEImageData(buffer, size, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
bLoadImage = tgaLoadImageData(pBuffer, size, info);
|
||||
bLoadImage = tgaLoadImageData(buffer, size, info);
|
||||
}
|
||||
|
||||
// check for errors when reading the pixels
|
||||
|
@ -270,11 +266,26 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
}
|
||||
} while(0);
|
||||
|
||||
free(pBuffer);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
// this is the function to call when we want to load an image
|
||||
tImageTGA * tgaLoad(const char *filename)
|
||||
{
|
||||
long size = 0;
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
|
||||
if (buffer != nullptr)
|
||||
{
|
||||
tImageTGA* data = tgaLoadBuffer(buffer, size);
|
||||
free(buffer);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// converts RGB to grayscale
|
||||
void tgaRGBtogreyscale(tImageTGA *psInfo) {
|
||||
|
||||
|
@ -326,4 +337,4 @@ void tgaDestroy(tImageTGA *psInfo) {
|
|||
free(psInfo);
|
||||
}
|
||||
}
|
||||
}//namespace cocos2d
|
||||
NS_CC_END
|
||||
|
|
|
@ -58,6 +58,9 @@ bool tgaLoadHeader(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psIn
|
|||
/// loads the image pixels. You shouldn't call this function directly
|
||||
bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psInfo);
|
||||
|
||||
/// this is the function to call when we want to load an image buffer.
|
||||
tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size);
|
||||
|
||||
/// this is the function to call when we want to load an image
|
||||
tImageTGA * tgaLoad(const char *filename);
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@ public:
|
|||
S3TC,
|
||||
//! ATITC
|
||||
ATITC,
|
||||
//! TGA
|
||||
TGA,
|
||||
//! Raw Data
|
||||
RAW_DATA,
|
||||
//! Unknown format
|
||||
|
@ -206,6 +208,8 @@ protected:
|
|||
bool initWithETCData(const unsigned char * data, int dataLen);
|
||||
bool initWithS3TCData(const unsigned char * data, int dataLen);
|
||||
bool initWithATITCData(const unsigned char *data, int dataLen);
|
||||
typedef struct sImageTGA tImageTGA;
|
||||
bool initWithTGAData(tImageTGA* tgaData);
|
||||
|
||||
bool saveImageToPNG(const std::string& filePath, bool isToRGB = true);
|
||||
bool saveImageToJPG(const std::string& filePath);
|
||||
|
@ -227,6 +231,7 @@ private:
|
|||
int _numberOfMipmaps;
|
||||
// false if we cann't auto detect the image is premultiplied or not.
|
||||
bool _hasPremultipliedAlpha;
|
||||
std::string _filePath;
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -42,6 +42,7 @@ extern "C"
|
|||
}
|
||||
#include "s3tc.h"
|
||||
#include "atitc.h"
|
||||
#include "TGAlib.h"
|
||||
|
||||
#include "decode.h"
|
||||
|
||||
|
@ -388,13 +389,16 @@ Image::Image()
|
|||
|
||||
Image::~Image()
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(_data);
|
||||
if (_data != nullptr)
|
||||
{
|
||||
free(_data);
|
||||
}
|
||||
}
|
||||
|
||||
bool Image::initWithImageFile(const char * strPath)
|
||||
{
|
||||
bool bRet = false;
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath);
|
||||
_filePath = FileUtils::getInstance()->fullPathForFilename(strPath);
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
// Emscripten includes a re-implementation of SDL that uses HTML5 canvas
|
||||
|
@ -417,7 +421,7 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
SDL_FreeSurface(iSurf);
|
||||
#else
|
||||
long bufferLen = 0;
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &bufferLen);
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(_filePath.c_str(), "rb", &bufferLen);
|
||||
|
||||
if (buffer != nullptr && bufferLen > 0)
|
||||
{
|
||||
|
@ -434,6 +438,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
|||
{
|
||||
bool ret = false;
|
||||
long dataLen = 0;
|
||||
_filePath = fullpath;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance();
|
||||
unsigned char *buffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen);
|
||||
|
@ -503,8 +508,22 @@ bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
|||
ret = initWithATITCData(unpackedData, unpackedLen);
|
||||
break;
|
||||
default:
|
||||
CCAssert(false, "unsupport image format!");
|
||||
break;
|
||||
{
|
||||
// load and detect image format
|
||||
tImageTGA* tgaData = tgaLoadBuffer(unpackedData, unpackedLen);
|
||||
|
||||
if (tgaData != nullptr && tgaData->status == TGA_OK)
|
||||
{
|
||||
ret = initWithTGAData(tgaData);
|
||||
}
|
||||
else
|
||||
{
|
||||
CCAssert(false, "unsupport image format!");
|
||||
}
|
||||
|
||||
free(tgaData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(unpackedData != data)
|
||||
|
@ -613,7 +632,6 @@ bool Image::isPvr(const unsigned char * data, int dataLen)
|
|||
return memcmp(&headerv2->pvrTag, gPVRTexIdentifier, strlen(gPVRTexIdentifier)) == 0 || CC_SWAP_INT32_BIG_TO_HOST(headerv3->version) == 0x50565203;
|
||||
}
|
||||
|
||||
|
||||
Image::Format Image::detectFormat(const unsigned char * data, int dataLen)
|
||||
{
|
||||
if (isPng(data, dataLen))
|
||||
|
@ -787,11 +805,11 @@ bool Image::initWithJpgData(const unsigned char * data, int dataLen)
|
|||
_width = cinfo.output_width;
|
||||
_height = cinfo.output_height;
|
||||
_preMulti = false;
|
||||
row_pointer[0] = new unsigned char[cinfo.output_width*cinfo.output_components];
|
||||
row_pointer[0] = static_cast<unsigned char*>(malloc(cinfo.output_width*cinfo.output_components * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(! row_pointer[0]);
|
||||
|
||||
_dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(! _data);
|
||||
|
||||
/* now actually read the jpeg into the raw buffer */
|
||||
|
@ -816,7 +834,10 @@ bool Image::initWithJpgData(const unsigned char * data, int dataLen)
|
|||
bRet = true;
|
||||
} while (0);
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(row_pointer[0]);
|
||||
if (row_pointer[0] != nullptr)
|
||||
{
|
||||
free(row_pointer[0]);
|
||||
};
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
@ -926,7 +947,7 @@ bool Image::initWithPngData(const unsigned char * data, int dataLen)
|
|||
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
_dataLen = rowbytes * _height;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(!_data);
|
||||
|
||||
for (unsigned short i = 0; i < _height; ++i)
|
||||
|
@ -939,7 +960,10 @@ bool Image::initWithPngData(const unsigned char * data, int dataLen)
|
|||
|
||||
_preMulti = false;
|
||||
|
||||
CC_SAFE_FREE(row_pointers);
|
||||
if (row_pointers != nullptr)
|
||||
{
|
||||
free(row_pointers);
|
||||
};
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
@ -1097,7 +1121,7 @@ bool Image::initWithTiffData(const unsigned char * data, int dataLen)
|
|||
_height = h;
|
||||
|
||||
_dataLen = npixels * sizeof (uint32);
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
|
||||
uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
|
||||
if (raster != NULL)
|
||||
|
@ -1222,7 +1246,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
//Move by size of header
|
||||
_dataLen = dataLen - sizeof(PVRv2TexHeader);
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy(_data, (unsigned char*)data + sizeof(PVRv2TexHeader), _dataLen);
|
||||
|
||||
// Calculate the data size for each texture level and respect the minimum number of blocks
|
||||
|
@ -1344,7 +1368,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, int dataLen)
|
|||
int blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||
|
||||
_dataLen = dataLen - (sizeof(PVRv3TexHeader) + header->metadataLength);
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy(_data, static_cast<const unsigned char*>(data) + sizeof(PVRv3TexHeader) + header->metadataLength, _dataLen);
|
||||
|
||||
_numberOfMipmaps = header->numberOfMipmaps;
|
||||
|
@ -1431,7 +1455,7 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen)
|
|||
#ifdef GL_ETC1_RGB8_OES
|
||||
_renderFormat = Texture2D::PixelFormat::ETC;
|
||||
_dataLen = dataLen - ETC_PKM_HEADER_SIZE;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy(_data, static_cast<const unsigned char*>(data) + ETC_PKM_HEADER_SIZE, _dataLen);
|
||||
return true;
|
||||
#endif
|
||||
|
@ -1446,12 +1470,15 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen)
|
|||
_renderFormat = Texture2D::PixelFormat::RGB888;
|
||||
|
||||
_dataLen = _width * _height * bytePerPixel;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
|
||||
if (etc1_decode_image(static_cast<const unsigned char*>(data) + ETC_PKM_HEADER_SIZE, static_cast<etc1_byte*>(_data), _width, _height, bytePerPixel, stride) != 0)
|
||||
{
|
||||
_dataLen = 0;
|
||||
CC_SAFE_DELETE_ARRAY(_data);
|
||||
if (_data != nullptr)
|
||||
{
|
||||
free(_data);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1460,6 +1487,85 @@ bool Image::initWithETCData(const unsigned char * data, int dataLen)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Image::initWithTGAData(tImageTGA* tgaData)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(tgaData == nullptr);
|
||||
|
||||
// tgaLoadBuffer only support type 2, 3, 10
|
||||
if (2 == tgaData->type || 10 == tgaData->type)
|
||||
{
|
||||
// true color
|
||||
// unsupport RGB555
|
||||
if (tgaData->pixelDepth == 16)
|
||||
{
|
||||
_renderFormat = Texture2D::PixelFormat::RGB5A1;
|
||||
}
|
||||
else if(tgaData->pixelDepth == 24)
|
||||
{
|
||||
_renderFormat = Texture2D::PixelFormat::RGB888;
|
||||
}
|
||||
else if(tgaData->pixelDepth == 32)
|
||||
{
|
||||
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Image WARNING: unsupport true color tga data pixel format. FILE: %s", _filePath.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(3 == tgaData->type)
|
||||
{
|
||||
// gray
|
||||
if (8 == tgaData->pixelDepth)
|
||||
{
|
||||
_renderFormat = Texture2D::PixelFormat::I8;
|
||||
}
|
||||
else
|
||||
{
|
||||
// actually this won't happen, if it happens, maybe the image file is not a tga
|
||||
CCLOG("Image WARNING: unsupport gray tga data pixel format. FILE: %s", _filePath.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_width = tgaData->width;
|
||||
_height = tgaData->height;
|
||||
_data = tgaData->imageData;
|
||||
_dataLen = _width * _height * tgaData->pixelDepth / 8;
|
||||
_fileType = Format::TGA;
|
||||
_preMulti = false;
|
||||
ret = true;
|
||||
|
||||
}while(false);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
const unsigned char tgaSuffix[] = ".tga";
|
||||
for(int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (std::tolower(_filePath[_filePath.length() - i - 1]) != tgaSuffix[3 - i])
|
||||
{
|
||||
CCLOG("Image WARNING: the image file suffix is not tga, but parsed as a tga image file. FILE: %s", _filePath.c_str());
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tgaData->imageData != nullptr)
|
||||
{
|
||||
free(tgaData->imageData);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static const uint32_t makeFourCC(char ch0, char ch1, char ch2, char ch3)
|
||||
|
@ -1479,7 +1585,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
|||
/* load the .dds file */
|
||||
|
||||
S3TCTexHeader *header = (S3TCTexHeader *)data;
|
||||
unsigned char *pixelData = new unsigned char [dataLen - sizeof(S3TCTexHeader)];
|
||||
unsigned char *pixelData = static_cast<unsigned char*>(malloc((dataLen - sizeof(S3TCTexHeader)) * sizeof(unsigned char)));
|
||||
memcpy((void *)pixelData, data + sizeof(S3TCTexHeader), dataLen - sizeof(S3TCTexHeader));
|
||||
|
||||
_width = header->ddsd.width;
|
||||
|
@ -1496,7 +1602,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
|||
if (Configuration::getInstance()->supportsS3TC()) //compressed data length
|
||||
{
|
||||
_dataLen = dataLen - sizeof(S3TCTexHeader);
|
||||
_data = new unsigned char [_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy((void *)_data,(void *)pixelData , _dataLen);
|
||||
}
|
||||
else //decompressed data length
|
||||
|
@ -1511,7 +1617,7 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
|||
width >>= 1;
|
||||
height >>= 1;
|
||||
}
|
||||
_data = new unsigned char [_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
}
|
||||
|
||||
/* load the mipmaps */
|
||||
|
@ -1582,7 +1688,10 @@ bool Image::initWithS3TCData(const unsigned char * data, int dataLen)
|
|||
|
||||
/* end load the mipmaps */
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(pixelData);
|
||||
if (pixelData != nullptr)
|
||||
{
|
||||
free(pixelData);
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1622,7 +1731,7 @@ bool Image::initWithATITCData(const unsigned char *data, int dataLen)
|
|||
if (Configuration::getInstance()->supportsATITC()) //compressed data length
|
||||
{
|
||||
_dataLen = dataLen - sizeof(ATITCTexHeader) - header->bytesOfKeyValueData - 4;
|
||||
_data = new unsigned char [_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
memcpy((void *)_data,(void *)pixelData , _dataLen);
|
||||
}
|
||||
else //decompressed data length
|
||||
|
@ -1637,7 +1746,7 @@ bool Image::initWithATITCData(const unsigned char *data, int dataLen)
|
|||
width >>= 1;
|
||||
height >>= 1;
|
||||
}
|
||||
_data = new unsigned char [_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
}
|
||||
|
||||
/* load the mipmaps */
|
||||
|
@ -1738,7 +1847,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
|||
_height = config.input.height;
|
||||
|
||||
_dataLen = _width * _height * 4;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
|
||||
config.output.u.RGBA.rgba = static_cast<uint8_t*>(_data);
|
||||
config.output.u.RGBA.stride = _width * 4;
|
||||
|
@ -1747,7 +1856,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
|||
|
||||
if (WebPDecode(static_cast<const uint8_t*>(data), dataLen, &config) != VP8_STATUS_OK)
|
||||
{
|
||||
delete []_data;
|
||||
free(_data);
|
||||
_data = NULL;
|
||||
break;
|
||||
}
|
||||
|
@ -1772,7 +1881,7 @@ bool Image::initWithRawData(const unsigned char * data, long dataLen, long width
|
|||
// only RGBA8888 supported
|
||||
int bytesPerComponent = 4;
|
||||
_dataLen = height * width * bytesPerComponent;
|
||||
_data = new unsigned char[_dataLen];
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(! _data);
|
||||
memcpy(_data, data, _dataLen);
|
||||
|
||||
|
@ -1907,7 +2016,7 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB)
|
|||
{
|
||||
if (isToRGB)
|
||||
{
|
||||
unsigned char *pTempData = new unsigned char[_width * _height * 3];
|
||||
unsigned char *pTempData = static_cast<unsigned char*>(malloc(_width * _height * 3 * sizeof(unsigned char*)));
|
||||
if (NULL == pTempData)
|
||||
{
|
||||
fclose(fp);
|
||||
|
@ -1935,7 +2044,10 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB)
|
|||
free(row_pointers);
|
||||
row_pointers = NULL;
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(pTempData);
|
||||
if (pTempData != nullptr)
|
||||
{
|
||||
free(pTempData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1996,7 +2108,7 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
|||
|
||||
if (hasAlpha())
|
||||
{
|
||||
unsigned char *pTempData = new unsigned char[_width * _height * 3];
|
||||
unsigned char *pTempData = static_cast<unsigned char*>(malloc(_width * _height * 3 * sizeof(unsigned char)));
|
||||
if (NULL == pTempData)
|
||||
{
|
||||
jpeg_finish_compress(&cinfo);
|
||||
|
@ -2021,7 +2133,10 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
|||
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE_ARRAY(pTempData);
|
||||
if (pTempData != nullptr)
|
||||
{
|
||||
free(pTempData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,17 +18,17 @@ void Device::setAccelerometerEnabled(bool isEnabled)
|
|||
{
|
||||
if (isEnabled)
|
||||
{
|
||||
enableAccelerometer();
|
||||
enableAccelerometerJni();
|
||||
}
|
||||
else
|
||||
{
|
||||
disableAccelerometer();
|
||||
disableAccelerometerJni();
|
||||
}
|
||||
}
|
||||
|
||||
void Device::setAccelerometerInterval(float interval)
|
||||
{
|
||||
setAccelerometerInterval(interval);
|
||||
setAccelerometerIntervalJni(interval);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -471,8 +471,8 @@ static int32_t engine_handle_input(struct android_app* app, AInputEvent* event)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void enableAccelerometer(void) {
|
||||
LOGI("enableAccelerometer()");
|
||||
void enableAccelerometerJni(void) {
|
||||
LOGI("enableAccelerometerJni()");
|
||||
|
||||
if (engine.accelerometerSensor != NULL) {
|
||||
ASensorEventQueue_enableSensor(engine.sensorEventQueue,
|
||||
|
@ -485,8 +485,8 @@ void enableAccelerometer(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void disableAccelerometer(void) {
|
||||
LOGI("disableAccelerometer()");
|
||||
void disableAccelerometerJni(void) {
|
||||
LOGI("disableAccelerometerJni()");
|
||||
|
||||
if (engine.accelerometerSensor != NULL) {
|
||||
ASensorEventQueue_disableSensor(engine.sensorEventQueue,
|
||||
|
@ -494,8 +494,8 @@ void disableAccelerometer(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void setAccelerometerInterval(float interval) {
|
||||
LOGI("setAccelerometerInterval(%f)", interval);
|
||||
void setAccelerometerIntervalJni(float interval) {
|
||||
LOGI("setAccelerometerIntervalJni(%f)", interval);
|
||||
// We'd like to get 60 events per second (in us).
|
||||
ASensorEventQueue_setEventRate(engine.sensorEventQueue,
|
||||
engine.accelerometerSensor, interval * 1000000L);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* This is the interface to the Android native activity
|
||||
*/
|
||||
|
||||
void enableAccelerometer(void);
|
||||
void disableAccelerometer(void);
|
||||
void setAccelerometerInterval(float interval);
|
||||
void enableAccelerometerJni(void);
|
||||
void disableAccelerometerJni(void);
|
||||
void setAccelerometerIntervalJni(float interval);
|
||||
|
||||
#endif // __COCOSNATIVEACTIVITY_H__
|
||||
|
|
|
@ -413,7 +413,7 @@ EGLView::EGLView()
|
|||
{
|
||||
g_keyCodeMap.insert(std::make_pair(item.glfwKeyCode, item.keyCode));
|
||||
}
|
||||
strcpy(_viewName, "Cocos2dxWin32");
|
||||
_viewName = "Cocos2dxWin32";
|
||||
glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError);
|
||||
glfwInit();
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ bool EGLView::init(const char* viewName, float width, float height, float frameZ
|
|||
setFrameZoomFactor(frameZoomFactor);
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
|
||||
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName, nullptr, nullptr);
|
||||
_mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName.c_str(), nullptr, nullptr);
|
||||
glfwMakeContextCurrent(_mainWindow);
|
||||
|
||||
glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]);
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
set(AUDIO_SRC
|
||||
linux/SimpleAudioEngineFMOD.cpp
|
||||
linux/FmodAudioPlayer.cpp
|
||||
)
|
||||
|
||||
# architecture
|
||||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(ARCH_DIR "64-bit")
|
||||
|
@ -10,14 +5,31 @@ else()
|
|||
set(ARCH_DIR "32-bit")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../../external/linux-specific/fmod/include/${ARCH_DIR}
|
||||
)
|
||||
if(WIN32)
|
||||
set(AUDIO_SRC
|
||||
win32/SimpleAudioEngine.cpp
|
||||
win32/MciPlayer.cpp
|
||||
)
|
||||
elseif(APPLE)
|
||||
|
||||
else()
|
||||
set(AUDIO_SRC
|
||||
linux/SimpleAudioEngineFMOD.cpp
|
||||
linux/FmodAudioPlayer.cpp
|
||||
)
|
||||
|
||||
include_directories(
|
||||
../../external/linux-specific/fmod/include/${ARCH_DIR}
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
add_library(audio STATIC
|
||||
${AUDIO_SRC}
|
||||
)
|
||||
|
||||
if((NOT APPLE) AND (NOT WIN32))
|
||||
|
||||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(FMOD_LIB "fmodex64")
|
||||
else()
|
||||
|
@ -33,4 +45,4 @@ set_target_properties(audio
|
|||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
|
|
@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(long capacity)
|
||||
Array* Array::createWithCapacity(size_t capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(long capacity)
|
||||
bool Array::initWithCapacity(size_t capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -196,11 +196,11 @@ bool Array::initWithArray(Array* otherArray)
|
|||
return true;
|
||||
}
|
||||
|
||||
int Array::getIndexOfObject(Object* object) const
|
||||
size_t Array::getIndexOfObject(Object* object) const
|
||||
{
|
||||
auto it = data.begin();
|
||||
|
||||
for (long i = 0; it != data.end(); ++it, ++i)
|
||||
for (size_t i = 0; it != data.end(); ++it, ++i)
|
||||
{
|
||||
if (it->get() == object)
|
||||
{
|
||||
|
@ -232,13 +232,13 @@ Object* Array::getRandomObject()
|
|||
|
||||
bool Array::containsObject(Object* object) const
|
||||
{
|
||||
int i = this->getIndexOfObject(object);
|
||||
return (i >=0);
|
||||
auto i = this->getIndexOfObject(object);
|
||||
return (i >= 0);
|
||||
}
|
||||
|
||||
bool Array::isEqualToArray(Array* otherArray)
|
||||
{
|
||||
for (long i = 0; i< this->count(); i++)
|
||||
for (size_t i = 0; i < this->count(); ++i)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ bool Array::isEqualToArray(Array* otherArray)
|
|||
|
||||
void Array::addObject(Object* object)
|
||||
{
|
||||
data.push_back( RCPtr<Object>(object) );
|
||||
data.push_back(RCPtr<Object>(object));
|
||||
}
|
||||
|
||||
void Array::addObjectsFromArray(Array* otherArray)
|
||||
|
@ -258,12 +258,12 @@ void Array::addObjectsFromArray(Array* otherArray)
|
|||
data.insert(data.end(), otherArray->data.begin(), otherArray->data.end());
|
||||
}
|
||||
|
||||
void Array::insertObject(Object* object, int index)
|
||||
void Array::insertObject(Object* object, size_t index)
|
||||
{
|
||||
data.insert( std::begin(data) + index, RCPtr<Object>(object) );
|
||||
data.insert(std::begin(data) + index, RCPtr<Object>(object));
|
||||
}
|
||||
|
||||
void Array::setObject(Object* object, int index)
|
||||
void Array::setObject(Object* object, size_t index)
|
||||
{
|
||||
data[index] = RCPtr<Object>(object);
|
||||
}
|
||||
|
@ -276,13 +276,13 @@ void Array::removeLastObject(bool releaseObj)
|
|||
|
||||
void Array::removeObject(Object* object, bool releaseObj /* ignored */)
|
||||
{
|
||||
data.erase( std::remove( data.begin(), data.end(), object ) );
|
||||
data.erase(std::remove(data.begin(), data.end(), object));
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(long index, bool releaseObj /* ignored */)
|
||||
void Array::removeObjectAtIndex(size_t index, bool releaseObj /* ignored */)
|
||||
{
|
||||
auto obj = data[index];
|
||||
data.erase( data.begin() + index );
|
||||
data.erase(data.begin() + index);
|
||||
}
|
||||
|
||||
void Array::removeObjectsInArray(Array* otherArray)
|
||||
|
@ -295,7 +295,7 @@ void Array::removeAllObjects()
|
|||
data.erase(std::begin(data), std::end(data));
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(long index)
|
||||
void Array::fastRemoveObjectAtIndex(size_t index)
|
||||
{
|
||||
removeObjectAtIndex(index);
|
||||
}
|
||||
|
@ -307,27 +307,27 @@ void Array::fastRemoveObject(Object* object)
|
|||
|
||||
void Array::exchangeObject(Object* object1, Object* object2)
|
||||
{
|
||||
int idx1 = getIndexOfObject(object1);
|
||||
int idx2 = getIndexOfObject(object2);
|
||||
auto idx1 = getIndexOfObject(object1);
|
||||
auto idx2 = getIndexOfObject(object2);
|
||||
|
||||
CCASSERT(idx1>=0 && idx2>=2, "invalid object index");
|
||||
CCASSERT(idx1 >= 0 && idx2 >= 2, "invalid object index");
|
||||
|
||||
std::swap( data[idx1], data[idx2] );
|
||||
std::swap(data[idx1], data[idx2]);
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(long index1, long index2)
|
||||
void Array::exchangeObjectAtIndex(size_t index1, size_t index2)
|
||||
{
|
||||
std::swap( data[index1], data[index2] );
|
||||
std::swap(data[index1], data[index2]);
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject /* ignored */)
|
||||
void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject /* ignored */)
|
||||
{
|
||||
data[index] = object;
|
||||
}
|
||||
|
||||
void Array::reverseObjects()
|
||||
{
|
||||
std::reverse( std::begin(data), std::end(data) );
|
||||
std::reverse(std::begin(data), std::end(data));
|
||||
}
|
||||
|
||||
void Array::reduceMemoryFootprint()
|
||||
|
@ -448,7 +448,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(long capacity)
|
||||
Array* Array::createWithCapacity(size_t capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -531,7 +531,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(long capacity)
|
||||
bool Array::initWithCapacity(size_t capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized");
|
||||
|
||||
|
@ -555,7 +555,7 @@ bool Array::initWithArray(Array* otherArray)
|
|||
return ret;
|
||||
}
|
||||
|
||||
long Array::getIndexOfObject(Object* object) const
|
||||
size_t Array::getIndexOfObject(Object* object) const
|
||||
{
|
||||
return ccArrayGetIndexOfObject(data, object);
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ Object* Array::getRandomObject()
|
|||
r = 0;
|
||||
}
|
||||
|
||||
return data->arr[(long)(data->num * r)];
|
||||
return data->arr[static_cast<size_t>(data->num * r)];
|
||||
}
|
||||
|
||||
bool Array::containsObject(Object* object) const
|
||||
|
@ -584,7 +584,7 @@ bool Array::containsObject(Object* object) const
|
|||
|
||||
bool Array::isEqualToArray(Array* otherArray)
|
||||
{
|
||||
for (long i = 0; i< this->count(); i++)
|
||||
for (size_t i = 0; i < this->count(); ++i)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -606,15 +606,15 @@ void Array::addObjectsFromArray(Array* otherArray)
|
|||
ccArrayAppendArrayWithResize(data, otherArray->data);
|
||||
}
|
||||
|
||||
void Array::insertObject(Object* object, long index)
|
||||
void Array::insertObject(Object* object, size_t index)
|
||||
{
|
||||
CCASSERT(data, "Array not initialized");
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
}
|
||||
|
||||
void Array::setObject(Object* object, long index)
|
||||
void Array::setObject(Object* object, size_t index)
|
||||
{
|
||||
CCASSERT(index>=0 && index < count(), "Invalid index");
|
||||
CCASSERT(index >= 0 && index < count(), "Invalid index");
|
||||
|
||||
if (object != data->arr[index])
|
||||
{
|
||||
|
@ -627,7 +627,7 @@ void Array::setObject(Object* object, long index)
|
|||
void Array::removeLastObject(bool releaseObj)
|
||||
{
|
||||
CCASSERT(data->num, "no objects added");
|
||||
ccArrayRemoveObjectAtIndex(data, data->num-1, releaseObj);
|
||||
ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj);
|
||||
}
|
||||
|
||||
void Array::removeObject(Object* object, bool releaseObj/* = true*/)
|
||||
|
@ -635,7 +635,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/)
|
|||
ccArrayRemoveObject(data, object, releaseObj);
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(long index, bool releaseObj)
|
||||
void Array::removeObjectAtIndex(size_t index, bool releaseObj)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(data, index, releaseObj);
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ void Array::removeAllObjects()
|
|||
ccArrayRemoveAllObjects(data);
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(long index)
|
||||
void Array::fastRemoveObjectAtIndex(size_t index)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(data, index);
|
||||
}
|
||||
|
@ -662,13 +662,13 @@ void Array::fastRemoveObject(Object* object)
|
|||
|
||||
void Array::exchangeObject(Object* object1, Object* object2)
|
||||
{
|
||||
long index1 = ccArrayGetIndexOfObject(data, object1);
|
||||
auto index1 = ccArrayGetIndexOfObject(data, object1);
|
||||
if (index1 == CC_INVALID_INDEX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
long index2 = ccArrayGetIndexOfObject(data, object2);
|
||||
auto index2 = ccArrayGetIndexOfObject(data, object2);
|
||||
if (index2 == CC_INVALID_INDEX)
|
||||
{
|
||||
return;
|
||||
|
@ -677,15 +677,15 @@ void Array::exchangeObject(Object* object1, Object* object2)
|
|||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(long index1, long index2)
|
||||
void Array::exchangeObjectAtIndex(size_t index1, size_t index2)
|
||||
{
|
||||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject/* = true*/)
|
||||
void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject/* = true*/)
|
||||
{
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
ccArrayRemoveObjectAtIndex(data, index+1);
|
||||
ccArrayRemoveObjectAtIndex(data, index + 1);
|
||||
}
|
||||
|
||||
void Array::reverseObjects()
|
||||
|
@ -693,10 +693,10 @@ void Array::reverseObjects()
|
|||
if (data->num > 1)
|
||||
{
|
||||
// floorf(), since in the case of an even number, the number of swaps stays the same
|
||||
long count = (long) floorf(data->num/2.f);
|
||||
long maxIndex = data->num - 1;
|
||||
auto count = static_cast<int>(floorf(data->num/2.f));
|
||||
auto maxIndex = data->num - 1;
|
||||
|
||||
for (long i = 0; i < count ; i++)
|
||||
for (int i = 0; i < count ; ++i)
|
||||
{
|
||||
ccArraySwapObjectsAtIndexes(data, i, maxIndex);
|
||||
--maxIndex;
|
||||
|
|
|
@ -250,7 +250,7 @@ public:
|
|||
/** Create an array with a default capacity
|
||||
* @js NA
|
||||
*/
|
||||
static Array* createWithCapacity(long capacity);
|
||||
static Array* createWithCapacity(size_t capacity);
|
||||
/** Create an array with from an existing array
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithCapacity(long capacity);
|
||||
bool initWithCapacity(size_t capacity);
|
||||
/** Initializes an array with an existing array
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -307,7 +307,7 @@ public:
|
|||
/** Returns element count of the array
|
||||
* @js NA
|
||||
*/
|
||||
long count() const
|
||||
size_t count() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.size();
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
/** Returns capacity of the array
|
||||
* @js NA
|
||||
*/
|
||||
long capacity() const
|
||||
size_t capacity() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.capacity();
|
||||
|
@ -330,17 +330,17 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
long getIndexOfObject(Object* object) const;
|
||||
size_t getIndexOfObject(Object* object) const;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE long indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
CC_DEPRECATED_ATTRIBUTE size_t indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
|
||||
/** Returns an element with a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* getObjectAtIndex(long index)
|
||||
Object* getObjectAtIndex(size_t index)
|
||||
{
|
||||
CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()");
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
return data->arr[index];
|
||||
#endif
|
||||
}
|
||||
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(long index) { return getObjectAtIndex(index); }
|
||||
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(size_t index) { return getObjectAtIndex(index); }
|
||||
/** Returns the last element of the array
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -401,17 +401,17 @@ public:
|
|||
/** Insert a certain object at a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void insertObject(Object* object, long index);
|
||||
void insertObject(Object* object, size_t index);
|
||||
/** sets a certain object at a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setObject(Object* object, long index);
|
||||
void setObject(Object* object, size_t index);
|
||||
/** sets a certain object at a certain index without retaining. Use it with caution
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void fastSetObject(Object* object, long index)
|
||||
void fastSetObject(Object* object, size_t index)
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
setObject(object, index);
|
||||
|
@ -424,7 +424,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void swap( long indexOne, long indexTwo )
|
||||
void swap( size_t indexOne, size_t indexTwo )
|
||||
{
|
||||
CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices");
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -447,7 +447,7 @@ public:
|
|||
/** Remove an element with a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectAtIndex(long index, bool releaseObj = true);
|
||||
void removeObjectAtIndex(size_t index, bool releaseObj = true);
|
||||
/** Remove all elements
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -463,7 +463,7 @@ public:
|
|||
/** Fast way to remove an element with a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void fastRemoveObjectAtIndex(long index);
|
||||
void fastRemoveObjectAtIndex(size_t index);
|
||||
|
||||
// Rearranging Content
|
||||
|
||||
|
@ -474,12 +474,12 @@ public:
|
|||
/** Swap two elements with certain indexes
|
||||
* @js NA
|
||||
*/
|
||||
void exchangeObjectAtIndex(long index1, long index2);
|
||||
void exchangeObjectAtIndex(size_t index1, size_t index2);
|
||||
|
||||
/** Replace object at index with another object.
|
||||
* @js NA
|
||||
*/
|
||||
void replaceObjectAtIndex(long index, Object* object, bool releaseObject = true);
|
||||
void replaceObjectAtIndex(size_t index, Object* object, bool releaseObject = true);
|
||||
|
||||
/** Revers the array
|
||||
* @js NA
|
||||
|
|
|
@ -237,14 +237,14 @@ public: virtual void set##funName(varType var) \
|
|||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \
|
||||
|| (defined(__clang__) && (__clang_major__ >= 3))
|
||||
|| (defined(__clang__) && (__clang_major__ >= 3)) || (_MSC_VER >= 1800)
|
||||
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName &) = delete; \
|
||||
TypeName &operator =(const TypeName &) = delete;
|
||||
#else
|
||||
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
Class(const TypeName &); \
|
||||
Class &operator =(const TypeName &);
|
||||
TypeName(const TypeName &); \
|
||||
TypeName &operator =(const TypeName &);
|
||||
#endif
|
||||
|
||||
// A macro to disallow all the implicit constructors, namely the
|
||||
|
|
|
@ -367,7 +367,7 @@ void SIOClientImpl::onOpen(WebSocket* ws)
|
|||
c->onOpen();
|
||||
}
|
||||
|
||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
|
||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9f), false);
|
||||
|
||||
log("SIOClientImpl::onOpen socket connected!");
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <climits>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "chipmunk.h"
|
||||
|
||||
|
@ -348,7 +349,7 @@ void PhysicsBody::setPosition(Point position)
|
|||
|
||||
void PhysicsBody::setRotation(float rotation)
|
||||
{
|
||||
cpBodySetAngle(_info->getBody(), PhysicsHelper::float2cpfloat(rotation));
|
||||
cpBodySetAngle(_info->getBody(), PhysicsHelper::float2cpfloat(rotation * M_PI / 180.0f));
|
||||
}
|
||||
|
||||
Point PhysicsBody::getPosition() const
|
||||
|
@ -359,7 +360,7 @@ Point PhysicsBody::getPosition() const
|
|||
|
||||
float PhysicsBody::getRotation() const
|
||||
{
|
||||
return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) / 3.14f * 180.0f);
|
||||
return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) / M_PI * 180.0f);
|
||||
}
|
||||
|
||||
PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* = true*/)
|
||||
|
|
|
@ -97,46 +97,6 @@ void PhysicsJoint::setEnable(bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
PhysicsJointPin::PhysicsJointPin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointPin::~PhysicsJointPin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointFixed::PhysicsJointFixed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointFixed::~PhysicsJointFixed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointLimit::PhysicsJointLimit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointLimit::~PhysicsJointLimit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointDistance::PhysicsJointDistance()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsJointDistance::~PhysicsJointDistance()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PhysicsBodyInfo* PhysicsJoint::getBodyInfo(PhysicsBody* body) const
|
||||
{
|
||||
return body->_info;
|
||||
|
@ -147,7 +107,6 @@ Node* PhysicsJoint::getBodyNode(PhysicsBody* body) const
|
|||
return body->_node;
|
||||
}
|
||||
|
||||
|
||||
void PhysicsJoint::setCollisionEnable(bool enable)
|
||||
{
|
||||
if (_collisionEnable != enable)
|
||||
|
@ -190,6 +149,19 @@ void PhysicsJoint::destroy(PhysicsJoint* joint)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsJoint::setMaxForce(float force)
|
||||
{
|
||||
for (cpConstraint* joint : _info->getJoints())
|
||||
{
|
||||
joint->maxForce = PhysicsHelper::float2cpfloat(force);
|
||||
}
|
||||
}
|
||||
|
||||
float PhysicsJoint::getMaxForce() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce);
|
||||
}
|
||||
|
||||
PhysicsJointFixed* PhysicsJointFixed::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr)
|
||||
{
|
||||
PhysicsJointFixed* joint = new PhysicsJointFixed();
|
||||
|
@ -262,21 +234,11 @@ bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr)
|
|||
return false;
|
||||
}
|
||||
|
||||
void PhysicsJointPin::setMaxForce(float force)
|
||||
{
|
||||
_info->getJoints().front()->maxForce = PhysicsHelper::float2cpfloat(force);
|
||||
}
|
||||
|
||||
float PhysicsJointPin::getMaxForce() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(_info->getJoints().front()->maxForce);
|
||||
}
|
||||
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max)
|
||||
{
|
||||
PhysicsJointLimit* joint = new PhysicsJointLimit();
|
||||
|
||||
if (joint && joint->init(a, b, anchr1, anchr2))
|
||||
if (joint && joint->init(a, b, anchr1, anchr2, min, max))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
@ -285,7 +247,12 @@ PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
|
||||
PhysicsJointLimit* PhysicsJointLimit::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
|
||||
{
|
||||
return construct(a, b, anchr1, anchr2, 0, b->local2World(anchr1).getDistance(a->local2World(anchr2)));
|
||||
}
|
||||
|
||||
bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -294,8 +261,8 @@ bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1
|
|||
cpConstraint* joint = cpSlideJointNew(getBodyInfo(a)->getBody(), getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::point2cpv(anchr1),
|
||||
PhysicsHelper::point2cpv(anchr2),
|
||||
0,
|
||||
PhysicsHelper::float2cpfloat(_bodyA->local2World(anchr1).getDistance(_bodyB->local2World(anchr2))));
|
||||
PhysicsHelper::float2cpfloat(min),
|
||||
PhysicsHelper::float2cpfloat(max));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
|
@ -327,6 +294,26 @@ void PhysicsJointLimit::setMax(float max)
|
|||
cpSlideJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max));
|
||||
}
|
||||
|
||||
Point PhysicsJointLimit::getAnchr1() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpSlideJointGetAnchr1(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointLimit::setAnchr1(const Point& anchr)
|
||||
{
|
||||
cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
Point PhysicsJointLimit::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpSlideJointGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointLimit::setAnchr2(const Point& anchr)
|
||||
{
|
||||
cpSlideJointSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
PhysicsJointDistance* PhysicsJointDistance::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2)
|
||||
{
|
||||
PhysicsJointDistance* joint = new PhysicsJointDistance();
|
||||
|
@ -361,5 +348,449 @@ bool PhysicsJointDistance::init(PhysicsBody* a, PhysicsBody* b, const Point& anc
|
|||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointDistance::getDistance() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpPinJointGetDist(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointDistance::setDistance(float distance)
|
||||
{
|
||||
cpPinJointSetDist(_info->getJoints().front(), PhysicsHelper::float2cpfloat(distance));
|
||||
}
|
||||
|
||||
PhysicsJointSpring* PhysicsJointSpring::construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping)
|
||||
{
|
||||
PhysicsJointSpring* joint = new PhysicsJointSpring();
|
||||
|
||||
if (joint && joint->init(a, b, anchr1, anchr2, stiffness, damping))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointSpring::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping)
|
||||
{
|
||||
do {
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpDampedSpringNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::point2cpv(anchr1),
|
||||
PhysicsHelper::point2cpv(anchr2),
|
||||
PhysicsHelper::float2cpfloat(_bodyB->local2World(anchr1).getDistance(_bodyA->local2World(anchr2))),
|
||||
PhysicsHelper::float2cpfloat(stiffness),
|
||||
PhysicsHelper::float2cpfloat(damping));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsJointSpring::getAnchr1() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr1(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setAnchr1(const Point& anchr)
|
||||
{
|
||||
cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
Point PhysicsJointSpring::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpDampedSpringGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setAnchr2(const Point& anchr)
|
||||
{
|
||||
cpDampedSpringSetAnchr1(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr));
|
||||
}
|
||||
|
||||
float PhysicsJointSpring::getRestLength() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedSpringGetRestLength(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setRestLength(float restLength)
|
||||
{
|
||||
cpDampedSpringSetRestLength(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restLength));
|
||||
}
|
||||
|
||||
float PhysicsJointSpring::getStiffness() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedSpringGetStiffness(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setStiffness(float stiffness)
|
||||
{
|
||||
cpDampedSpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness));
|
||||
}
|
||||
|
||||
float PhysicsJointSpring::getDamping() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedSpringGetDamping(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointSpring::setDamping(float damping)
|
||||
{
|
||||
cpDampedSpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping));
|
||||
}
|
||||
|
||||
PhysicsJointGroove* PhysicsJointGroove::construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2)
|
||||
{
|
||||
PhysicsJointGroove* joint = new PhysicsJointGroove();
|
||||
|
||||
if (joint && joint->init(a, b, grooveA, grooveB, anchr2))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointGroove::init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2)
|
||||
{
|
||||
do {
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpGrooveJointNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::point2cpv(grooveA),
|
||||
PhysicsHelper::point2cpv(grooveB),
|
||||
PhysicsHelper::point2cpv(anchr2));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getGrooveA() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveA(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setGrooveA(const Point& grooveA)
|
||||
{
|
||||
cpGrooveJointSetGrooveA(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveA));
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getGrooveB() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetGrooveB(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setGrooveB(const Point& grooveB)
|
||||
{
|
||||
cpGrooveJointSetGrooveB(_info->getJoints().front(), PhysicsHelper::point2cpv(grooveB));
|
||||
}
|
||||
|
||||
Point PhysicsJointGroove::getAnchr2() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpGrooveJointGetAnchr2(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGroove::setAnchr2(const Point& anchr2)
|
||||
{
|
||||
cpGrooveJointSetAnchr2(_info->getJoints().front(), PhysicsHelper::point2cpv(anchr2));
|
||||
}
|
||||
|
||||
PhysicsJointRotarySpring* PhysicsJointRotarySpring::construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping)
|
||||
{
|
||||
PhysicsJointRotarySpring* joint = new PhysicsJointRotarySpring();
|
||||
|
||||
if (joint && joint->init(a, b, stiffness, damping))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointRotarySpring::init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping)
|
||||
{
|
||||
do {
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpDampedRotarySpringNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::float2cpfloat(_bodyB->getRotation() - _bodyA->getRotation()),
|
||||
PhysicsHelper::float2cpfloat(stiffness),
|
||||
PhysicsHelper::float2cpfloat(damping));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointRotarySpring::getRestAngle() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetRestAngle(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRotarySpring::setRestAngle(float restAngle)
|
||||
{
|
||||
cpDampedRotarySpringSetRestAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(restAngle));
|
||||
}
|
||||
|
||||
float PhysicsJointRotarySpring::getStiffness() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetStiffness(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRotarySpring::setStiffness(float stiffness)
|
||||
{
|
||||
cpDampedRotarySpringSetStiffness(_info->getJoints().front(), PhysicsHelper::float2cpfloat(stiffness));
|
||||
}
|
||||
|
||||
float PhysicsJointRotarySpring::getDamping() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpDampedRotarySpringGetDamping(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRotarySpring::setDamping(float damping)
|
||||
{
|
||||
cpDampedRotarySpringSetDamping(_info->getJoints().front(), PhysicsHelper::float2cpfloat(damping));
|
||||
}
|
||||
|
||||
PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b, float min, float max)
|
||||
{
|
||||
PhysicsJointRotaryLimit* joint = new PhysicsJointRotaryLimit();
|
||||
|
||||
if (joint && joint->init(a, b, min, max))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PhysicsJointRotaryLimit* PhysicsJointRotaryLimit::construct(PhysicsBody* a, PhysicsBody* b)
|
||||
{
|
||||
return construct(a, b, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
bool PhysicsJointRotaryLimit::init(PhysicsBody* a, PhysicsBody* b, float min, float max)
|
||||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpRotaryLimitJointNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::float2cpfloat(min),
|
||||
PhysicsHelper::float2cpfloat(max));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointRotaryLimit::getMin() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMin(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRotaryLimit::setMin(float min)
|
||||
{
|
||||
cpRotaryLimitJointSetMin(_info->getJoints().front(), PhysicsHelper::float2cpfloat(min));
|
||||
}
|
||||
|
||||
float PhysicsJointRotaryLimit::getMax() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpRotaryLimitJointGetMax(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRotaryLimit::setMax(float max)
|
||||
{
|
||||
cpRotaryLimitJointSetMax(_info->getJoints().front(), PhysicsHelper::float2cpfloat(max));
|
||||
}
|
||||
|
||||
PhysicsJointRatchet* PhysicsJointRatchet::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet)
|
||||
{
|
||||
PhysicsJointRatchet* joint = new PhysicsJointRatchet();
|
||||
|
||||
if (joint && joint->init(a, b, phase, ratchet))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointRatchet::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet)
|
||||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpRatchetJointNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::float2cpfloat(phase),
|
||||
PhysicsHelper::cpfloat2float(ratchet));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointRatchet::getAngle() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpRatchetJointGetAngle(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRatchet::setAngle(float angle)
|
||||
{
|
||||
cpRatchetJointSetAngle(_info->getJoints().front(), PhysicsHelper::float2cpfloat(angle));
|
||||
}
|
||||
|
||||
float PhysicsJointRatchet::getPhase() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpRatchetJointGetPhase(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRatchet::setPhase(float phase)
|
||||
{
|
||||
cpRatchetJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase));
|
||||
}
|
||||
|
||||
float PhysicsJointRatchet::getRatchet() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpRatchetJointGetRatchet(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointRatchet::setRatchet(float ratchet)
|
||||
{
|
||||
cpRatchetJointSetRatchet(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratchet));
|
||||
}
|
||||
|
||||
PhysicsJointGear* PhysicsJointGear::construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet)
|
||||
{
|
||||
PhysicsJointGear* joint = new PhysicsJointGear();
|
||||
|
||||
if (joint && joint->init(a, b, phase, ratchet))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointGear::init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio)
|
||||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpGearJointNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::float2cpfloat(phase),
|
||||
PhysicsHelper::float2cpfloat(ratio));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointGear::getPhase() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpGearJointGetPhase(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGear::setPhase(float phase)
|
||||
{
|
||||
cpGearJointSetPhase(_info->getJoints().front(), PhysicsHelper::float2cpfloat(phase));
|
||||
}
|
||||
|
||||
float PhysicsJointGear::getRatio() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpGearJointGetRatio(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointGear::setRatio(float ratio)
|
||||
{
|
||||
cpGearJointSetRatio(_info->getJoints().front(), PhysicsHelper::float2cpfloat(ratio));
|
||||
}
|
||||
|
||||
PhysicsJointMotor* PhysicsJointMotor::construct(PhysicsBody* a, PhysicsBody* b, float rate)
|
||||
{
|
||||
PhysicsJointMotor* joint = new PhysicsJointMotor();
|
||||
|
||||
if (joint && joint->init(a, b, rate))
|
||||
{
|
||||
return joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(joint);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsJointMotor::init(PhysicsBody* a, PhysicsBody* b, float rate)
|
||||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsJoint::init(a, b));
|
||||
|
||||
cpConstraint* joint = cpSimpleMotorNew(getBodyInfo(a)->getBody(),
|
||||
getBodyInfo(b)->getBody(),
|
||||
PhysicsHelper::float2cpfloat(rate));
|
||||
|
||||
CC_BREAK_IF(joint == nullptr);
|
||||
|
||||
_info->add(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
float PhysicsJointMotor::getRate() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpSimpleMotorGetRate(_info->getJoints().front()));
|
||||
}
|
||||
|
||||
void PhysicsJointMotor::setRate(float rate)
|
||||
{
|
||||
cpSimpleMotorSetRate(_info->getJoints().front(), PhysicsHelper::float2cpfloat(rate));
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
void removeFormWorld();
|
||||
static void destroy(PhysicsJoint* joint);
|
||||
|
||||
void setMaxForce(float force);
|
||||
float getMaxForce() const;
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b);
|
||||
|
||||
|
@ -95,8 +98,8 @@ protected:
|
|||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
|
||||
|
||||
protected:
|
||||
PhysicsJointFixed();
|
||||
virtual ~PhysicsJointFixed();
|
||||
PhysicsJointFixed() {}
|
||||
virtual ~PhysicsJointFixed() {}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -106,18 +109,23 @@ class PhysicsJointLimit : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
|
||||
static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max);
|
||||
|
||||
Point getAnchr1() const;
|
||||
void setAnchr1(const Point& anchr1);
|
||||
Point getAnchr2() const;
|
||||
void setAnchr2(const Point& anchr2);
|
||||
float getMin() const;
|
||||
void setMin(float min);
|
||||
float getMax() const;
|
||||
void setMax(float max);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max);
|
||||
|
||||
protected:
|
||||
PhysicsJointLimit();
|
||||
virtual ~PhysicsJointLimit();
|
||||
PhysicsJointLimit() {}
|
||||
virtual ~PhysicsJointLimit() {}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -128,15 +136,12 @@ class PhysicsJointPin : public PhysicsJoint
|
|||
public:
|
||||
static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
|
||||
|
||||
void setMaxForce(float force);
|
||||
float getMaxForce() const;
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr);
|
||||
|
||||
protected:
|
||||
PhysicsJointPin();
|
||||
virtual ~PhysicsJointPin();
|
||||
PhysicsJointPin() {}
|
||||
virtual ~PhysicsJointPin() {}
|
||||
};
|
||||
|
||||
class PhysicsJointDistance : public PhysicsJoint
|
||||
|
@ -144,12 +149,151 @@ class PhysicsJointDistance : public PhysicsJoint
|
|||
public:
|
||||
static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
|
||||
|
||||
float getDistance() const;
|
||||
void setDistance(float distance);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2);
|
||||
|
||||
protected:
|
||||
PhysicsJointDistance();
|
||||
virtual ~PhysicsJointDistance();
|
||||
PhysicsJointDistance() {}
|
||||
virtual ~PhysicsJointDistance() {}
|
||||
};
|
||||
|
||||
class PhysicsJointSpring : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointSpring* construct(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping);
|
||||
Point getAnchr1() const;
|
||||
void setAnchr1(const Point& anchr1);
|
||||
Point getAnchr2() const;
|
||||
void setAnchr2(const Point& anchr2);
|
||||
float getRestLength() const;
|
||||
void setRestLength(float restLength);
|
||||
float getStiffness() const;
|
||||
void setStiffness(float stiffness);
|
||||
float getDamping() const;
|
||||
void setDamping(float damping);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float stiffness, float damping);
|
||||
|
||||
protected:
|
||||
PhysicsJointSpring() {}
|
||||
virtual ~PhysicsJointSpring() {}
|
||||
};
|
||||
|
||||
class PhysicsJointGroove : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr2);
|
||||
|
||||
Point getGrooveA() const;
|
||||
void setGrooveA(const Point& grooveA);
|
||||
Point getGrooveB() const;
|
||||
void setGrooveB(const Point& grooveB);
|
||||
Point getAnchr2() const;
|
||||
void setAnchr2(const Point& anchr2);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr);
|
||||
|
||||
protected:
|
||||
PhysicsJointGroove() {}
|
||||
virtual ~PhysicsJointGroove() {}
|
||||
};
|
||||
|
||||
class PhysicsJointRotarySpring : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointRotarySpring* construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping);
|
||||
|
||||
float getRestAngle() const;
|
||||
void setRestAngle(float restAngle);
|
||||
float getStiffness() const;
|
||||
void setStiffness(float stiffness);
|
||||
float getDamping() const;
|
||||
void setDamping(float damping);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping);
|
||||
|
||||
protected:
|
||||
PhysicsJointRotarySpring() {}
|
||||
virtual ~PhysicsJointRotarySpring() {}
|
||||
};
|
||||
|
||||
class PhysicsJointRotaryLimit : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b, float min, float max);
|
||||
static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b);
|
||||
|
||||
float getMin() const;
|
||||
void setMin(float min);
|
||||
float getMax() const;
|
||||
void setMax(float max);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float min, float max);
|
||||
|
||||
protected:
|
||||
PhysicsJointRotaryLimit() {}
|
||||
virtual ~PhysicsJointRotaryLimit() {}
|
||||
};
|
||||
|
||||
class PhysicsJointRatchet : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointRatchet* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet);
|
||||
|
||||
float getAngle() const;
|
||||
void setAngle(float angle);
|
||||
float getPhase() const;
|
||||
void setPhase(float phase);
|
||||
float getRatchet() const;
|
||||
void setRatchet(float ratchet);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet);
|
||||
|
||||
protected:
|
||||
PhysicsJointRatchet() {}
|
||||
virtual ~PhysicsJointRatchet() {}
|
||||
};
|
||||
|
||||
class PhysicsJointGear : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointGear* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratio);
|
||||
|
||||
float getPhase() const;
|
||||
void setPhase(float phase);
|
||||
float getRatio() const;
|
||||
void setRatio(float ratchet);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio);
|
||||
|
||||
protected:
|
||||
PhysicsJointGear() {}
|
||||
virtual ~PhysicsJointGear() {}
|
||||
};
|
||||
|
||||
class PhysicsJointMotor : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointMotor* construct(PhysicsBody* a, PhysicsBody* b, float rate);
|
||||
|
||||
float getRate() const;
|
||||
void setRate(float rate);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float rate);
|
||||
|
||||
protected:
|
||||
PhysicsJointMotor() {}
|
||||
virtual ~PhysicsJointMotor() {}
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -519,6 +519,19 @@ void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint)
|
|||
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
_drawNode->drawDot(PhysicsHelper::cpv2point(c), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
}
|
||||
else if(klass == cpDampedSpringGetClass())
|
||||
{
|
||||
cpDampedSpring *subJoint = (cpDampedSpring *)constraint;
|
||||
|
||||
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
|
||||
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
|
||||
|
||||
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
|
||||
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1 +0,0 @@
|
|||
e70a68a07977b12b3f233641ac8d558e48c5517c
|
|
@ -112,3 +112,10 @@ function CCBReaderLoad(strFilePath,proxy,owner)
|
|||
|
||||
return node
|
||||
end
|
||||
|
||||
|
||||
local function CCBuilderReaderLoad(strFilePath,proxy,owner)
|
||||
print("\n********** \n".."CCBuilderReaderLoad(strFilePath,proxy,owner)".." was deprecated please use ".. "CCBReaderLoad(strFilePath,proxy,owner)" .. " instead.\n**********")
|
||||
return CCBReaderLoad(strFilePath,proxy,owner)
|
||||
end
|
||||
rawset(_G,"CCBuilderReaderLoad",CCBuilderReaderLoad)
|
|
@ -291,4 +291,72 @@ function cc.c4f( _r,_g,_b,_a )
|
|||
return { r = _r, g = _g, b = _b, a = _a }
|
||||
end
|
||||
|
||||
--Vertex2F
|
||||
function cc.vertex2F(_x,_y)
|
||||
return { x = _x, y = _y }
|
||||
end
|
||||
|
||||
--Vertex3F
|
||||
function cc.Vertex3F(_x,_y,_z)
|
||||
return { x = _x, y = _y, z = _z }
|
||||
end
|
||||
|
||||
--Tex2F
|
||||
function cc.tex2F(_u,_v)
|
||||
return { u = _u, v = _v }
|
||||
end
|
||||
|
||||
--PointSprite
|
||||
function cc.PointSprite(_pos,_color,_size)
|
||||
return { pos = _pos, color = _color, size = _size }
|
||||
end
|
||||
|
||||
--Quad2
|
||||
function cc.Quad2(_tl,_tr,_bl,_br)
|
||||
return { tl = _tl, tr = _tr, bl = _bl, br = _br }
|
||||
end
|
||||
|
||||
--Quad3
|
||||
function cc.Quad3(_tl, _tr, _bl, _br)
|
||||
return { tl = _tl, tr = _tr, bl = _bl, br = _br }
|
||||
end
|
||||
|
||||
--V2F_C4B_T2F
|
||||
function cc.V2F_C4B_T2F(_vertices, _colors, _texCoords)
|
||||
return { vertices = _vertices, colors = _colors, texCoords = _texCoords }
|
||||
end
|
||||
|
||||
--V2F_C4F_T2F
|
||||
function cc.V2F_C4F_T2F(_vertices, _colors, _texCoords)
|
||||
return { vertices = _vertices, colors = _colors, texCoords = _texCoords }
|
||||
end
|
||||
|
||||
--V3F_C4B_T2F
|
||||
function cc.V3F_C4B_T2F(_vertices, _colors, _texCoords)
|
||||
return { vertices = _vertices, colors = _colors, texCoords = _texCoords }
|
||||
end
|
||||
|
||||
--V2F_C4B_T2F_Quad
|
||||
function cc.V2F_C4B_T2F_Quad(_bl, _br, _tl, _tr)
|
||||
return { bl = _bl, br = _br, tl = _tl, tr = _tr }
|
||||
end
|
||||
|
||||
--V3F_C4B_T2F_Quad
|
||||
function cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br)
|
||||
return { tl = _tl, bl = _bl, tr = _tr, br = _br }
|
||||
end
|
||||
|
||||
--V2F_C4F_T2F_Quad
|
||||
function cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr)
|
||||
return { bl = _bl, br = _br, tl = _tl, tr = _tr }
|
||||
end
|
||||
|
||||
--T2F_Quad
|
||||
function cc.T2F_Quad(_bl, _br, _tl, _tr)
|
||||
return { bl = _bl, br = _br, tl = _tl, tr = _tr }
|
||||
end
|
||||
|
||||
--AnimationFrameData
|
||||
function cc.AnimationFrameData( _texCoords, _delay, _size)
|
||||
return { texCoords = _texCoords, delay = _delay, size = _size }
|
||||
end
|
||||
|
|
|
@ -591,20 +591,20 @@ rawset(_G,"ccpIntersectPoint",ccpIntersectPoint)
|
|||
|
||||
|
||||
local function vertex2(x,y)
|
||||
deprecatedTip("vertex2(x,y)","Vertex2F(x,y)")
|
||||
return Vertex2F(x,y)
|
||||
deprecatedTip("vertex2(x,y)","cc.vertex2F(x,y)")
|
||||
return cc.vertex2F(x,y)
|
||||
end
|
||||
rawset(_G,"vertex2",vertex2)
|
||||
|
||||
local function vertex3(x,y,z)
|
||||
deprecatedTip("vertex3(x,y,z)","Vertex3F(x,y,z)")
|
||||
return Vertex3F(x,y,z)
|
||||
deprecatedTip("vertex3(x,y,z)","cc.Vertex3F(x,y,z)")
|
||||
return cc.Vertex3F(x,y,z)
|
||||
end
|
||||
rawset(_G,"vertex3",vertex3)
|
||||
|
||||
local function tex2(u,v)
|
||||
deprecatedTip("tex2(u,v)","Tex2F(u,v)")
|
||||
return Tex2F(u,v)
|
||||
deprecatedTip("tex2(u,v)","cc.tex2f(u,v)")
|
||||
return cc.tex2f(u,v)
|
||||
end
|
||||
rawset(_G,"tex2",tex2)
|
||||
|
||||
|
@ -615,109 +615,116 @@ end
|
|||
rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F)
|
||||
|
||||
local function ccColor3BDeprecated()
|
||||
deprecatedTip("ccColor3B","Color3B")
|
||||
return Color3B
|
||||
deprecatedTip("ccColor3B","cc.c3b(0,0,0)")
|
||||
return cc.c3b(0,0,0)
|
||||
end
|
||||
_G["ccColor3B"] = ccColor3BDeprecated()
|
||||
_G["ccColor3B"] = ccColor3BDeprecated
|
||||
|
||||
local function ccColor4BDeprecated()
|
||||
deprecatedTip("ccColor4B","Color4B")
|
||||
return Color4B
|
||||
deprecatedTip("ccColor4B","cc.c4b(0,0,0,0)")
|
||||
return cc.c4b(0,0,0,0)
|
||||
end
|
||||
_G["ccColor4B"] = ccColor4BDeprecated()
|
||||
_G["ccColor4B"] = ccColor4BDeprecated
|
||||
|
||||
local function ccColor4FDeprecated()
|
||||
deprecatedTip("ccColor4F","Color4F")
|
||||
return Color4F
|
||||
deprecatedTip("ccColor4F","cc.c4f(0.0,0.0,0.0,0.0)")
|
||||
return cc.c4f(0.0,0.0,0.0,0.0)
|
||||
end
|
||||
_G["ccColor4F"] = ccColor4FDeprecated()
|
||||
_G["ccColor4F"] = ccColor4FDeprecated
|
||||
|
||||
local function ccVertex2FDeprecated()
|
||||
deprecatedTip("ccVertex2F","Vertex2F")
|
||||
return Vertex2F
|
||||
deprecatedTip("ccVertex2F","cc.vertex2F(0.0,0.0)")
|
||||
return cc.vertex2F(0.0,0.0)
|
||||
end
|
||||
_G["ccVertex2F"] = ccVertex2FDeprecated()
|
||||
_G["ccVertex2F"] = ccVertex2FDeprecated
|
||||
|
||||
local function ccVertex3FDeprecated()
|
||||
deprecatedTip("ccVertex3F","Vertex3F")
|
||||
return Vertex3F
|
||||
deprecatedTip("ccVertex3F","cc.Vertex3F(0.0, 0.0, 0.0)")
|
||||
return cc.Vertex3F(0.0, 0.0, 0.0)
|
||||
end
|
||||
_G["ccVertex3F"] = ccVertex3FDeprecated()
|
||||
_G["ccVertex3F"] = ccVertex3FDeprecated
|
||||
|
||||
local function ccTex2FDeprecated()
|
||||
deprecatedTip("ccTex2F","Tex2F")
|
||||
return Tex2F
|
||||
deprecatedTip("ccTex2F","cc.tex2F(0.0, 0.0)")
|
||||
return cc.tex2F(0.0, 0.0)
|
||||
end
|
||||
_G["ccTex2F"] = ccTex2FDeprecated()
|
||||
_G["ccTex2F"] = ccTex2FDeprecated
|
||||
|
||||
local function ccPointSpriteDeprecated()
|
||||
deprecatedTip("ccPointSprite","PointSprite")
|
||||
return PointSprite
|
||||
deprecatedTip("ccPointSprite","cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0)")
|
||||
return cc.PointSprite(cc.vertex2F(0.0, 0.0),cc.c4b(0.0, 0.0, 0.0),0)
|
||||
end
|
||||
_G["ccPointSprite"] = ccPointSpriteDeprecated()
|
||||
_G["ccPointSprite"] = ccPointSpriteDeprecated
|
||||
|
||||
local function ccQuad2Deprecated()
|
||||
deprecatedTip("ccQuad2","Quad2")
|
||||
return Quad2
|
||||
deprecatedTip("ccQuad2","cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0))")
|
||||
return cc.Quad2(cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0), cc.vertex2F(0.0, 0.0))
|
||||
end
|
||||
_G["ccQuad2"] = ccQuad2Deprecated()
|
||||
_G["ccQuad2"] = ccQuad2Deprecated
|
||||
|
||||
local function ccQuad3Deprecated()
|
||||
deprecatedTip("ccQuad3","Quad3")
|
||||
return Quad3
|
||||
deprecatedTip("ccQuad3","cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0))")
|
||||
return cc.Quad3(cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0), cc.Vertex3F(0.0, 0.0 ,0.0))
|
||||
end
|
||||
_G["ccQuad3"] = ccQuad3Deprecated()
|
||||
_G["ccQuad3"] = ccQuad3Deprecated
|
||||
|
||||
local function ccV2FC4BT2FDeprecated()
|
||||
deprecatedTip("ccV2F_C4B_T2F","V2F_C4B_T2F")
|
||||
return V2F_C4B_T2F
|
||||
deprecatedTip("ccV2F_C4B_T2F","cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))")
|
||||
return cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0))
|
||||
end
|
||||
_G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated()
|
||||
_G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated
|
||||
|
||||
|
||||
local function ccV2FC4FT2FDeprecated()
|
||||
deprecatedTip("ccV2F_C4F_T2F","V2F_C4F_T2F")
|
||||
return V2F_C4F_T2F
|
||||
deprecatedTip("ccV2F_C4F_T2F","cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0 ), cc.tex2F(0.0, 0.0))")
|
||||
return cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0 , 0.0 , 0.0), cc.tex2F(0.0, 0.0))
|
||||
end
|
||||
_G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated()
|
||||
_G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated
|
||||
|
||||
local function ccV3FC4BT2FDeprecated()
|
||||
deprecatedTip("ccV3F_C4B_T2F","V3F_C4B_T2F")
|
||||
return V3F_C4B_T2F
|
||||
deprecatedTip("ccV3F_C4B_T2F","cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0))")
|
||||
return cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0 , 0, 0 ), cc.tex2F(0.0, 0.0))
|
||||
end
|
||||
_G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated()
|
||||
_G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated
|
||||
|
||||
local function ccV2FC4BT2FQuadDeprecated()
|
||||
deprecatedTip("ccV2F_C4B_T2F_Quad","V2F_C4B_T2F_Quad")
|
||||
return V2F_C4B_T2F_Quad
|
||||
deprecatedTip("ccV2F_C4B_T2F_Quad","cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))")
|
||||
return cc.V2F_C4B_T2F_Quad(cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))
|
||||
end
|
||||
_G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated()
|
||||
_G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated
|
||||
|
||||
local function ccV3FC4BT2FQuadDeprecated()
|
||||
deprecatedTip("ccV3F_C4B_T2F_Quad","V3F_C4B_T2F_Quad")
|
||||
return V3F_C4B_T2F_Quad
|
||||
deprecatedTip("ccV3F_C4B_T2F_Quad","cc.V3F_C4B_T2F_Quad(_tl, _bl, _tr, _br)")
|
||||
return cc.V3F_C4B_T2F_Quad(cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex3F(0.0, 0.0, 0.0), cc.c4b(0 , 0, 0, 0 ), cc.tex2F(0.0, 0.0)))
|
||||
end
|
||||
_G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated()
|
||||
_G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated
|
||||
|
||||
local function ccV2FC4FT2FQuadDeprecated()
|
||||
deprecatedTip("ccV2F_C4F_T2F_Quad","V2F_C4F_T2F_Quad")
|
||||
return V2F_C4F_T2F_Quad
|
||||
deprecatedTip("ccV2F_C4F_T2F_Quad","cc.V2F_C4F_T2F_Quad(_bl, _br, _tl, _tr)")
|
||||
return cc.V2F_C4F_T2F_Quad(cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V3F_C4B_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)), cc.V2F_C4F_T2F(cc.vertex2F(0.0, 0.0), cc.c4f(0.0 , 0.0, 0.0, 0.0 ), cc.tex2F(0.0, 0.0)))
|
||||
end
|
||||
_G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated()
|
||||
_G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated
|
||||
|
||||
local function ccT2FQuadDeprecated()
|
||||
deprecatedTip("ccT2F_Quad","T2F_Quad")
|
||||
return T2F_Quad
|
||||
deprecatedTip("ccT2F_Quad","cc.T2F_Quad(_bl, _br, _tl, _tr)")
|
||||
return cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0))
|
||||
end
|
||||
_G["ccT2F_Quad"] = ccT2FQuadDeprecated()
|
||||
_G["ccT2F_Quad"] = ccT2FQuadDeprecated
|
||||
|
||||
local function ccAnimationFrameDataDeprecated()
|
||||
deprecatedTip("ccAnimationFrameData","AnimationFrameData")
|
||||
return AnimationFrameData
|
||||
deprecatedTip("ccAnimationFrameData","cc.AnimationFrameData( _texCoords, _delay, _size)")
|
||||
return cc.AnimationFrameData(cc.T2F_Quad(cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0), cc.tex2F(0.0,0.0)), 0, cc.size(0,0))
|
||||
end
|
||||
_G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated()
|
||||
_G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated
|
||||
|
||||
|
||||
|
||||
local function tex2(u,v)
|
||||
deprecatedTip("tex2(u,v)","cc.tex2f(u,v)")
|
||||
return cc.tex2f(u,v)
|
||||
end
|
||||
rawset(_G,"tex2",tex2)
|
||||
|
||||
--functions of CCControl will be deprecated end
|
||||
local CCControlDeprecated = { }
|
||||
function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent)
|
||||
|
@ -1047,3 +1054,114 @@ function CCLayerDeprecated.isKeypadEnabled(self)
|
|||
end
|
||||
rawset(cc.Layer, "isKeypadEnabled", CCLayerDeprecated.isKeypadEnabled )
|
||||
--functions of Layer will be deprecated end
|
||||
|
||||
--functions of ccs.GUIReader will be deprecated begin
|
||||
local CCSGUIReaderDeprecated = { }
|
||||
function CCSGUIReaderDeprecated.purgeGUIReader()
|
||||
deprecatedTip("ccs.GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance")
|
||||
return ccs.GUIReader:destroyInstance()
|
||||
end
|
||||
rawset(ccs.GUIReader,"purgeGUIReader",CCSGUIReaderDeprecated.purgeGUIReader)
|
||||
--functions of ccs.GUIReader will be deprecated end
|
||||
|
||||
--functions of ccs.ActionManagerEx will be deprecated begin
|
||||
local CCSActionManagerExDeprecated = { }
|
||||
function CCSActionManagerExDeprecated.destroyActionManager()
|
||||
deprecatedTip("ccs.ActionManagerEx:destroyActionManager","ccs.ActionManagerEx:destroyInstance")
|
||||
return ccs.ActionManagerEx:destroyInstance()
|
||||
end
|
||||
rawset(ccs.ActionManagerEx,"destroyActionManager",CCSActionManagerExDeprecated.destroyActionManager)
|
||||
--functions of ccs.ActionManagerEx will be deprecated end
|
||||
|
||||
--functions of ccs.SceneReader will be deprecated begin
|
||||
local CCSSceneReaderDeprecated = { }
|
||||
function CCSSceneReaderDeprecated.destroySceneReader(self)
|
||||
deprecatedTip("ccs.SceneReader:destroySceneReader","ccs.SceneReader:destroyInstance")
|
||||
return self:destroyInstance()
|
||||
end
|
||||
rawset(ccs.SceneReader,"destroySceneReader",CCSSceneReaderDeprecated.destroySceneReader)
|
||||
--functions of ccs.SceneReader will be deprecated end
|
||||
|
||||
--functions of CCArmatureDataManager will be deprecated begin
|
||||
local CCArmatureDataManagerDeprecated = { }
|
||||
function CCArmatureDataManagerDeprecated.sharedArmatureDataManager()
|
||||
deprecatedTip("CCArmatureDataManager:sharedArmatureDataManager","ccs.ArmatureDataManager:getInstance")
|
||||
return ccs.ArmatureDataManager:getInstance()
|
||||
end
|
||||
rawset(CCArmatureDataManager,"sharedArmatureDataManager",CCArmatureDataManagerDeprecated.sharedArmatureDataManager)
|
||||
|
||||
function CCArmatureDataManagerDeprecated.purge()
|
||||
deprecatedTip("CCArmatureDataManager:purge","ccs.ArmatureDataManager:destoryInstance")
|
||||
return ccs.ArmatureDataManager:destoryInstance()
|
||||
end
|
||||
rawset(CCArmatureDataManager,"purge",CCArmatureDataManagerDeprecated.purge)
|
||||
--functions of CCArmatureDataManager will be deprecated end
|
||||
|
||||
--functions of GUIReader will be deprecated begin
|
||||
local GUIReaderDeprecated = { }
|
||||
function GUIReaderDeprecated.shareReader()
|
||||
deprecatedTip("GUIReader:shareReader","ccs.GUIReader:getInstance")
|
||||
return ccs.GUIReader:getInstance()
|
||||
end
|
||||
rawset(GUIReader,"shareReader",GUIReaderDeprecated.shareReader)
|
||||
|
||||
function GUIReaderDeprecated.purgeGUIReader()
|
||||
deprecatedTip("GUIReader:purgeGUIReader","ccs.GUIReader:destroyInstance")
|
||||
return ccs.GUIReader:destroyInstance()
|
||||
end
|
||||
rawset(GUIReader,"purgeGUIReader",GUIReaderDeprecated.purgeGUIReader)
|
||||
--functions of GUIReader will be deprecated end
|
||||
|
||||
--functions of SceneReader will be deprecated begin
|
||||
local SceneReaderDeprecated = { }
|
||||
function SceneReaderDeprecated.sharedSceneReader()
|
||||
deprecatedTip("SceneReader:sharedSceneReader","ccs.SceneReader:getInstance")
|
||||
return ccs.SceneReader:getInstance()
|
||||
end
|
||||
rawset(SceneReader,"sharedSceneReader",SceneReaderDeprecated.sharedSceneReader)
|
||||
|
||||
function SceneReaderDeprecated.purgeSceneReader(self)
|
||||
deprecatedTip("SceneReader:purgeSceneReader","ccs.SceneReader:destroyInstance")
|
||||
return self:destroyInstance()
|
||||
end
|
||||
rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader)
|
||||
--functions of SceneReader will be deprecated end
|
||||
|
||||
--functions of ActionManager will be deprecated begin
|
||||
local ActionManagerDeprecated = { }
|
||||
function ActionManagerDeprecated.shareManager()
|
||||
deprecatedTip("ActionManager:shareManager","ccs.ActionManagerEx:getInstance")
|
||||
return ccs.ActionManagerEx:getInstance()
|
||||
end
|
||||
rawset(ActionManager,"shareManager",ActionManagerDeprecated.shareManager)
|
||||
|
||||
function ActionManagerDeprecated.purgeActionManager()
|
||||
deprecatedTip("ActionManager:purgeActionManager","ccs.ActionManagerEx:destroyActionManager")
|
||||
return ccs.ActionManagerEx:destroyActionManager()
|
||||
end
|
||||
rawset(ActionManager,"purgeActionManager",ActionManagerDeprecated.purgeActionManager)
|
||||
--functions of ActionManager will be deprecated end
|
||||
|
||||
--functions of CCEGLView will be deprecated begin
|
||||
local CCEGLViewDeprecated = { }
|
||||
function CCEGLViewDeprecated.sharedOpenGLView()
|
||||
deprecatedTip("CCEGLView:sharedOpenGLView","cc.EGLView:getInstance")
|
||||
return cc.EGLView:getInstance()
|
||||
end
|
||||
rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView)
|
||||
--functions of CCEGLView will be deprecated end
|
||||
|
||||
--Enums of CCTableView will be deprecated begin
|
||||
rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED)
|
||||
rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX)
|
||||
rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX)
|
||||
rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW)
|
||||
--Enums of CCTableView will be deprecated end
|
||||
|
||||
--Enums of CCScrollView will be deprecated begin
|
||||
rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL)
|
||||
rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM)
|
||||
--Enums of CCScrollView will be deprecated end
|
||||
|
||||
|
|
|
@ -1815,13 +1815,324 @@ end
|
|||
_G["CCCallFuncN"] = DeprecatedClass.CCCallFuncN()
|
||||
--CCCallFuncN class will be Deprecated,end
|
||||
|
||||
--ccBlendFunc class will be Deprecated,begin
|
||||
function DeprecatedClass.ccBlendFunc()
|
||||
deprecatedTip("ccBlendFunc","BlendFunc")
|
||||
return BlendFunc
|
||||
--CCArmature class will be Deprecated,begin
|
||||
function DeprecatedClass.CCArmature()
|
||||
deprecatedTip("CCArmature","ccs.Armature")
|
||||
return ccs.Armature
|
||||
end
|
||||
_G["ccBlendFunc"] = DeprecatedClass.ccBlendFunc()
|
||||
--ccBlendFunc class will be Deprecated,end
|
||||
|
||||
_G["CCArmature"] = DeprecatedClass.CCArmature()
|
||||
--CCArmature class will be Deprecated,end
|
||||
|
||||
--CCArmatureAnimation class will be Deprecated,begin
|
||||
function DeprecatedClass.CCArmatureAnimation()
|
||||
deprecatedTip("CCArmatureAnimation","ccs.ArmatureAnimation")
|
||||
return ccs.ArmatureAnimation
|
||||
end
|
||||
_G["CCArmatureAnimation"] = DeprecatedClass.CCArmatureAnimation()
|
||||
--CCArmatureAnimation class will be Deprecated,end
|
||||
|
||||
--CCSkin class will be Deprecated,begin
|
||||
function DeprecatedClass.CCSkin()
|
||||
deprecatedTip("CCSkin","ccs.Skin")
|
||||
return ccs.Skin
|
||||
end
|
||||
_G["CCSkin"] = DeprecatedClass.CCSkin()
|
||||
--CCSkin class will be Deprecated,end
|
||||
|
||||
--CCBone class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBone()
|
||||
deprecatedTip("CCBone","ccs.Bone")
|
||||
return ccs.Bone
|
||||
end
|
||||
_G["CCBone"] = DeprecatedClass.CCBone()
|
||||
--CCBone class will be Deprecated,end
|
||||
|
||||
--CCArmatureDataManager class will be Deprecated,begin
|
||||
function DeprecatedClass.CCArmatureDataManager()
|
||||
deprecatedTip("CCArmatureDataManager","ccs.ArmatureDataManager")
|
||||
return ccs.ArmatureDataManager
|
||||
end
|
||||
_G["CCArmatureDataManager"] = DeprecatedClass.CCArmatureDataManager()
|
||||
--CCArmatureDataManager class will be Deprecated,end
|
||||
|
||||
--CCBatchNode class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBatchNode()
|
||||
deprecatedTip("CCBatchNode","ccs.BatchNode")
|
||||
return ccs.BatchNode
|
||||
end
|
||||
_G["CCBatchNode"] = DeprecatedClass.CCBatchNode()
|
||||
--CCBatchNode class will be Deprecated,end
|
||||
|
||||
--CCTween class will be Deprecated,begin
|
||||
function DeprecatedClass.CCTween()
|
||||
deprecatedTip("CCTween","ccs.Tween")
|
||||
return ccs.Tween
|
||||
end
|
||||
_G["CCTween"] = DeprecatedClass.CCTween()
|
||||
--CCTween class will be Deprecated,end
|
||||
|
||||
--CCBaseData class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBaseData()
|
||||
deprecatedTip("CCBaseData","ccs.BaseData")
|
||||
return ccs.BaseData
|
||||
end
|
||||
_G["CCBaseData"] = DeprecatedClass.CCBaseData()
|
||||
--CCBaseData class will be Deprecated,end
|
||||
|
||||
--CCDisplayManager class will be Deprecated,begin
|
||||
function DeprecatedClass.CCDisplayManager()
|
||||
deprecatedTip("CCDisplayManager","ccs.DisplayManager")
|
||||
return ccs.DisplayManager
|
||||
end
|
||||
_G["CCDisplayManager"] = DeprecatedClass.CCDisplayManager()
|
||||
--CCDisplayManager class will be Deprecated,end
|
||||
|
||||
--UIHelper class will be Deprecated,begin
|
||||
function DeprecatedClass.UIHelper()
|
||||
deprecatedTip("UIHelper","ccs.UIHelper")
|
||||
return ccs.UIHelper
|
||||
end
|
||||
_G["UIHelper"] = DeprecatedClass.UIHelper()
|
||||
--UIHelper class will be Deprecated,end
|
||||
|
||||
--UILayout class will be Deprecated,begin
|
||||
function DeprecatedClass.UILayout()
|
||||
deprecatedTip("UILayout","ccs.UILayout")
|
||||
return ccs.UILayout
|
||||
end
|
||||
_G["UILayout"] = DeprecatedClass.UILayout()
|
||||
--UILayout class will be Deprecated,end
|
||||
|
||||
--UIWidget class will be Deprecated,begin
|
||||
function DeprecatedClass.UIWidget()
|
||||
deprecatedTip("UIWidget","ccs.UIWidget")
|
||||
return ccs.UIWidget
|
||||
end
|
||||
_G["UIWidget"] = DeprecatedClass.UIWidget()
|
||||
--UIWidget class will be Deprecated,end
|
||||
|
||||
--UILayer class will be Deprecated,begin
|
||||
function DeprecatedClass.UILayer()
|
||||
deprecatedTip("UILayer","ccs.UILayer")
|
||||
return ccs.UILayer
|
||||
end
|
||||
_G["UILayer"] = DeprecatedClass.UILayer()
|
||||
--UILayer class will be Deprecated,end
|
||||
|
||||
--UIButton class will be Deprecated,begin
|
||||
function DeprecatedClass.UIButton()
|
||||
deprecatedTip("UIButton","ccs.UIButton")
|
||||
return ccs.UIButton
|
||||
end
|
||||
_G["UIButton"] = DeprecatedClass.UIButton()
|
||||
--UIButton class will be Deprecated,end
|
||||
|
||||
--UICheckBox class will be Deprecated,begin
|
||||
function DeprecatedClass.UICheckBox()
|
||||
deprecatedTip("UICheckBox","ccs.UICheckBox")
|
||||
return ccs.UICheckBox
|
||||
end
|
||||
_G["UICheckBox"] = DeprecatedClass.UICheckBox()
|
||||
--UICheckBox class will be Deprecated,end
|
||||
|
||||
--UIImageView class will be Deprecated,begin
|
||||
function DeprecatedClass.UIImageView()
|
||||
deprecatedTip("UIImageView","ccs.UIImageView")
|
||||
return ccs.UIImageView
|
||||
end
|
||||
_G["UIImageView"] = DeprecatedClass.UIImageView()
|
||||
--UIImageView class will be Deprecated,end
|
||||
|
||||
--UILabel class will be Deprecated,begin
|
||||
function DeprecatedClass.UILabel()
|
||||
deprecatedTip("UILabel","ccs.UILabel")
|
||||
return ccs.UILabel
|
||||
end
|
||||
_G["UILabel"] = DeprecatedClass.UILabel()
|
||||
--UILabel class will be Deprecated,end
|
||||
|
||||
--UILabelAtlas class will be Deprecated,begin
|
||||
function DeprecatedClass.UILabelAtlas()
|
||||
deprecatedTip("UILabelAtlas","ccs.UILabelAtlas")
|
||||
return ccs.UILabelAtlas
|
||||
end
|
||||
_G["UILabelAtlas"] = DeprecatedClass.UILabelAtlas()
|
||||
--UILabelAtlas class will be Deprecated,end
|
||||
|
||||
--UILabelBMFont class will be Deprecated,begin
|
||||
function DeprecatedClass.UILabelBMFont()
|
||||
deprecatedTip("UILabelBMFont","ccs.UILabelBMFont")
|
||||
return ccs.UILabelBMFont
|
||||
end
|
||||
_G["UILabelBMFont"] = DeprecatedClass.UILabelBMFont()
|
||||
--UILabelBMFont class will be Deprecated,end
|
||||
|
||||
--UILoadingBar class will be Deprecated,begin
|
||||
function DeprecatedClass.UILoadingBar()
|
||||
deprecatedTip("UILoadingBar","ccs.UILoadingBar")
|
||||
return ccs.UILoadingBar
|
||||
end
|
||||
_G["UILoadingBar"] = DeprecatedClass.UILoadingBar()
|
||||
--UILoadingBar class will be Deprecated,end
|
||||
|
||||
--UISlider class will be Deprecated,begin
|
||||
function DeprecatedClass.UISlider()
|
||||
deprecatedTip("UISlider","ccs.UISlider")
|
||||
return ccs.UISlider
|
||||
end
|
||||
_G["UISlider"] = DeprecatedClass.UISlider()
|
||||
--UISlider class will be Deprecated,end
|
||||
|
||||
--UITextField class will be Deprecated,begin
|
||||
function DeprecatedClass.UITextField()
|
||||
deprecatedTip("UITextField","ccs.UITextField")
|
||||
return ccs.UITextField
|
||||
end
|
||||
_G["UITextField"] = DeprecatedClass.UITextField()
|
||||
--UITextField class will be Deprecated,end
|
||||
|
||||
--UIScrollView class will be Deprecated,begin
|
||||
function DeprecatedClass.UIScrollView()
|
||||
deprecatedTip("UIScrollView","ccs.UIScrollView")
|
||||
return ccs.UIScrollView
|
||||
end
|
||||
_G["UIScrollView"] = DeprecatedClass.UIScrollView()
|
||||
--UIScrollView class will be Deprecated,end
|
||||
|
||||
--UIPageView class will be Deprecated,begin
|
||||
function DeprecatedClass.UIPageView()
|
||||
deprecatedTip("UIPageView","ccs.UIPageView")
|
||||
return ccs.UIPageView
|
||||
end
|
||||
_G["UIPageView"] = DeprecatedClass.UIPageView()
|
||||
--UIPageView class will be Deprecated,end
|
||||
|
||||
--UIListView class will be Deprecated,begin
|
||||
function DeprecatedClass.UIListView()
|
||||
deprecatedTip("UIListView","ccs.UIListView")
|
||||
return ccs.UIListView
|
||||
end
|
||||
_G["UIListView"] = DeprecatedClass.UIListView()
|
||||
--UIListView class will be Deprecated,end
|
||||
|
||||
--UILayoutParameter class will be Deprecated,begin
|
||||
function DeprecatedClass.UILayoutParameter()
|
||||
deprecatedTip("UILayoutParameter","ccs.UILayoutParameter")
|
||||
return ccs.UILayoutParameter
|
||||
end
|
||||
_G["UILayoutParameter"] = DeprecatedClass.UILayoutParameter()
|
||||
--UILayoutParameter class will be Deprecated,end
|
||||
|
||||
--UILinearLayoutParameter class will be Deprecated,begin
|
||||
function DeprecatedClass.UILinearLayoutParameter()
|
||||
deprecatedTip("UILinearLayoutParameter","ccs.UILinearLayoutParameter")
|
||||
return ccs.UILinearLayoutParameter
|
||||
end
|
||||
_G["UILinearLayoutParameter"] = DeprecatedClass.UILinearLayoutParameter()
|
||||
--UILinearLayoutParameter class will be Deprecated,end
|
||||
|
||||
--UIRelativeLayoutParameter class will be Deprecated,begin
|
||||
function DeprecatedClass.UIRelativeLayoutParameter()
|
||||
deprecatedTip("UIRelativeLayoutParameter","ccs.UIRelativeLayoutParameter")
|
||||
return ccs.UIRelativeLayoutParameter
|
||||
end
|
||||
_G["UIRelativeLayoutParameter"] = DeprecatedClass.UIRelativeLayoutParameter()
|
||||
--UIRelativeLayoutParameter class will be Deprecated,end
|
||||
|
||||
--CCComController class will be Deprecated,begin
|
||||
function DeprecatedClass.CCComController()
|
||||
deprecatedTip("CCComController","ccs.ComController")
|
||||
return ccs.CCComController
|
||||
end
|
||||
_G["CCComController"] = DeprecatedClass.CCComController()
|
||||
--CCComController class will be Deprecated,end
|
||||
|
||||
--CCComAudio class will be Deprecated,begin
|
||||
function DeprecatedClass.CCComAudio()
|
||||
deprecatedTip("CCComAudio","ccs.ComAudio")
|
||||
return ccs.ComAudio
|
||||
end
|
||||
_G["CCComAudio"] = DeprecatedClass.CCComAudio()
|
||||
--CCComAudio class will be Deprecated,end
|
||||
|
||||
--CCComAttribute class will be Deprecated,begin
|
||||
function DeprecatedClass.CCComAttribute()
|
||||
deprecatedTip("CCComAttribute","ccs.ComAttribute")
|
||||
return ccs.ComAttribute
|
||||
end
|
||||
_G["CCComAttribute"] = DeprecatedClass.CCComAttribute()
|
||||
--CCComAttribute class will be Deprecated,end
|
||||
|
||||
--CCComRender class will be Deprecated,begin
|
||||
function DeprecatedClass.CCComRender()
|
||||
deprecatedTip("CCComRender","ccs.ComRender")
|
||||
return ccs.ComRender
|
||||
end
|
||||
_G["CCComRender"] = DeprecatedClass.CCComRender()
|
||||
--CCComRender class will be Deprecated,end
|
||||
|
||||
--ActionManager class will be Deprecated,begin
|
||||
function DeprecatedClass.ActionManager()
|
||||
deprecatedTip("ActionManager","ccs.ActionManagerEx")
|
||||
return ccs.ActionManagerEx
|
||||
end
|
||||
_G["ActionManager"] = DeprecatedClass.ActionManager()
|
||||
--CCComRender class will be Deprecated,end
|
||||
|
||||
--SceneReader class will be Deprecated,begin
|
||||
function DeprecatedClass.SceneReader()
|
||||
deprecatedTip("SceneReader","ccs.SceneReader")
|
||||
return ccs.SceneReader
|
||||
end
|
||||
_G["SceneReader"] = DeprecatedClass.SceneReader()
|
||||
--SceneReader class will be Deprecated,end
|
||||
|
||||
--GUIReader class will be Deprecated,begin
|
||||
function DeprecatedClass.GUIReader()
|
||||
deprecatedTip("GUIReader","ccs.GUIReader")
|
||||
return ccs.GUIReader
|
||||
end
|
||||
_G["GUIReader"] = DeprecatedClass.GUIReader()
|
||||
--GUIReader class will be Deprecated,end
|
||||
|
||||
--UIRootWidget class will be Deprecated,begin
|
||||
function DeprecatedClass.UIRootWidget()
|
||||
deprecatedTip("UIRootWidget","ccs.UIRootWidget")
|
||||
return ccs.UIRootWidget
|
||||
end
|
||||
_G["UIRootWidget"] = DeprecatedClass.UIRootWidget()
|
||||
--UIRootWidget class will be Deprecated,end
|
||||
|
||||
--ActionObject class will be Deprecated,begin
|
||||
function DeprecatedClass.ActionObject()
|
||||
deprecatedTip("ActionObject","ccs.ActionObject")
|
||||
return ccs.ActionObject
|
||||
end
|
||||
_G["ActionObject"] = DeprecatedClass.ActionObject()
|
||||
--ActionObject class will be Deprecated,end
|
||||
|
||||
--CCEGLViewProtocol class will be Deprecated,begin
|
||||
function DeprecatedClass.CCEGLViewProtocol()
|
||||
deprecatedTip("CCEGLViewProtocol","cc.EGLViewProtocol")
|
||||
return cc.EGLViewProtocol
|
||||
end
|
||||
_G["CCEGLViewProtocol"] = DeprecatedClass.CCEGLViewProtocol()
|
||||
--CCEGLViewProtocol class will be Deprecated,end
|
||||
|
||||
--CCEGLView class will be Deprecated,begin
|
||||
function DeprecatedClass.CCEGLView()
|
||||
deprecatedTip("CCEGLView","cc.EGLView")
|
||||
return cc.EGLView
|
||||
end
|
||||
_G["CCEGLView"] = DeprecatedClass.CCEGLView()
|
||||
--CCEGLView class will be Deprecated,end
|
||||
|
||||
--CCBProxy class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBProxy()
|
||||
deprecatedTip("CCBProxy","cc.CCBProxy")
|
||||
return cc.CCBProxy
|
||||
end
|
||||
_G["CCBProxy"] = DeprecatedClass.CCBProxy()
|
||||
--CCBProxy class will be Deprecated,end
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
require "Cocos2dConstants.lua"
|
||||
require "OpenglConstants.lua"
|
||||
require "StudioConstants.lua"
|
||||
--Enums will be deprecated,begin
|
||||
_G.kCCTextAlignmentLeft = cc.TEXT_ALIGNMENT_LEFT
|
||||
_G.kCCTextAlignmentRight = cc.TEXT_ALIGNMENT_RIGHT
|
||||
|
@ -395,3 +396,91 @@ _G.kStateConnecting = cc.WEBSOCKET_STATE_CONNECTING
|
|||
_G.kStateOpen = cc.WEBSOCKET_STATE_OPEN
|
||||
_G.kStateClosing = cc.WEBSOCKET_STATE_CLOSING
|
||||
_G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED
|
||||
|
||||
_G.LAYOUT_COLOR_NONE = ccs.LayoutBackGroundColorType.none
|
||||
_G.LAYOUT_COLOR_SOLID = ccs.LayoutBackGroundColorType.solid
|
||||
_G.LAYOUT_COLOR_GRADIENT = ccs.LayoutBackGroundColorType.gradient
|
||||
|
||||
_G.LAYOUT_ABSOLUTE = ccs.LayoutType.absolute
|
||||
_G.LAYOUT_LINEAR_VERTICAL = ccs.LayoutType.linearVertical
|
||||
_G.LAYOUT_LINEAR_HORIZONTAL = ccs.LayoutType.linearHorizontal
|
||||
_G.LAYOUT_RELATIVE = ccs.LayoutType.relative
|
||||
|
||||
_G.BRIGHT_NONE = ccs.BrightStyle.none
|
||||
_G.BRIGHT_NORMAL = ccs.BrightStyle.normal
|
||||
_G.BRIGHT_HIGHLIGHT = ccs.BrightStyle.highlight
|
||||
|
||||
_G.WidgetTypeWidget = ccs.WidgetType.widget
|
||||
_G.WidgetTypeContainer = ccs.WidgetType.container
|
||||
|
||||
_G.UI_TEX_TYPE_LOCAL = ccs.TextureResType.UI_TEX_TYPE_LOCAL
|
||||
_G.UI_TEX_TYPE_PLIST = ccs.TextureResType.UI_TEX_TYPE_PLIST
|
||||
|
||||
_G.TOUCH_EVENT_BEGAN = ccs.TouchEventType.began
|
||||
_G.TOUCH_EVENT_MOVED = ccs.TouchEventType.moved
|
||||
_G.TOUCH_EVENT_ENDED = ccs.TouchEventType.ended
|
||||
_G.TOUCH_EVENT_CANCELED = ccs.TouchEventType.canceled
|
||||
|
||||
_G.SIZE_ABSOLUTE = ccs.SizeType.absolute
|
||||
_G.SIZE_PERCENT = ccs.SizeType.percent
|
||||
|
||||
_G.POSITION_ABSOLUTE = ccs.PositionType.absolute
|
||||
_G.POSITION_PERCENT = ccs.PositionType.percent
|
||||
|
||||
_G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected
|
||||
_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected
|
||||
|
||||
_G.CHECKBOX_STATE_EVENT_SELECTED = ccs.CheckBoxEventType.selected
|
||||
_G.CHECKBOX_STATE_EVENT_UNSELECTED = ccs.CheckBoxEventType.unselected
|
||||
|
||||
_G.LoadingBarTypeLeft = ccs.LoadingBarType.left
|
||||
_G.LoadingBarTypeRight = ccs.LoadingBarType.right
|
||||
|
||||
_G.LoadingBarTypeRight = ccs.SliderEventType.percent_changed
|
||||
|
||||
_G.TEXTFIELD_EVENT_ATTACH_WITH_IME = ccs.TextFiledEventType.attach_with_ime
|
||||
_G.TEXTFIELD_EVENT_DETACH_WITH_IME = ccs.TextFiledEventType.detach_with_ime
|
||||
_G.TEXTFIELD_EVENT_INSERT_TEXT = ccs.TextFiledEventType.insert_text
|
||||
_G.TEXTFIELD_EVENT_DELETE_BACKWARD = ccs.TextFiledEventType.delete_backward
|
||||
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.SCROLLVIEW_DIR.none
|
||||
_G.SCROLLVIEW_DIR_VERTICAL = ccs.SCROLLVIEW_DIR.vertical
|
||||
_G.SCROLLVIEW_DIR_HORIZONTAL = ccs.SCROLLVIEW_DIR.horizontal
|
||||
_G.SCROLLVIEW_DIR_BOTH = ccs.SCROLLVIEW_DIR.both
|
||||
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccs.ScrollviewEventType.SCROLL_TO_TOP
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccs.ScrollviewEventType.SCROLL_TO_BOTTOM
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccs.ScrollviewEventType.SCROLL_TO_LEFT
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccs.ScrollviewEventType.SCROLL_TO_RIGHT
|
||||
_G.SCROLLVIEW_EVENT_SCROLLING = ccs.ScrollviewEventType.SCROLLING
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccs.ScrollviewEventType.BOUNCE_TOP
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccs.ScrollviewEventType.BOUNCE_BOTTOM
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccs.ScrollviewEventType.BOUNCE_LEFT
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccs.ScrollviewEventType.BOUNCE_RIGHT
|
||||
|
||||
_G.PAGEVIEW_EVENT_TURNING = ccs.PageViewEventType.turning
|
||||
|
||||
_G.PAGEVIEW_TOUCHLEFT = ccs.PVTouchDir.touch_left
|
||||
_G.PAGEVIEW_TOUCHRIGHT = ccs.PVTouchDir.touch_right
|
||||
|
||||
_G.LISTVIEW_DIR_NONE = ccs.ListViewDirection.none
|
||||
_G.LISTVIEW_DIR_VERTICAL = ccs.ListViewDirection.vertical
|
||||
_G.LISTVIEW_DIR_HORIZONTAL = ccs.ListViewDirection.horizontal
|
||||
|
||||
_G.LISTVIEW_MOVE_DIR_NONE = ccs.ListViewMoveDirection.none
|
||||
_G.LISTVIEW_MOVE_DIR_UP = ccs.ListViewMoveDirection.up
|
||||
_G.LISTVIEW_MOVE_DIR_DOWN = ccs.ListViewMoveDirection.down
|
||||
_G.LISTVIEW_MOVE_DIR_LEFT = ccs.ListViewMoveDirection.left
|
||||
_G.LISTVIEW_MOVE_DIR_RIGHT = ccs.ListViewMoveDirection.right
|
||||
|
||||
_G.LISTVIEW_EVENT_INIT_CHILD = ccs.ListViewEventType.init_child
|
||||
_G.LISTVIEW_EVENT_UPDATE_CHILD = ccs.ListViewEventType.update_child
|
||||
|
||||
_G.LAYOUT_PARAMETER_NONE = ccs.UILayoutParameterType.none
|
||||
_G.LAYOUT_PARAMETER_LINEAR = ccs.UILayoutParameterType.linear
|
||||
_G.LAYOUT_PARAMETER_RELATIVE = ccs.UILayoutParameterType.relative
|
||||
|
||||
_G.kCCScrollViewDirectionHorizontal = cc.SCROLLVIEW_DIRECTION_HORIZONTAL
|
||||
_G.kCCScrollViewDirectionVertical = cc.SCROLLVIEW_DIRECTION_VERTICAL
|
||||
_G.kCCTableViewFillTopDown = cc.TABLEVIEW_FILL_TOPDOWN
|
||||
_G.kCCTableViewFillBottomUp = cc.TABLEVIEW_FILL_BOTTOMUP
|
||||
|
|
|
@ -20,11 +20,11 @@ ccs.WidgetType =
|
|||
container = 1, --container
|
||||
}
|
||||
|
||||
-- ccs.TextureResType =
|
||||
-- {
|
||||
-- "local" = 0,
|
||||
-- "plist" = 1,
|
||||
-- }
|
||||
ccs.TextureResType =
|
||||
{
|
||||
UI_TEX_TYPE_LOCAL = 0,
|
||||
UI_TEX_TYPE_PLIST = 1,
|
||||
}
|
||||
|
||||
ccs.TouchEventType =
|
||||
{
|
||||
|
@ -138,10 +138,15 @@ ccs.SCROLLVIEW_MOVE_DIR = {
|
|||
}
|
||||
|
||||
ccs.ScrollviewEventType = {
|
||||
top = 0,
|
||||
bottom = 1,
|
||||
left = 2,
|
||||
right = 3,
|
||||
SCROLL_TO_TOP = 0,
|
||||
SCROLL_TO_BOTTOM = 1,
|
||||
SCROLL_TO_LEFT = 2,
|
||||
SCROLL_TO_RIGHT = 3,
|
||||
SCROLLING = 4,
|
||||
BOUNCE_TOP = 5,
|
||||
BOUNCE_BOTTOM = 6,
|
||||
BOUNCE_LEFT = 7,
|
||||
BOUNCE_RIGHT = 8,
|
||||
}
|
||||
|
||||
ccs.ListViewDirection = {
|
||||
|
|
|
@ -1,7 +1,37 @@
|
|||
set(APP_NAME hellocpp)
|
||||
|
||||
if(QT)
|
||||
set(PLATFORM_SRC
|
||||
proj.qt/main.cpp
|
||||
)
|
||||
elseif(ANDROID)
|
||||
set(PLATFORM_SRC
|
||||
proj.android/jni/hellocpp/main.cpp
|
||||
)
|
||||
elseif(WIN32)
|
||||
set(PLATFORM_SRC
|
||||
proj.win32/main.cpp
|
||||
)
|
||||
elseif(APPLE)
|
||||
if(IOS)
|
||||
set(PLATFORM_SRC
|
||||
proj.ios/main.m
|
||||
proj.ios/AppController.mm
|
||||
proj.ios/RootViewController.mm
|
||||
)
|
||||
else()
|
||||
set(PLATFORM_SRC
|
||||
proj.mac/main.m
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(PLATFORM_SRC
|
||||
proj.linux/main.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(SAMPLE_SRC
|
||||
proj.linux/main.cpp
|
||||
${PLATFORM_SRC}
|
||||
Classes/AppDelegate.cpp
|
||||
Classes/HelloWorldScene.cpp
|
||||
)
|
||||
|
@ -11,15 +41,27 @@ add_executable(${APP_NAME}
|
|||
${SAMPLE_SRC}
|
||||
)
|
||||
|
||||
#get our resources
|
||||
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(WIN32 AND MSVC)
|
||||
|
||||
#get our dlls
|
||||
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/gles/prebuilt/glew32.dll
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_custom_command(TARGET ${APP_NAME} PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../../external/win32-specific/zlib/prebuilt/zlib1.dll
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Debug)
|
||||
|
||||
#Visual Studio Defaults to wrong type
|
||||
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
|
||||
set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
||||
endif()
|
||||
|
||||
target_link_libraries(${APP_NAME} audio cocos2d)
|
||||
|
||||
set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
||||
|
||||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
pre_build(${APP_NAME}
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void TestPerformance::onDecrease(Object* pSender)
|
|||
{
|
||||
removeArmatureFromParent(ArmaturePerformanceTag + armatureCount);
|
||||
armatureCount --;
|
||||
refreshTitile();
|
||||
refreshTitle();
|
||||
}
|
||||
}
|
||||
void TestPerformance::addArmature(int number)
|
||||
|
@ -423,7 +423,7 @@ void TestPerformance::addArmature(int number)
|
|||
armature->release();
|
||||
}
|
||||
|
||||
refreshTitile();
|
||||
refreshTitle();
|
||||
}
|
||||
void TestPerformance::addArmatureToParent(cocostudio::Armature *armature)
|
||||
{
|
||||
|
@ -433,7 +433,7 @@ void TestPerformance::removeArmatureFromParent(int tag)
|
|||
{
|
||||
removeChildByTag(ArmaturePerformanceTag + armatureCount);
|
||||
}
|
||||
void TestPerformance::refreshTitile()
|
||||
void TestPerformance::refreshTitle()
|
||||
{
|
||||
char pszCount[255];
|
||||
sprintf(pszCount, "%s %i", subtitle().c_str(), armatureCount);
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
virtual void addArmature(int number);
|
||||
virtual void addArmatureToParent(cocostudio::Armature *armature);
|
||||
virtual void removeArmatureFromParent(int tag);
|
||||
virtual void refreshTitile();
|
||||
virtual void refreshTitle();
|
||||
|
||||
int armatureCount;
|
||||
|
||||
|
|
|
@ -1110,7 +1110,7 @@ std::string ParticleDemo::title()
|
|||
|
||||
std::string ParticleDemo::subtitle()
|
||||
{
|
||||
return "No titile";
|
||||
return "No title";
|
||||
}
|
||||
|
||||
void ParticleDemo::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
|
||||
|
@ -1238,7 +1238,7 @@ void ParticleBatchHybrid::switchRender(float dt)
|
|||
|
||||
std::string ParticleBatchHybrid::title()
|
||||
{
|
||||
return "Paticle Batch";
|
||||
return "Particle Batch";
|
||||
}
|
||||
|
||||
std::string ParticleBatchHybrid::subtitle()
|
||||
|
@ -1280,7 +1280,7 @@ void ParticleBatchMultipleEmitters::onEnter()
|
|||
|
||||
std::string ParticleBatchMultipleEmitters::title()
|
||||
{
|
||||
return "Paticle Batch";
|
||||
return "Particle Batch";
|
||||
}
|
||||
|
||||
std::string ParticleBatchMultipleEmitters::subtitle()
|
||||
|
|
|
@ -519,7 +519,7 @@ void SpriteMainScene::onEnter()
|
|||
auto director = Director::getInstance();
|
||||
auto sched = director->getScheduler();
|
||||
|
||||
sched->scheduleSelector(SEL_SCHEDULE(&SpriteMainScene::updateAutoTest), this, 0.2, false);
|
||||
sched->scheduleSelector(SEL_SCHEDULE(&SpriteMainScene::updateAutoTest), this, 0.2f, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -686,7 +686,6 @@ void PhysicsDemoJoints::onEnter()
|
|||
node->setPhysicsBody(box);
|
||||
box->setDynamic(false);
|
||||
node->setPosition(Point::ZERO);
|
||||
|
||||
this->addChild(node);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
|
@ -749,9 +748,115 @@ void PhysicsDemoJoints::onEnter()
|
|||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO);
|
||||
joint->setMin(30.0f);
|
||||
joint->setMax(60.0f);
|
||||
PhysicsJointLimit* joint = PhysicsJointLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 30.0f, 60.0f);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
auto sp1 = makeBall(offset - Point(30, 0), 10);
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
PhysicsJointSpring* joint = PhysicsJointSpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point::ZERO, Point::ZERO, 500.0f, 0.3f);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
auto sp1 = makeBall(offset - Point(30, 0), 10);
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
PhysicsJointGroove* joint = PhysicsJointGroove::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), Point(30, 15), Point(30, -15), Point(-30, 0));
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10));
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointRotarySpring* joint = PhysicsJointRotarySpring::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 3000.0f, 60.0f);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10));
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10));
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10));
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointGear* joint = PhysicsJointGear::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, 2.0f);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
this->addChild(sp2);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
auto sp1 = makeBox(offset - Point(30, 0), Size(30, 10));
|
||||
sp1->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
auto sp2 = makeBox(offset + Point(30, 0), Size(30, 10));
|
||||
sp2->getPhysicsBody()->setTag(DRAG_BODYS_TAG);
|
||||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
|
|
|
@ -52,6 +52,7 @@ static std::function<Layer*()> createFunctions[] =
|
|||
CL(TexturePNG),
|
||||
CL(TextureJPEG),
|
||||
CL(TextureTIFF),
|
||||
CL(TextureTGA),
|
||||
CL(TextureWEBP),
|
||||
CL(TexturePixelFormat),
|
||||
CL(TextureBlend),
|
||||
|
@ -190,6 +191,29 @@ std::string TextureTIFF::title()
|
|||
return "TIFF Test";
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// TextureTGA
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void TextureTGA::onEnter()
|
||||
{
|
||||
TextureDemo::onEnter();
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
auto img = Sprite::create("TileMaps/levelmap.tga");
|
||||
img->setPosition(Point( s.width/2.0f, s.height/2.0f));
|
||||
this->addChild(img);
|
||||
Director::getInstance()->getTextureCache()->dumpCachedTextureInfo();
|
||||
}
|
||||
|
||||
std::string TextureTGA::title()
|
||||
{
|
||||
return "TGA Test";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// TexturePNG
|
||||
|
|
|
@ -26,6 +26,15 @@ public:
|
|||
virtual void onEnter();
|
||||
};
|
||||
|
||||
|
||||
class TextureTGA : public TextureDemo
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(TextureTGA);
|
||||
virtual std::string title();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
class TexturePNG : public TextureDemo
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -405,7 +405,7 @@ function TestPerformance.extend(target)
|
|||
return target
|
||||
end
|
||||
|
||||
function TestPerformance:refreshTitile()
|
||||
function TestPerformance:refreshTitle()
|
||||
local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount
|
||||
local label = tolua.cast(self:getChildByTag(10001),"LabelTTF")
|
||||
label:setString(subTitleInfo)
|
||||
|
@ -429,7 +429,7 @@ function TestPerformance:addArmature(num)
|
|||
self:addArmatureToParent(armature)
|
||||
end
|
||||
|
||||
self:refreshTitile()
|
||||
self:refreshTitle()
|
||||
end
|
||||
|
||||
function TestPerformance:onEnter()
|
||||
|
@ -446,7 +446,7 @@ function TestPerformance:onEnter()
|
|||
for i = 1, 20 do
|
||||
self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount)
|
||||
self._armatureCount = self._armatureCount - 1
|
||||
self:refreshTitile()
|
||||
self:refreshTitle()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -523,7 +523,7 @@ function TestPerformanceBatchNode:onEnter()
|
|||
for i = 1, 20 do
|
||||
self:removeArmatureFromParent(armaturePerformanceTag + self._armatureCount)
|
||||
self._armatureCount = self._armatureCount - 1
|
||||
self:refreshTitile()
|
||||
self:refreshTitle()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ local function ParticleBatchHybrid()
|
|||
|
||||
layer:registerScriptHandler(ParticleBatchHybrid_onEnterOrExit)
|
||||
|
||||
titleLabel:setString("Paticle Batch")
|
||||
titleLabel:setString("Particle Batch")
|
||||
subtitleLabel:setString("Hybrid: batched and non batched every 2 seconds")
|
||||
return layer
|
||||
end
|
||||
|
@ -364,7 +364,7 @@ local function ParticleBatchMultipleEmitters()
|
|||
|
||||
layer:addChild(batch, 10)
|
||||
|
||||
titleLabel:setString("Paticle Batch")
|
||||
titleLabel:setString("Particle Batch")
|
||||
subtitleLabel:setString("Multiple emitters. One Batch")
|
||||
return layer
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault Image
|
||||
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -50,7 +50,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
MenuItem.*::[create setCallback initWithCallback],
|
||||
Label::[getLettersInfo],
|
||||
Copying::[*],
|
||||
.*Protocol::[*],
|
||||
LabelProtocol::[*],
|
||||
LabelTextFormatProtocol::[*],
|
||||
.*Delegate::[*],
|
||||
PoolManager::[*],
|
||||
Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData],
|
||||
|
@ -68,7 +69,6 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
ScriptEngineManager::[*],
|
||||
KeypadHandler::[*],
|
||||
Invocation::[*],
|
||||
EGLView::[*],
|
||||
SchedulerScriptHandlerEntry::[*],
|
||||
Size::[*],
|
||||
Point::[*],
|
||||
|
@ -105,7 +105,9 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
ccFontDefinition::[*],
|
||||
Object::[autorelease isEqual acceptVisitor update],
|
||||
UserDefault::[getInstance (s|g)etDataForKey],
|
||||
Label::[getLettersInfo]
|
||||
Label::[getLettersInfo],
|
||||
EGLViewProtocol::[setTouchDelegate],
|
||||
EGLView::[end swapBuffers]
|
||||
|
||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||
ProgressTimer::[setReverseProgress=setReverseDirection],
|
||||
|
@ -136,7 +138,7 @@ base_classes_to_skip = Clonable
|
|||
|
||||
# classes that create no constructor
|
||||
# Set is special and we will use a hand-written constructor
|
||||
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label
|
||||
abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application ClippingNode Label EGLViewProtocol EGLView
|
||||
|
||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||
script_control_cpp = no
|
||||
|
|
|
@ -49,11 +49,9 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*
|
|||
UIWidget::[(s|g)etUserObject],
|
||||
UIImageView::[doubleClickEvent]
|
||||
|
||||
rename_functions = UIHelper::[instance=getInstance],
|
||||
ArmatureDataManager::[sharedArmatureDataManager=getInstance],
|
||||
GUIReader::[shareReader=getInstance],
|
||||
ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyActionManager],
|
||||
SceneReader::[purgeSceneReader=destroySceneReader]
|
||||
rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance],
|
||||
ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance],
|
||||
SceneReader::[purgeSceneReader=destroyInstance]
|
||||
|
||||
|
||||
rename_classes =
|
||||
|
|
Loading…
Reference in New Issue