resolve conflict

This commit is contained in:
yangxiao 2015-02-13 15:46:19 +08:00
commit 9b117bf87c
28 changed files with 193 additions and 81 deletions

View File

@ -1,3 +1,8 @@
cocos2d-x-3.5 ??
[FIX] Audio: audio can not resume if it is interrupt, and back from background
[FIX] C++: compiling error when using CC_USE_CULLING
[FIX] Label: texture size of string has unexpected padding on iOS 7 and upper version
cocos2d-x-3.4 Jan.30 2015
[FIX] Animate3D: `setSpeed` has not effect if `Animate3D` is used in Sequence
[FIX] C++: will crash if built with armeabi-v7a enabled on Android devices that with armeabi-v7a architecture but doesn't support NEON instructions

View File

@ -29,6 +29,12 @@ cmake_minimum_required(VERSION 2.8)
# also from cmake's Modules dir, to not clash with per-project files.
cmake_policy(SET CMP0017 NEW)
# Use new behaviour with cmake >= 3.0:
# Only interpret if() arguments as variables or keywords when unquoted.
if(CMAKE_VERSION VERSION_GREATER 3)
cmake_policy(SET CMP0054 NEW)
endif()
project (Cocos2d-X)
# The version number
@ -49,6 +55,16 @@ if(MINGW)
set(USE_PREBUILT_LIBS_DEFAULT OFF)
endif()
set(BUILD_CPP_TESTS_DEFAULT ON)
set(BUILD_LUA_LIBS_DEFAULT ON)
set(BUILD_LUA_TESTS_DEFAULT ON)
# TODO: fix test samples for MSVC
if(MSVC)
set(BUILD_CPP_TESTS_DEFAULT OFF)
set(BUILD_LUA_LIBS_DEFAULT OFF)
set(BUILD_LUA_TESTS_DEFAULT OFF)
endif()
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
option(USE_BOX2D "Use box2d for physics library" OFF)
option(USE_WEBP "Use WebP codec" ${USE_WEBP_DEFAULT})
@ -58,9 +74,9 @@ option(BUILD_EXTENSIONS "Build extension library" ON)
option(BUILD_EDITOR_SPINE "Build editor support for spine" ON)
option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON)
option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
option(BUILD_CPP_TESTS "Build TestCpp samples" ON)
option(BUILD_LUA_LIBS "Build lua libraries" ON)
option(BUILD_LUA_TESTS "Build TestLua samples" ON)
option(BUILD_CPP_TESTS "Build TestCpp samples" ${BUILD_CPP_TESTS_DEFAULT})
option(BUILD_LUA_LIBS "Build lua libraries" ${BUILD_LUA_LIBS_DEFAULT})
option(BUILD_LUA_TESTS "Build TestLua samples" ${BUILD_LUA_TESTS_DEFAULT})
option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT})
if(USE_PREBUILT_LIBS AND MINGW)
@ -81,6 +97,14 @@ if(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
-wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710
-wd4514 -wd4056 -wd4996 -wd4099)
# Use inline debug info (/Z7) format. Or internal error may occur.
# Errors looks like: "xmemory0(592): error C3130: Internal Compiler Error: failed to write injected code block to PDB"
foreach(lang C CXX)
string(REGEX REPLACE "/Z[iI7]" "" CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}")
set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG} /Z7")
endforeach()
else()
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
@ -150,12 +174,14 @@ if(USE_PREBUILT_LIBS)
include(CocosUsePrebuiltLibs)
endif()
# GLFW3 used on Mac, Windows and Linux desktop platforms
# desktop platforms
if(LINUX OR MACOSX OR WINDOWS)
cocos_find_package(OpenGL OPENGL REQUIRED)
if(LINUX OR WINDOWS)
cocos_find_package(GLEW GLEW REQUIRED)
#TODO: implement correct schema for pass cocos2d specific requirements to projects
include_directories(${GLEW_INCLUDE_DIRS})
endif()
cocos_find_package(GLFW3 GLFW3 REQUIRED)
@ -236,9 +262,11 @@ cocos_find_package(ZLIB ZLIB REQUIRED)
# moreover our embedded version modified to quick provide
# functionality needed by cocos.
if(USE_PREBUILT_LIBS OR NOT MINGW)
#TODO: hack! should be in external/unzip/CMakeLists.txt
include_directories(${ZLIB_INCLUDE_DIRS})
add_subdirectory(external/unzip)
set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip)
set(MINIZIP_LIBRARIES unzip)
set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip ${ZLIB_INCLUDE_DIRS})
set(MINIZIP_LIBRARIES unzip ${ZLIB_LIBRARIES})
message(STATUS "MINIZIP include dirs: ${MINIZIP_INCLUDE_DIRS}")
else()
cocos_find_package(MINIZIP MINIZIP REQUIRED)
@ -261,10 +289,10 @@ set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external)
message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}")
# build for 3rd party libraries
if(LINUX OR APPLE)
# build xxhash
add_subdirectory(external/xxhash)
endif()
set(XXHASH_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash)
set(XXHASH_LIBRARIES xxhash)
# libcocos2d.a
add_subdirectory(cocos)

View File

@ -36,7 +36,7 @@ set(_sqlite3_inc sqlite3.h)
set(_sqlite3_libs sqlite3)
set(_gles_prefix GLEW)
set(_gles_inc glew.h)
set(_gles_inc GL/glew.h)
set(_gles_inc_paths OGLES)
set(_gles_libs glew32)

View File

@ -201,16 +201,8 @@ bool Follow::initWithTarget(Node *followedNode, const Rect& rect/* = Rect::ZERO*
followedNode->retain();
_followedNode = followedNode;
_worldRect = rect;
if (rect.equals(Rect::ZERO))
{
_boundarySet = false;
}
else
{
_boundarySet = true;
}
_worldRect = rect;
_boundarySet = !rect.equals(Rect::ZERO);
_boundaryFullyCovered = false;
Size winSize = Director::getInstance()->getWinSize();
@ -254,7 +246,9 @@ void Follow::step(float dt)
{
// whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased
if(_boundaryFullyCovered)
{
return;
}
Vec2 tempPos = _halfScreenSize - _followedNode->getPosition();

View File

@ -896,8 +896,8 @@ void Label::drawShadowWithoutBlur()
void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
// Don't do calculate the culling if the transform was not updated
#if CC_USE_CULLING
bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY;
#if CC_USE_CULLING
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
if(_insideBounds)

View File

@ -198,6 +198,8 @@ Node::~Node()
#endif
stopAllActions();
unscheduleAllCallbacks();
CC_SAFE_RELEASE_NULL(_actionManager);
CC_SAFE_RELEASE_NULL(_scheduler);

View File

@ -67,7 +67,7 @@ SpriteBatchNode* SpriteBatchNode::create(const std::string& fileImage, ssize_t c
/*
* init with Texture2D
*/
bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity)
bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{
CCASSERT(capacity>=0, "Capacity must be >= 0");
@ -105,7 +105,7 @@ bool SpriteBatchNode::init()
/*
* init with FileImage
*/
bool SpriteBatchNode::initWithFile(const std::string& fileImage, ssize_t capacity)
bool SpriteBatchNode::initWithFile(const std::string& fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
{
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
return initWithTexture(texture2D, capacity);

View File

@ -67,12 +67,12 @@ class CC_DLL SpriteBatchNode : public Node, public TextureProtocol
public:
/** creates a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The capacity will be increased in 33% in runtime if it runs out of space.
*/
static SpriteBatchNode* createWithTexture(Texture2D* tex, ssize_t capacity = DEFAULT_CAPACITY);
/** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The capacity will be increased in 33% in runtime if it runs out of space.
The file will be loaded using the TextureMgr.
*/
static SpriteBatchNode* create(const std::string& fileImage, ssize_t capacity = DEFAULT_CAPACITY);
@ -168,16 +168,16 @@ CC_CONSTRUCTOR_ACCESS:
virtual ~SpriteBatchNode();
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The capacity will be increased in 33% in runtime if it runs out of space.
*/
bool initWithTexture(Texture2D *tex, ssize_t capacity);
bool initWithTexture(Texture2D *tex, ssize_t capacity = DEFAULT_CAPACITY);
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The capacity will be increased in 33% in runtime if it runs out of space.
The file will be loaded using the TextureMgr.
* @js init
* @lua init
*/
bool initWithFile(const std::string& fileImage, ssize_t capacity);
bool initWithFile(const std::string& fileImage, ssize_t capacity = DEFAULT_CAPACITY);
bool init();
protected:

View File

@ -55,7 +55,7 @@ public:
*/
virtual ~TMXObjectGroup();
inline const std::string& getGroupName(){ return _groupName; }
inline const std::string& getGroupName() const { return _groupName; }
inline void setGroupName(const std::string& groupName){ _groupName = groupName; }
/** return the value for the specific property name */

View File

@ -110,8 +110,8 @@ void Animate3D::startWithTarget(Node *target)
_boneCurves.clear();
auto skin = sprite->getSkeleton();
bool hasCurve = false;
for (unsigned int i = 0; i < skin->getBoneCount(); i++) {
auto bone = skin->getBoneByIndex(i);
for (int i = 0; i < skin->getBoneCount(); i++) {
auto bone = skin->getBoneByIndex(static_cast<unsigned int>(i));
auto curve = _animation->getBoneCurveByName(bone->getName());
if (curve)
{

View File

@ -113,9 +113,9 @@ void getChildMap(std::map<int, std::vector<int> >& map, SkinData* skinData, cons
skinData->nodeBoneOriginMatrices.push_back(transform);
parent_name_index = skinData->getBoneNameIndex(parent_name);
}
else if (parent_name_index < skinData->skinBoneNames.size())
else if (parent_name_index < static_cast<int>(skinData->skinBoneNames.size()))
{
skinData->skinBoneOriginMatrices[parent_name_index] = (transform);
skinData->skinBoneOriginMatrices[parent_name_index] = transform;
}
// set root bone index
@ -246,7 +246,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
meshdata->attribs.push_back(attrib);
}
auto vertexNum = shapes.positions.size() / 3;
for(auto i = 0; i < vertexNum; i++)
for(unsigned int i = 0; i < vertexNum; i++)
{
meshdata->vertex.push_back(shapes.positions[i * 3]);
meshdata->vertex.push_back(shapes.positions[i * 3 + 1]);
@ -372,7 +372,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str());
return false;
}
for(int i = 0; i < meshSize ; i++ )
for(unsigned int i = 0; i < meshSize ; i++ )
{
MeshData* meshData = new (std::nothrow) MeshData();
unsigned int attribSize=0;
@ -442,7 +442,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
if (_version != "0.3" && _version != "0.4" && _version != "0.5")
{
//read mesh aabb
float aabb[6];
float aabb[6];
if (_binaryReader.read(aabb, 4, 6) != 6)
{
CCLOG("warning: Failed to read meshdata: aabb '%s'.", _path.c_str());
@ -489,7 +489,7 @@ bool Bundle3D::loadMeshDatasBinary_0_1(MeshDatas& meshdatas)
// backward compatibility
VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD,
};
for (ssize_t i = 0; i < attribSize; i++)
for (unsigned int i = 0; i < attribSize; i++)
{
unsigned int vUsage, vSize;
if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1)
@ -598,7 +598,7 @@ bool Bundle3D::loadMeshDatasBinary_0_2(MeshDatas& meshdatas)
// backward compatibility
VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD,
};
for (ssize_t i = 0; i < attribSize; i++)
for (unsigned int i = 0; i < attribSize; i++)
{
unsigned int vUsage, vSize;
if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1)
@ -695,7 +695,7 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
MeshVertexAttrib tempAttrib;
meshData->attribCount=mesh_vertex_attribute.Size();
meshData->attribs.resize(meshData->attribCount);
for (int i = 0; i < mesh_vertex_attribute.Size(); i++)
for (rapidjson::SizeType i = 0; i < mesh_vertex_attribute.Size(); i++)
{
const rapidjson::Value& mesh_vertex_attribute_val = mesh_vertex_attribute[i];
@ -856,7 +856,7 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas)
return false;
unsigned int materialnum = 1;
_binaryReader.read(&materialnum, 4, 1);
for (int i = 0; i < materialnum; i++)
for (unsigned int i = 0; i < materialnum; i++)
{
NMaterialData materialData;
materialData.id = _binaryReader.readString();
@ -865,7 +865,7 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas)
unsigned int textruenum = 1;
_binaryReader.read(&textruenum, 4, 1);
for(int j = 0; j < textruenum ; j++ )
for(unsigned int j = 0; j < textruenum ; j++ )
{
NTextureData textureData;
textureData.id = _binaryReader.readString();
@ -924,7 +924,7 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas)
unsigned int materialnum = 1;
_binaryReader.read(&materialnum, 4, 1);
for (int i = 0; i < materialnum; i++)
for (unsigned int i = 0; i < materialnum; i++)
{
NMaterialData materialData;
@ -1051,14 +1051,14 @@ bool Bundle3D::loadBinary(const std::string& path)
// Read all refs
CC_SAFE_DELETE_ARRAY(_references);
_references = new (std::nothrow) Reference[_referenceCount];
for (ssize_t i = 0; i < _referenceCount; ++i)
for (unsigned int i = 0; i < _referenceCount; ++i)
{
if ((_references[i].id = _binaryReader.readString()).empty() ||
_binaryReader.read(&_references[i].type, 4, 1) != 1 ||
_binaryReader.read(&_references[i].offset, 4, 1) != 1)
{
clear();
CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str());
CCLOG("warning: Failed to read ref number %u for bundle '%s'.", i, path.c_str());
CC_SAFE_DELETE_ARRAY(_references);
return false;
}
@ -1376,17 +1376,17 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani
if (!_jsonReader.HasMember(anim.c_str())) return false;
int the_index = -1;
const rapidjson::Value& animation_data_array = _jsonReader[anim.c_str()];
const rapidjson::Value& animation_data_array = _jsonReader[anim.c_str()];
if (animation_data_array.Size()==0) return false;
if(!id.empty())
{
for(int i=0 ;i<animation_data_array.Size();i++)
for (rapidjson::SizeType i = 0; i < animation_data_array.Size(); i++)
{
if(animation_data_array[i][ID].GetString() ==id )
if(animation_data_array[i][ID].GetString() == id)
{
the_index = i;
the_index = static_cast<int>(i);
}
}
if(the_index < 0) return false;
@ -1797,7 +1797,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton)
CCLOG("warning: Failed to read nodedata: uvMapping '%s'.", _path.c_str());
return nullptr;
}
for(int j = 0 ; j < uvMapping ; j++)
for(unsigned int j = 0; j < uvMapping; j++)
{
unsigned int textureIndexSize=0;
if (_binaryReader.read(&textureIndexSize, 4, 1) != 1)
@ -1805,7 +1805,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton)
CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str());
return nullptr;
}
for(unsigned int k = 0; k < textureIndexSize ; k++)
for(unsigned int k = 0; k < textureIndexSize; k++)
{
unsigned int index=0;
if (_binaryReader.read(&index, 4, 1) != 1)

View File

@ -170,7 +170,7 @@ std::string BundleReader::readString()
std::string str;
ssize_t validLength = _length - _position;
if (length > 0 && length <= validLength)
if (length > 0 && static_cast<ssize_t>(length) <= validLength)
{
str.resize(length);
if (read(&str[0], 1, length) != length)
@ -187,4 +187,4 @@ bool BundleReader::readMatrix(float* m)
return (read(m, sizeof(float), 16) == 16);
}
}
NS_CC_END

View File

@ -70,7 +70,7 @@ ssize_t MeshSkin::getBoneCount() const
//get bone
Bone3D* MeshSkin::getBoneByIndex(unsigned int index) const
{
if (index < _skinBones.size())
if (static_cast<int>(index) < _skinBones.size())
return _skinBones.at(index);
return nullptr;

View File

@ -79,9 +79,7 @@ set(COCOS_SRC cocos2d.cpp
)
#todo: provide prebuild versions of the xx libs for all platforms
include_directories(
../external/xxhash
../external/xxtea)
include_directories(../external/xxtea)
add_library(cocos2d ${COCOS_SRC})
@ -127,11 +125,11 @@ else()
message( FATAL_ERROR "Unsupported platform, CMake will exit" )
endif()
foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS)
foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS XXHASH)
cocos_use_pkg(cocos2d ${pkg})
endforeach()
target_link_libraries(cocos2d xxhash ${PLATFORM_SPECIFIC_LIBS})
target_link_libraries(cocos2d ${PLATFORM_SPECIFIC_LIBS})
if(USE_WEBP)
add_definitions(-DCC_USE_WEBP=1)

View File

@ -26,9 +26,11 @@
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC
#include "AudioEngine-inl.h"
#include "audio/include/AudioEngine.h"
#import <OpenAL/alc.h>
#import <AVFoundation/AVFoundation.h>
#include "audio/include/AudioEngine.h"
#include "platform/CCFileUtils.h"
#include "base/CCDirector.h"
#include "base/CCScheduler.h"
@ -127,11 +129,61 @@ namespace cocos2d {
}
}
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
@interface AudioEngineSessionHandler : NSObject
{
}
-(id) init;
-(void)handleInterruption:(NSNotification*)notification;
@end
@implementation AudioEngineSessionHandler
-(id) init
{
if (self == [super init])
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
}
return self;
}
-(void)handleInterruption:(NSNotification*)notification
{
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
NSInteger reason = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] integerValue];
if (reason == AVAudioSessionInterruptionTypeBegan) {
alcMakeContextCurrent(NULL);
}
if (reason == AVAudioSessionInterruptionTypeEnded) {
OSStatus result = AudioSessionSetActive(true);
if (result) NSLog(@"Error setting audio session active! %d\n", result);
alcMakeContextCurrent(s_ALContext);
}
}
}
-(void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionInterruptionNotification object:nil];
[super dealloc];
}
@end
static id s_AudioEngineSessionHandler = nullptr;
#endif
AudioEngineImpl::AudioEngineImpl()
: _threadPool(nullptr)
, _lazyInitLoop(true)
, _currentAudioID(0)
{
}
AudioEngineImpl::~AudioEngineImpl()
@ -151,12 +203,19 @@ AudioEngineImpl::~AudioEngineImpl()
_threadPool->destroy();
delete _threadPool;
}
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
[s_AudioEngineSessionHandler release];
#endif
}
bool AudioEngineImpl::init()
{
bool ret = false;
do{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
s_AudioEngineSessionHandler = [[AudioEngineSessionHandler alloc] init];
#endif
s_ALDevice = alcOpenDevice(nullptr);
if (s_ALDevice) {

View File

@ -609,7 +609,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBK
}
else
{
log("CCBReader: Unkown easing type %d", easingType);
log("CCBReader: Unkown easing type %d", static_cast<int>(easingType));
return pAction;
}
}

View File

@ -361,7 +361,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbRe
break;
}
default:
ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type);
ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(static_cast<int>(type));
break;
}
}

View File

@ -722,10 +722,10 @@ void EventFrame::setNode(cocos2d::Node* node)
void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
if(_frameIndex < _action->getStartFrame() || _frameIndex > _action->getEndFrame())
if (static_cast<int>(_frameIndex) < _action->getStartFrame() || static_cast<int>(_frameIndex) > _action->getEndFrame())
return;
if(currentFrameIndex >= _frameIndex)
if (currentFrameIndex >= static_cast<int>(_frameIndex))
emitEvent();
}

View File

@ -38,6 +38,8 @@
#import<CoreMotion/CoreMotion.h>
#import<CoreFoundation/CoreFoundation.h>
#define SENSOR_DELAY_GAME 0.02
@interface CCAccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
{
cocos2d::Acceleration *_acceleration;
@ -69,6 +71,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
if( (self = [super init]) ) {
_acceleration = new cocos2d::Acceleration();
_motionManager = [[CMMotionManager alloc] init];
_motionManager.accelerometerUpdateInterval = SENSOR_DELAY_GAME;
}
return self;
}
@ -226,7 +229,7 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
CGSize dim;
if(s_isIOS7OrHigher){
NSDictionary *attibutes = @{NSFontAttributeName:font};
dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:attibutes context:nil].size;
dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin) attributes:attibutes context:nil].size;
}
else {
dim = [str sizeWithFont:font constrainedToSize:textRect];

View File

@ -192,8 +192,8 @@ MeshCommand::~MeshCommand()
void MeshCommand::applyRenderState()
{
_renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE);
_renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST);
_renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE) != GL_FALSE;
_renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE;
glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite);
GLint cullface;
glGetIntegerv(GL_CULL_FACE_MODE, &cullface);

View File

@ -137,8 +137,8 @@ void RenderQueue::clear()
void RenderQueue::saveRenderState()
{
_isDepthEnabled = glIsEnabled(GL_DEPTH_TEST);
_isCullEnabled = glIsEnabled(GL_CULL_FACE);
_isDepthEnabled = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE;
_isCullEnabled = glIsEnabled(GL_CULL_FACE) != GL_FALSE;
glGetBooleanv(GL_DEPTH_WRITEMASK, &_isDepthWrite);
CHECK_GL_ERROR_DEBUG();

View File

@ -1,9 +1,5 @@
set(cocos_root ${Cocos2d-X_SOURCE_DIR})
if(WINDOWS)
add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON)
endif()
include_directories(
${cocos_root}/external/lua/tolua
${cocos_root}/external/lua/lua
@ -53,6 +49,10 @@ list(APPEND lua_cocos2d_source_files
)
if(WINDOWS)
if(MINGW)
add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON)
endif()
add_definitions(-DWIN32 -D_WINDOWS)
list(APPEND lua_cocos2d_source_files
${cocos_root}/external/lua/luasocket/wsocket.c
)

View File

@ -142,7 +142,7 @@
--------------------------------
-- creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.<br>
-- The capacity will be increased in 33% in runtime if it run out of space.<br>
-- The capacity will be increased in 33% in runtime if it runs out of space.<br>
-- The file will be loaded using the TextureMgr.
-- @function [parent=#SpriteBatchNode] create
-- @param self
@ -152,7 +152,7 @@
--------------------------------
-- creates a SpriteBatchNode with a texture2d and capacity of children.<br>
-- The capacity will be increased in 33% in runtime if it run out of space.
-- The capacity will be increased in 33% in runtime if it runs out of space.
-- @function [parent=#SpriteBatchNode] createWithTexture
-- @param self
-- @param #cc.Texture2D tex

View File

@ -45,8 +45,8 @@ function Sprite:playAnimationOnce(animation, args)
actions[#actions + 1] = cc.RemoveSelf:create()
end
if onComplete then
actions[#actions + 1] = cc.CallFunc:create(onComplete)
if args.onComplete then
actions[#actions + 1] = cc.CallFunc:create(args.onComplete)
end
local action

View File

@ -1,5 +1,8 @@
set(APP_NAME cpp-tests)
# Use same method as in cocos library
cocos_find_package(CURL CURL REQUIRED)
if(WIN32)
set(PLATFORM_SRC proj.win32/main.cpp)
set(RES_PREFIX "")
@ -252,6 +255,8 @@ target_link_libraries(${APP_NAME}
cocos2d
)
cocos_use_pkg(${APP_NAME} CURL)
if(MACOSX OR APPLE)
set_target_properties(${APP_NAME} PROPERTIES
MACOSX_BUNDLE 1

View File

@ -90,6 +90,15 @@ std::string getCurAppPath(void)
return fuldir;
}
static void initGLContextAttrs()
{
//set OpenGL context attributions,now can only set six attributions:
//red,green,blue,alpha,depth,stencil
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
SimulatorWin *SimulatorWin::_instance = nullptr;
SimulatorWin *SimulatorWin::getInstance()
@ -317,6 +326,7 @@ int SimulatorWin::run()
const bool isResize = _project.isResizeWindow();
std::stringstream title;
title << "Cocos Simulator - " << ConfigParser::getInstance()->getInitViewName();
initGLContextAttrs();
auto glview = GLViewImpl::createWithRect(title.str(), frameRect, frameScale);
_hwnd = glview->getWin32Window();
player::PlayerWin::createWithHwnd(_hwnd);

View File

@ -86,6 +86,15 @@ std::string getCurAppPath(void)
return fuldir;
}
static void initGLContextAttrs()
{
//set OpenGL context attributions,now can only set six attributions:
//red,green,blue,alpha,depth,stencil
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
SimulatorWin *SimulatorWin::_instance = nullptr;
SimulatorWin *SimulatorWin::getInstance()
@ -313,6 +322,7 @@ int SimulatorWin::run()
const bool isResize = _project.isResizeWindow();
std::stringstream title;
title << "Cocos Simulator - " << ConfigParser::getInstance()->getInitViewName();
initGLContextAttrs();
auto glview = GLViewImpl::createWithRect(title.str(), frameRect, frameScale);
_hwnd = glview->getWin32Window();
DragAcceptFiles(_hwnd, TRUE);

View File

@ -10,10 +10,8 @@ env:
# - PLATFORM=mac-ios SDK=iphonesimulator7.1 ARCH=x86_64 SCHEME="build all tests iOS"
- PLATFORM=mac-ios SDK=macosx10.9 ARCH=x86_64 SCHEME="build all tests Mac"
#notifications:
# email:
# - xiaoming.zhang@cocos2d-x.org
# - jianhua.chen@cocos2d-x.org
notifications:
email: false
# whitelist
branches: