Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop

This commit is contained in:
yinkaile 2013-11-11 14:57:20 +08:00
commit 9f67ea786e
17 changed files with 72 additions and 70 deletions

View File

@ -646,6 +646,9 @@ Developers:
Luis Parravicini (luisparravicini)
Fixed typos in create_project.py.
xhcnb
Device::setAccelerometerEnabled needs to be invoked before adding ACC listener.
Retired Core Developers:
WenSheng Yang
Author of windows port, CCTextField,

View File

@ -1073,9 +1073,9 @@ void LabelBMFont::updateLabel()
int size = multiline_string.size();
unsigned short* str_new = new unsigned short[size + 1];
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
{
str_new[i] = multiline_string[i];
str_new[j] = multiline_string[j];
}
str_new[size] = '\0';

View File

@ -200,9 +200,9 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
int size = multiline_string.size();
unsigned short* strNew = new unsigned short[size + 1];
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
{
strNew[i] = multiline_string[i];
strNew[j] = multiline_string[j];
}
strNew[size] = 0;

View File

@ -166,7 +166,7 @@ void ProfilingEndTimingBlock(const char *timerName)
CCASSERT(timer, "CCProfilingTimer not found");
long duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count();
long duration = static_cast<long>(chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count());
timer->totalTime += duration;
timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f;

View File

@ -133,12 +133,12 @@ void Scene::addChildToPhysicsWorld(Node* child)
if (_physicsWorld)
{
std::function<void(Object*)> addToPhysicsWorldFunc = nullptr;
addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Object* child) -> void
addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Object* obj) -> void
{
if (dynamic_cast<Node*>(child) != nullptr)
if (dynamic_cast<Node*>(obj) != nullptr)
{
Node* node = dynamic_cast<Node*>(child);
Node* node = dynamic_cast<Node*>(obj);
if (node->getPhysicsBody())
{

View File

@ -601,31 +601,31 @@ void Scheduler::unscheduleAllWithMinPriority(int nMinPriority)
}
// Updates selectors
tListEntry *pEntry, *pTmp;
tListEntry *entry, *tmp;
if(nMinPriority < 0)
{
DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesNegList, entry, tmp)
{
if(pEntry->priority >= nMinPriority)
if(entry->priority >= nMinPriority)
{
unscheduleUpdateForTarget(pEntry->target);
unscheduleUpdateForTarget(entry->target);
}
}
}
if(nMinPriority <= 0)
{
DL_FOREACH_SAFE(_updates0List, pEntry, pTmp)
DL_FOREACH_SAFE(_updates0List, entry, tmp)
{
unscheduleUpdateForTarget(pEntry->target);
unscheduleUpdateForTarget(entry->target);
}
}
DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesPosList, entry, tmp)
{
if(pEntry->priority >= nMinPriority)
if(entry->priority >= nMinPriority)
{
unscheduleUpdateForTarget(pEntry->target);
unscheduleUpdateForTarget(entry->target);
}
}
@ -836,32 +836,32 @@ void Scheduler::update(float dt)
}
// Iterate over all the Updates' selectors
tListEntry *pEntry, *pTmp;
tListEntry *entry, *tmp;
// updates with priority < 0
DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesNegList, entry, tmp)
{
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
if ((! entry->paused) && (! entry->markedForDeletion))
{
pEntry->target->update(dt);
entry->target->update(dt);
}
}
// updates with priority == 0
DL_FOREACH_SAFE(_updates0List, pEntry, pTmp)
DL_FOREACH_SAFE(_updates0List, entry, tmp)
{
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
if ((! entry->paused) && (! entry->markedForDeletion))
{
pEntry->target->update(dt);
entry->target->update(dt);
}
}
// updates with priority > 0
DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesPosList, entry, tmp)
{
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
if ((! entry->paused) && (! entry->markedForDeletion))
{
pEntry->target->update(dt);
entry->target->update(dt);
}
}
@ -909,43 +909,43 @@ void Scheduler::update(float dt)
{
for (int i = _scriptHandlerEntries->count() - 1; i >= 0; i--)
{
SchedulerScriptHandlerEntry* pEntry = static_cast<SchedulerScriptHandlerEntry*>(_scriptHandlerEntries->getObjectAtIndex(i));
if (pEntry->isMarkedForDeletion())
SchedulerScriptHandlerEntry* eachEntry = static_cast<SchedulerScriptHandlerEntry*>(_scriptHandlerEntries->getObjectAtIndex(i));
if (eachEntry->isMarkedForDeletion())
{
_scriptHandlerEntries->removeObjectAtIndex(i);
}
else if (!pEntry->isPaused())
else if (!eachEntry->isPaused())
{
pEntry->getTimer()->update(dt);
eachEntry->getTimer()->update(dt);
}
}
}
// delete all updates that are marked for deletion
// updates with priority < 0
DL_FOREACH_SAFE(_updatesNegList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesNegList, entry, tmp)
{
if (pEntry->markedForDeletion)
if (entry->markedForDeletion)
{
this->removeUpdateFromHash(pEntry);
this->removeUpdateFromHash(entry);
}
}
// updates with priority == 0
DL_FOREACH_SAFE(_updates0List, pEntry, pTmp)
DL_FOREACH_SAFE(_updates0List, entry, tmp)
{
if (pEntry->markedForDeletion)
if (entry->markedForDeletion)
{
this->removeUpdateFromHash(pEntry);
this->removeUpdateFromHash(entry);
}
}
// updates with priority > 0
DL_FOREACH_SAFE(_updatesPosList, pEntry, pTmp)
DL_FOREACH_SAFE(_updatesPosList, entry, tmp)
{
if (pEntry->markedForDeletion)
if (entry->markedForDeletion)
{
this->removeUpdateFromHash(pEntry);
this->removeUpdateFromHash(entry);
}
}

View File

@ -598,8 +598,8 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite)
{
auto next = std::next(it);
std::for_each(next, _descendants.end(), [](Sprite *sprite) {
sprite->setAtlasIndex( sprite->getAtlasIndex() - 1 );
std::for_each(next, _descendants.end(), [](Sprite *spr) {
spr->setAtlasIndex( spr->getAtlasIndex() - 1 );
});
_descendants.erase(it);

View File

@ -138,7 +138,7 @@ static void atitc_decode_block(uint8_t **blockData,
{
for (int x = 0; x < 4; ++x)
{
initAlpha = (alpha & 0x0f) << 28;
initAlpha = (static_cast<int>(alpha) & 0x0f) << 28;
initAlpha += initAlpha >> 4;
decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3];
pixelsIndex >>= 2;

View File

@ -126,7 +126,7 @@ static void s3tc_decode_block(uint8_t **blockData,
{
for (int x = 0; x < 4; ++x)
{
initAlpha = (alpha & 0x0f) << 28;
initAlpha = (static_cast<int>(alpha) & 0x0f) << 28;
initAlpha += initAlpha >> 4;
decodeBlockData[x] = initAlpha + colors[pixelsIndex & 3];
pixelsIndex >>= 2;

View File

@ -482,12 +482,12 @@ int CCBReader::readInt(bool pSigned) {
if(pSigned) {
int s = current % 2;
if(s) {
num = (int)(current / 2);
num = static_cast<int>(current / 2);
} else {
num = (int)(-current / 2);
num = static_cast<int>(-current / 2);
}
} else {
num = current - 1;
num = static_cast<int>(current - 1);
}
this->alignBits();

View File

@ -579,8 +579,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
ArmatureData *armatureData = new ArmatureData();
armatureData->init();
const char *name = armatureXML->Attribute(A_NAME);
armatureData->name = name;
armatureData->name = armatureXML->Attribute(A_NAME);
tinyxml2::XMLElement *boneXML = armatureXML->FirstChildElement(BONE);
@ -887,21 +886,21 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
FrameData **frames = (FrameData **)movBoneData->frameList.data->arr;
for (int i = movBoneData->frameList.count() - 1; i >= 0; i--)
for (int j = movBoneData->frameList.count() - 1; j >= 0; j--)
{
if (i > 0)
if (j > 0)
{
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
float difSkewX = frames[j]->skewX - frames[j - 1]->skewX;
float difSkewY = frames[j]->skewY - frames[j - 1]->skewY;
if (difSkewX < -M_PI || difSkewX > M_PI)
{
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
frames[j - 1]->skewX = difSkewX < 0 ? frames[j - 1]->skewX - 2 * M_PI : frames[j - 1]->skewX + 2 * M_PI;
}
if (difSkewY < -M_PI || difSkewY > M_PI)
{
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
frames[j - 1]->skewY = difSkewY < 0 ? frames[j - 1]->skewY - 2 * M_PI : frames[j - 1]->skewY + 2 * M_PI;
}
}
}

View File

@ -227,9 +227,9 @@ namespace cocostudio {
const char *name = DICTOOL->getStringValue_json(subData, "name");
childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path");
for (long i = 0; i < childrenCount; ++i)
for (long j = 0; j < childrenCount; ++j)
{
const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i);
const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", j);
std::string plistpath;
plistpath += file_path;
plistpath.append(plist);

View File

@ -248,12 +248,12 @@ void _RotateTimeline_apply (const Timeline* timeline, Skeleton* skeleton, float
bone = skeleton->bones[self->boneIndex];
if (time >= self->frames[self->framesLength - 2]) { /* Time is after last frame. */
float amount = bone->data->rotation + self->frames[self->framesLength - 1] - bone->rotation;
while (amount > 180)
amount -= 360;
while (amount < -180)
amount += 360;
bone->rotation += amount * alpha;
float count = bone->data->rotation + self->frames[self->framesLength - 1] - bone->rotation;
while (count > 180)
count -= 360;
while (count < -180)
count += 360;
bone->rotation += count * alpha;
return;
}

View File

@ -118,7 +118,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
skeletonData->animationCount++;
for (i = 0; i < boneCount; ++i) {
int timelineCount;
timelineCount = 0;
Json* boneMap = Json_getItemAt(bones, i);
const char* boneName = boneMap->name;
@ -175,7 +175,7 @@ static Animation* _SkeletonJson_readAnimation (SkeletonJson* self, Json* root, S
}
for (i = 0; i < slotCount; ++i) {
int timelineCount;
timelineCount = 0;
Json* slotMap = Json_getItemAt(slots, i);
const char* slotName = slotMap->name;

View File

@ -33,7 +33,7 @@ class SortedObject : public Object, public SortableObject
{
public:
SortedObject() : objectID(0) {}
virtual void setObjectID(unsigned int objectID) { this->objectID = objectID; }
virtual void setObjectID(unsigned int id) { this->objectID = id; }
virtual unsigned int getObjectID() { return objectID; }
private:
unsigned int objectID;

View File

@ -214,7 +214,7 @@ void AssetsManager::downloadAndUncompress()
_isDownloading = false;
}
void AssetsManager::update()
void AssetsManager::update(float delta)
{
if (_isDownloading) return;
@ -651,8 +651,8 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version
class DelegateProtocolImpl : public AssetsManagerDelegateProtocol
{
public :
DelegateProtocolImpl(ErrorCallback errorCallback, ProgressCallback progressCallback, SuccessCallback successCallback)
: errorCallback(errorCallback), progressCallback(progressCallback), successCallback(successCallback)
DelegateProtocolImpl(ErrorCallback aErrorCallback, ProgressCallback aProgressCallback, SuccessCallback aSuccessCallback)
: errorCallback(aErrorCallback), progressCallback(aProgressCallback), successCallback(aSuccessCallback)
{}
virtual void onError(AssetsManager::ErrorCode errorCode) { errorCallback(int(errorCode)); }

View File

@ -98,7 +98,7 @@ public:
/* @brief Download new package if there is a new version, and uncompress downloaded zip file.
* Ofcourse it will set search path that stores downloaded files.
*/
virtual void update();
virtual void update(float delta) override;
/* @brief Gets url of package.
*/