Merge branch 'develop' into develop_migrate_math_lib_merge

Conflicts:
	cocos/2d/CCSprite.cpp
	tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp
This commit is contained in:
Huabing.Xu 2014-04-15 22:21:04 +08:00
commit 95cb7721f6
20 changed files with 239 additions and 195 deletions

View File

@ -1 +1 @@
0f35c93ef2907727c9ace16b5760935861409117
f9627687e49dc44eace02e9648208c4cd1987246

View File

@ -349,9 +349,9 @@ void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive
{
EventListener * listener = *iter;
if (listener->getSceneGraphPriority() == target)
if (listener->getAssociatedNode() == target)
{
listener->setSceneGraphPriority(nullptr); // Ensure no dangling ptr to the target node.
listener->setAssociatedNode(nullptr); // Ensure no dangling ptr to the target node.
listener->setRegistered(false);
listener->release();
iter = _toAddedListeners.erase(iter);
@ -446,7 +446,7 @@ void EventDispatcher::forceAddEventListener(EventListener* listener)
{
setDirty(listenerID, DirtyFlag::SCENE_GRAPH_PRIORITY);
auto node = listener->getSceneGraphPriority();
auto node = listener->getAssociatedNode();
CCASSERT(node != nullptr, "Invalid scene graph priority!");
associateNodeAndEventListener(node, listener);
@ -470,7 +470,7 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list
if (!listener->checkAvailable())
return;
listener->setSceneGraphPriority(node);
listener->setAssociatedNode(node);
listener->setFixedPriority(0);
listener->setRegistered(true);
@ -493,7 +493,7 @@ void EventDispatcher::debugCheckNodeHasNoEventListenersOnDestruction(Node* node)
for (EventListener * listener : *eventListenerVector->getSceneGraphPriorityListeners())
{
CCASSERT(!listener ||
listener->getSceneGraphPriority() != node,
listener->getAssociatedNode() != node,
"Node should have no event listeners registered for it upon destruction!");
}
}
@ -509,7 +509,7 @@ void EventDispatcher::debugCheckNodeHasNoEventListenersOnDestruction(Node* node)
{
for (EventListener * listener : *keyValuePair.second)
{
CCASSERT(listener->getSceneGraphPriority() != node,
CCASSERT(listener->getAssociatedNode() != node,
"Node should have no event listeners registered for it upon destruction!");
}
}
@ -525,7 +525,7 @@ void EventDispatcher::debugCheckNodeHasNoEventListenersOnDestruction(Node* node)
// Check the to be added list
for (EventListener * listener : _toAddedListeners)
{
CCASSERT(listener->getSceneGraphPriority() != node,
CCASSERT(listener->getAssociatedNode() != node,
"Node should have no event listeners registered for it upon destruction!");
}
@ -549,7 +549,7 @@ void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener,
if (!listener->checkAvailable())
return;
listener->setSceneGraphPriority(nullptr);
listener->setAssociatedNode(nullptr);
listener->setFixedPriority(fixedPriority);
listener->setRegistered(true);
listener->setPaused(false);
@ -582,10 +582,10 @@ void EventDispatcher::removeEventListener(EventListener* listener)
{
CC_SAFE_RETAIN(l);
l->setRegistered(false);
if (l->getSceneGraphPriority() != nullptr)
if (l->getAssociatedNode() != nullptr)
{
dissociateNodeAndEventListener(l->getSceneGraphPriority(), l);
l->setSceneGraphPriority(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.
dissociateNodeAndEventListener(l->getAssociatedNode(), l);
l->setAssociatedNode(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.
}
if (_inDispatch == 0)
@ -681,7 +681,7 @@ void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
auto found = std::find(fixedPriorityListeners->begin(), fixedPriorityListeners->end(), listener);
if (found != fixedPriorityListeners->end())
{
CCASSERT(listener->getSceneGraphPriority() == nullptr, "Can't set fixed priority with scene graph based listener.");
CCASSERT(listener->getAssociatedNode() == nullptr, "Can't set fixed priority with scene graph based listener.");
if (listener->getFixedPriority() != fixedPriority)
{
@ -782,7 +782,7 @@ void EventDispatcher::dispatchEvent(Event* event)
auto listeners = iter->second;
auto onEvent = [&event](EventListener* listener) -> bool{
event->setCurrentTarget(listener->getSceneGraphPriority());
event->setCurrentTarget(listener->getAssociatedNode());
listener->_onEvent(event);
return event->isStopped();
};
@ -1168,7 +1168,7 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener
// After sort: priority < 0, > 0
std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) {
return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()];
return _nodePriorityMap[l1->getAssociatedNode()] > _nodePriorityMap[l2->getAssociatedNode()];
});
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
@ -1245,10 +1245,10 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
{
auto l = *iter;
l->setRegistered(false);
if (l->getSceneGraphPriority() != nullptr)
if (l->getAssociatedNode() != nullptr)
{
dissociateNodeAndEventListener(l->getSceneGraphPriority(), l);
l->setSceneGraphPriority(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.
dissociateNodeAndEventListener(l->getAssociatedNode(), l);
l->setAssociatedNode(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes.
}
if (_inDispatch == 0)

View File

@ -128,13 +128,13 @@ protected:
*/
inline int getFixedPriority() const { return _fixedPriority; };
/** Sets scene graph priority for this listener */
inline void setSceneGraphPriority(Node* node) { _node = node; };
/** Sets the node associated with this listener */
inline void setAssociatedNode(Node* node) { _node = node; };
/** Gets scene graph priority of this listener
* @return nullptr if it's a fixed priority listener, non-nullptr for scene graph priority listener
/** Gets the node associated with this listener
* @return nullptr if it's a fixed priority listener, otherwise return non-nullptr
*/
inline Node* getSceneGraphPriority() const { return _node; };
inline Node* getAssociatedNode() const { return _node; };
///////////////
// Properties

View File

@ -258,6 +258,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
, _textSprite(nullptr)
, _contentDirty(false)
, _shadowDirty(false)
, _compatibleMode(false)
{
setAnchorPoint(Vector2::ANCHOR_MIDDLE);
reset();
@ -943,6 +944,7 @@ void Label::setFontDefinition(const FontDefinition& textDefinition)
_fontDefinition._shadow._shadowEnabled = false;
enableShadow(Color4B(0,0,0,255 * _fontDefinition._shadow._shadowOpacity),_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur);
}
_compatibleMode = true;
}
void Label::updateContent()
@ -968,41 +970,44 @@ void Label::updateContent()
}
else
{
_fontDefinition._fontName = _systemFont;
_fontDefinition._fontSize = _systemFontSize;
_fontDefinition._alignment = _hAlignment;
_fontDefinition._vertAlignment = _vAlignment;
_fontDefinition._dimensions.width = _labelWidth;
_fontDefinition._dimensions.height = _labelHeight;
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
_fontDefinition._shadow._shadowEnabled = false;
if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0)
if (!_compatibleMode)
{
_fontDefinition._stroke._strokeEnabled = true;
_fontDefinition._stroke._strokeSize = _outlineSize;
_fontDefinition._stroke._strokeColor.r = _effectColor.r;
_fontDefinition._stroke._strokeColor.g = _effectColor.g;
_fontDefinition._stroke._strokeColor.b = _effectColor.b;
}
else
{
_fontDefinition._stroke._strokeEnabled = false;
}
_fontDefinition._fontName = _systemFont;
_fontDefinition._fontSize = _systemFontSize;
_fontDefinition._alignment = _hAlignment;
_fontDefinition._vertAlignment = _vAlignment;
_fontDefinition._dimensions.width = _labelWidth;
_fontDefinition._dimensions.height = _labelHeight;
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
_fontDefinition._shadow._shadowEnabled = false;
if (_currLabelEffect == LabelEffect::OUTLINE && _outlineSize > 0)
{
_fontDefinition._stroke._strokeEnabled = true;
_fontDefinition._stroke._strokeSize = _outlineSize;
_fontDefinition._stroke._strokeColor.r = _effectColor.r;
_fontDefinition._stroke._strokeColor.g = _effectColor.g;
_fontDefinition._stroke._strokeColor.b = _effectColor.b;
}
else
{
_fontDefinition._stroke._strokeEnabled = false;
}
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
if (_fontDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Currently only supported on iOS and Android!");
}
_fontDefinition._stroke._strokeEnabled = false;
if (_fontDefinition._stroke._strokeEnabled)
{
CCLOGERROR("Currently only supported on iOS and Android!");
}
_fontDefinition._stroke._strokeEnabled = false;
#endif
}
createSpriteWithFontDefinition();
}

View File

@ -325,6 +325,7 @@ protected:
//compatibility with older LabelTTF
Sprite* _textSprite;
FontDefinition _fontDefinition;
bool _compatibleMode;
//! used for optimization
Sprite *_reusedLetter;

View File

@ -588,7 +588,7 @@ void Sprite::updateTransform(void)
void Sprite::draw(Renderer *renderer, const Matrix &transform, bool transformUpdated)
{
// Don't do calculate the culling if the transform was not updated
_insideBounds = transformUpdated ? isInsideBounds() : _insideBounds;
_insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
if(_insideBounds)
{
@ -622,35 +622,6 @@ void Sprite::drawDebugData()
}
#endif //CC_SPRITE_DEBUG_DRAW
// Culling function from cocos2d-iphone CCSprite.m file
bool Sprite::isInsideBounds() const
{
// half size of the screen
Size screen_half = Director::getInstance()->getWinSize();
screen_half.width /= 2;
screen_half.height /= 2;
float hcsx = _contentSize.width / 2;
float hcsy = _contentSize.height / 2;
// convert to world coordinates
float x = hcsx * _modelViewTransform.m[0] + hcsy * _modelViewTransform.m[4] + _modelViewTransform.m[12];
float y = hcsx * _modelViewTransform.m[1] + hcsy * _modelViewTransform.m[5] + _modelViewTransform.m[13];
// center of screen is (0,0)
x -= screen_half.width;
y -= screen_half.height;
// convert content size to world coordinates
float wchw = hcsx * std::max(fabsf(_modelViewTransform.m[0] + _modelViewTransform.m[4]), fabsf(_modelViewTransform.m[0] - _modelViewTransform.m[4]));
float wchh = hcsy * std::max(fabsf(_modelViewTransform.m[1] + _modelViewTransform.m[5]), fabsf(_modelViewTransform.m[1] - _modelViewTransform.m[5]));
// compare if it in the positive quadrant of the screen
float tmpx = (fabsf(x)-wchw);
float tmpy = (fabsf(y)-wchh);
return (tmpx < screen_half.width && tmpy < screen_half.height);
}
// Node overrides
void Sprite::addChild(Node *child, int zOrder, int tag)
{

View File

@ -526,8 +526,6 @@ protected:
virtual void setReorderChildDirtyRecursively(void);
virtual void setDirtyRecursively(bool bValue);
bool isInsideBounds() const;
//
// Data used when the sprite is rendered using a SpriteSheet
//
@ -573,7 +571,6 @@ protected:
bool _flippedY; /// Whether the sprite is flipped vertically or not
bool _insideBounds; /// whether or not the sprite was inside bounds the previous frame
private:
CC_DISALLOW_COPY_AND_ASSIGN(Sprite);
};

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "3.0";
return "3.0-rc2";
}
NS_CC_END

View File

@ -29,20 +29,6 @@
NS_CC_BEGIN
static GroupCommandManager* s_instance;
GroupCommandManager *GroupCommandManager::getInstance()
{
if(!s_instance)
{
s_instance = new GroupCommandManager();
if(!s_instance->init())
{
CC_SAFE_DELETE(s_instance);
}
}
return s_instance;
}
GroupCommandManager::GroupCommandManager()
{
@ -50,7 +36,7 @@ GroupCommandManager::GroupCommandManager()
GroupCommandManager::~GroupCommandManager()
{
CC_SAFE_RELEASE_NULL(s_instance);
}
bool GroupCommandManager::init()
@ -88,19 +74,20 @@ void GroupCommandManager::releaseGroupID(int groupID)
GroupCommand::GroupCommand()
{
_type = RenderCommand::Type::GROUP_COMMAND;
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
_renderQueueID = Director::getInstance()->getRenderer()->getGroupCommandManager()->getGroupID();
}
void GroupCommand::init(float globalOrder)
{
_globalOrder = globalOrder;
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
_renderQueueID = GroupCommandManager::getInstance()->getGroupID();
auto manager = Director::getInstance()->getRenderer()->getGroupCommandManager();
manager->releaseGroupID(_renderQueueID);
_renderQueueID = manager->getGroupID();
}
GroupCommand::~GroupCommand()
{
GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID);
Director::getInstance()->getRenderer()->getGroupCommandManager()->releaseGroupID(_renderQueueID);
}
NS_CC_END

View File

@ -37,17 +37,14 @@ NS_CC_BEGIN
class GroupCommandManager : public Ref
{
public:
static GroupCommandManager* getInstance();
~GroupCommandManager();
bool init();
int getGroupID();
void releaseGroupID(int groupID);
protected:
friend class Renderer;
GroupCommandManager();
~GroupCommandManager();
bool init();
std::unordered_map<int, bool> _groupMapping;
};

View File

@ -23,6 +23,9 @@
****************************************************************************/
#include "renderer/CCRenderer.h"
#include <algorithm>
#include "renderer/CCQuadCommand.h"
#include "renderer/CCBatchCommand.h"
#include "renderer/CCCustomCommand.h"
@ -34,15 +37,19 @@
#include "CCEventDispatcher.h"
#include "CCEventListenerCustom.h"
#include "CCEventType.h"
#include <algorithm>
#include "kazmath/kazmath.h"
NS_CC_BEGIN
// helper
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
{
return a->getGlobalOrder() < b->getGlobalOrder();
}
// queue
void RenderQueue::push_back(RenderCommand* command)
{
float z = command->getGlobalOrder();
@ -92,12 +99,14 @@ void RenderQueue::clear()
_queuePosZ.clear();
}
//
//
//
static const int DEFAULT_RENDER_QUEUE = 0;
//
// constructors, destructors, init
//
//
#define DEFAULT_RENDER_QUEUE 0
Renderer::Renderer()
:_lastMaterialID(0)
,_numQuads(0)
@ -107,6 +116,8 @@ Renderer::Renderer()
,_cacheTextureListener(nullptr)
#endif
{
_groupCommandManager = new GroupCommandManager();
_commandGroupStack.push(DEFAULT_RENDER_QUEUE);
RenderQueue defaultRenderQueue;
@ -117,6 +128,7 @@ Renderer::Renderer()
Renderer::~Renderer()
{
_renderGroups.clear();
_groupCommandManager->release();
glDeleteBuffers(2, _buffersVBO);
@ -493,4 +505,36 @@ void Renderer::flush()
_lastMaterialID = 0;
}
// helpers
bool Renderer::checkVisibility(const kmMat4 &transform, const Size &size)
{
// half size of the screen
Size screen_half = Director::getInstance()->getWinSize();
screen_half.width /= 2;
screen_half.height /= 2;
float hSizeX = size.width/2;
float hSizeY = size.height/2;
kmVec4 v4world, v4local;
kmVec4Fill(&v4local, hSizeX, hSizeY, 0, 1);
kmVec4MultiplyMat4(&v4world, &v4local, &transform);
// center of screen is (0,0)
v4world.x -= screen_half.width;
v4world.y -= screen_half.height;
// convert content size to world coordinates
float wshw = std::max(fabsf(hSizeX * transform.mat[0] + hSizeY * transform.mat[4]), fabsf(hSizeX * transform.mat[0] - hSizeY * transform.mat[4]));
float wshh = std::max(fabsf(hSizeX * transform.mat[1] + hSizeY * transform.mat[5]), fabsf(hSizeX * transform.mat[1] - hSizeY * transform.mat[5]));
// compare if it in the positive quadrant of the screen
float tmpx = (fabsf(v4world.x)-wshw);
float tmpy = (fabsf(v4world.y)-wshh);
bool ret = (tmpx < screen_half.width && tmpy < screen_half.height);
return ret;
}
NS_CC_END

View File

@ -64,6 +64,8 @@ struct RenderStackElement
ssize_t currentIndex;
};
class GroupCommandManager;
/* Class responsible for the rendering in.
Whenever possible prefer to use `QuadCommand` objects since the renderer will automatically batch them.
@ -110,6 +112,11 @@ public:
/* RenderCommands (except) QuadCommand should update this value */
void addDrawnVertices(ssize_t number) { _drawnVertices += number; };
inline GroupCommandManager* getGroupCommandManager() const { return _groupCommandManager; };
/** returns whether or not a rectangle is visible or not */
bool checkVisibility(const kmMat4& transform, const Size& size);
protected:
void setupIndices();
@ -151,6 +158,8 @@ protected:
//the flag for checking whether renderer is rendering
bool _isRendering;
GroupCommandManager* _groupCommandManager;
#if CC_ENABLE_CACHE_TEXTURE_DATA
EventListenerCustom* _cacheTextureListener;
#endif

View File

@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vec2.h"
#include "vec3.h"
#include "vec4.h"
#include "mat3.h"
#include "mat4.h"
#include "utility.h"

View File

@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vec4.h"
#include "mat4.h"
#include "neon_matrix_impl.h"
kmVec4* kmVec4Fill(kmVec4* pOut, kmScalar x, kmScalar y, kmScalar z, kmScalar w)
{
@ -137,10 +138,14 @@ kmVec4* kmVec4Div( kmVec4* pOut,const kmVec4* pV1, const kmVec4* pV2 ) {
/// Multiplies a 4D vector by a matrix, the result is stored in pOut, and pOut is returned.
kmVec4* kmVec4MultiplyMat4(kmVec4* pOut, const kmVec4* pV, const struct kmMat4* pM) {
#if defined(__ARM_NEON__) && !defined(__arm64__)
NEON_Matrix4Vector4Mul(&pM->mat[0], (const float*)pV, (float*)pOut);
#else
pOut->x = pV->x * pM->mat[0] + pV->y * pM->mat[4] + pV->z * pM->mat[8] + pV->w * pM->mat[12];
pOut->y = pV->x * pM->mat[1] + pV->y * pM->mat[5] + pV->z * pM->mat[9] + pV->w * pM->mat[13];
pOut->z = pV->x * pM->mat[2] + pV->y * pM->mat[6] + pV->z * pM->mat[10] + pV->w * pM->mat[14];
pOut->w = pV->x * pM->mat[3] + pV->y * pM->mat[7] + pV->z * pM->mat[11] + pV->w * pM->mat[15];
#endif
return pOut;
}

View File

@ -60,6 +60,14 @@ NDK_ROOT = 'NDK_ROOT'
ANDROID_SDK_ROOT = 'ANDROID_SDK_ROOT'
ANT_ROOT = 'ANT_ROOT'
def _check_python_version():
major_ver = sys.version_info[0]
if major_ver > 2:
print ("The python version is %d.%d. But python 2.x is required. (Version 2.7 is well tested)\n"
"Download it here: https://www.python.org/" % (major_ver, sys.version_info[1]))
return False
return True
class SetEnvVar(object):
@ -168,7 +176,7 @@ class SetEnvVar(object):
def _set_environment_variable(self, key, value):
print " -> Add %s environment variable..." % key
print(" -> Add %s environment variable..." % key)
ret = False
if self._isWindows():
ret = self._set_environment_variable_win32(key, value)
@ -176,9 +184,9 @@ class SetEnvVar(object):
ret = self._set_environment_variable_unix(key, value)
if ret:
print " ->Added %s=%s\n" % (key, value)
print(" ->Added %s=%s\n" % (key, value))
else:
print " ->Add failed\n"
print(" ->Add failed\n")
return ret
@ -199,7 +207,7 @@ class SetEnvVar(object):
return ret
def _find_environment_variable(self, var):
print " ->Find environment variable %s..." % var
print(" ->Find environment variable %s..." % var)
ret = None
try:
ret = os.environ[var]
@ -235,9 +243,9 @@ class SetEnvVar(object):
ret = None
if ret is None:
print " ->%s not found\n" % var
print(" ->%s not found\n" % var)
else:
print " ->%s is found : %s\n" % (var, ret)
print(" ->%s is found : %s\n" % (var, ret))
return ret
@ -320,7 +328,7 @@ class SetEnvVar(object):
ret = False
if not ret:
print ' ->Error: "%s" is not a valid path of %s. Ignoring it.' % (value, var_name)
print(' ->Error: "%s" is not a valid path of %s. Ignoring it.' % (value, var_name))
return ret
@ -384,9 +392,9 @@ class SetEnvVar(object):
_winreg.FlushKey(env)
_winreg.CloseKey(env)
print ' ->Remove directory \"%s\" from PATH!\n' % remove_dir
print(' ->Remove directory \"%s\" from PATH!\n' % remove_dir)
except Exception:
print ' ->Remove directory \"%s\" from PATH failed!\n' % remove_dir
print(' ->Remove directory \"%s\" from PATH failed!\n' % remove_dir)
def set_windows_path(self, add_dir):
ret = False
@ -425,13 +433,13 @@ class SetEnvVar(object):
_winreg.CloseKey(env)
if ret:
print " ->Add directory \"%s\" into PATH succeed!\n" % add_dir
print(" ->Add directory \"%s\" into PATH succeed!\n" % add_dir)
else:
print " ->Add directory \"%s\" into PATH failed!\n" % add_dir
print(" ->Add directory \"%s\" into PATH failed!\n" % add_dir)
def set_console_root(self):
print "->Check environment variable %s" % COCOS_CONSOLE_ROOT
print("->Check environment variable %s" % COCOS_CONSOLE_ROOT)
cocos_consle_root = os.path.join(self.current_absolute_path, 'tools', 'cocos2d-console', 'bin')
old_dir = self._find_environment_variable(COCOS_CONSOLE_ROOT)
if old_dir is None:
@ -441,6 +449,10 @@ class SetEnvVar(object):
self._set_environment_variable(COCOS_CONSOLE_ROOT, cocos_consle_root)
else:
if old_dir == cocos_consle_root:
# is same with before, nothing to do
return
# update the environment variable
if self._isWindows():
self.remove_dir_from_win_path(old_dir)
@ -459,7 +471,7 @@ class SetEnvVar(object):
if self._isLinux():
file_list = SetEnvVar.LINUX_CHECK_FILES
print " ->Update variable %s in files %s" % (var_name, str(file_list))
print(" ->Update variable %s in files %s" % (var_name, str(file_list)))
variable_updated = False
for file_name in file_list:
path = os.path.join(home, file_name)
@ -484,11 +496,11 @@ class SetEnvVar(object):
file_obj = open(path, 'w')
file_obj.writelines(lines)
file_obj.close()
print " ->File %s updated!" % path
print(" ->File %s updated!" % path)
# nothing updated, should add variable
if not variable_updated:
print "\n ->No files updated, add variable %s instead!" % var_name
print("\n ->No files updated, add variable %s instead!" % var_name)
ret = self._set_environment_variable(var_name, value)
else:
ret = True
@ -499,18 +511,18 @@ class SetEnvVar(object):
def _force_update_env(self, var_name, value):
ret = False
if self._isWindows():
print " ->Force update environment variable %s" % var_name
print(" ->Force update environment variable %s" % var_name)
ret = self._set_environment_variable_win32(var_name, value)
if not ret:
print " ->Failed!"
print(" ->Failed!")
else:
print " ->Succeed : %s=%s" % (var_name, value)
print(" ->Succeed : %s=%s" % (var_name, value))
else:
ret = self._force_update_unix_env(var_name, value)
return ret
def set_variable(self, var_name, value):
print "->Check environment variable %s" % var_name
print("->Check environment variable %s" % var_name)
find_value = self._find_environment_variable(var_name)
var_found = (find_value is not None)
action_none = 0
@ -558,7 +570,7 @@ class SetEnvVar(object):
def set_environment_variables(self, ndk_root, android_sdk_root, ant_root):
print '\nSetting up cocos2d-x...'
print('\nSetting up cocos2d-x...')
self.file_used_for_setup = self._get_filepath_for_setup()
@ -569,15 +581,17 @@ class SetEnvVar(object):
# tip the backup file
if (self.backup_file is not None) and (os.path.exists(self.backup_file)):
print '\nA backup file \"%s\" is created for \"%s\".' % (self.backup_file, self.file_used_for_setup)
print('\nA backup file \"%s\" is created for \"%s\".' % (self.backup_file, self.file_used_for_setup))
if self._isWindows():
print '\nPlease restart the terminal or restart computer to make added system variables take effect\n'
print('\nPlease restart the terminal or restart computer to make added system variables take effect\n')
else:
print '\nPlease execute command: "source %s" to make added system variables take effect\n' % self.file_used_for_setup
print('\nPlease execute command: "source %s" to make added system variables take effect\n' % self.file_used_for_setup)
if __name__ == '__main__':
if not _check_python_version():
exit()
parser = OptionParser()
parser.add_option('-n', '--ndkroot', dest='ndk_root', help='directory of ndk root')
parser.add_option('-a', '--androidsdkroot', dest='android_sdk_root', help='directory of android sdk root')
@ -587,3 +601,12 @@ if __name__ == '__main__':
# set environment variables
env = SetEnvVar()
env.set_environment_variables(opts.ndk_root, opts.android_sdk_root, opts.ant_root)
if env._isWindows():
import ctypes
HWND_BROADCAST = 0xFFFF
WM_SETTINGCHANGE = 0x1A
SMTO_ABORTIFHUNG = 0x0002
result = ctypes.c_long()
SendMessageTimeoutW = ctypes.windll.user32.SendMessageTimeoutW
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, u'Environment', SMTO_ABORTIFHUNG, 5000, ctypes.byref(result))

View File

@ -70,14 +70,20 @@
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
cocos2d::GLView *glview = cocos2d::Director::getInstance()->getOpenGLView();
cocos2d::GLView *glview = cocos2d::Director::getInstance()->getOpenGLView();
if (glview)
{
CCEAGLView *eaglview = (CCEAGLView*) glview->getEAGLView();
CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);
if (eaglview)
{
CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);
}
}
}
//fix not hide status on ios7

View File

@ -472,54 +472,47 @@ std::string NewDrawNodeTest::subtitle() const
NewCullingTest::NewCullingTest()
{
auto s = Director::getInstance()->getWinSize();
std::vector<std::string> images;
images.push_back("Images/grossini_dance_01.png");
images.push_back("Images/grossini_dance_02.png");
images.push_back("Images/grossini_dance_03.png");
images.push_back("Images/grossini_dance_04.png");
images.push_back("Images/grossini_dance_05.png");
images.push_back("Images/grossini_dance_06.png");
images.push_back("Images/grossini_dance_07.png");
images.push_back("Images/grossini_dance_08.png");
images.push_back("Images/grossini_dance_09.png");
images.push_back("Images/grossini_dance_10.png");
images.push_back("Images/grossini_dance_11.png");
images.push_back("Images/grossini_dance_12.png");
images.push_back("Images/grossini_dance_13.png");
images.push_back("Images/grossini_dance_14.png");
images.push_back("Images/grossini.png");
auto parent = Node::create();
parent->setPosition(s.width/2, s.height/2);
addChild(parent);
for(int index = 0; index < 500; ++index)
{
auto parent2 = Node::create();
parent2->setPosition(0,0);
parent->addChild(parent2);
parent2->setPosition(-50,0);
parent2->runAction(RepeatForever::create((JumpBy::create(10, Vector2(0,0), 400, 1))));
Sprite* sprite = Sprite::create(images[index % images.size()].c_str());
sprite->setPosition(Vector2(0,0));
//sprite->runAction(RepeatForever::create(RotateBy::create(3, 360)));
sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5))));
parent2->addChild(sprite);
}
for(int index = 0; index < 500; ++index)
{
auto parent2 = Node::create();
parent->addChild(parent2);
parent2->setPosition(50,0);
parent2->runAction(RepeatForever::create((JumpBy::create(7, Vector2(0,0), 400, 1))));
Sprite* sprite = Sprite::create(images[index % images.size()].c_str());
sprite->setPosition(Vector2(0,0));
//sprite->runAction(RepeatForever::create(RotateBy::create(3, 360)));
sprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(2, 2), ScaleBy::create(2,0.5))));
parent2->addChild(sprite);
}
Size size = Director::getInstance()->getWinSize();
auto sprite = Sprite::create("Images/btn-about-normal-vertical.png");
sprite->setRotation(5);
sprite->setPosition(Point(size.width/2,size.height/3));
sprite->setScale(2);
addChild(sprite);
auto sprite2 = Sprite::create("Images/btn-about-normal-vertical.png");
sprite2->setRotation(-85);
sprite2->setPosition(Point(size.width/2,size.height * 2/3));
sprite2->setScale(2);
addChild(sprite2);
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(NewCullingTest::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(NewCullingTest::onTouchMoved, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
}
bool NewCullingTest::onTouchBegan(Touch* touch, Event *event)
{
auto pos = touch->getLocation();
_lastPos = pos;
return true;
}
void NewCullingTest::onTouchMoved(Touch* touch, Event *event)
{
auto pos = touch->getLocation();
auto offset = pos - _lastPos;
auto layerPos = getPosition();
auto newPos = layerPos + offset;
setPosition(newPos);
_lastPos = pos;
}
NewCullingTest::~NewCullingTest()
@ -534,7 +527,7 @@ std::string NewCullingTest::title() const
std::string NewCullingTest::subtitle() const
{
return "Culling";
return "Drag the layer to test the result of culling";
}
VBOFullTest::VBOFullTest()

View File

@ -129,6 +129,9 @@ public:
protected:
NewCullingTest();
virtual ~NewCullingTest();
bool onTouchBegan(Touch* touch, Event *event);
void onTouchMoved(Touch* touch, Event *event);
Point _lastPos;
};
class VBOFullTest : public MultiSceneTest

View File

@ -1105,12 +1105,14 @@ void TMXIsoVertexZ::onEnter()
// TIP: 2d projection should be used
Director::getInstance()->setProjection(Director::Projection::_2D);
Director::getInstance()->setDepthTest(true);
}
void TMXIsoVertexZ::onExit()
{
// At exit use any other projection.
Director::getInstance()->setProjection(Director::Projection::DEFAULT);
Director::getInstance()->setDepthTest(false);
TileDemo::onExit();
}

@ -1 +1 @@
Subproject commit ae27f3bafbbdda9c32e5b89c79183183486e1299
Subproject commit b594698b5974304694e990cfd63887564d877c53