mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into develop_nutty_Mergemasterbranchtodevelopbranch
Conflicts: cocos/gui/UIHelper.h
This commit is contained in:
commit
7a207431cd
1
AUTHORS
1
AUTHORS
|
@ -628,6 +628,7 @@ Developers:
|
|||
HoGarfield (garfield_ho)
|
||||
Fixed a bug that CCBReader can't play sequence automatically in JSB.
|
||||
Could not set next animation in CCBAnimationCompleted callback.
|
||||
Fixed missing to add JSAutoCompartment when invoking JS functions from C++.
|
||||
|
||||
lite3
|
||||
Fixed a bug that Node's anchor point was changed after being added to ScrollView.
|
||||
|
|
|
@ -10,21 +10,25 @@ cocos2d-x-3.0alpha1 @??? 2013
|
|||
[FIX] Could not set next animation in CCBAnimationCompleted callback.
|
||||
[FIX] The Node's anchor point was changed after being added to ScrollView.
|
||||
[FIX] Refactored and improved EventDispatcher.
|
||||
[NEW] Added Mouse Support For Desktop Platforms.
|
||||
[FIX] EventListeners can't be removed sometimes.
|
||||
[FIX] When parsing XML using TinyXML, the data size has to be specified.
|
||||
[FIX] Parameter type: const char* -> const string&
|
||||
[NEW] Arm64 support.
|
||||
[NEW] Added Mouse Support For Desktop Platforms.
|
||||
[Android]
|
||||
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
|
||||
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
|
||||
[FIX] Fixed application will crash when pause and resume.
|
||||
[FIX] Clear NoSuchMethodError Exception when JniHelper fails to find method id
|
||||
[NEW] Added xlargeScreens="true" to supports-screens
|
||||
[NEW] Added build/android-build.py to build all Android samples, and remove all build_native.sh/cmd
|
||||
[NEW] Added build_native.py to build template projects, and remove build_native.sh/cmd
|
||||
[NEW] Added Cocos2dxHelper.runOnGLThread(Runnable) again
|
||||
[Mac]
|
||||
[FIX] Removed unused CCLOG() from GL initialization
|
||||
[iOS]
|
||||
[FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox.
|
||||
[Linux]
|
||||
[NEW] Used CMake to build linux projects.
|
||||
[Desktop]
|
||||
[FIX] Trigger onKeyReleased only after the key has been released.
|
||||
[Javascript binding]
|
||||
|
|
|
@ -1,53 +1,13 @@
|
|||
# This file was copied from GamePlay
|
||||
# Copies files for the given game into the target res directory
|
||||
# GAME_NAME name of the game
|
||||
# REL_DIR to which directory these files are relative
|
||||
# SRC_FILES which files from the REL_DIR to copy (GLOB)
|
||||
macro(COPY_RES_FILES GAME_NAME GAME_RES_TARGET REL_DIR SRC_FILES)
|
||||
file( GLOB_RECURSE RES_FILES RELATIVE ${REL_DIR} ${SRC_FILES} )
|
||||
macro(pre_build TARGET_NAME)
|
||||
add_custom_target( ${TARGET_NAME}_PRE_BUILD ALL )
|
||||
|
||||
set(ALL_FILES)
|
||||
foreach(SRC_FILE ${RES_FILES})
|
||||
IF(NOT (SRC_FILE MATCHES "(^\\.\\.)"))
|
||||
add_custom_command(
|
||||
OUTPUT "${APP_BIN_DIR}/${SRC_FILE}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${REL_DIR}/${SRC_FILE}"
|
||||
"${APP_BIN_DIR}/Resources/${SRC_FILE}"
|
||||
COMMENT "Copy ${SRC_FILE}"
|
||||
)
|
||||
list(APPEND ALL_FILES "${APP_BIN_DIR}/${SRC_FILE}" )
|
||||
ENDIF(NOT (SRC_FILE MATCHES "(^\\.\\.)"))
|
||||
endforeach()
|
||||
# create target for copying these files
|
||||
add_custom_target( ${GAME_RES_TARGET} DEPENDS ${ALL_FILES} )
|
||||
endmacro()
|
||||
add_custom_command(
|
||||
TARGET ${TARGET_NAME}_PRE_BUILD
|
||||
${ARGN}
|
||||
PRE_BUILD
|
||||
COMMENT "${TARGET_NAME}_PRE_BUILD ..."
|
||||
)
|
||||
|
||||
# convenience to call above with current directory and everything in "res"
|
||||
macro(COPY_RES GAME_NAME)
|
||||
# a target for all addition asserts (will be done in default compile, but if you target the executable
|
||||
# it won't be done -- good for testing)
|
||||
add_custom_target( ${GAME_NAME}_ASSETS ALL )
|
||||
|
||||
# copy entire "res" directory and "game.config" if there is one
|
||||
set(CRG_PATTERN "*")
|
||||
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_CORE_RES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Resources
|
||||
"${CRG_PATTERN}"
|
||||
)
|
||||
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_CORE_RES )
|
||||
endmacro()
|
||||
|
||||
# Copies resources from an additional directory
|
||||
# GAME_NAME name of the game
|
||||
# REL_DIR from which directory
|
||||
# ARGN which patterns to copy (should include res/ in name if to be placed in the res/ output)
|
||||
macro(COPY_RES_EXTRA GAME_NAME EXTRA_RES REL_DIR)
|
||||
# convert src's to full paths (based on rel_dir)
|
||||
set(SRC_FILES)
|
||||
foreach(SRC_FILE ${ARGN} )
|
||||
list(APPEND SRC_FILES "${REL_DIR}/${SRC_FILE}")
|
||||
endforeach()
|
||||
COPY_RES_FILES( ${GAME_NAME} ${GAME_NAME}_${EXTRA_RES} ${REL_DIR} "${SRC_FILES}" )
|
||||
add_dependencies( ${GAME_NAME}_ASSETS ${GAME_NAME}_${EXTRA_RES} )
|
||||
add_custom_target( ${TARGET_NAME}_CORE_PRE_BUILD )
|
||||
add_dependencies( ${TARGET_NAME}_PRE_BUILD ${TARGET_NAME}_CORE_PRE_BUILD )
|
||||
endmacro()
|
||||
|
|
|
@ -1 +1 @@
|
|||
12034db6a7c20a09b3e866ab79a536bfc0208d3f
|
||||
30ca6c02884f9bc20405b3e657b444c0153bead7
|
|
@ -1 +1 @@
|
|||
f441e32e09388d5c434035e100e591cf9a6d29fd
|
||||
3ff18018375c71f683a484652678740cc6395eaf
|
|
@ -65,55 +65,55 @@ ActionManager::~ActionManager(void)
|
|||
|
||||
// private
|
||||
|
||||
void ActionManager::deleteHashElement(tHashElement *pElement)
|
||||
void ActionManager::deleteHashElement(tHashElement *element)
|
||||
{
|
||||
ccArrayFree(pElement->actions);
|
||||
HASH_DEL(_targets, pElement);
|
||||
pElement->target->release();
|
||||
free(pElement);
|
||||
ccArrayFree(element->actions);
|
||||
HASH_DEL(_targets, element);
|
||||
element->target->release();
|
||||
free(element);
|
||||
}
|
||||
|
||||
void ActionManager::actionAllocWithHashElement(tHashElement *pElement)
|
||||
void ActionManager::actionAllocWithHashElement(tHashElement *element)
|
||||
{
|
||||
// 4 actions per Node by default
|
||||
if (pElement->actions == NULL)
|
||||
if (element->actions == NULL)
|
||||
{
|
||||
pElement->actions = ccArrayNew(4);
|
||||
element->actions = ccArrayNew(4);
|
||||
}else
|
||||
if (pElement->actions->num == pElement->actions->max)
|
||||
if (element->actions->num == element->actions->max)
|
||||
{
|
||||
ccArrayDoubleCapacity(pElement->actions);
|
||||
ccArrayDoubleCapacity(element->actions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ActionManager::removeActionAtIndex(int index, tHashElement *pElement)
|
||||
void ActionManager::removeActionAtIndex(long index, tHashElement *element)
|
||||
{
|
||||
Action *pAction = (Action*)pElement->actions->arr[index];
|
||||
Action *action = (Action*)element->actions->arr[index];
|
||||
|
||||
if (pAction == pElement->currentAction && (! pElement->currentActionSalvaged))
|
||||
if (action == element->currentAction && (! element->currentActionSalvaged))
|
||||
{
|
||||
pElement->currentAction->retain();
|
||||
pElement->currentActionSalvaged = true;
|
||||
element->currentAction->retain();
|
||||
element->currentActionSalvaged = true;
|
||||
}
|
||||
|
||||
ccArrayRemoveObjectAtIndex(pElement->actions, index, true);
|
||||
ccArrayRemoveObjectAtIndex(element->actions, index, true);
|
||||
|
||||
// update actionIndex in case we are in tick. looping over the actions
|
||||
if (pElement->actionIndex >= index)
|
||||
if (element->actionIndex >= index)
|
||||
{
|
||||
pElement->actionIndex--;
|
||||
element->actionIndex--;
|
||||
}
|
||||
|
||||
if (pElement->actions->num == 0)
|
||||
if (element->actions->num == 0)
|
||||
{
|
||||
if (_currentTarget == pElement)
|
||||
if (_currentTarget == element)
|
||||
{
|
||||
_currentTargetSalvaged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteHashElement(pElement);
|
||||
deleteHashElement(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,21 +122,21 @@ void ActionManager::removeActionAtIndex(int index, tHashElement *pElement)
|
|||
|
||||
void ActionManager::pauseTarget(Object *target)
|
||||
{
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
if (pElement)
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
pElement->paused = true;
|
||||
element->paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionManager::resumeTarget(Object *target)
|
||||
{
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
if (pElement)
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
pElement->paused = false;
|
||||
element->paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,40 +168,40 @@ void ActionManager::resumeTargets(cocos2d::Set *targetsToResume)
|
|||
|
||||
// run
|
||||
|
||||
void ActionManager::addAction(Action *pAction, Node *target, bool paused)
|
||||
void ActionManager::addAction(Action *action, Node *target, bool paused)
|
||||
{
|
||||
CCASSERT(pAction != NULL, "");
|
||||
CCASSERT(action != NULL, "");
|
||||
CCASSERT(target != NULL, "");
|
||||
|
||||
tHashElement *pElement = NULL;
|
||||
tHashElement *element = NULL;
|
||||
// we should convert it to Object*, because we save it as Object*
|
||||
Object *tmp = target;
|
||||
HASH_FIND_INT(_targets, &tmp, pElement);
|
||||
if (! pElement)
|
||||
HASH_FIND_INT(_targets, &tmp, element);
|
||||
if (! element)
|
||||
{
|
||||
pElement = (tHashElement*)calloc(sizeof(*pElement), 1);
|
||||
pElement->paused = paused;
|
||||
element = (tHashElement*)calloc(sizeof(*element), 1);
|
||||
element->paused = paused;
|
||||
target->retain();
|
||||
pElement->target = target;
|
||||
HASH_ADD_INT(_targets, target, pElement);
|
||||
element->target = target;
|
||||
HASH_ADD_INT(_targets, target, element);
|
||||
}
|
||||
|
||||
actionAllocWithHashElement(pElement);
|
||||
actionAllocWithHashElement(element);
|
||||
|
||||
CCASSERT(! ccArrayContainsObject(pElement->actions, pAction), "");
|
||||
ccArrayAppendObject(pElement->actions, pAction);
|
||||
CCASSERT(! ccArrayContainsObject(element->actions, action), "");
|
||||
ccArrayAppendObject(element->actions, action);
|
||||
|
||||
pAction->startWithTarget(target);
|
||||
action->startWithTarget(target);
|
||||
}
|
||||
|
||||
// remove
|
||||
|
||||
void ActionManager::removeAllActions(void)
|
||||
{
|
||||
for (tHashElement *pElement = _targets; pElement != NULL; )
|
||||
for (tHashElement *element = _targets; element != NULL; )
|
||||
{
|
||||
Object *target = pElement->target;
|
||||
pElement = (tHashElement*)pElement->hh.next;
|
||||
Object *target = element->target;
|
||||
element = (tHashElement*)element->hh.next;
|
||||
removeAllActionsFromTarget(target);
|
||||
}
|
||||
}
|
||||
|
@ -214,24 +214,24 @@ void ActionManager::removeAllActionsFromTarget(Object *target)
|
|||
return;
|
||||
}
|
||||
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
if (pElement)
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
if (ccArrayContainsObject(pElement->actions, pElement->currentAction) && (! pElement->currentActionSalvaged))
|
||||
if (ccArrayContainsObject(element->actions, element->currentAction) && (! element->currentActionSalvaged))
|
||||
{
|
||||
pElement->currentAction->retain();
|
||||
pElement->currentActionSalvaged = true;
|
||||
element->currentAction->retain();
|
||||
element->currentActionSalvaged = true;
|
||||
}
|
||||
|
||||
ccArrayRemoveAllObjects(pElement->actions);
|
||||
if (_currentTarget == pElement)
|
||||
ccArrayRemoveAllObjects(element->actions);
|
||||
if (_currentTarget == element)
|
||||
{
|
||||
_currentTargetSalvaged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteHashElement(pElement);
|
||||
deleteHashElement(element);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -240,23 +240,23 @@ void ActionManager::removeAllActionsFromTarget(Object *target)
|
|||
}
|
||||
}
|
||||
|
||||
void ActionManager::removeAction(Action *pAction)
|
||||
void ActionManager::removeAction(Action *action)
|
||||
{
|
||||
// explicit null handling
|
||||
if (pAction == NULL)
|
||||
if (action == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tHashElement *pElement = NULL;
|
||||
Object *target = pAction->getOriginalTarget();
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
if (pElement)
|
||||
tHashElement *element = NULL;
|
||||
Object *target = action->getOriginalTarget();
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction);
|
||||
if (UINT_MAX != i)
|
||||
long i = ccArrayGetIndexOfObject(element->actions, action);
|
||||
if (i != CC_INVALID_INDEX)
|
||||
{
|
||||
removeActionAtIndex(i, pElement);
|
||||
removeActionAtIndex(i, element);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -270,19 +270,19 @@ void ActionManager::removeActionByTag(int tag, Object *target)
|
|||
CCASSERT(tag != Action::INVALID_TAG, "");
|
||||
CCASSERT(target != NULL, "");
|
||||
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
|
||||
if (pElement)
|
||||
if (element)
|
||||
{
|
||||
unsigned int limit = pElement->actions->num;
|
||||
for (unsigned int i = 0; i < limit; ++i)
|
||||
long limit = element->actions->num;
|
||||
for (long i = 0; i < limit; ++i)
|
||||
{
|
||||
Action *pAction = (Action*)pElement->actions->arr[i];
|
||||
Action *action = (Action*)element->actions->arr[i];
|
||||
|
||||
if (pAction->getTag() == (int)tag && pAction->getOriginalTarget() == target)
|
||||
if (action->getTag() == (int)tag && action->getOriginalTarget() == target)
|
||||
{
|
||||
removeActionAtIndex(i, pElement);
|
||||
removeActionAtIndex(i, element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -297,21 +297,21 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
|
|||
{
|
||||
CCASSERT(tag != Action::INVALID_TAG, "");
|
||||
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
|
||||
if (pElement)
|
||||
if (element)
|
||||
{
|
||||
if (pElement->actions != NULL)
|
||||
if (element->actions != NULL)
|
||||
{
|
||||
unsigned int limit = pElement->actions->num;
|
||||
for (unsigned int i = 0; i < limit; ++i)
|
||||
long limit = element->actions->num;
|
||||
for (long i = 0; i < limit; ++i)
|
||||
{
|
||||
Action *pAction = (Action*)pElement->actions->arr[i];
|
||||
Action *action = (Action*)element->actions->arr[i];
|
||||
|
||||
if (pAction->getTag() == (int)tag)
|
||||
if (action->getTag() == (int)tag)
|
||||
{
|
||||
return pAction;
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -329,11 +329,11 @@ Action* ActionManager::getActionByTag(int tag, const Object *target) const
|
|||
// and, it is not possible to get the address of a reference
|
||||
unsigned int ActionManager::getNumberOfRunningActionsInTarget(const Object *target) const
|
||||
{
|
||||
tHashElement *pElement = NULL;
|
||||
HASH_FIND_INT(_targets, &target, pElement);
|
||||
if (pElement)
|
||||
tHashElement *element = NULL;
|
||||
HASH_FIND_INT(_targets, &target, element);
|
||||
if (element)
|
||||
{
|
||||
return pElement->actions ? pElement->actions->num : 0;
|
||||
return element->actions ? element->actions->num : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -374,10 +374,10 @@ void ActionManager::update(float dt)
|
|||
{
|
||||
_currentTarget->currentAction->stop();
|
||||
|
||||
Action *pAction = _currentTarget->currentAction;
|
||||
Action *action = _currentTarget->currentAction;
|
||||
// Make currentAction nil to prevent removeAction from salvaging it.
|
||||
_currentTarget->currentAction = NULL;
|
||||
removeAction(pAction);
|
||||
removeAction(action);
|
||||
}
|
||||
|
||||
_currentTarget->currentAction = NULL;
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
protected:
|
||||
// declared in ActionManager.m
|
||||
|
||||
void removeActionAtIndex(int index, struct _hashElement *pElement);
|
||||
void removeActionAtIndex(long index, struct _hashElement *pElement);
|
||||
void deleteHashElement(struct _hashElement *pElement);
|
||||
void actionAllocWithHashElement(struct _hashElement *pElement);
|
||||
void update(float dt);
|
||||
|
|
|
@ -71,22 +71,20 @@ AnimationCache::~AnimationCache()
|
|||
CC_SAFE_RELEASE(_animations);
|
||||
}
|
||||
|
||||
void AnimationCache::addAnimation(Animation *animation, const char * name)
|
||||
void AnimationCache::addAnimation(Animation *animation, const std::string& name)
|
||||
{
|
||||
_animations->setObject(animation, name);
|
||||
}
|
||||
|
||||
void AnimationCache::removeAnimation(const char* name)
|
||||
void AnimationCache::removeAnimation(const std::string& name)
|
||||
{
|
||||
if (! name)
|
||||
{
|
||||
if (name.size()==0)
|
||||
return;
|
||||
}
|
||||
|
||||
_animations->removeObjectForKey(name);
|
||||
}
|
||||
|
||||
Animation* AnimationCache::getAnimation(const char* name)
|
||||
Animation* AnimationCache::getAnimation(const std::string& name)
|
||||
{
|
||||
return (Animation*)_animations->objectForKey(name);
|
||||
}
|
||||
|
@ -95,17 +93,17 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
{
|
||||
SpriteFrameCache *frameCache = SpriteFrameCache::getInstance();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(animations, element)
|
||||
{
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(element->getObject());
|
||||
Array* frameNames = static_cast<Array*>(animationDict->objectForKey("frames"));
|
||||
float delay = animationDict->valueForKey("delay")->floatValue();
|
||||
Animation* animation = NULL;
|
||||
|
||||
if ( frameNames == NULL )
|
||||
{
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.", element->getStrKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -115,11 +113,11 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(frameNames, pObj)
|
||||
{
|
||||
const char* frameName = static_cast<String*>(pObj)->getCString();
|
||||
const std::string& frameName = static_cast<String*>(pObj)->getCString();
|
||||
SpriteFrame* spriteFrame = frameCache->getSpriteFrameByName(frameName);
|
||||
|
||||
if ( ! spriteFrame ) {
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", pElement->getStrKey(), frameName);
|
||||
CCLOG("cocos2d: AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the SpriteFrameCache. This frame will not be added to the animation.", element->getStrKey(), frameName.c_str());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -131,15 +129,15 @@ void AnimationCache::parseVersion1(Dictionary* animations)
|
|||
}
|
||||
|
||||
if ( frames->count() == 0 ) {
|
||||
CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: None of the frames for animation '%s' were found in the SpriteFrameCache. Animation is not being added to the Animation Cache.", element->getStrKey());
|
||||
continue;
|
||||
} else if ( frames->count() != frameNames->count() ) {
|
||||
CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey());
|
||||
CCLOG("cocos2d: AnimationCache: An animation in your dictionary refers to a frame which is not in the SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", element->getStrKey());
|
||||
}
|
||||
|
||||
animation = Animation::create(frames, delay, 1);
|
||||
|
||||
AnimationCache::getInstance()->addAnimation(animation, pElement->getStrKey());
|
||||
AnimationCache::getInstance()->addAnimation(animation, element->getStrKey());
|
||||
frames->release();
|
||||
}
|
||||
}
|
||||
|
@ -148,11 +146,11 @@ void AnimationCache::parseVersion2(Dictionary* animations)
|
|||
{
|
||||
SpriteFrameCache *frameCache = SpriteFrameCache::getInstance();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(animations, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(animations, element)
|
||||
{
|
||||
const char* name = pElement->getStrKey();
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
const char* name = element->getStrKey();
|
||||
Dictionary* animationDict = static_cast<Dictionary*>(element->getObject());
|
||||
|
||||
const String* loops = animationDict->valueForKey("loops");
|
||||
bool restoreOriginalFrame = animationDict->valueForKey("restoreOriginalFrame")->boolValue();
|
||||
|
@ -241,9 +239,9 @@ void AnimationCache::addAnimationsWithDictionary(Dictionary* dictionary)
|
|||
}
|
||||
|
||||
/** Read an NSDictionary from a plist file and parse it automatically for animations */
|
||||
void AnimationCache::addAnimationsWithFile(const char* plist)
|
||||
void AnimationCache::addAnimationsWithFile(const std::string& plist)
|
||||
{
|
||||
CCASSERT( plist, "Invalid texture file name");
|
||||
CCASSERT( plist.size()>0, "Invalid texture file name");
|
||||
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
Dictionary* dict = Dictionary::createWithContentsOfFile(path.c_str());
|
||||
|
|
|
@ -76,29 +76,29 @@ public:
|
|||
|
||||
/** Adds a Animation with a name.
|
||||
*/
|
||||
void addAnimation(Animation *animation, const char * name);
|
||||
void addAnimation(Animation *animation, const std::string& name);
|
||||
|
||||
/** Deletes a Animation from the cache.
|
||||
|
||||
*/
|
||||
void removeAnimation(const char* name);
|
||||
void removeAnimation(const std::string& name);
|
||||
/** @deprecated. Use removeAnimation() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const char* name){ removeAnimation(name);}
|
||||
CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const std::string& name){ removeAnimation(name);}
|
||||
|
||||
/** Returns a Animation that was previously added.
|
||||
If the name is not found it will return nil.
|
||||
You should retain the returned copy if you are going to use it.
|
||||
*/
|
||||
Animation* getAnimation(const char* name);
|
||||
Animation* getAnimation(const std::string& name);
|
||||
/**
|
||||
@deprecated. Use getAnimation() instead
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const char* name){ return getAnimation(name); }
|
||||
CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const std::string& name){ return getAnimation(name); }
|
||||
|
||||
/** Adds an animation from an NSDictionary
|
||||
Make sure that the frames were previously loaded in the SpriteFrameCache.
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
* @js addAnimations
|
||||
* @lua addAnimations
|
||||
*/
|
||||
void addAnimationsWithFile(const char* plist);
|
||||
void addAnimationsWithFile(const std::string& plist);
|
||||
|
||||
private:
|
||||
void parseVersion1(Dictionary* animations);
|
||||
|
|
|
@ -831,7 +831,7 @@ void Director::calculateMPF()
|
|||
}
|
||||
|
||||
// returns the FPS image data pointer and len
|
||||
void Director::getFPSImageData(unsigned char** datapointer, unsigned int* length)
|
||||
void Director::getFPSImageData(unsigned char** datapointer, long* length)
|
||||
{
|
||||
// XXX fixed me if it should be used
|
||||
*datapointer = cc_fps_images_png;
|
||||
|
@ -855,7 +855,7 @@ void Director::createStatsLabel()
|
|||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
unsigned char *data = nullptr;
|
||||
unsigned int dataLength = 0;
|
||||
long dataLength = 0;
|
||||
getFPSImageData(&data, &dataLength);
|
||||
|
||||
Image* image = new Image();
|
||||
|
|
|
@ -376,7 +376,7 @@ protected:
|
|||
void showStats();
|
||||
void createStatsLabel();
|
||||
void calculateMPF();
|
||||
void getFPSImageData(unsigned char** datapointer, unsigned int* length);
|
||||
void getFPSImageData(unsigned char** datapointer, long* length);
|
||||
|
||||
/** calculates delta time since last time it was called */
|
||||
void calculateDeltaTime();
|
||||
|
|
|
@ -75,7 +75,7 @@ void Font::setCurrentGlyphCollection(GlyphCollection glyphs, const char *customG
|
|||
default:
|
||||
if (customGlyphs)
|
||||
{
|
||||
int lenght = strlen(customGlyphs);
|
||||
size_t lenght = strlen(customGlyphs);
|
||||
_customGlyphs = new char [lenght + 2];
|
||||
memcpy(_customGlyphs, customGlyphs, lenght);
|
||||
|
||||
|
|
|
@ -99,8 +99,8 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
|||
{
|
||||
FT_Face face;
|
||||
|
||||
int len = 0;
|
||||
_ttfData = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", (unsigned long *)(&len));
|
||||
long len = 0;
|
||||
_ttfData = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", &len);
|
||||
if (!_ttfData)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
|
||||
Label* Label::createWithTTF(const std::string& label, const std::string& fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
|
||||
{
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath.c_str(), fontSize, glyphs, customGlyphs);
|
||||
|
||||
if (!tmpAtlas)
|
||||
return nullptr;
|
||||
|
@ -48,10 +48,10 @@ Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fo
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment, int lineSize)
|
||||
Label* Label::createWithBMFont(const std::string& label, const std::string& bmfontFilePath, TextHAlignment alignment, int lineSize)
|
||||
{
|
||||
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath.c_str());
|
||||
|
||||
if (!tmpAtlas)
|
||||
return 0;
|
||||
|
@ -135,12 +135,12 @@ bool Label::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Label::setString(const char *stringToRender)
|
||||
void Label::setString(const std::string &stringToRender)
|
||||
{
|
||||
setText(stringToRender, _width, TextHAlignment::CENTER, false);
|
||||
}
|
||||
|
||||
bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment alignment, bool lineBreakWithoutSpaces)
|
||||
bool Label::setText(const std::string& stringToRender, float lineWidth, TextHAlignment alignment, bool lineBreakWithoutSpaces)
|
||||
{
|
||||
if (!_fontAtlas)
|
||||
return false;
|
||||
|
@ -158,8 +158,8 @@ bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment
|
|||
if (_commonLineHeight <= 0)
|
||||
return false;
|
||||
|
||||
int numLetter = 0;
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender);
|
||||
// int numLetter = 0;
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender.c_str());
|
||||
if(!utf16String)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -51,13 +51,13 @@ class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public RGBAPr
|
|||
public:
|
||||
|
||||
// static create
|
||||
static Label* createWithTTF(const char* label, const char* fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0);
|
||||
static Label* createWithTTF(const std::string& label, const std::string& fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::CENTER, GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0);
|
||||
|
||||
static Label* createWithBMFont(const char* label, const char* bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0);
|
||||
static Label* createWithBMFont(const std::string& label, const std::string& bmfontFilePath, TextHAlignment alignment = TextHAlignment::CENTER, int lineSize = 0);
|
||||
|
||||
bool setText(const char *stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false);
|
||||
bool setText(const std::string& stringToRender, float lineWidth, TextHAlignment alignment = TextHAlignment::LEFT, bool lineBreakWithoutSpaces = false);
|
||||
|
||||
virtual void setString(const char *stringToRender) override;
|
||||
virtual void setString(const std::string &stringToRender) override;
|
||||
virtual void setAlignment(TextHAlignment alignment);
|
||||
virtual void setWidth(float width);
|
||||
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
||||
|
|
|
@ -113,7 +113,7 @@ bool LabelAtlas::initWithString(const char *theString, const char *fntFile)
|
|||
//CCLabelAtlas - Atlas generation
|
||||
void LabelAtlas::updateAtlasValues()
|
||||
{
|
||||
int n = _string.length();
|
||||
size_t n = _string.length();
|
||||
|
||||
const unsigned char *s = (unsigned char*)_string.c_str();
|
||||
|
||||
|
@ -186,9 +186,9 @@ void LabelAtlas::updateAtlasValues()
|
|||
}
|
||||
|
||||
//CCLabelAtlas - LabelProtocol
|
||||
void LabelAtlas::setString(const char *label)
|
||||
void LabelAtlas::setString(const std::string &label)
|
||||
{
|
||||
int len = strlen(label);
|
||||
size_t len = label.size();
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
|
||||
// super methods
|
||||
virtual void updateAtlasValues();
|
||||
virtual void setString(const char *label);
|
||||
virtual void setString(const std::string &label);
|
||||
virtual const char* getString(void) const;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
|
|
|
@ -62,7 +62,7 @@ static unsigned short* copyUTF16StringN(unsigned short* str)
|
|||
//
|
||||
static Dictionary* s_pConfigurations = NULL;
|
||||
|
||||
CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
||||
CCBMFontConfiguration* FNTConfigLoadFile(const std::string& fntFile)
|
||||
{
|
||||
CCBMFontConfiguration* pRet = NULL;
|
||||
|
||||
|
@ -75,7 +75,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
|||
pRet = static_cast<CCBMFontConfiguration*>( s_pConfigurations->objectForKey(fntFile) );
|
||||
if( pRet == NULL )
|
||||
{
|
||||
pRet = CCBMFontConfiguration::create(fntFile);
|
||||
pRet = CCBMFontConfiguration::create(fntFile.c_str());
|
||||
if (pRet)
|
||||
{
|
||||
s_pConfigurations->setObject(pRet, fntFile);
|
||||
|
@ -180,7 +180,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary()
|
|||
}
|
||||
}
|
||||
|
||||
std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *controlFile)
|
||||
std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const std::string& controlFile)
|
||||
{
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(controlFile);
|
||||
String *contents = String::createWithContentsOfFile(fullpath.c_str());
|
||||
|
@ -191,7 +191,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
|
|||
|
||||
if (!contents)
|
||||
{
|
||||
CCLOG("cocos2d: Error parsing FNTfile %s", controlFile);
|
||||
CCLOG("cocos2d: Error parsing FNTfile %s", controlFile.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
|
|||
std::string strLeft = contents->getCString();
|
||||
while (strLeft.length() > 0)
|
||||
{
|
||||
int pos = strLeft.find('\n');
|
||||
size_t pos = strLeft.find('\n');
|
||||
|
||||
if (pos != (int)std::string::npos)
|
||||
{
|
||||
|
@ -259,7 +259,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const char *contr
|
|||
return validCharsString;
|
||||
}
|
||||
|
||||
void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fntFile)
|
||||
void CCBMFontConfiguration::parseImageFileName(std::string line, const std::string& fntFile)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -267,8 +267,8 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// page ID. Sanity check
|
||||
int index = line.find('=')+1;
|
||||
int index2 = line.find(' ', index);
|
||||
long index = line.find('=')+1;
|
||||
long index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
CCASSERT(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
|
||||
// file
|
||||
|
@ -288,8 +288,8 @@ void CCBMFontConfiguration::parseInfoArguments(std::string line)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// padding
|
||||
int index = line.find("padding=");
|
||||
int index2 = line.find(' ', index);
|
||||
long index = line.find("padding=");
|
||||
long index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "padding=%d,%d,%d,%d", &_padding.top, &_padding.right, &_padding.bottom, &_padding.left);
|
||||
CCLOG("cocos2d: padding: %d,%d,%d,%d", _padding.left, _padding.top, _padding.right, _padding.bottom);
|
||||
|
@ -303,8 +303,8 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Height
|
||||
int index = line.find("lineHeight=");
|
||||
int index2 = line.find(' ', index);
|
||||
long index = line.find("lineHeight=");
|
||||
long index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "lineHeight=%d", &_commonHeight);
|
||||
// scaleW. sanity check
|
||||
|
@ -334,8 +334,8 @@ void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontD
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Character ID
|
||||
int index = line.find("id=");
|
||||
int index2 = line.find(' ', index);
|
||||
long index = line.find("id=");
|
||||
long index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "id=%u", &characterDefinition->charID);
|
||||
|
||||
|
@ -385,8 +385,8 @@ void CCBMFontConfiguration::parseKerningEntry(std::string line)
|
|||
|
||||
// first
|
||||
int first;
|
||||
int index = line.find("first=");
|
||||
int index2 = line.find(' ', index);
|
||||
long index = line.find("first=");
|
||||
long index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "first=%d", &first);
|
||||
|
||||
|
@ -431,23 +431,23 @@ LabelBMFont * LabelBMFont::create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextHAlignment alignment)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile, float width)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, width, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
|
||||
LabelBMFont * LabelBMFont::create(const std::string& str, const std::string& fntFile)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
//LabelBMFont - Creation & Init
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
LabelBMFont *LabelBMFont::create(const std::string& str, const std::string& fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
LabelBMFont *pRet = new LabelBMFont();
|
||||
if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset))
|
||||
|
@ -461,22 +461,21 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid
|
|||
|
||||
bool LabelBMFont::init()
|
||||
{
|
||||
return initWithString(NULL, NULL, kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
return initWithString("", "", kLabelAutomaticWidth, TextHAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
bool LabelBMFont::initWithString(const std::string& theString, const std::string& fntFile, float width/* = kLabelAutomaticWidth*/, TextHAlignment alignment/* = TextHAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
{
|
||||
CCASSERT(!_configuration, "re-init is no longer supported");
|
||||
CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
|
||||
|
||||
|
||||
Texture2D *texture = NULL;
|
||||
|
||||
if (fntFile)
|
||||
if (fntFile.size() > 0 )
|
||||
{
|
||||
CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile);
|
||||
if (!newConf)
|
||||
{
|
||||
CCLOG("cocos2d: WARNING. LabelBMFont: Impossible to create font. Please check file: '%s'", fntFile);
|
||||
CCLOG("cocos2d: WARNING. LabelBMFont: Impossible to create font. Please check file: '%s'", fntFile.c_str());
|
||||
release();
|
||||
return false;
|
||||
}
|
||||
|
@ -495,12 +494,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
|
|||
texture->autorelease();
|
||||
}
|
||||
|
||||
if (theString == NULL)
|
||||
{
|
||||
theString = "";
|
||||
}
|
||||
|
||||
if (SpriteBatchNode::initWithTexture(texture, strlen(theString)))
|
||||
if (SpriteBatchNode::initWithTexture(texture, theString.size()))
|
||||
{
|
||||
_width = width;
|
||||
_alignment = alignment;
|
||||
|
@ -724,20 +718,17 @@ void LabelBMFont::createFontChars()
|
|||
}
|
||||
|
||||
//LabelBMFont - LabelProtocol protocol
|
||||
void LabelBMFont::setString(const char *newString)
|
||||
void LabelBMFont::setString(const std::string &newString)
|
||||
{
|
||||
this->setString(newString, true);
|
||||
}
|
||||
|
||||
void LabelBMFont::setString(const char *newString, bool needUpdateLabel)
|
||||
void LabelBMFont::setString(const std::string &newString, bool needUpdateLabel)
|
||||
{
|
||||
if (newString == NULL) {
|
||||
newString = "";
|
||||
}
|
||||
if (needUpdateLabel) {
|
||||
_initialStringUTF8 = newString;
|
||||
}
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(newString);
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(newString.c_str());
|
||||
setString(utf16String, needUpdateLabel);
|
||||
CC_SAFE_DELETE_ARRAY(utf16String);
|
||||
}
|
||||
|
|
|
@ -145,16 +145,16 @@ public:
|
|||
/** initializes a BitmapFontConfiguration with a FNT file */
|
||||
bool initWithFNTfile(const char *FNTfile);
|
||||
|
||||
inline const char* getAtlasName(){ return _atlasName.c_str(); }
|
||||
inline void setAtlasName(const char* atlasName) { _atlasName = atlasName; }
|
||||
inline const std::string& getAtlasName(){ return _atlasName; }
|
||||
inline void setAtlasName(const std::string& atlasName) { _atlasName = atlasName; }
|
||||
|
||||
std::set<unsigned int>* getCharacterSet() const;
|
||||
private:
|
||||
std::set<unsigned int>* parseConfigFile(const char *controlFile);
|
||||
std::set<unsigned int>* parseConfigFile(const std::string& controlFile);
|
||||
void parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition);
|
||||
void parseInfoArguments(std::string line);
|
||||
void parseCommonArguments(std::string line);
|
||||
void parseImageFileName(std::string line, const char *fntFile);
|
||||
void parseImageFileName(std::string line, const std::string& fntFile);
|
||||
void parseKerningEntry(std::string line);
|
||||
void purgeKerningDictionary();
|
||||
void purgeFontDefDictionary();
|
||||
|
@ -209,13 +209,13 @@ public:
|
|||
static void purgeCachedData();
|
||||
|
||||
/** creates a bitmap font atlas with an initial string and the FNT file */
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextHAlignment alignment, Point imageOffset);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment, Point imageOffset);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextHAlignment alignment);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width, TextHAlignment alignment);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile, float width);
|
||||
|
||||
static LabelBMFont * create(const char *str, const char *fntFile);
|
||||
static LabelBMFont * create(const std::string& str, const std::string& fntFile);
|
||||
|
||||
/** Creates an label.
|
||||
*/
|
||||
|
@ -223,15 +223,15 @@ public:
|
|||
|
||||
bool init();
|
||||
/** init a bitmap font atlas with an initial string and the FNT file */
|
||||
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextHAlignment alignment = TextHAlignment::LEFT, Point imageOffset = Point::ZERO);
|
||||
bool initWithString(const std::string& str, const std::string& fntFile, float width = kLabelAutomaticWidth, TextHAlignment alignment = TextHAlignment::LEFT, Point imageOffset = Point::ZERO);
|
||||
|
||||
/** updates the font chars based on the string to render */
|
||||
void createFontChars();
|
||||
// super method
|
||||
virtual void setString(const char *newString);
|
||||
virtual void setString(const char *newString, bool needUpdateLabel);
|
||||
virtual void setString(const std::string& newString);
|
||||
virtual void setString(const std::string& newString, bool needUpdateLabel);
|
||||
|
||||
virtual const char* getString(void) const;
|
||||
virtual const char* getString() const;
|
||||
virtual void setCString(const char *label);
|
||||
virtual void setAnchorPoint(const Point& var);
|
||||
virtual void updateLabel();
|
||||
|
@ -264,7 +264,7 @@ public:
|
|||
virtual void draw();
|
||||
#endif // CC_LABELBMFONT_DEBUG_DRAW
|
||||
private:
|
||||
char * atlasNameFromFntFile(const char *fntFile);
|
||||
char * atlasNameFromFntFile(const std::string& fntFile);
|
||||
int kerningAmountForFirst(unsigned short first, unsigned short second);
|
||||
float getLetterPosXLeft( Sprite* characterSprite );
|
||||
float getLetterPosXRight( Sprite* characterSprite );
|
||||
|
@ -309,7 +309,7 @@ protected:
|
|||
|
||||
/** Free function that parses a FNT file a place it on the cache
|
||||
*/
|
||||
CC_DLL CCBMFontConfiguration * FNTConfigLoadFile( const char *file );
|
||||
CC_DLL CCBMFontConfiguration * FNTConfigLoadFile(const std::string &file);
|
||||
/** Purges the FNT config cache
|
||||
*/
|
||||
CC_DLL void FNTConfigRemoveCache( void );
|
||||
|
|
|
@ -171,10 +171,8 @@ bool LabelTTF::initWithStringAndTextDefinition(const char *string, FontDefinitio
|
|||
}
|
||||
|
||||
|
||||
void LabelTTF::setString(const char *string)
|
||||
void LabelTTF::setString(const std::string &string)
|
||||
{
|
||||
CCASSERT(string != NULL, "Invalid string");
|
||||
|
||||
if (_string.compare(string))
|
||||
{
|
||||
_string = string;
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
/** changes the string to render
|
||||
* @warning Changing the string is as expensive as creating a new LabelTTF. To obtain better performance use LabelAtlas
|
||||
*/
|
||||
virtual void setString(const char *label);
|
||||
virtual void setString(const std::string &label);
|
||||
virtual const char* getString(void) const;
|
||||
|
||||
TextHAlignment getHorizontalAlignment() const;
|
||||
|
|
|
@ -402,7 +402,7 @@ void Node::setPositionY(float y)
|
|||
setPosition(Point(_position.x, y));
|
||||
}
|
||||
|
||||
unsigned int Node::getChildrenCount() const
|
||||
long Node::getChildrenCount() const
|
||||
{
|
||||
return _children ? _children->count() : 0;
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
|
|||
return;
|
||||
}
|
||||
|
||||
int index = _children->getIndexOfObject(child);
|
||||
long index = _children->getIndexOfObject(child);
|
||||
if( index != CC_INVALID_INDEX )
|
||||
this->detachChild( child, index, cleanup );
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ void Node::removeAllChildrenWithCleanup(bool cleanup)
|
|||
|
||||
}
|
||||
|
||||
void Node::detachChild(Node *child, int childIndex, bool doCleanup)
|
||||
void Node::detachChild(Node *child, long childIndex, bool doCleanup)
|
||||
{
|
||||
// IMPORTANT:
|
||||
// -1st do onExit
|
||||
|
|
|
@ -644,7 +644,7 @@ public:
|
|||
*
|
||||
* @return The amount of children.
|
||||
*/
|
||||
unsigned int getChildrenCount() const;
|
||||
long getChildrenCount() const;
|
||||
|
||||
/**
|
||||
* Sets the parent node
|
||||
|
@ -1421,7 +1421,7 @@ protected:
|
|||
void insertChild(Node* child, int z);
|
||||
|
||||
/// Removes a child, call child->onExit(), do cleanup, remove it from children array.
|
||||
void detachChild(Node *child, int index, bool doCleanup);
|
||||
void detachChild(Node *child, long index, bool doCleanup);
|
||||
|
||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
||||
|
|
|
@ -136,7 +136,7 @@ ParticleSystem::ParticleSystem()
|
|||
}
|
||||
// implementation ParticleSystem
|
||||
|
||||
ParticleSystem * ParticleSystem::create(const char *plistFile)
|
||||
ParticleSystem * ParticleSystem::create(const std::string& plistFile)
|
||||
{
|
||||
ParticleSystem *pRet = new ParticleSystem();
|
||||
if (pRet && pRet->initWithFile(plistFile))
|
||||
|
@ -165,7 +165,7 @@ bool ParticleSystem::init()
|
|||
return initWithTotalParticles(150);
|
||||
}
|
||||
|
||||
bool ParticleSystem::initWithFile(const char *plistFile)
|
||||
bool ParticleSystem::initWithFile(const std::string& plistFile)
|
||||
{
|
||||
bool bRet = false;
|
||||
_plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile);
|
||||
|
@ -195,7 +195,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary)
|
|||
return initWithDictionary(dictionary, "");
|
||||
}
|
||||
|
||||
bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirname)
|
||||
bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const std::string& dirname)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned char *buffer = NULL;
|
||||
|
@ -353,17 +353,17 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
{
|
||||
string textureDir = textureName.substr(0, rPos + 1);
|
||||
|
||||
if (dirname != NULL && textureDir != dirname)
|
||||
if (dirname.size()>0 && textureDir != dirname)
|
||||
{
|
||||
textureName = textureName.substr(rPos+1);
|
||||
textureName = string(dirname) + textureName;
|
||||
textureName = dirname + textureName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dirname != NULL)
|
||||
if (dirname.size()>0)
|
||||
{
|
||||
textureName = string(dirname) + textureName;
|
||||
textureName = dirname + textureName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
const char *textureData = dictionary->valueForKey("textureImageData")->getCString();
|
||||
CCASSERT(textureData, "");
|
||||
|
||||
int dataLen = strlen(textureData);
|
||||
long dataLen = strlen(textureData);
|
||||
if(dataLen != 0)
|
||||
{
|
||||
// if it fails, try to get it from the base64-gzipped data
|
||||
|
|
|
@ -167,7 +167,7 @@ public:
|
|||
http://particledesigner.71squared.com/
|
||||
@since v2.0
|
||||
*/
|
||||
static ParticleSystem * create(const char *plistFile);
|
||||
static ParticleSystem * create(const std::string& plistFile);
|
||||
|
||||
//! create a system with a fixed number of particles
|
||||
static ParticleSystem* createWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
http://particledesigner.71squared.com/
|
||||
@since v0.99.3
|
||||
*/
|
||||
bool initWithFile(const char *plistFile);
|
||||
bool initWithFile(const std::string& plistFile);
|
||||
|
||||
/** initializes a QuadParticleSystem from a Dictionary.
|
||||
@since v0.99.3
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
/** initializes a particle system from a NSDictionary and the path from where to load the png
|
||||
@since v2.1
|
||||
*/
|
||||
bool initWithDictionary(Dictionary *dictionary, const char *dirname);
|
||||
bool initWithDictionary(Dictionary *dictionary, const std::string& dirname);
|
||||
|
||||
//! Initializes a system with a fixed number of particles
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
|
|
|
@ -166,7 +166,7 @@ void ProfilingEndTimingBlock(const char *timerName)
|
|||
CCASSERT(timer, "CCProfilingTimer not found");
|
||||
|
||||
|
||||
int duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count();
|
||||
long duration = chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count();
|
||||
|
||||
timer->totalTime += duration;
|
||||
timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f;
|
||||
|
|
|
@ -134,12 +134,12 @@ public:
|
|||
|
||||
std::string _nameStr;
|
||||
std::chrono::high_resolution_clock::time_point _startTime;
|
||||
int _averageTime1;
|
||||
int _averageTime2;
|
||||
int minTime;
|
||||
int maxTime;
|
||||
long long totalTime;
|
||||
int numberOfCalls;
|
||||
long _averageTime1;
|
||||
long _averageTime2;
|
||||
long minTime;
|
||||
long maxTime;
|
||||
long totalTime;
|
||||
long numberOfCalls;
|
||||
};
|
||||
|
||||
extern void ProfilingBeginTimingBlock(const char *timerName);
|
||||
|
|
|
@ -229,7 +229,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setString(const char *label) = 0;
|
||||
virtual void setString(const std::string &label) = 0;
|
||||
|
||||
/**
|
||||
* Returns the string that is currently being used in this label
|
||||
|
|
|
@ -198,8 +198,8 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
|
||||
|
||||
// textures must be power of two squared
|
||||
unsigned int powW = 0;
|
||||
unsigned int powH = 0;
|
||||
long powW = 0;
|
||||
long powH = 0;
|
||||
|
||||
if (Configuration::getInstance()->supportsNPOT())
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
powH = ccNextPOT(h);
|
||||
}
|
||||
|
||||
int dataLen = (int)(powW * powH * 4);
|
||||
long dataLen = (long)(powW * powH * 4);
|
||||
data = malloc(dataLen);
|
||||
CC_BREAK_IF(! data);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ Sprite* Sprite::createWithTexture(Texture2D *texture, const Rect& rect)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::create(const char *filename)
|
||||
Sprite* Sprite::create(const std::string& filename)
|
||||
{
|
||||
Sprite *sprite = new Sprite();
|
||||
if (sprite && sprite->initWithFile(filename))
|
||||
|
@ -94,7 +94,7 @@ Sprite* Sprite::create(const char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::create(const char *filename, const Rect& rect)
|
||||
Sprite* Sprite::create(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
Sprite *sprite = new Sprite();
|
||||
if (sprite && sprite->initWithFile(filename, rect))
|
||||
|
@ -118,13 +118,13 @@ Sprite* Sprite::createWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Sprite* Sprite::createWithSpriteFrameName(const char *spriteFrameName)
|
||||
Sprite* Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
|
||||
|
||||
#if COCOS2D_DEBUG > 0
|
||||
char msg[256] = {0};
|
||||
sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName);
|
||||
sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName.c_str());
|
||||
CCASSERT(frame != NULL, msg);
|
||||
#endif
|
||||
|
||||
|
@ -215,9 +215,9 @@ bool Sprite::initWithTexture(Texture2D *texture)
|
|||
return initWithTexture(texture, rect);
|
||||
}
|
||||
|
||||
bool Sprite::initWithFile(const char *filename)
|
||||
bool Sprite::initWithFile(const std::string& filename)
|
||||
{
|
||||
CCASSERT(filename != NULL, "Invalid filename for sprite");
|
||||
CCASSERT(filename.size()>0, "Invalid filename for sprite");
|
||||
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(filename);
|
||||
if (texture)
|
||||
|
@ -233,9 +233,9 @@ bool Sprite::initWithFile(const char *filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Sprite::initWithFile(const char *filename, const Rect& rect)
|
||||
bool Sprite::initWithFile(const std::string &filename, const Rect& rect)
|
||||
{
|
||||
CCASSERT(filename != NULL, "");
|
||||
CCASSERT(filename.size()>0, "Invalid filename");
|
||||
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(filename);
|
||||
if (texture)
|
||||
|
@ -259,9 +259,9 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Sprite::initWithSpriteFrameName(const char *spriteFrameName)
|
||||
bool Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||
{
|
||||
CCASSERT(spriteFrameName != NULL, "");
|
||||
CCASSERT(spriteFrameName.size() > 0, "Invalid spriteFrameName");
|
||||
|
||||
SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);
|
||||
return initWithSpriteFrame(frame);
|
||||
|
@ -992,9 +992,9 @@ void Sprite::setDisplayFrame(SpriteFrame *pNewFrame)
|
|||
setTextureRect(pNewFrame->getRect(), _rectRotated, pNewFrame->getOriginalSize());
|
||||
}
|
||||
|
||||
void Sprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
|
||||
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex)
|
||||
{
|
||||
CCASSERT(animationName, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
||||
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
||||
|
||||
Animation *a = AnimationCache::getInstance()->getAnimation(animationName);
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
* @param filename The string which indicates a path to image file, e.g., "scene1/monster.png".
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* create(const char *filename);
|
||||
static Sprite* create(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Creates a sprite with an image filename and a rect.
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
* @param rect Only the contents inside rect of filename's texture will be applied for this sprite.
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* create(const char *filename, const Rect& rect);
|
||||
static Sprite* create(const std::string& filename, const Rect& rect);
|
||||
|
||||
/**
|
||||
* Creates a sprite with an exsiting texture contained in a Texture2D object
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
* @param spriteFrameName A null terminated string which indicates the sprite frame name.
|
||||
* @return A valid sprite object that is marked as autoreleased.
|
||||
*/
|
||||
static Sprite* createWithSpriteFrameName(const char *spriteFrameName);
|
||||
static Sprite* createWithSpriteFrameName(const std::string& spriteFrameName);
|
||||
|
||||
/// @} end of creators group
|
||||
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
* @param spriteFrameName A key string that can fected a volid SpriteFrame from SpriteFrameCache
|
||||
* @return true if the sprite is initialized properly, false otherwise.
|
||||
*/
|
||||
virtual bool initWithSpriteFrameName(const char *spriteFrameName);
|
||||
virtual bool initWithSpriteFrameName(const std::string& spriteFrameName);
|
||||
|
||||
/**
|
||||
* Initializes a sprite with an image filename.
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
virtual bool initWithFile(const char *filename);
|
||||
virtual bool initWithFile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Initializes a sprite with an image filename, and a rect.
|
||||
|
@ -262,7 +262,7 @@ public:
|
|||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
virtual bool initWithFile(const char *filename, const Rect& rect);
|
||||
virtual bool initWithFile(const std::string& filename, const Rect& rect);
|
||||
|
||||
/// @} end of initializers
|
||||
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
* Changes the display frame with animation name and index.
|
||||
* The animation name will be get from the AnimationCache
|
||||
*/
|
||||
virtual void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex);
|
||||
virtual void setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex);
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity
|
|||
* creation with File Image
|
||||
*/
|
||||
|
||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = DEFAULT_CAPACITY*/)
|
||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, long capacity/* = DEFAULT_CAPACITY*/)
|
||||
{
|
||||
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
||||
batchNode->initWithFile(fileImage, capacity);
|
||||
|
@ -76,7 +76,7 @@ SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* =
|
|||
/*
|
||||
* init with Texture2D
|
||||
*/
|
||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
|
||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||
|
||||
|
@ -112,7 +112,7 @@ bool SpriteBatchNode::init()
|
|||
/*
|
||||
* init with FileImage
|
||||
*/
|
||||
bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity)
|
||||
bool SpriteBatchNode::initWithFile(const char* fileImage, long capacity)
|
||||
{
|
||||
Texture2D *texture2D = TextureCache::getInstance()->addImage(fileImage);
|
||||
return initWithTexture(texture2D, capacity);
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
The file will be loaded using the TextureMgr.
|
||||
*/
|
||||
static SpriteBatchNode* create(const char* fileImage, int capacity = DEFAULT_CAPACITY);
|
||||
static SpriteBatchNode* create(const char* fileImage, long capacity = DEFAULT_CAPACITY);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
|
@ -88,14 +88,14 @@ public:
|
|||
/** 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.
|
||||
*/
|
||||
bool initWithTexture(Texture2D *tex, int capacity);
|
||||
bool initWithTexture(Texture2D *tex, long 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 file will be loaded using the TextureMgr.
|
||||
* @js init
|
||||
* @lua init
|
||||
*/
|
||||
bool initWithFile(const char* fileImage, int capacity);
|
||||
bool initWithFile(const char* fileImage, long capacity);
|
||||
bool init();
|
||||
|
||||
/** returns the TextureAtlas object */
|
||||
|
|
|
@ -31,61 +31,61 @@ NS_CC_BEGIN
|
|||
|
||||
// implementation of SpriteFrame
|
||||
|
||||
SpriteFrame* SpriteFrame::create(const char* filename, const Rect& rect)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTextureFilename(filename, rect);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D *pobTexture, const Rect& rect)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D *texture, const Rect& rect)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
pSpriteFrame->initWithTexture(pobTexture, rect);
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTexture(texture, rect);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::createWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
pSpriteFrame->initWithTexture(pobTexture, rect, rotated, offset, originalSize);
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTexture(texture, rect, rotated, offset, originalSize);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrame::create(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
SpriteFrame* SpriteFrame::create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();;
|
||||
SpriteFrame *pSpriteFrame = new SpriteFrame();
|
||||
pSpriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize);
|
||||
pSpriteFrame->autorelease();
|
||||
|
||||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS(rect);
|
||||
return initWithTexture(pobTexture, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
return initWithTexture(texture, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect)
|
||||
{
|
||||
Rect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect );
|
||||
return initWithTextureFilename(filename, rectInPixels, false, Point::ZERO, rectInPixels.size);
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTexture(Texture2D* texture, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = pobTexture;
|
||||
_texture = texture;
|
||||
|
||||
if (pobTexture)
|
||||
if (texture)
|
||||
{
|
||||
pobTexture->retain();
|
||||
texture->retain();
|
||||
}
|
||||
|
||||
_rectInPixels = rect;
|
||||
|
@ -99,7 +99,7 @@ bool SpriteFrame::initWithTexture(Texture2D* pobTexture, const Rect& rect, bool
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize)
|
||||
{
|
||||
_texture = NULL;
|
||||
_textureFilename = filename;
|
||||
|
|
|
@ -58,12 +58,12 @@ public:
|
|||
/** Create a SpriteFrame with a texture filename, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
static SpriteFrame* create(const char* filename, const Rect& rect);
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
*/
|
||||
static SpriteFrame* create(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
|
||||
/** Create a SpriteFrame with a texture, rect in points.
|
||||
It is assumed that the frame was not trimmed.
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
/** Initializes a SpriteFrame with a texture filename, rect in points;
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
bool initWithTextureFilename(const char* filename, const Rect& rect);
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect);
|
||||
|
||||
/** Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
The originalSize is the size in points of the frame before being trimmed.
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
@since v1.1
|
||||
*/
|
||||
bool initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize);
|
||||
|
||||
|
||||
// attributes
|
||||
|
|
|
@ -102,11 +102,11 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
|
|||
// check the format
|
||||
CCASSERT(format >=0 && format <= 3, "format is not supported for SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(framesDict, element)
|
||||
{
|
||||
Dictionary* frameDict = static_cast<Dictionary*>(pElement->getObject());
|
||||
std::string spriteFrameName = pElement->getStrKey();
|
||||
Dictionary* frameDict = static_cast<Dictionary*>(element->getObject());
|
||||
std::string spriteFrameName = element->getStrKey();
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(spriteFrameName));
|
||||
if (spriteFrame)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(Dictionary* dictionary, Tex
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D *pobTexture)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
Dictionary *dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
|
||||
|
@ -212,9 +212,9 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, Texture2D *
|
|||
dict->release();
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* textureFileName)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName)
|
||||
{
|
||||
CCASSERT(textureFileName, "texture name should not be null");
|
||||
CCASSERT(textureFileName.size()>0, "texture name should not be null");
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(textureFileName);
|
||||
|
||||
if (texture)
|
||||
|
@ -223,13 +223,13 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* te
|
|||
}
|
||||
else
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: couldn't load texture file. File not found %s", textureFileName);
|
||||
CCLOG("cocos2d: SpriteFrameCache: couldn't load texture file. File not found %s", textureFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
||||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
||||
{
|
||||
CCASSERT(pszPlist, "plist filename should not be NULL");
|
||||
CCASSERT(pszPlist.size()>0, "plist filename should not be NULL");
|
||||
|
||||
if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end())
|
||||
{
|
||||
|
@ -280,7 +280,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteFrameCache::addSpriteFrame(SpriteFrame *pobFrame, const char *pszFrameName)
|
||||
void SpriteFrameCache::addSpriteFrame(SpriteFrame *pobFrame, const std::string& pszFrameName)
|
||||
{
|
||||
_spriteFrames->setObject(pobFrame, pszFrameName);
|
||||
}
|
||||
|
@ -295,14 +295,14 @@ void SpriteFrameCache::removeSpriteFrames(void)
|
|||
void SpriteFrameCache::removeUnusedSpriteFrames(void)
|
||||
{
|
||||
bool bRemoved = false;
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, element)
|
||||
{
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(pElement->getObject());
|
||||
SpriteFrame* spriteFrame = static_cast<SpriteFrame*>(element->getObject());
|
||||
if( spriteFrame->retainCount() == 1 )
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", pElement->getStrKey());
|
||||
_spriteFrames->removeObjectForElememt(pElement);
|
||||
CCLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", element->getStrKey());
|
||||
_spriteFrames->removeObjectForElememt(element);
|
||||
bRemoved = true;
|
||||
}
|
||||
}
|
||||
|
@ -315,16 +315,14 @@ void SpriteFrameCache::removeUnusedSpriteFrames(void)
|
|||
}
|
||||
|
||||
|
||||
void SpriteFrameCache::removeSpriteFrameByName(const char *pszName)
|
||||
void SpriteFrameCache::removeSpriteFrameByName(const std::string& name)
|
||||
{
|
||||
// explicit nil handling
|
||||
if( ! pszName )
|
||||
{
|
||||
if( ! name.size()>0 )
|
||||
return;
|
||||
}
|
||||
|
||||
// Is this an alias ?
|
||||
String* key = (String*)_spriteFramesAliases->objectForKey(pszName);
|
||||
String* key = (String*)_spriteFramesAliases->objectForKey(name);
|
||||
|
||||
if (key)
|
||||
{
|
||||
|
@ -333,20 +331,20 @@ void SpriteFrameCache::removeSpriteFrameByName(const char *pszName)
|
|||
}
|
||||
else
|
||||
{
|
||||
_spriteFrames->removeObjectForKey(pszName);
|
||||
_spriteFrames->removeObjectForKey(name);
|
||||
}
|
||||
|
||||
// XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache
|
||||
_loadedFileNames->clear();
|
||||
}
|
||||
|
||||
void SpriteFrameCache::removeSpriteFramesFromFile(const char* plist)
|
||||
void SpriteFrameCache::removeSpriteFramesFromFile(const std::string& plist)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
Dictionary* dict = Dictionary::createWithContentsOfFileThreadSafe(fullPath.c_str());
|
||||
if (dict == nullptr)
|
||||
{
|
||||
CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist);
|
||||
CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist.c_str());
|
||||
return;
|
||||
}
|
||||
removeSpriteFramesFromDictionary((Dictionary*)dict);
|
||||
|
@ -365,12 +363,12 @@ void SpriteFrameCache::removeSpriteFramesFromDictionary(Dictionary* dictionary)
|
|||
Dictionary* framesDict = static_cast<Dictionary*>(dictionary->objectForKey("frames"));
|
||||
Array* keysToRemove = Array::create();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(framesDict, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(framesDict, element)
|
||||
{
|
||||
if (_spriteFrames->objectForKey(pElement->getStrKey()))
|
||||
if (_spriteFrames->objectForKey(element->getStrKey()))
|
||||
{
|
||||
keysToRemove->addObject(String::create(pElement->getStrKey()));
|
||||
keysToRemove->addObject(String::create(element->getStrKey()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,33 +379,33 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture)
|
|||
{
|
||||
Array* keysToRemove = Array::create();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, pElement)
|
||||
DictElement* element = NULL;
|
||||
CCDICT_FOREACH(_spriteFrames, element)
|
||||
{
|
||||
string key = pElement->getStrKey();
|
||||
string key = element->getStrKey();
|
||||
SpriteFrame* frame = static_cast<SpriteFrame*>(_spriteFrames->objectForKey(key.c_str()));
|
||||
if (frame && (frame->getTexture() == texture))
|
||||
{
|
||||
keysToRemove->addObject(String::create(pElement->getStrKey()));
|
||||
keysToRemove->addObject(String::create(element->getStrKey()));
|
||||
}
|
||||
}
|
||||
|
||||
_spriteFrames->removeObjectsForKeys(keysToRemove);
|
||||
}
|
||||
|
||||
SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const char *pszName)
|
||||
SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name)
|
||||
{
|
||||
SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(pszName);
|
||||
SpriteFrame* frame = (SpriteFrame*)_spriteFrames->objectForKey(name);
|
||||
if (!frame)
|
||||
{
|
||||
// try alias dictionary
|
||||
String *key = (String*)_spriteFramesAliases->objectForKey(pszName);
|
||||
String *key = (String*)_spriteFramesAliases->objectForKey(name);
|
||||
if (key)
|
||||
{
|
||||
frame = (SpriteFrame*)_spriteFrames->objectForKey(key->getCString());
|
||||
if (! frame)
|
||||
{
|
||||
CCLOG("cocos2d: SpriteFrameCache: Frame '%s' not found", pszName);
|
||||
CCLOG("cocos2d: SpriteFrameCache: Frame '%s' not found", name.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,29 +85,29 @@ public:
|
|||
public:
|
||||
/** Adds multiple Sprite Frames from a plist file.
|
||||
* A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png
|
||||
* If you want to use another texture, you should use the addSpriteFramesWithFile(const char *plist, const char *textureFileName) method.
|
||||
* If you want to use another texture, you should use the addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) method.
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char *plist);
|
||||
void addSpriteFramesWithFile(const std::string& plist);
|
||||
|
||||
/** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
|
||||
@since v0.99.5
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char* plist, const char* textureFileName);
|
||||
void addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName);
|
||||
|
||||
/** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
|
||||
* @js addSpriteFrames
|
||||
* @lua addSpriteFrames
|
||||
*/
|
||||
void addSpriteFramesWithFile(const char *plist, Texture2D *texture);
|
||||
void addSpriteFramesWithFile(const std::string&plist, Texture2D *texture);
|
||||
|
||||
/** Adds an sprite frame with a given name.
|
||||
If the name already exists, then the contents of the old name will be replaced with the new one.
|
||||
*/
|
||||
void addSpriteFrame(SpriteFrame *frame, const char *frameName);
|
||||
void addSpriteFrame(SpriteFrame *frame, const std::string& frameName);
|
||||
|
||||
/** Purges the dictionary of loaded sprite frames.
|
||||
* Call this method if you receive the "Memory Warning".
|
||||
|
@ -124,14 +124,14 @@ public:
|
|||
void removeUnusedSpriteFrames(void);
|
||||
|
||||
/** Deletes an sprite frame from the sprite frame cache. */
|
||||
void removeSpriteFrameByName(const char *name);
|
||||
void removeSpriteFrameByName(const std::string& name);
|
||||
|
||||
/** Removes multiple Sprite Frames from a plist file.
|
||||
* Sprite Frames stored in this file will be removed.
|
||||
* It is convenient to call this method when a specific texture needs to be removed.
|
||||
* @since v0.99.5
|
||||
*/
|
||||
void removeSpriteFramesFromFile(const char* plist);
|
||||
void removeSpriteFramesFromFile(const std::string& plist);
|
||||
|
||||
/** Removes all Sprite Frames associated with the specified textures.
|
||||
* It is convenient to call this method when a specific texture needs to be removed.
|
||||
|
@ -145,10 +145,10 @@ public:
|
|||
* @js getSpriteFrame
|
||||
* @lua getSpriteFrame
|
||||
*/
|
||||
SpriteFrame* getSpriteFrameByName(const char *name);
|
||||
SpriteFrame* getSpriteFrameByName(const std::string& name);
|
||||
|
||||
/** @deprecated use getSpriteFrameByName() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const char *name) { return getSpriteFrameByName(name); }
|
||||
CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const std::string&name) { return getSpriteFrameByName(name); }
|
||||
|
||||
private:
|
||||
/*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
|
||||
|
|
|
@ -119,7 +119,7 @@ static bool _PVRHaveAlphaPremultiplied = false;
|
|||
//conventer function
|
||||
|
||||
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertI8ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i=0; i < dataLen; ++i)
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ void Texture2D::convertI8ToRGB888(const unsigned char* data, int dataLen, unsign
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertAI88ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ void Texture2D::convertAI88ToRGB888(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRRRRGGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
{
|
||||
|
@ -153,7 +153,7 @@ void Texture2D::convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ void Texture2D::convertAI88ToRGBA8888(const unsigned char* data, int dataLen, un
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertI8ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -177,7 +177,7 @@ void Texture2D::convertI8ToRGB565(const unsigned char* data, int dataLen, unsign
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertAI88ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
|
@ -189,7 +189,7 @@ void Texture2D::convertAI88ToRGB565(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -202,7 +202,7 @@ void Texture2D::convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
|
@ -215,7 +215,7 @@ void Texture2D::convertAI88ToRGBA4444(const unsigned char* data, int dataLen, un
|
|||
}
|
||||
|
||||
// IIIIIIII -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -228,7 +228,7 @@ void Texture2D::convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsign
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
|
@ -241,7 +241,7 @@ void Texture2D::convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// IIIIIIII -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertI8ToAI88(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0; i < dataLen; ++i)
|
||||
|
@ -252,7 +252,7 @@ void Texture2D::convertI8ToAI88(const unsigned char* data, int dataLen, unsigned
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> AAAAAAAA
|
||||
void Texture2D::convertAI88ToA8(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 1; i < dataLen; i += 2)
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ void Texture2D::convertAI88ToA8(const unsigned char* data, int dataLen, unsigned
|
|||
}
|
||||
|
||||
// IIIIIIIIAAAAAAAA -> IIIIIIII
|
||||
void Texture2D::convertAI88ToI8(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 1; i < l; i += 2)
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ void Texture2D::convertAI88ToI8(const unsigned char* data, int dataLen, unsigned
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA
|
||||
void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ void Texture2D::convertRGB888ToRGBA8888(const unsigned char* data, int dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRRRRGGGGGGGGBBBBBBBB
|
||||
void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
|
@ -293,7 +293,7 @@ void Texture2D::convertRGBA8888ToRGB888(const unsigned char* data, int dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertRGB888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
|
@ -305,7 +305,7 @@ void Texture2D::convertRGB888ToRGB565(const unsigned char* data, int dataLen, un
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRRGGGGGGBBBBB
|
||||
void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
|
@ -317,7 +317,7 @@ void Texture2D::convertRGBA8888ToRGB565(const unsigned char* data, int dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIII
|
||||
void Texture2D::convertRGB888ToI8(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
|
@ -326,7 +326,7 @@ void Texture2D::convertRGB888ToI8(const unsigned char* data, int dataLen, unsign
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIII
|
||||
void Texture2D::convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ void Texture2D::convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> AAAAAAAA
|
||||
void Texture2D::convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen -3; i < l; i += 4)
|
||||
{
|
||||
|
@ -344,7 +344,7 @@ void Texture2D::convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsi
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertRGB888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
|
@ -355,7 +355,7 @@ void Texture2D::convertRGB888ToAI88(const unsigned char* data, int dataLen, unsi
|
|||
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> IIIIIIIIAAAAAAAA
|
||||
void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
{
|
||||
|
@ -365,7 +365,7 @@ void Texture2D::convertRGBA8888ToAI88(const unsigned char* data, int dataLen, un
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
|
@ -378,7 +378,7 @@ void Texture2D::convertRGB888ToRGBA4444(const unsigned char* data, int dataLen,
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA -> RRRRGGGGBBBBAAAA
|
||||
void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 3; i < l; i += 4)
|
||||
|
@ -391,10 +391,10 @@ void Texture2D::convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
for (long i = 0, l = dataLen - 2; i < l; i += 3)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00F8) << 3 //G
|
||||
|
@ -404,10 +404,10 @@ void Texture2D::convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, un
|
|||
}
|
||||
|
||||
// RRRRRRRRGGGGGGGGBBBBBBBB -> RRRRRGGGGGBBBBBA
|
||||
void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData)
|
||||
void Texture2D::convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData)
|
||||
{
|
||||
unsigned short* out16 = (unsigned short*)outData;
|
||||
for (int i = 0, l = dataLen - 2; i < l; i += 4)
|
||||
for (long i = 0, l = dataLen - 2; i < l; i += 4)
|
||||
{
|
||||
*out16++ = (data[i] & 0x00F8) << 8 //R
|
||||
| (data[i + 1] & 0x00F8) << 3 //G
|
||||
|
@ -451,12 +451,12 @@ Texture2D::PixelFormat Texture2D::getPixelFormat() const
|
|||
return _pixelFormat;
|
||||
}
|
||||
|
||||
unsigned int Texture2D::getPixelsWide() const
|
||||
long Texture2D::getPixelsWide() const
|
||||
{
|
||||
return _pixelsWide;
|
||||
}
|
||||
|
||||
unsigned int Texture2D::getPixelsHigh() const
|
||||
long Texture2D::getPixelsHigh() const
|
||||
{
|
||||
return _pixelsHigh;
|
||||
}
|
||||
|
@ -529,8 +529,10 @@ bool Texture2D::hasPremultipliedAlpha() const
|
|||
return _hasPremultipliedAlpha;
|
||||
}
|
||||
|
||||
bool Texture2D::initWithData(const void *data, int dataLen, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize)
|
||||
bool Texture2D::initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize)
|
||||
{
|
||||
CCASSERT(dataLen>0 && pixelsWide>0 && pixelsHigh>0, "Invalid size");
|
||||
|
||||
//if data has no mipmaps, we will consider it has only one mipmap
|
||||
MipmapInfo mipmap;
|
||||
mipmap.address = (unsigned char*)data;
|
||||
|
@ -544,10 +546,11 @@ bool Texture2D::initWithData(const void *data, int dataLen, Texture2D::PixelForm
|
|||
|
||||
}
|
||||
|
||||
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh)
|
||||
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, long pixelsWide, long pixelsHigh)
|
||||
{
|
||||
//the pixelFormat must be a certain value
|
||||
CCAssert(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
|
||||
CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
|
||||
CCASSERT(pixelsWide>0 && pixelsHigh>0, "Invalid size");
|
||||
|
||||
if (mipmapsNum <= 0)
|
||||
{
|
||||
|
@ -670,7 +673,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
|
||||
const char* Texture2D::description(void) const
|
||||
{
|
||||
return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %u x %u | Coordinates = (%.2f, %.2f)>", _name, _pixelsWide, _pixelsHigh, _maxS, _maxT)->getCString();
|
||||
return String::createWithFormat("<Texture2D | Name = %u | Dimensions = %ld x %ld | Coordinates = (%.2f, %.2f)>", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT)->getCString();
|
||||
}
|
||||
|
||||
// implementation Texture2D (Image)
|
||||
|
@ -771,7 +774,7 @@ bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -820,7 +823,7 @@ Texture2D::PixelFormat Texture2D::convertI8ToFormat(const unsigned char* data, i
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -875,7 +878,7 @@ Texture2D::PixelFormat Texture2D::convertAI88ToFormat(const unsigned char* data,
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
|
@ -923,7 +926,7 @@ Texture2D::PixelFormat Texture2D::convertRGB888ToFormat(const unsigned char* dat
|
|||
return format;
|
||||
}
|
||||
|
||||
Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
{
|
||||
|
||||
switch (format)
|
||||
|
@ -995,7 +998,7 @@ rgb(2) -> 1235678
|
|||
rgba(1) -> 12345678
|
||||
|
||||
*/
|
||||
Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, int dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
Texture2D::PixelFormat Texture2D::convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen)
|
||||
{
|
||||
switch (originFormat)
|
||||
{
|
||||
|
|
|
@ -120,13 +120,13 @@ public:
|
|||
|
||||
struct PixelFormatInfo {
|
||||
|
||||
PixelFormatInfo(GLenum internalFormat, GLenum format, GLenum type, int bpp, bool compressed, bool alpha)
|
||||
: internalFormat(internalFormat)
|
||||
, format(format)
|
||||
, type(type)
|
||||
, bpp(bpp)
|
||||
, compressed(compressed)
|
||||
, alpha(alpha)
|
||||
PixelFormatInfo(GLenum anInternalFormat, GLenum aFormat, GLenum aType, int aBpp, bool aCompressed, bool anAlpha)
|
||||
: internalFormat(anInternalFormat)
|
||||
, format(aFormat)
|
||||
, type(aType)
|
||||
, bpp(aBpp)
|
||||
, compressed(aCompressed)
|
||||
, alpha(anAlpha)
|
||||
{}
|
||||
|
||||
GLenum internalFormat;
|
||||
|
@ -216,10 +216,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithData(const void *data, int dataLen, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize);
|
||||
bool initWithData(const void *data, long dataLen, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh, const Size& contentSize);
|
||||
|
||||
/** Initializes with mipmaps */
|
||||
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, long pixelsWide, long pixelsHigh);
|
||||
|
||||
/**
|
||||
Drawing extensions to make it easy to draw basic quads using a Texture2D object.
|
||||
|
@ -326,10 +326,10 @@ public:
|
|||
Texture2D::PixelFormat getPixelFormat() const;
|
||||
|
||||
/** Gets the width of the texture in pixels */
|
||||
unsigned int getPixelsWide() const;
|
||||
long getPixelsWide() const;
|
||||
|
||||
/** Gets the height of the texture in pixels */
|
||||
unsigned int getPixelsHigh() const;
|
||||
long getPixelsHigh() const;
|
||||
|
||||
/** Gets the texture name */
|
||||
GLuint getName() const;
|
||||
|
@ -360,56 +360,56 @@ private:
|
|||
Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you.
|
||||
It will return the converted format to you. if the outData != data, you must delete it manually.
|
||||
*/
|
||||
static PixelFormat convertDataToFormat(const unsigned char* data, int dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertDataToFormat(const unsigned char* data, long dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
|
||||
static PixelFormat convertI8ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertAI88ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGB888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertI8ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertAI88ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGB888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, long dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||
|
||||
//I8 to XXX
|
||||
static void convertI8ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToAI88(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertI8ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
|
||||
//AI88 to XXX
|
||||
static void convertAI88ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToA8(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToI8(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertAI88ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
|
||||
//RGB888 to XXX
|
||||
static void convertRGB888ToRGBA8888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToI8(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA8888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGB888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
|
||||
//RGBA8888 to XXX
|
||||
static void convertRGBA8888ToRGB888(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB565(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToI8(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToA8(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToAI88(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGBA4444(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB5A1(const unsigned char* data, int dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB888(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB565(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToI8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToA8(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToAI88(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGBA4444(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
static void convertRGBA8888ToRGB5A1(const unsigned char* data, long dataLen, unsigned char* outData);
|
||||
|
||||
protected:
|
||||
/** pixel format of the texture */
|
||||
Texture2D::PixelFormat _pixelFormat;
|
||||
|
||||
/** width in pixels */
|
||||
unsigned int _pixelsWide;
|
||||
long _pixelsWide;
|
||||
|
||||
/** height in pixels */
|
||||
unsigned int _pixelsHigh;
|
||||
long _pixelsHigh;
|
||||
|
||||
/** texture name */
|
||||
GLuint _name;
|
||||
|
|
|
@ -107,7 +107,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
|
|||
|
||||
// TextureAtlas - alloc & init
|
||||
|
||||
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
||||
TextureAtlas * TextureAtlas::create(const char* file, long capacity)
|
||||
{
|
||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||
|
@ -119,7 +119,7 @@ TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
|
||||
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, long capacity)
|
||||
{
|
||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
|
||||
|
@ -131,7 +131,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool TextureAtlas::initWithFile(const char * file, int capacity)
|
||||
bool TextureAtlas::initWithFile(const char * file, long capacity)
|
||||
{
|
||||
// retained in property
|
||||
Texture2D *texture = TextureCache::getInstance()->addImage(file);
|
||||
|
@ -147,7 +147,7 @@ bool TextureAtlas::initWithFile(const char * file, int capacity)
|
|||
}
|
||||
}
|
||||
|
||||
bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity)
|
||||
bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||
|
||||
|
@ -310,7 +310,7 @@ void TextureAtlas::mapBuffers()
|
|||
|
||||
// TextureAtlas - Update, Insert, Move & Remove
|
||||
|
||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, long index)
|
||||
{
|
||||
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
||||
|
||||
|
@ -323,7 +323,7 @@ void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
|
|||
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, long index)
|
||||
{
|
||||
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
|
||||
|
||||
|
@ -347,7 +347,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
|
|||
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
||||
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
|
||||
|
||||
|
@ -378,7 +378,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
|
||||
void TextureAtlas::insertQuadFromIndex(long oldIndex, long newIndex)
|
||||
{
|
||||
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
|
@ -407,7 +407,7 @@ void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::removeQuadAtIndex(int index)
|
||||
void TextureAtlas::removeQuadAtIndex(long index)
|
||||
{
|
||||
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
|
||||
|
||||
|
@ -426,7 +426,7 @@ void TextureAtlas::removeQuadAtIndex(int index)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::removeQuadsAtIndex(int index, int amount)
|
||||
void TextureAtlas::removeQuadsAtIndex(long index, long amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
|
||||
|
||||
|
@ -448,7 +448,7 @@ void TextureAtlas::removeAllQuads()
|
|||
}
|
||||
|
||||
// TextureAtlas - Resize
|
||||
bool TextureAtlas::resizeCapacity(int newCapacity)
|
||||
bool TextureAtlas::resizeCapacity(long newCapacity)
|
||||
{
|
||||
CCASSERT(newCapacity>=0, "capacity >= 0");
|
||||
if( newCapacity == _capacity )
|
||||
|
@ -522,13 +522,13 @@ bool TextureAtlas::resizeCapacity(int newCapacity)
|
|||
return true;
|
||||
}
|
||||
|
||||
void TextureAtlas::increaseTotalQuadsWith(int amount)
|
||||
void TextureAtlas::increaseTotalQuadsWith(long amount)
|
||||
{
|
||||
CCASSERT(amount>=0, "amount >= 0");
|
||||
_totalQuads += amount;
|
||||
}
|
||||
|
||||
void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
|
||||
void TextureAtlas::moveQuadsFromIndex(long oldIndex, long amount, long newIndex)
|
||||
{
|
||||
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
|
||||
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||
|
@ -560,7 +560,7 @@ void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
|
|||
_dirty = true;
|
||||
}
|
||||
|
||||
void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
|
||||
void TextureAtlas::moveQuadsFromIndex(long index, long newIndex)
|
||||
{
|
||||
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
|
||||
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
|
||||
|
@ -568,7 +568,7 @@ void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
|
|||
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
|
||||
}
|
||||
|
||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount)
|
||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(long index, long amount)
|
||||
{
|
||||
CCASSERT(index>=0 && amount>=0, "values must be >= 0");
|
||||
V3F_C4B_T2F_Quad quad;
|
||||
|
@ -588,13 +588,13 @@ void TextureAtlas::drawQuads()
|
|||
this->drawNumberOfQuads(_totalQuads, 0);
|
||||
}
|
||||
|
||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads)
|
||||
void TextureAtlas::drawNumberOfQuads(long numberOfQuads)
|
||||
{
|
||||
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
|
||||
this->drawNumberOfQuads(numberOfQuads, 0);
|
||||
}
|
||||
|
||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start)
|
||||
void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start)
|
||||
{
|
||||
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ public:
|
|||
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
||||
* The TextureAtlas capacity can be increased in runtime.
|
||||
*/
|
||||
static TextureAtlas* create(const char* file , int capacity);
|
||||
static TextureAtlas* create(const char* file , long capacity);
|
||||
|
||||
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
||||
* with an initial capacity for n Quads.
|
||||
* The TextureAtlas capacity can be increased in runtime.
|
||||
*/
|
||||
static TextureAtlas* createWithTexture(Texture2D *texture, int capacity);
|
||||
static TextureAtlas* createWithTexture(Texture2D *texture, long capacity);
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
bool initWithFile(const char* file, int capacity);
|
||||
bool initWithFile(const char* file, long capacity);
|
||||
|
||||
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
||||
* with an initial capacity for Quads.
|
||||
|
@ -89,43 +89,43 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
bool initWithTexture(Texture2D *texture, int capacity);
|
||||
bool initWithTexture(Texture2D *texture, long capacity);
|
||||
|
||||
/** updates a Quad (texture, vertex and color) at a certain index
|
||||
* index must be between 0 and the atlas capacity - 1
|
||||
@since v0.8
|
||||
*/
|
||||
void updateQuad(V3F_C4B_T2F_Quad* quad, int index);
|
||||
void updateQuad(V3F_C4B_T2F_Quad* quad, long index);
|
||||
|
||||
/** Inserts a Quad (texture, vertex and color) at a certain index
|
||||
index must be between 0 and the atlas capacity - 1
|
||||
@since v0.8
|
||||
*/
|
||||
void insertQuad(V3F_C4B_T2F_Quad* quad, int index);
|
||||
void insertQuad(V3F_C4B_T2F_Quad* quad, long index);
|
||||
|
||||
/** Inserts a c array of quads at a given index
|
||||
index must be between 0 and the atlas capacity - 1
|
||||
this method doesn't enlarge the array when amount + index > totalQuads
|
||||
@since v1.1
|
||||
*/
|
||||
void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount);
|
||||
void insertQuads(V3F_C4B_T2F_Quad* quads, long index, long amount);
|
||||
|
||||
/** Removes the quad that is located at a certain index and inserts it at a new index
|
||||
This operation is faster than removing and inserting in a quad in 2 different steps
|
||||
@since v0.7.2
|
||||
*/
|
||||
void insertQuadFromIndex(int fromIndex, int newIndex);
|
||||
void insertQuadFromIndex(long fromIndex, long newIndex);
|
||||
|
||||
/** removes a quad at a given index number.
|
||||
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
|
||||
@since v0.7.2
|
||||
*/
|
||||
void removeQuadAtIndex(int index);
|
||||
void removeQuadAtIndex(long index);
|
||||
|
||||
/** removes a amount of quads starting from index
|
||||
@since 1.1
|
||||
*/
|
||||
void removeQuadsAtIndex(int index, int amount);
|
||||
void removeQuadsAtIndex(long index, long amount);
|
||||
/** removes all Quads.
|
||||
The TextureAtlas capacity remains untouched. No memory is freed.
|
||||
The total number of quads to be drawn will be 0
|
||||
|
@ -138,19 +138,19 @@ public:
|
|||
* It returns true if the resize was successful.
|
||||
* If it fails to resize the capacity it will return false with a new capacity of 0.
|
||||
*/
|
||||
bool resizeCapacity(int capacity);
|
||||
bool resizeCapacity(long capacity);
|
||||
|
||||
/**
|
||||
Used internally by ParticleBatchNode
|
||||
don't use this unless you know what you're doing
|
||||
@since 1.1
|
||||
*/
|
||||
void increaseTotalQuadsWith(int amount);
|
||||
void increaseTotalQuadsWith(long amount);
|
||||
|
||||
/** Moves an amount of quads from oldIndex at newIndex
|
||||
@since v1.1
|
||||
*/
|
||||
void moveQuadsFromIndex(int oldIndex, int amount, int newIndex);
|
||||
void moveQuadsFromIndex(long oldIndex, long amount, long newIndex);
|
||||
|
||||
/**
|
||||
Moves quads from index till totalQuads to the newIndex
|
||||
|
@ -158,26 +158,26 @@ public:
|
|||
This method doesn't enlarge the array if newIndex + quads to be moved > capacity
|
||||
@since 1.1
|
||||
*/
|
||||
void moveQuadsFromIndex(int index, int newIndex);
|
||||
void moveQuadsFromIndex(long index, long newIndex);
|
||||
|
||||
/**
|
||||
Ensures that after a realloc quads are still empty
|
||||
Used internally by ParticleBatchNode
|
||||
@since 1.1
|
||||
*/
|
||||
void fillWithEmptyQuadsFromIndex(int index, int amount);
|
||||
void fillWithEmptyQuadsFromIndex(long index, long amount);
|
||||
|
||||
/** draws n quads
|
||||
* n can't be greater than the capacity of the Atlas
|
||||
*/
|
||||
void drawNumberOfQuads(int n);
|
||||
void drawNumberOfQuads(long n);
|
||||
|
||||
/** draws n quads from an index (offset).
|
||||
n + start can't be greater than the capacity of the atlas
|
||||
|
||||
@since v1.0
|
||||
*/
|
||||
void drawNumberOfQuads(int numberOfQuads, int start);
|
||||
void drawNumberOfQuads(long numberOfQuads, long start);
|
||||
|
||||
/** draws all the Atlas's Quads
|
||||
*/
|
||||
|
|
|
@ -614,10 +614,10 @@ void VolatileTexture::reloadAllTextures()
|
|||
case kImageFile:
|
||||
{
|
||||
Image* image = new Image();
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &nSize);
|
||||
long size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &size);
|
||||
|
||||
if (image && image->initWithImageData(pBuffer, nSize))
|
||||
if (image && image->initWithImageData(pBuffer, size))
|
||||
{
|
||||
Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
|
||||
|
|
|
@ -58,7 +58,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
|
|||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
//CCFileData data(UserDefault::getInstance()->getXMLFilePath().c_str(),"rt");
|
||||
unsigned long nSize;
|
||||
long nSize;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
|
|
|
@ -73,8 +73,8 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLDoc
|
|||
{
|
||||
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
|
||||
*doc = xmlDoc;
|
||||
unsigned long nSize;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &nSize);
|
||||
long size;
|
||||
const char* pXmlBuffer = (const char*)FileUtils::getInstance()->getFileData(UserDefault::getInstance()->getXMLFilePath().c_str(), "rb", &size);
|
||||
//const char* pXmlBuffer = (const char*)data.getBuffer();
|
||||
if(NULL == pXmlBuffer)
|
||||
{
|
||||
|
|
|
@ -134,9 +134,11 @@ target_link_libraries(cocos2d
|
|||
freetype
|
||||
fontconfig
|
||||
png
|
||||
pthread
|
||||
glfw
|
||||
GLEW
|
||||
GL
|
||||
X11
|
||||
rt
|
||||
z
|
||||
)
|
||||
|
|
|
@ -198,8 +198,8 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
int mode,total;
|
||||
tImageTGA *info = NULL;
|
||||
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &nSize);
|
||||
long size = 0;
|
||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
info = (tImageTGA *)malloc(sizeof(tImageTGA));
|
||||
|
||||
// get the file header info
|
||||
if (! tgaLoadHeader(pBuffer, nSize, info))
|
||||
if (! tgaLoadHeader(pBuffer, size, info))
|
||||
{
|
||||
info->status = TGA_ERROR_MEMORY;
|
||||
break;
|
||||
|
@ -245,11 +245,11 @@ tImageTGA * tgaLoad(const char *filename)
|
|||
// finally load the image pixels
|
||||
if ( info->type == 10 )
|
||||
{
|
||||
bLoadImage = tgaLoadRLEImageData(pBuffer, nSize, info);
|
||||
bLoadImage = tgaLoadRLEImageData(pBuffer, size, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
bLoadImage = tgaLoadImageData(pBuffer, nSize, info);
|
||||
bLoadImage = tgaLoadImageData(pBuffer, size, info);
|
||||
}
|
||||
|
||||
// check for errors when reading the pixels
|
||||
|
|
|
@ -39,7 +39,7 @@ bool ZipUtils::s_bEncryptionKeyIsValid = false;
|
|||
|
||||
// --------------------- ZipUtils ---------------------
|
||||
|
||||
inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, int len)
|
||||
inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, long len)
|
||||
{
|
||||
const int enclen = 1024;
|
||||
const int securelen = 512;
|
||||
|
@ -108,7 +108,7 @@ inline void ZipUtils::ccDecodeEncodedPvr(unsigned int *data, int len)
|
|||
}
|
||||
}
|
||||
|
||||
inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, int len)
|
||||
inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, long len)
|
||||
{
|
||||
unsigned int cs = 0;
|
||||
const int cslen = 128;
|
||||
|
@ -127,12 +127,12 @@ inline unsigned int ZipUtils::ccChecksumPvr(const unsigned int *data, int len)
|
|||
// Should buffer factor be 1.5 instead of 2 ?
|
||||
#define BUFFER_INC_FACTOR (2)
|
||||
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength, unsigned int outLenghtHint)
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint)
|
||||
{
|
||||
/* ret value */
|
||||
int err = Z_OK;
|
||||
|
||||
int bufferSize = outLenghtHint;
|
||||
long bufferSize = outLenghtHint;
|
||||
*out = new unsigned char[bufferSize];
|
||||
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -192,9 +192,9 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength,
|
|||
return err;
|
||||
}
|
||||
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint)
|
||||
int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint)
|
||||
{
|
||||
unsigned int outLength = 0;
|
||||
long outLength = 0;
|
||||
int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint);
|
||||
|
||||
if (err != Z_OK || *out == NULL) {
|
||||
|
@ -223,7 +223,7 @@ int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength,
|
|||
return outLength;
|
||||
}
|
||||
|
||||
int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out)
|
||||
int ZipUtils::ccInflateMemory(unsigned char *in, long inLength, unsigned char **out)
|
||||
{
|
||||
// 256k for hint
|
||||
return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024);
|
||||
|
@ -304,7 +304,7 @@ bool ZipUtils::ccIsCCZFile(const char *path)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -316,7 +316,7 @@ bool ZipUtils::ccIsCCZFile(const char *path)
|
|||
return ccIsCCZBuffer(compressed, fileLen);
|
||||
}
|
||||
|
||||
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, int len)
|
||||
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, long len)
|
||||
{
|
||||
if (len < sizeof(struct CCZHeader))
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool ZipUtils::ccIsGZipFile(const char *path)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -345,7 +345,7 @@ bool ZipUtils::ccIsGZipFile(const char *path)
|
|||
return ccIsGZipBuffer(compressed, fileLen);
|
||||
}
|
||||
|
||||
bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, int len)
|
||||
bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, long len)
|
||||
{
|
||||
if (len < 2)
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, int len)
|
|||
}
|
||||
|
||||
|
||||
int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, int bufferLen, unsigned char **out)
|
||||
int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsigned char **out)
|
||||
{
|
||||
struct CCZHeader *header = (struct CCZHeader*) buffer;
|
||||
|
||||
|
@ -454,7 +454,7 @@ int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
|
|||
// load file into memory
|
||||
unsigned char* compressed = NULL;
|
||||
|
||||
unsigned long fileLen = 0;
|
||||
long fileLen = 0;
|
||||
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||
|
||||
if(NULL == compressed || 0 == fileLen)
|
||||
|
@ -582,7 +582,7 @@ bool ZipFile::fileExists(const std::string &fileName) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, unsigned long *pSize)
|
||||
unsigned char *ZipFile::getFileData(const std::string &fileName, long *pSize)
|
||||
{
|
||||
unsigned char * pBuffer = NULL;
|
||||
if (pSize)
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace cocos2d
|
|||
*
|
||||
@since v0.8.1
|
||||
*/
|
||||
static int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
|
||||
static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out);
|
||||
|
||||
/**
|
||||
* Inflates either zlib or gzip deflated memory. The inflated memory is
|
||||
|
@ -76,7 +76,7 @@ namespace cocos2d
|
|||
*
|
||||
@since v1.0.0
|
||||
*/
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint);
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLenghtHint);
|
||||
|
||||
/** inflates a GZip file into memory
|
||||
*
|
||||
|
@ -100,7 +100,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static bool ccIsGZipBuffer(const unsigned char *buffer, int len);
|
||||
static bool ccIsGZipBuffer(const unsigned char *buffer, long len);
|
||||
|
||||
/** inflates a CCZ file into memory
|
||||
*
|
||||
|
@ -116,7 +116,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static int ccInflateCCZBuffer(const unsigned char *buffer, int len, unsigned char **out);
|
||||
static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out);
|
||||
|
||||
/** test a file is a CCZ format file or not
|
||||
*
|
||||
|
@ -132,7 +132,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
static bool ccIsCCZBuffer(const unsigned char *buffer, int len);
|
||||
static bool ccIsCCZBuffer(const unsigned char *buffer, long len);
|
||||
|
||||
/** Sets the pvr.ccz encryption key parts separately for added
|
||||
* security.
|
||||
|
@ -187,10 +187,10 @@ namespace cocos2d
|
|||
static void ccSetPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4);
|
||||
|
||||
private:
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength,
|
||||
unsigned int outLenghtHint);
|
||||
static inline void ccDecodeEncodedPvr (unsigned int *data, int len);
|
||||
static inline unsigned int ccChecksumPvr(const unsigned int *data, int len);
|
||||
static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength,
|
||||
long outLenghtHint);
|
||||
static inline void ccDecodeEncodedPvr (unsigned int *data, long len);
|
||||
static inline unsigned int ccChecksumPvr(const unsigned int *data, long len);
|
||||
|
||||
static unsigned int s_uEncryptedPvrKeyParts[4];
|
||||
static unsigned int s_uEncryptionKey[1024];
|
||||
|
@ -253,7 +253,7 @@ namespace cocos2d
|
|||
*
|
||||
* @since v2.0.5
|
||||
*/
|
||||
unsigned char *getFileData(const std::string &fileName, unsigned long *pSize);
|
||||
unsigned char *getFileData(const std::string &fileName, long *size);
|
||||
|
||||
private:
|
||||
/** Internal data like zip file pointer / file list array and so on */
|
||||
|
|
|
@ -28,10 +28,10 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
const int CC_INVALID_INDEX = -1;
|
||||
const long CC_INVALID_INDEX = -1;
|
||||
|
||||
/** Allocates and initializes a new array with specified capacity */
|
||||
ccArray* ccArrayNew(int capacity)
|
||||
ccArray* ccArrayNew(long capacity)
|
||||
{
|
||||
if (capacity == 0)
|
||||
capacity = 7;
|
||||
|
@ -68,7 +68,7 @@ void ccArrayDoubleCapacity(ccArray *arr)
|
|||
arr->arr = newArr;
|
||||
}
|
||||
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra)
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, long extra)
|
||||
{
|
||||
while (arr->max < arr->num + extra)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ void ccArrayEnsureExtraCapacity(ccArray *arr, int extra)
|
|||
|
||||
void ccArrayShrink(ccArray *arr)
|
||||
{
|
||||
int newSize = 0;
|
||||
long newSize = 0;
|
||||
|
||||
//only resize when necessary
|
||||
if (arr->max > arr->num && !(arr->num==0 && arr->max==1))
|
||||
|
@ -104,11 +104,11 @@ void ccArrayShrink(ccArray *arr)
|
|||
}
|
||||
|
||||
/** Returns index of first occurrence of object, CC_INVALID_INDEX if object not found. */
|
||||
int ccArrayGetIndexOfObject(ccArray *arr, Object* object)
|
||||
long ccArrayGetIndexOfObject(ccArray *arr, Object* object)
|
||||
{
|
||||
const int arrNum = arr->num;
|
||||
const long arrNum = arr->num;
|
||||
Object** ptr = arr->arr;
|
||||
for(int i = 0; i < arrNum; ++i, ++ptr)
|
||||
for(long i = 0; i < arrNum; ++i, ++ptr)
|
||||
{
|
||||
if( *ptr == object )
|
||||
return i;
|
||||
|
@ -143,7 +143,7 @@ void ccArrayAppendObjectWithResize(ccArray *arr, Object* object)
|
|||
enough capacity. */
|
||||
void ccArrayAppendArray(ccArray *arr, ccArray *plusArr)
|
||||
{
|
||||
for(int i = 0; i < plusArr->num; i++)
|
||||
for(long i = 0; i < plusArr->num; i++)
|
||||
{
|
||||
ccArrayAppendObject(arr, plusArr->arr[i]);
|
||||
}
|
||||
|
@ -157,14 +157,14 @@ void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr)
|
|||
}
|
||||
|
||||
/** Inserts an object at index */
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index)
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index)
|
||||
{
|
||||
CCASSERT(index<=arr->num, "Invalid index. Out of bounds");
|
||||
CCASSERT(object != NULL, "Invalid parameter!");
|
||||
|
||||
ccArrayEnsureExtraCapacity(arr, 1);
|
||||
|
||||
int remaining = arr->num - index;
|
||||
long remaining = arr->num - index;
|
||||
if( remaining > 0)
|
||||
{
|
||||
memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(Object*) * remaining );
|
||||
|
@ -176,7 +176,7 @@ void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index)
|
|||
}
|
||||
|
||||
/** Swaps two objects */
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2)
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2)
|
||||
{
|
||||
CCASSERT(index1>=0 && index1 < arr->num, "(1) Invalid index. Out of bounds");
|
||||
CCASSERT(index2>=0 && index2 < arr->num, "(2) Invalid index. Out of bounds");
|
||||
|
@ -198,7 +198,7 @@ void ccArrayRemoveAllObjects(ccArray *arr)
|
|||
|
||||
/** Removes object at specified index and pushes back all subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = true*/)
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj/* = true*/)
|
||||
{
|
||||
CCASSERT(arr && arr->num > 0 && index>=0 && index < arr->num, "Invalid index. Out of bounds");
|
||||
if (bReleaseObj)
|
||||
|
@ -208,7 +208,7 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = tr
|
|||
|
||||
arr->num--;
|
||||
|
||||
int remaining = arr->num - index;
|
||||
long remaining = arr->num - index;
|
||||
if(remaining>0)
|
||||
{
|
||||
memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(Object*));
|
||||
|
@ -218,16 +218,16 @@ void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj/* = tr
|
|||
/** Removes object at specified index and fills the gap with the last object,
|
||||
thereby avoiding the need to push back subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index)
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index)
|
||||
{
|
||||
CC_SAFE_RELEASE(arr->arr[index]);
|
||||
int last = --arr->num;
|
||||
long last = --arr->num;
|
||||
arr->arr[index] = arr->arr[last];
|
||||
}
|
||||
|
||||
void ccArrayFastRemoveObject(ccArray *arr, Object* object)
|
||||
{
|
||||
int index = ccArrayGetIndexOfObject(arr, object);
|
||||
long index = ccArrayGetIndexOfObject(arr, object);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(arr, index);
|
||||
|
@ -238,7 +238,7 @@ void ccArrayFastRemoveObject(ccArray *arr, Object* object)
|
|||
found the function has no effect. */
|
||||
void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true*/)
|
||||
{
|
||||
int index = ccArrayGetIndexOfObject(arr, object);
|
||||
long index = ccArrayGetIndexOfObject(arr, object);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj);
|
||||
|
@ -249,7 +249,7 @@ void ccArrayRemoveObject(ccArray *arr, Object* object, bool bReleaseObj/* = true
|
|||
first matching instance in arr will be removed. */
|
||||
void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
|
||||
{
|
||||
for(int i = 0; i < minusArr->num; i++)
|
||||
for(long i = 0; i < minusArr->num; i++)
|
||||
{
|
||||
ccArrayRemoveObject(arr, minusArr->arr[i]);
|
||||
}
|
||||
|
@ -259,8 +259,8 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
matching instances in arr will be removed. */
|
||||
void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
|
||||
{
|
||||
int back = 0;
|
||||
int i = 0;
|
||||
long back = 0;
|
||||
long i = 0;
|
||||
|
||||
for( i = 0; i < arr->num; i++)
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
|
|||
// #pragma mark ccCArray for Values (c structures)
|
||||
|
||||
/** Allocates and initializes a new C array with specified capacity */
|
||||
ccCArray* ccCArrayNew(int capacity)
|
||||
ccCArray* ccCArrayNew(long capacity)
|
||||
{
|
||||
if (capacity == 0)
|
||||
{
|
||||
|
@ -317,15 +317,15 @@ void ccCArrayDoubleCapacity(ccCArray *arr)
|
|||
}
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra)
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra)
|
||||
{
|
||||
ccArrayEnsureExtraCapacity((ccArray*)arr,extra);
|
||||
}
|
||||
|
||||
/** Returns index of first occurrence of value, CC_INVALID_INDEX if value not found. */
|
||||
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
|
||||
long ccCArrayGetIndexOfValue(ccCArray *arr, void* value)
|
||||
{
|
||||
for( int i = 0; i < arr->num; i++)
|
||||
for(long i = 0; i < arr->num; i++)
|
||||
{
|
||||
if( arr->arr[i] == value )
|
||||
return i;
|
||||
|
@ -340,11 +340,11 @@ bool ccCArrayContainsValue(ccCArray *arr, void* value)
|
|||
}
|
||||
|
||||
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index)
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index)
|
||||
{
|
||||
CCASSERT( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index");
|
||||
|
||||
int remaining = arr->num - index;
|
||||
long remaining = arr->num - index;
|
||||
// make sure it has enough capacity
|
||||
if (arr->num + 1 == arr->max)
|
||||
{
|
||||
|
@ -385,7 +385,7 @@ void ccCArrayAppendValueWithResize(ccCArray *arr, void* value)
|
|||
enough capacity. */
|
||||
void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr)
|
||||
{
|
||||
for( int i = 0; i < plusArr->num; i++)
|
||||
for( long i = 0; i < plusArr->num; i++)
|
||||
{
|
||||
ccCArrayAppendValue(arr, plusArr->arr[i]);
|
||||
}
|
||||
|
@ -408,9 +408,9 @@ void ccCArrayRemoveAllValues(ccCArray *arr)
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index)
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index)
|
||||
{
|
||||
for( int last = --arr->num; index < last; index++)
|
||||
for( long last = --arr->num; index < last; index++)
|
||||
{
|
||||
arr->arr[index] = arr->arr[index + 1];
|
||||
}
|
||||
|
@ -421,9 +421,9 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index)
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index)
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index)
|
||||
{
|
||||
int last = --arr->num;
|
||||
long last = --arr->num;
|
||||
arr->arr[index] = arr->arr[last];
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index)
|
|||
*/
|
||||
void ccCArrayRemoveValue(ccCArray *arr, void* value)
|
||||
{
|
||||
int index = ccCArrayGetIndexOfValue(arr, value);
|
||||
long index = ccCArrayGetIndexOfValue(arr, value);
|
||||
if (index != CC_INVALID_INDEX)
|
||||
{
|
||||
ccCArrayRemoveValueAtIndex(arr, index);
|
||||
|
@ -444,7 +444,7 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value)
|
|||
*/
|
||||
void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
||||
{
|
||||
for(int i = 0; i < minusArr->num; i++)
|
||||
for(long i = 0; i < minusArr->num; i++)
|
||||
{
|
||||
ccCArrayRemoveValue(arr, minusArr->arr[i]);
|
||||
}
|
||||
|
@ -455,9 +455,9 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
|||
*/
|
||||
void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr)
|
||||
{
|
||||
int back = 0;
|
||||
long back = 0;
|
||||
|
||||
for(int i = 0; i < arr->num; i++)
|
||||
for(long i = 0; i < arr->num; i++)
|
||||
{
|
||||
if( ccCArrayContainsValue(minusArr, arr->arr[i]) )
|
||||
{
|
||||
|
|
|
@ -51,20 +51,20 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
extern const int CC_INVALID_INDEX;
|
||||
extern const long CC_INVALID_INDEX;
|
||||
|
||||
// Easy integration
|
||||
#define CCARRAYDATA_FOREACH(__array__, __object__) \
|
||||
__object__=__array__->arr[0]; for(int i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
|
||||
__object__=__array__->arr[0]; for(long i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
|
||||
|
||||
|
||||
typedef struct _ccArray {
|
||||
int num, max;
|
||||
long num, max;
|
||||
Object** arr;
|
||||
} ccArray;
|
||||
|
||||
/** Allocates and initializes a new array with specified capacity */
|
||||
ccArray* ccArrayNew(int capacity);
|
||||
ccArray* ccArrayNew(long capacity);
|
||||
|
||||
/** Frees array after removing all remaining objects. Silently ignores nil arr. */
|
||||
void ccArrayFree(ccArray*& arr);
|
||||
|
@ -73,13 +73,13 @@ void ccArrayFree(ccArray*& arr);
|
|||
void ccArrayDoubleCapacity(ccArray *arr);
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, int extra);
|
||||
void ccArrayEnsureExtraCapacity(ccArray *arr, long extra);
|
||||
|
||||
/** shrinks the array so the memory footprint corresponds with the number of items */
|
||||
void ccArrayShrink(ccArray *arr);
|
||||
|
||||
/** Returns index of first occurrence of object, NSNotFound if object not found. */
|
||||
int ccArrayGetIndexOfObject(ccArray *arr, Object* object);
|
||||
long ccArrayGetIndexOfObject(ccArray *arr, Object* object);
|
||||
|
||||
/** Returns a Boolean value that indicates whether object is present in array. */
|
||||
bool ccArrayContainsObject(ccArray *arr, Object* object);
|
||||
|
@ -98,22 +98,22 @@ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr);
|
|||
void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr);
|
||||
|
||||
/** Inserts an object at index */
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, int index);
|
||||
void ccArrayInsertObjectAtIndex(ccArray *arr, Object* object, long index);
|
||||
|
||||
/** Swaps two objects */
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, int index1, int index2);
|
||||
void ccArraySwapObjectsAtIndexes(ccArray *arr, long index1, long index2);
|
||||
|
||||
/** Removes all objects from arr */
|
||||
void ccArrayRemoveAllObjects(ccArray *arr);
|
||||
|
||||
/** Removes object at specified index and pushes back all subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, int index, bool bReleaseObj = true);
|
||||
void ccArrayRemoveObjectAtIndex(ccArray *arr, long index, bool bReleaseObj = true);
|
||||
|
||||
/** Removes object at specified index and fills the gap with the last object,
|
||||
thereby avoiding the need to push back subsequent objects.
|
||||
Behavior undefined if index outside [0, num-1]. */
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, int index);
|
||||
void ccArrayFastRemoveObjectAtIndex(ccArray *arr, long index);
|
||||
|
||||
void ccArrayFastRemoveObject(ccArray *arr, Object* object);
|
||||
|
||||
|
@ -133,12 +133,12 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr);
|
|||
// #pragma mark ccCArray for Values (c structures)
|
||||
|
||||
typedef struct _ccCArray {
|
||||
int num, max;
|
||||
long num, max;
|
||||
void** arr;
|
||||
} ccCArray;
|
||||
|
||||
/** Allocates and initializes a new C array with specified capacity */
|
||||
ccCArray* ccCArrayNew(int capacity);
|
||||
ccCArray* ccCArrayNew(long capacity);
|
||||
|
||||
/** Frees C array after removing all remaining values. Silently ignores nil arr. */
|
||||
void ccCArrayFree(ccCArray *arr);
|
||||
|
@ -147,16 +147,16 @@ void ccCArrayFree(ccCArray *arr);
|
|||
void ccCArrayDoubleCapacity(ccCArray *arr);
|
||||
|
||||
/** Increases array capacity such that max >= num + extra. */
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, int extra);
|
||||
void ccCArrayEnsureExtraCapacity(ccCArray *arr, long extra);
|
||||
|
||||
/** Returns index of first occurrence of value, NSNotFound if value not found. */
|
||||
int ccCArrayGetIndexOfValue(ccCArray *arr, void* value);
|
||||
long ccCArrayGetIndexOfValue(ccCArray *arr, void* value);
|
||||
|
||||
/** Returns a Boolean value that indicates whether value is present in the C array. */
|
||||
bool ccCArrayContainsValue(ccCArray *arr, void* value);
|
||||
|
||||
/** Inserts a value at a certain position. Behavior undefined if array doesn't have enough capacity */
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, int index);
|
||||
void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, long index);
|
||||
|
||||
/** Appends an value. Behavior undefined if array doesn't have enough capacity. */
|
||||
void ccCArrayAppendValue(ccCArray *arr, void* value);
|
||||
|
@ -178,14 +178,14 @@ void ccCArrayRemoveAllValues(ccCArray *arr);
|
|||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, int index);
|
||||
void ccCArrayRemoveValueAtIndex(ccCArray *arr, long index);
|
||||
|
||||
/** Removes value at specified index and fills the gap with the last value,
|
||||
thereby avoiding the need to push back subsequent values.
|
||||
Behavior undefined if index outside [0, num-1].
|
||||
@since v0.99.4
|
||||
*/
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, int index);
|
||||
void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, long index);
|
||||
|
||||
/** Searches for the first occurrence of value and removes it. If value is not found the function has no effect.
|
||||
@since v0.99.4
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace {
|
|||
static Touch* g_touches[EventTouch::MAX_TOUCHES] = { NULL };
|
||||
static unsigned int g_indexBitsUsed = 0;
|
||||
// System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0
|
||||
static std::map<int, int> g_touchIdReorderMap;
|
||||
static std::map<long, int> g_touchIdReorderMap;
|
||||
|
||||
static int getUnUsedIndex()
|
||||
{
|
||||
|
@ -201,9 +201,9 @@ const char* EGLViewProtocol::getViewName()
|
|||
return _viewName;
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesBegin(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
int nUnusedIndex = 0;
|
||||
|
@ -251,9 +251,9 @@ void EGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float y
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesMove(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
EventTouch touchEvent;
|
||||
|
@ -283,7 +283,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
|
|||
else
|
||||
{
|
||||
// It is error, should return.
|
||||
CCLOG("Moving touches with id: %d error", id);
|
||||
CCLOG("Moving touches with id: %ld error", id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -299,9 +299,9 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
EventTouch touchEvent;
|
||||
|
@ -336,7 +336,7 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
|
|||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Ending touches with id: %d error", id);
|
||||
CCLOG("Ending touches with id: %ld error", id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -359,12 +359,12 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
|
|||
}
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesEnd(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesCancel(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
|
||||
}
|
||||
|
|
|
@ -136,10 +136,10 @@ public:
|
|||
const char* getViewName();
|
||||
|
||||
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
|
||||
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesBegin(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesEnd(int num, long ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesCancel(int num, long ids[], float xs[], float ys[]);
|
||||
|
||||
/**
|
||||
* Get the opengl view port rectangle.
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
*/
|
||||
float getScaleY() const;
|
||||
private:
|
||||
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]);
|
||||
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[]);
|
||||
|
||||
protected:
|
||||
EGLTouchDelegate* _delegate;
|
||||
|
|
|
@ -451,7 +451,7 @@ NS_CC_BEGIN
|
|||
|
||||
/* The subclass FileUtilsApple should override these two method. */
|
||||
Dictionary* FileUtils::createDictionaryWithContentsOfFile(const std::string& filename) {return NULL;}
|
||||
bool FileUtils::writeToFile(cocos2d::Dictionary *dict, const std::string &fullPath) {return NULL;}
|
||||
bool FileUtils::writeToFile(cocos2d::Dictionary *dict, const std::string &fullPath) {return false;}
|
||||
Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {return NULL;}
|
||||
|
||||
#endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */
|
||||
|
@ -488,7 +488,7 @@ void FileUtils::purgeCachedEntries()
|
|||
_fullPathCache.clear();
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, unsigned long * size)
|
||||
unsigned char* FileUtils::getFileData(const char* filename, const char* mode, long *size)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters.");
|
||||
|
@ -518,7 +518,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, un
|
|||
return buffer;
|
||||
}
|
||||
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long * size)
|
||||
unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, long *size)
|
||||
{
|
||||
unsigned char * buffer = NULL;
|
||||
unzFile pFile = NULL;
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size);
|
||||
virtual unsigned char* getFileData(const char* filename, const char* mode, long *size);
|
||||
|
||||
/**
|
||||
* Gets resource file data from a zip file.
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
|
||||
*/
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long *size);
|
||||
virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, long *size);
|
||||
|
||||
|
||||
/** Returns the fullpath for a given filename.
|
||||
|
|
|
@ -119,10 +119,10 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithImageData(const unsigned char * data, int dataLen);
|
||||
bool initWithImageData(const unsigned char * data, long dataLen);
|
||||
|
||||
// @warning kFmtRawData only support RGBA8888
|
||||
bool initWithRawData(const unsigned char * data, int dataLen, int width, int height, int bitsPerComponent, bool preMulti = false);
|
||||
bool initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti = false);
|
||||
|
||||
/**
|
||||
@brief Create image with specified string.
|
||||
|
|
|
@ -416,7 +416,7 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
|
||||
SDL_FreeSurface(iSurf);
|
||||
#else
|
||||
unsigned long bufferLen = 0;
|
||||
long bufferLen = 0;
|
||||
unsigned char* buffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &bufferLen);
|
||||
|
||||
if (buffer != nullptr && bufferLen > 0)
|
||||
|
@ -432,23 +432,23 @@ bool Image::initWithImageFile(const char * strPath)
|
|||
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned long dataLen = 0;
|
||||
bool ret = false;
|
||||
long dataLen = 0;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
FileUtilsAndroid *fileUitls = (FileUtilsAndroid*)FileUtils::getInstance();
|
||||
unsigned char *pBuffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen);
|
||||
unsigned char *buffer = fileUitls->getFileDataForAsync(fullpath, "rb", &dataLen);
|
||||
#else
|
||||
unsigned char *pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &dataLen);
|
||||
unsigned char *buffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &dataLen);
|
||||
#endif
|
||||
if (pBuffer != NULL && dataLen > 0)
|
||||
if (buffer != NULL && dataLen > 0)
|
||||
{
|
||||
bRet = initWithImageData(pBuffer, dataLen);
|
||||
ret = initWithImageData(buffer, dataLen);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
return bRet;
|
||||
CC_SAFE_DELETE_ARRAY(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Image::initWithImageData(const unsigned char * data, int dataLen)
|
||||
bool Image::initWithImageData(const unsigned char * data, long dataLen)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -1190,13 +1190,13 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
if (!testFormatForPvr2TCSupport(formatFlags))
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (v2_pixel_formathash.find(formatFlags) == v2_pixel_formathash.end())
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1204,7 @@ bool Image::initWithPVRv2Data(const unsigned char * data, int dataLen)
|
|||
|
||||
if (it == Texture2D::getPixelFormatInfoMap().end())
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", formatFlags);
|
||||
CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%02X. Re-encode it with a OpenGL pixel format variant", (int)formatFlags);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithRawData(const unsigned char * data, int dataLen, int width, int height, int bitsPerComponent, bool preMulti)
|
||||
bool Image::initWithRawData(const unsigned char * data, long dataLen, long width, long height, long bitsPerComponent, bool preMulti)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
|
|
@ -114,15 +114,15 @@ bool SAXParser::parse(const char* pXMLData, unsigned int uDataLength)
|
|||
|
||||
bool SAXParser::parse(const char *pszFile)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned long size = 0;
|
||||
bool ret = false;
|
||||
long size = 0;
|
||||
char* pBuffer = (char*)FileUtils::getInstance()->getFileData(pszFile, "rt", &size);
|
||||
if (pBuffer != NULL && size > 0)
|
||||
{
|
||||
bRet = parse(pBuffer, size);
|
||||
ret = parse(pBuffer, size);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SAXParser::startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts)
|
||||
|
|
|
@ -292,7 +292,7 @@ static void engine_term_display(struct engine* engine) {
|
|||
/*
|
||||
* Get X, Y positions and ID's for all pointers
|
||||
*/
|
||||
static void getTouchPos(AInputEvent *event, int ids[], float xs[], float ys[]) {
|
||||
static void getTouchPos(AInputEvent *event, long ids[], float xs[], float ys[]) {
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
for(int i = 0; i < pointerCount; ++i) {
|
||||
ids[i] = AMotionEvent_getPointerId(event, i);
|
||||
|
@ -321,7 +321,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -340,7 +340,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER DOWN x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -353,10 +353,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_MOVE");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
int ids[pointerCount];
|
||||
long ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(pointerCount, ids, xs, ys);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -369,7 +369,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,0);
|
||||
LOG_EVENTS_DEBUG("Event: Action UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerId);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -387,7 +387,7 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
float yP = AMotionEvent_getY(event,pointerIndex);
|
||||
LOG_EVENTS_DEBUG("Event: Action POINTER UP x=%f y=%f pointerID=%d\n",
|
||||
xP, yP, pointerIndex);
|
||||
int pId = pointerId;
|
||||
long pId = pointerId;
|
||||
float x = xP;
|
||||
float y = yP;
|
||||
|
||||
|
@ -400,10 +400,10 @@ static int32_t handle_touch_input(AInputEvent *event) {
|
|||
{
|
||||
LOG_EVENTS_DEBUG("AMOTION_EVENT_ACTION_CANCEL");
|
||||
int pointerCount = AMotionEvent_getPointerCount(event);
|
||||
int ids[pointerCount];
|
||||
long ids[pointerCount];
|
||||
float xs[pointerCount], ys[pointerCount];
|
||||
getTouchPos(event, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(pointerCount, ids, xs, ys);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -75,7 +75,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
|
|||
|
||||
#define IOS_MAX_TOUCHES_COUNT 10
|
||||
|
||||
static CCEAGLView *view = 0;
|
||||
static CCEAGLView *__view = 0;
|
||||
|
||||
@interface CCEAGLView (Private)
|
||||
- (BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup;
|
||||
|
@ -117,7 +117,7 @@ static CCEAGLView *view = 0;
|
|||
|
||||
+ (id) sharedEGLView
|
||||
{
|
||||
return view;
|
||||
return __view;
|
||||
}
|
||||
|
||||
- (id) initWithFrame:(CGRect)frame
|
||||
|
@ -147,14 +147,14 @@ static CCEAGLView *view = 0;
|
|||
}
|
||||
|
||||
|
||||
view = self;
|
||||
__view = self;
|
||||
|
||||
originalRect_ = self.frame;
|
||||
self.keyboardShowNotification = nil;
|
||||
|
||||
if ([view respondsToSelector:@selector(setContentScaleFactor:)])
|
||||
if ([__view respondsToSelector:@selector(setContentScaleFactor:)])
|
||||
{
|
||||
view.contentScaleFactor = [[UIScreen mainScreen] scale];
|
||||
__view.contentScaleFactor = [[UIScreen mainScreen] scale];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ static CCEAGLView *view = 0;
|
|||
}
|
||||
}
|
||||
|
||||
view = self;
|
||||
__view = self;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -205,13 +205,13 @@ static CCEAGLView *view = 0;
|
|||
-(int) getWidth
|
||||
{
|
||||
CGSize bound = [self bounds].size;
|
||||
return bound.width * self.contentScaleFactor;
|
||||
return (int)bound.width * self.contentScaleFactor;
|
||||
}
|
||||
|
||||
-(int) getHeight
|
||||
{
|
||||
CGSize bound = [self bounds].size;
|
||||
return bound.height * self.contentScaleFactor;
|
||||
return (int)bound.height * self.contentScaleFactor;
|
||||
}
|
||||
|
||||
|
||||
|
@ -399,18 +399,18 @@ static CCEAGLView *view = 0;
|
|||
return;
|
||||
}
|
||||
|
||||
int ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
|
||||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -419,18 +419,18 @@ static CCEAGLView *view = 0;
|
|||
{
|
||||
return;
|
||||
}
|
||||
int ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
|
||||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -440,18 +440,18 @@ static CCEAGLView *view = 0;
|
|||
return;
|
||||
}
|
||||
|
||||
int ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
|
||||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -461,18 +461,18 @@ static CCEAGLView *view = 0;
|
|||
return;
|
||||
}
|
||||
|
||||
int ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
|
||||
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
|
||||
|
||||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = (int)touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
|
|
@ -186,7 +186,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ static CCEAGLView *view;
|
|||
float x = local_point.x;
|
||||
float y = [self getHeight] - local_point.y;
|
||||
|
||||
int ids[1] = {0};
|
||||
NSInteger ids[1] = {0};
|
||||
float xs[1] = {0.0f};
|
||||
float ys[1] = {0.0f};
|
||||
|
||||
|
@ -335,7 +335,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesBegin(1, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
|
@ -351,7 +351,7 @@ static CCEAGLView *view;
|
|||
float x = local_point.x;
|
||||
float y = [self getHeight] - local_point.y;
|
||||
|
||||
int ids[1] = {0};
|
||||
NSInteger ids[1] = {0};
|
||||
float xs[1] = {0.0f};
|
||||
float ys[1] = {0.0f};
|
||||
|
||||
|
@ -359,7 +359,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(1, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent
|
||||
|
@ -370,7 +370,7 @@ static CCEAGLView *view;
|
|||
float x = local_point.x;
|
||||
float y = [self getHeight] - local_point.y;
|
||||
|
||||
int ids[1] = {0};
|
||||
NSInteger ids[1] = {0};
|
||||
float xs[1] = {0.0f};
|
||||
float ys[1] = {0.0f};
|
||||
|
||||
|
@ -378,7 +378,7 @@ static CCEAGLView *view;
|
|||
xs[0] = x / frameZoomFactor_;
|
||||
ys[0] = y / frameZoomFactor_;
|
||||
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, ids, xs, ys);
|
||||
cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesEnd(1, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)rightMouseDown:(NSEvent *)theEvent {
|
||||
|
|
|
@ -303,7 +303,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = true;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in
|
|||
s_captured = false;
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
|||
{
|
||||
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
|
||||
{
|
||||
int id = 0;
|
||||
long id = 0;
|
||||
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,14 @@ add_library(audio STATIC
|
|||
${AUDIO_SRC}
|
||||
)
|
||||
|
||||
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(FMOD_LIB "fmodex64")
|
||||
else()
|
||||
set(FMOD_LIB "fmodex")
|
||||
endif()
|
||||
|
||||
target_link_libraries(audio
|
||||
fmodex64
|
||||
${FMOD_LIB}
|
||||
)
|
||||
|
||||
set_target_properties(audio
|
||||
|
|
|
@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(int capacity)
|
||||
Array* Array::createWithCapacity(long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(int capacity)
|
||||
bool Array::initWithCapacity(long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -200,7 +200,7 @@ int Array::getIndexOfObject(Object* object) const
|
|||
{
|
||||
auto it = data.begin();
|
||||
|
||||
for (int i = 0; it != data.end(); ++it, ++i)
|
||||
for (long i = 0; it != data.end(); ++it, ++i)
|
||||
{
|
||||
if (it->get() == object)
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ bool Array::containsObject(Object* object) const
|
|||
|
||||
bool Array::isEqualToArray(Array* otherArray)
|
||||
{
|
||||
for (int i = 0; i< this->count(); i++)
|
||||
for (long i = 0; i< this->count(); i++)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -279,7 +279,7 @@ void Array::removeObject(Object* object, bool releaseObj /* ignored */)
|
|||
data.erase( std::remove( data.begin(), data.end(), object ) );
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */)
|
||||
void Array::removeObjectAtIndex(long index, bool releaseObj /* ignored */)
|
||||
{
|
||||
auto obj = data[index];
|
||||
data.erase( data.begin() + index );
|
||||
|
@ -295,7 +295,7 @@ void Array::removeAllObjects()
|
|||
data.erase(std::begin(data), std::end(data));
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(int index)
|
||||
void Array::fastRemoveObjectAtIndex(long index)
|
||||
{
|
||||
removeObjectAtIndex(index);
|
||||
}
|
||||
|
@ -315,12 +315,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
|
|||
std::swap( data[idx1], data[idx2] );
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(int index1, int index2)
|
||||
void Array::exchangeObjectAtIndex(long index1, long index2)
|
||||
{
|
||||
std::swap( data[index1], data[index2] );
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */)
|
||||
void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject /* ignored */)
|
||||
{
|
||||
data[index] = object;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(int capacity)
|
||||
Array* Array::createWithCapacity(long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -531,7 +531,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(int capacity)
|
||||
bool Array::initWithCapacity(long capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized");
|
||||
|
||||
|
@ -555,7 +555,7 @@ bool Array::initWithArray(Array* otherArray)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int Array::getIndexOfObject(Object* object) const
|
||||
long Array::getIndexOfObject(Object* object) const
|
||||
{
|
||||
return ccArrayGetIndexOfObject(data, object);
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ Object* Array::getRandomObject()
|
|||
r = 0;
|
||||
}
|
||||
|
||||
return data->arr[(int)(data->num * r)];
|
||||
return data->arr[(long)(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 (int i = 0; i< this->count(); i++)
|
||||
for (long i = 0; i< this->count(); i++)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -606,13 +606,13 @@ void Array::addObjectsFromArray(Array* otherArray)
|
|||
ccArrayAppendArrayWithResize(data, otherArray->data);
|
||||
}
|
||||
|
||||
void Array::insertObject(Object* object, int index)
|
||||
void Array::insertObject(Object* object, long index)
|
||||
{
|
||||
CCASSERT(data, "Array not initialized");
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
}
|
||||
|
||||
void Array::setObject(Object* object, int index)
|
||||
void Array::setObject(Object* object, long index)
|
||||
{
|
||||
CCASSERT(index>=0 && index < count(), "Invalid index");
|
||||
|
||||
|
@ -635,7 +635,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/)
|
|||
ccArrayRemoveObject(data, object, releaseObj);
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(int index, bool releaseObj)
|
||||
void Array::removeObjectAtIndex(long index, bool releaseObj)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(data, index, releaseObj);
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ void Array::removeAllObjects()
|
|||
ccArrayRemoveAllObjects(data);
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(int index)
|
||||
void Array::fastRemoveObjectAtIndex(long index)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(data, index);
|
||||
}
|
||||
|
@ -662,14 +662,14 @@ void Array::fastRemoveObject(Object* object)
|
|||
|
||||
void Array::exchangeObject(Object* object1, Object* object2)
|
||||
{
|
||||
int index1 = ccArrayGetIndexOfObject(data, object1);
|
||||
if (index1 == UINT_MAX)
|
||||
long index1 = ccArrayGetIndexOfObject(data, object1);
|
||||
if (index1 == CC_INVALID_INDEX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index2 = ccArrayGetIndexOfObject(data, object2);
|
||||
if (index2 == UINT_MAX)
|
||||
long index2 = ccArrayGetIndexOfObject(data, object2);
|
||||
if (index2 == CC_INVALID_INDEX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -677,12 +677,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
|
|||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(int index1, int index2)
|
||||
void Array::exchangeObjectAtIndex(long index1, long index2)
|
||||
{
|
||||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/)
|
||||
void Array::replaceObjectAtIndex(long index, Object* object, bool releaseObject/* = true*/)
|
||||
{
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
ccArrayRemoveObjectAtIndex(data, index+1);
|
||||
|
@ -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
|
||||
int count = (int) floorf(data->num/2.f);
|
||||
int maxIndex = data->num - 1;
|
||||
long count = (long) floorf(data->num/2.f);
|
||||
long maxIndex = data->num - 1;
|
||||
|
||||
for (int i = 0; i < count ; i++)
|
||||
for (long 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(int capacity);
|
||||
static Array* createWithCapacity(long capacity);
|
||||
/** Create an array with from an existing array
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithCapacity(int capacity);
|
||||
bool initWithCapacity(long 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
|
||||
*/
|
||||
int count() const
|
||||
long count() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.size();
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
/** Returns capacity of the array
|
||||
* @js NA
|
||||
*/
|
||||
int capacity() const
|
||||
long capacity() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.capacity();
|
||||
|
@ -330,17 +330,17 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
int getIndexOfObject(Object* object) const;
|
||||
long getIndexOfObject(Object* object) const;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
CC_DEPRECATED_ATTRIBUTE long indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
|
||||
/** Returns an element with a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* getObjectAtIndex(int index)
|
||||
Object* getObjectAtIndex(long 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(int index) { return getObjectAtIndex(index); }
|
||||
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(long 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, int index);
|
||||
void insertObject(Object* object, long index);
|
||||
/** sets a certain object at a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setObject(Object* object, int index);
|
||||
void setObject(Object* object, long index);
|
||||
/** sets a certain object at a certain index without retaining. Use it with caution
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void fastSetObject(Object* object, int index)
|
||||
void fastSetObject(Object* object, long index)
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
setObject(object, index);
|
||||
|
@ -424,7 +424,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void swap( int indexOne, int indexTwo )
|
||||
void swap( long indexOne, long 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(int index, bool releaseObj = true);
|
||||
void removeObjectAtIndex(long 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(int index);
|
||||
void fastRemoveObjectAtIndex(long index);
|
||||
|
||||
// Rearranging Content
|
||||
|
||||
|
@ -474,12 +474,12 @@ public:
|
|||
/** Swap two elements with certain indexes
|
||||
* @js NA
|
||||
*/
|
||||
void exchangeObjectAtIndex(int index1, int index2);
|
||||
void exchangeObjectAtIndex(long index1, long index2);
|
||||
|
||||
/** Replace object at index with another object.
|
||||
* @js NA
|
||||
*/
|
||||
void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true);
|
||||
void replaceObjectAtIndex(long index, Object* object, bool releaseObject = true);
|
||||
|
||||
/** Revers the array
|
||||
* @js NA
|
||||
|
|
|
@ -216,15 +216,15 @@ bool String::isEqual(const Object* pObject)
|
|||
|
||||
String* String::create(const std::string& str)
|
||||
{
|
||||
String* pRet = new String(str);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
String* ret = new String(str);
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithData(const unsigned char* pData, unsigned long nLen)
|
||||
String* String::createWithData(const unsigned char* data, unsigned long nLen)
|
||||
{
|
||||
String* pRet = NULL;
|
||||
if (pData != NULL)
|
||||
String* ret = NULL;
|
||||
if (data != NULL)
|
||||
{
|
||||
char* pStr = (char*)malloc(nLen+1);
|
||||
if (pStr != NULL)
|
||||
|
@ -232,36 +232,36 @@ String* String::createWithData(const unsigned char* pData, unsigned long nLen)
|
|||
pStr[nLen] = '\0';
|
||||
if (nLen > 0)
|
||||
{
|
||||
memcpy(pStr, pData, nLen);
|
||||
memcpy(pStr, data, nLen);
|
||||
}
|
||||
|
||||
pRet = String::create(pStr);
|
||||
ret = String::create(pStr);
|
||||
free(pStr);
|
||||
}
|
||||
}
|
||||
return pRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithFormat(const char* format, ...)
|
||||
{
|
||||
String* pRet = String::create("");
|
||||
String* ret = String::create("");
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
pRet->initWithFormatAndValist(format, ap);
|
||||
ret->initWithFormatAndValist(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return pRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
String* String::createWithContentsOfFile(const char* filename)
|
||||
{
|
||||
unsigned long size = 0;
|
||||
unsigned char* pData = 0;
|
||||
String* pRet = NULL;
|
||||
pData = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
pRet = String::createWithData(pData, size);
|
||||
CC_SAFE_DELETE_ARRAY(pData);
|
||||
return pRet;
|
||||
long size = 0;
|
||||
unsigned char* data = 0;
|
||||
String* ret = NULL;
|
||||
data = FileUtils::getInstance()->getFileData(filename, "rb", &size);
|
||||
ret = String::createWithData(data, size);
|
||||
CC_SAFE_DELETE_ARRAY(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void String::acceptVisitor(DataVisitor &visitor)
|
||||
|
|
|
@ -244,7 +244,7 @@ Node* CCBReader::readNodeGraphFromFile(const char *pCCBFileName, Object *pOwner,
|
|||
}
|
||||
|
||||
std::string strPath = FileUtils::getInstance()->fullPathForFilename(strCCBFileName.c_str());
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
|
||||
unsigned char * pBytes = FileUtils::getInstance()->getFileData(strPath.c_str(), "rb", &size);
|
||||
Data *data = new Data(pBytes, size);
|
||||
|
|
|
@ -918,7 +918,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
|||
|
||||
// Load sub file
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename(ccbFileName.c_str());
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
unsigned char * pBytes = FileUtils::getInstance()->getFileData(path.c_str(), "rb", &size);
|
||||
|
||||
CCBReader * reader = new CCBReader(pCCBReader);
|
||||
|
|
|
@ -424,7 +424,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
|
|||
bool bFindFrame = false;
|
||||
|
||||
ActionFrame* srcFrame = NULL;
|
||||
ActionFrame* destFrame = NULL;
|
||||
// ActionFrame* destFrame = NULL;
|
||||
|
||||
for (int n = 0; n < _frameArrayNum; n++)
|
||||
{
|
||||
|
|
|
@ -298,7 +298,7 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
size_t startPos = filePathStr.find_last_of(".");
|
||||
std::string str = &filePathStr[startPos];
|
||||
|
||||
unsigned long size;
|
||||
long size;
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
const char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
|
@ -389,7 +389,7 @@ void DataReaderHelper::addDataFromFileAsync(const char *filePath, Object *target
|
|||
std::string str = &filePathStr[startPos];
|
||||
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
unsigned long size;
|
||||
long size;
|
||||
data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
|
|
|
@ -207,7 +207,7 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName)
|
|||
JsonDictionary *jsonDict = NULL;
|
||||
jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
des = (char*)(FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size));
|
||||
if(NULL == des || strcmp(des, "") == 0)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName)
|
|||
}
|
||||
|
||||
int texturesCount = DICTOOL->getArrayCount_json(jsonDict, "textures");
|
||||
int pos = jsonpath.find_last_of('/');
|
||||
long pos = jsonpath.find_last_of('/');
|
||||
m_strFilePath = jsonpath.substr(0,pos+1);
|
||||
for (int i=0; i<texturesCount; i++)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace cocostudio {
|
|||
|
||||
cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName)
|
||||
{
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
cocos2d::Node *pNode = NULL;
|
||||
do {
|
||||
|
@ -213,7 +213,7 @@ namespace cocostudio {
|
|||
{
|
||||
file_path = reDir.substr(0, pos+1);
|
||||
}
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size));
|
||||
JsonDictionary *jsonDict = new JsonDictionary();
|
||||
jsonDict->initWithDescription(des);
|
||||
|
@ -227,7 +227,7 @@ namespace cocostudio {
|
|||
const char *name = DICTOOL->getStringValue_json(subData, "name");
|
||||
|
||||
childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path");
|
||||
for (int i = 0; i < childrenCount; ++i)
|
||||
for (long i = 0; i < childrenCount; ++i)
|
||||
{
|
||||
const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i);
|
||||
std::string plistpath;
|
||||
|
@ -283,7 +283,7 @@ namespace cocostudio {
|
|||
if (nResType == 0)
|
||||
{
|
||||
pAttribute = ComAttribute::create();
|
||||
unsigned long size = 0;
|
||||
long size = 0;
|
||||
const char* pData = 0;
|
||||
pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size));
|
||||
if(pData != NULL && strcmp(pData, "") != 0)
|
||||
|
|
|
@ -47,7 +47,7 @@ void _AtlasPage_disposeTexture (AtlasPage* self) {
|
|||
}
|
||||
|
||||
char* _Util_readFile (const char* path, int* length) {
|
||||
unsigned long size;
|
||||
long size;
|
||||
char* data = reinterpret_cast<char*>(FileUtils::getInstance()->getFileData(
|
||||
FileUtils::getInstance()->fullPathForFilename(path).c_str(), "r", &size));
|
||||
*length = size;
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace gui {
|
|||
class UIHelper
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Finds a widget whose tag equals to param tag from root widget.
|
||||
*
|
||||
|
|
|
@ -216,7 +216,7 @@ kmMat4* const kmMat4Transpose(kmMat4* pOut, const kmMat4* pIn)
|
|||
*/
|
||||
kmMat4* const kmMat4Multiply(kmMat4* pOut, const kmMat4* pM1, const kmMat4* pM2)
|
||||
{
|
||||
#if defined(__ARM_NEON__)
|
||||
#if defined(__ARM_NEON__) && !defined(__arm64__)
|
||||
|
||||
// It is possible to skip the memcpy() since "out" does not overwrite p1 or p2.
|
||||
// otherwise a temp must be needed.
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
#include "kazmath/neon_matrix_impl.h"
|
||||
|
||||
#if defined(__ARM_NEON__)
|
||||
#if defined(__ARM_NEON__) && !defined(__arm64__)
|
||||
|
||||
|
||||
void NEON_Matrix4Mul(const float* a, const float* b, float* output )
|
||||
{
|
||||
|
|
|
@ -9,6 +9,10 @@ add_library(network STATIC
|
|||
|
||||
target_link_libraries(network
|
||||
curl
|
||||
ldap
|
||||
lber
|
||||
idn
|
||||
rtmp
|
||||
)
|
||||
|
||||
set_target_properties(network
|
||||
|
|
|
@ -600,7 +600,7 @@ Point* PhysicsShapePolygon::getPoints(Point* points) const
|
|||
return PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, points, ((cpPolyShape*)shape)->numVerts);
|
||||
}
|
||||
|
||||
int PhysicsShapePolygon::getPointsCount() const
|
||||
long PhysicsShapePolygon::getPointsCount() const
|
||||
{
|
||||
return ((cpPolyShape*)_info->shapes.front())->numVerts;
|
||||
}
|
||||
|
@ -715,7 +715,7 @@ Point PhysicsShapeEdgePolygon::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
int PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
long PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
{
|
||||
return _info->shapes.size() + 1;
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ Point PhysicsShapeEdgeChain::getCenter()
|
|||
return _center;
|
||||
}
|
||||
|
||||
int PhysicsShapeEdgeChain::getPointsCount() const
|
||||
long PhysicsShapeEdgeChain::getPointsCount() const
|
||||
{
|
||||
return _info->shapes.size() + 1;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ typedef struct PhysicsMaterial
|
|||
, friction(0.0f)
|
||||
{}
|
||||
|
||||
PhysicsMaterial(float density, float restitution, float friction)
|
||||
: density(density)
|
||||
, restitution(restitution)
|
||||
, friction(friction)
|
||||
PhysicsMaterial(float aDensity, float aRestitution, float aFriction)
|
||||
: density(aDensity)
|
||||
, restitution(aRestitution)
|
||||
, friction(aFriction)
|
||||
{}
|
||||
}PhysicsMaterial;
|
||||
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
float calculateDefaultMoment() override;
|
||||
|
||||
Point* getPoints(Point* points) const;
|
||||
int getPointsCount() const;
|
||||
long getPointsCount() const;
|
||||
Point getCenter() override;
|
||||
protected:
|
||||
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, Point offset = Point(0, 0));
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
static PhysicsShapeEdgeBox* create(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, Point offset = Point(0, 0));
|
||||
Point getOffset() override { return _offset; }
|
||||
Point* getPoints(Point* points) const;
|
||||
int getPointsCount() const;
|
||||
long getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(Size size, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, Point offset = Point(0, 0));
|
||||
|
@ -269,7 +269,7 @@ public:
|
|||
static PhysicsShapeEdgePolygon* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
Point getCenter() override;
|
||||
Point* getPoints(Point* points) const;
|
||||
int getPointsCount() const;
|
||||
long getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
|
@ -291,7 +291,7 @@ public:
|
|||
static PhysicsShapeEdgeChain* create(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
Point getCenter() override;
|
||||
Point* getPoints(Point* points) const;
|
||||
int getPointsCount() const;
|
||||
long getPointsCount() const;
|
||||
|
||||
protected:
|
||||
bool init(Point* points, int count, PhysicsMaterial material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
|
|
|
@ -465,9 +465,9 @@ void PhysicsWorld::debugDraw()
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joint)
|
||||
void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joints)
|
||||
{
|
||||
for (auto it = joint->_info->joints.begin(); it != joint->_info->joints.end(); ++it)
|
||||
for (auto it = joints->_info->joints.begin(); it != joints->_info->joints.end(); ++it)
|
||||
{
|
||||
cpConstraint *constraint = *it;
|
||||
|
||||
|
@ -526,9 +526,9 @@ void PhysicsWorld::drawWithJoint(DrawNode* node, PhysicsJoint* joint)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape)
|
||||
void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shapes)
|
||||
{
|
||||
for (auto it = shape->_info->shapes.begin(); it != shape->_info->shapes.end(); ++it)
|
||||
for (auto it = shapes->_info->shapes.begin(); it != shapes->_info->shapes.end(); ++it)
|
||||
{
|
||||
cpShape *shape = *it;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
set(LUABINDING_SRC
|
||||
auto-generated/lua-bindings/lua_cocos2dx_auto.cpp
|
||||
auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp
|
||||
auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp
|
||||
lua/bindings/tolua_fix.c
|
||||
lua/bindings/CCLuaBridge.cpp
|
||||
lua/bindings/CCLuaEngine.cpp
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 006193d9b4081c8af2b79be3cd9bcf90aedfdbae
|
||||
Subproject commit 9b0b068f923249440b8a8c758b1c06d29f6cbdfe
|
|
@ -96,6 +96,7 @@ static void executeJSFunctionFromReservedSpot(JSContext *cx, JSObject *obj,
|
|||
if (func == JSVAL_VOID) { return; }
|
||||
jsval thisObj = JS_GetReservedSlot(obj, 1);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
if (thisObj == JSVAL_VOID) {
|
||||
JS_CallFunctionValue(cx, obj, func, 1, &dataVal, &retval);
|
||||
} else {
|
||||
|
@ -527,7 +528,7 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c
|
|||
|
||||
// a) check jsc file first
|
||||
std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT;
|
||||
unsigned long length = 0;
|
||||
long length = 0;
|
||||
unsigned char* data = futil->getFileData(byteCodePath.c_str(),
|
||||
"rb",
|
||||
&length);
|
||||
|
|
|
@ -320,6 +320,8 @@ public:
|
|||
JS_RemoveObjectRoot(this->_cx, &this->_jsthis);
|
||||
}
|
||||
JSBool invoke(unsigned int argc, jsval *argv, jsval &rval) {
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
return JS_CallFunctionValue(this->_cx, this->_jsthis, this->_fval, argc, argv, &rval);
|
||||
}
|
||||
private:
|
||||
|
|
|
@ -638,6 +638,8 @@ static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval rval;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->begin), 2, args, &rval);
|
||||
|
@ -662,6 +664,8 @@ static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval rval;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->pre), 2, args, &rval);
|
||||
|
@ -687,6 +691,8 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval ignore;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->post), 2, args, &ignore);
|
||||
|
@ -705,6 +711,8 @@ static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data)
|
|||
args[0] = opaque_to_jsval( handler->cx, arb);
|
||||
args[1] = opaque_to_jsval( handler->cx, space );
|
||||
}
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval ignore;
|
||||
JSBool ok = JS_CallFunctionValue( handler->cx, handler->jsthis, OBJECT_TO_JSVAL(handler->separate), 2, args, &ignore);
|
||||
|
|
|
@ -1 +1 @@
|
|||
c93df276adb92b5e076db49c4f9482b8eb37d45c
|
||||
927efea93a520eeb9db9f62c8d8eb7a7b93b08dc
|
|
@ -14,6 +14,8 @@ public:
|
|||
jsval retval = JSVAL_NULL;
|
||||
|
||||
if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) {
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *pArmature, co
|
|||
valArr[2] = idVal;
|
||||
|
||||
JS_AddValueRoot(cx, valArr);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 3, valArr, &retval);
|
||||
JS_RemoveValueRoot(cx, valArr);
|
||||
}
|
||||
|
@ -88,6 +91,9 @@ void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent)
|
|||
jsval percentVal = DOUBLE_TO_JSVAL(percent);
|
||||
|
||||
JS_AddValueRoot(cx, &percentVal);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 1, &percentVal, &retval);
|
||||
JS_RemoveValueRoot(cx, &percentVal);
|
||||
}
|
||||
|
@ -113,6 +119,9 @@ void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *pBone, const char *f
|
|||
valArr[3] = currentIndexVal;
|
||||
|
||||
JS_AddValueRoot(cx, valArr);
|
||||
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
JS_CallFunctionValue(cx, thisObj, _jsCallback, 4, valArr, &retval);
|
||||
JS_RemoveValueRoot(cx, valArr);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ LOCAL_SRC_FILES := CCLuaBridge.cpp \
|
|||
LuaBasicConversions.cpp \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \
|
||||
lua_cocos2dx_manual.cpp \
|
||||
lua_cocos2dx_extension_manual.cpp \
|
||||
lua_cocos2dx_deprecated.cpp \
|
||||
|
|
|
@ -54,6 +54,7 @@ extern "C" {
|
|||
#include "lua_cocos2dx_extension_manual.h"
|
||||
#include "lua_cocos2dx_deprecated.h"
|
||||
#include "lua_xml_http_request.h"
|
||||
#include "lua_cocos2dx_studio_auto.hpp"
|
||||
|
||||
namespace {
|
||||
int lua_print(lua_State * luastate)
|
||||
|
@ -135,6 +136,7 @@ bool LuaStack::init(void)
|
|||
register_all_cocos2dx_deprecated(_state);
|
||||
register_cocos2dx_extension_CCBProxy(_state);
|
||||
tolua_opengl_open(_state);
|
||||
register_all_cocos2dx_studio(_state);
|
||||
register_all_cocos2dx_manual(_state);
|
||||
register_all_cocos2dx_extension_manual(_state);
|
||||
register_all_cocos2dx_manual_deprecated(_state);
|
||||
|
|
|
@ -46,7 +46,7 @@ extern "C"
|
|||
}
|
||||
filename.append(".lua");
|
||||
|
||||
unsigned long codeBufferSize = 0;
|
||||
long codeBufferSize = 0;
|
||||
unsigned char* codeBuffer = FileUtils::getInstance()->getFileData(filename.c_str(), "rb", &codeBufferSize);
|
||||
|
||||
if (codeBuffer)
|
||||
|
|
|
@ -49,6 +49,7 @@ SOURCES = ../../../../external/lua/lua/lapi.c \
|
|||
tolua_fix.c \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \
|
||||
../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \
|
||||
CCLuaBridge.cpp \
|
||||
CCLuaEngine.cpp \
|
||||
CCLuaStack.cpp \
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
#endif
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define CURL_SIZEOF_LONG 4
|
||||
#define CURL_SIZEOF_LONG sizeof(long)
|
||||
|
||||
/* Integral data type used for curl_socklen_t. */
|
||||
#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
|
|
|
@ -18,5 +18,8 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES( ${APP_NAME} )
|
||||
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
|
||||
)
|
||||
|
||||
|
|
|
@ -159,5 +159,8 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES( ${APP_NAME} )
|
||||
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
|
||||
)
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES( ${APP_NAME} )
|
||||
|
||||
COPY_RES_EXTRA(${APP_NAME} copy_core_scripts ${CMAKE_SOURCE_DIR}/cocos/scripting/lua
|
||||
script/*
|
||||
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
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua/script ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
|
|
@ -33,11 +33,10 @@ set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}")
|
|||
set_target_properties(${APP_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
|
||||
|
||||
COPY_RES(${APP_NAME})
|
||||
COPY_RES_EXTRA(${APP_NAME} copy_core_scripts ${CMAKE_SOURCE_DIR}/cocos/scripting/lua
|
||||
script/*
|
||||
)
|
||||
COPY_RES_EXTRA(${APP_NAME} copy_cpp_res ${CMAKE_SOURCE_DIR}/samples/Cpp/TestCpp/Resources
|
||||
*
|
||||
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
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua/script ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/samples/Cpp/TestCpp/Resources ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
||||
|
|
|
@ -4,16 +4,15 @@ local scheduler = cc.Director:getInstance():getScheduler()
|
|||
local ArmatureTestIndex =
|
||||
{
|
||||
TEST_COCOSTUDIO_WITH_SKELETON = 1,
|
||||
TEST_COCOSTUDIO_WITHOUT_SKELETON = 2,
|
||||
TEST_DRAGON_BONES_2_0 = 3,
|
||||
TEST_PERFORMANCE = 4,
|
||||
TEST_CHANGE_ZORDER = 5,
|
||||
TEST_ANIMATION_EVENT = 6,
|
||||
TEST_PARTICLE_DISPLAY = 7,
|
||||
TEST_USE_DIFFERENT_PICTURE = 8,
|
||||
TEST_BOUDINGBOX = 9,
|
||||
TEST_ANCHORPOINT = 10,
|
||||
TEST_ARMATURE_NESTING = 11,
|
||||
TEST_DRAGON_BONES_2_0 = 2,
|
||||
TEST_PERFORMANCE = 3,
|
||||
TEST_CHANGE_ZORDER = 4,
|
||||
TEST_ANIMATION_EVENT = 5,
|
||||
TEST_PARTICLE_DISPLAY = 6,
|
||||
TEST_USE_DIFFERENT_PICTURE = 7,
|
||||
TEST_BOUDINGBOX = 8,
|
||||
TEST_ANCHORPOINT = 9,
|
||||
TEST_ARMATURE_NESTING = 10,
|
||||
}
|
||||
local armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON
|
||||
|
||||
|
@ -31,13 +30,13 @@ function ArmatureTestScene.extend(target)
|
|||
end
|
||||
|
||||
function ArmatureTestScene:runThisTest()
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/TestBone0.png", "armature/TestBone0.plist", "armature/TestBone.json")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Cowboy0.png", "armature/Cowboy0.plist", "armature/Cowboy.ExportJson")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/knight.png", "armature/knight.plist", "armature/knight.xml")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/weapon.png", "armature/weapon.plist", "armature/weapon.xml")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/robot.png", "armature/robot.plist", "armature/robot.xml")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml")
|
||||
cc.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/TestBone0.png", "armature/TestBone0.plist", "armature/TestBone.json")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Cowboy0.png", "armature/Cowboy0.plist", "armature/Cowboy.ExportJson")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/knight.png", "armature/knight.plist", "armature/knight.xml")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/weapon.png", "armature/weapon.plist", "armature/weapon.xml")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/robot.png", "armature/robot.plist", "armature/robot.xml")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/cyborg.png", "armature/cyborg.plist", "armature/cyborg.xml")
|
||||
ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/Dragon.png", "armature/Dragon.plist", "armature/Dragon.xml")
|
||||
|
||||
armatureSceneIdx = ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON
|
||||
self:addChild(restartArmatureTest())
|
||||
|
@ -59,7 +58,7 @@ function ArmatureTestScene.create()
|
|||
end
|
||||
|
||||
function ArmatureTestScene.toMainMenuCallback()
|
||||
cc.ArmatureDataManager:purgeArmatureSystem()
|
||||
ccs.ArmatureDataManager:purgeArmatureSystem()
|
||||
end
|
||||
|
||||
local ArmatureTestLayer = class("ArmatureTestLayer")
|
||||
|
@ -72,8 +71,6 @@ end
|
|||
function ArmatureTestLayer.title(idx)
|
||||
if ArmatureTestIndex.TEST_COCOSTUDIO_WITH_SKELETON == idx then
|
||||
return "Test Export From CocoStudio With Skeleton Effect"
|
||||
elseif ArmatureTestIndex.TEST_COCOSTUDIO_WITHOUT_SKELETON == idx then
|
||||
return "Test Export From CocoStudio Without Skeleton Effect"
|
||||
elseif ArmatureTestIndex.TEST_DRAGON_BONES_2_0 == idx then
|
||||
return "Test Export From DragonBones version 2.0"
|
||||
elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then
|
||||
|
@ -209,7 +206,7 @@ function TestCSWithSkeleton.extend(target)
|
|||
end
|
||||
|
||||
function TestCSWithSkeleton:onEnter()
|
||||
local armature = cc.Armature:create("Cowboy")
|
||||
local armature = ccs.Armature:create("Cowboy")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setScale(0.2)
|
||||
armature:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
|
@ -230,40 +227,6 @@ function TestCSWithSkeleton.create()
|
|||
return layer
|
||||
end
|
||||
|
||||
local TestCSWithoutSkeleton = class("TestCSWithoutSkeleton",ArmatureTestLayer)
|
||||
TestCSWithoutSkeleton.__index = TestCSWithoutSkeleton
|
||||
|
||||
function TestCSWithoutSkeleton.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, TestCSWithoutSkeleton)
|
||||
return target
|
||||
end
|
||||
|
||||
function TestCSWithoutSkeleton:onEnter()
|
||||
local armature = cc.Armature:create("TestBone")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setScale(0.2)
|
||||
armature:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2))
|
||||
self:addChild(armature)
|
||||
end
|
||||
|
||||
function TestCSWithoutSkeleton.create()
|
||||
local layer = TestCSWithoutSkeleton.extend(cc.Layer:create())
|
||||
|
||||
if nil ~= layer then
|
||||
layer:createMenu()
|
||||
layer:createToExtensionMenu()
|
||||
layer:onEnter()
|
||||
layer:creatTitleAndSubTitle(armatureSceneIdx)
|
||||
end
|
||||
return layer
|
||||
end
|
||||
|
||||
local TestDragonBones20 = class("TestDragonBones20",ArmatureTestLayer)
|
||||
TestDragonBones20.__index = TestDragonBones20
|
||||
|
||||
|
@ -278,7 +241,7 @@ function TestDragonBones20.extend(target)
|
|||
end
|
||||
|
||||
function TestDragonBones20:onEnter()
|
||||
local armature = cc.Armature:create("Dragon")
|
||||
local armature = ccs.Armature:create("Dragon")
|
||||
armature:getAnimation():playByIndex(1)
|
||||
armature:getAnimation():setAnimationScale(0.4)
|
||||
armature:setScale(0.6)
|
||||
|
@ -320,7 +283,7 @@ function TestPerformance.update(delta)
|
|||
TestPerformance.times = TestPerformance.times + delta
|
||||
if TestPerformance.times > 0.25 then
|
||||
TestPerformance.time = 0
|
||||
local armature = cc.Armature:create("Knight_f/Knight")
|
||||
local armature = ccs.Armature:create("Knight_f/Knight")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setPosition(cc.p(50 + TestPerformance.armatureCount * 5, winSize.height / 2))
|
||||
armature:setScale(0.6)
|
||||
|
@ -363,40 +326,6 @@ function TestPerformance.create()
|
|||
return layer
|
||||
end
|
||||
|
||||
local TestCSWithoutSkeleton = class("TestCSWithoutSkeleton",ArmatureTestLayer)
|
||||
TestCSWithoutSkeleton.__index = TestCSWithoutSkeleton
|
||||
|
||||
function TestCSWithoutSkeleton.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, TestCSWithoutSkeleton)
|
||||
return target
|
||||
end
|
||||
|
||||
function TestCSWithoutSkeleton:onEnter()
|
||||
local armature = cc.Armature:create("TestBone")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setScale(0.2)
|
||||
armature:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2))
|
||||
self:addChild(armature)
|
||||
end
|
||||
|
||||
function TestCSWithoutSkeleton.create()
|
||||
local layer = TestCSWithoutSkeleton.extend(cc.Layer:create())
|
||||
|
||||
if nil ~= layer then
|
||||
layer:createMenu()
|
||||
layer:createToExtensionMenu()
|
||||
layer:onEnter()
|
||||
layer:creatTitleAndSubTitle(armatureSceneIdx)
|
||||
end
|
||||
return layer
|
||||
end
|
||||
|
||||
local TestChangeZorder = class("TestChangeZorder",ArmatureTestLayer)
|
||||
TestChangeZorder.__index = TestChangeZorder
|
||||
TestChangeZorder.currentTag = -1
|
||||
|
@ -414,21 +343,21 @@ end
|
|||
function TestChangeZorder:onEnter()
|
||||
self.currentTag = -1
|
||||
|
||||
local armature = cc.Armature:create("Knight_f/Knight")
|
||||
local armature = ccs.Armature:create("Knight_f/Knight")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 ))
|
||||
armature:setScale(0.6)
|
||||
self.currentTag = self.currentTag + 1
|
||||
self:addChild(armature, self.currentTag, self.currentTag)
|
||||
|
||||
armature = cc.Armature:create("TestBone")
|
||||
armature = ccs.Armature:create("Cowboy")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setScale(0.24)
|
||||
armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100))
|
||||
self.currentTag = self.currentTag + 1
|
||||
self:addChild(armature, self.currentTag, self.currentTag)
|
||||
|
||||
armature = cc.Armature:create("Dragon")
|
||||
armature = ccs.Armature:create("Dragon")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100))
|
||||
armature:setScale(0.6)
|
||||
|
@ -471,7 +400,7 @@ function TestAnimationEvent.extend(target)
|
|||
end
|
||||
|
||||
function TestAnimationEvent:onEnter()
|
||||
local armature = cc.Armature:create("Cowboy")
|
||||
local armature = ccs.Armature:create("Cowboy")
|
||||
armature:getAnimation():play("Fire")
|
||||
armature:setScaleX(-0.24)
|
||||
armature:setScaleY(0.24)
|
||||
|
@ -511,25 +440,25 @@ function TestParticleDisplay:onEnter()
|
|||
self:setTouchEnabled(true)
|
||||
self.animationID = 0
|
||||
|
||||
self.armature = cc.Armature:create("robot")
|
||||
self.armature = ccs.Armature:create("robot")
|
||||
self.armature:getAnimation():playByIndex(0)
|
||||
self.armature:setPosition(VisibleRect:center())
|
||||
self.armature:setScale(0.48)
|
||||
self:addChild(self.armature)
|
||||
|
||||
local displayData = cc.ParticleDisplayData:create()
|
||||
displayData:setParam("Particles/SmallSun.plist")
|
||||
local p1 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist")
|
||||
local p2 = cc.ParticleSystemQuad:create("Particles/SmallSun.plist")
|
||||
|
||||
local bone = cc.Bone:create("p1")
|
||||
bone:addDisplay(displayData, 0)
|
||||
local bone = ccs.Bone:create("p1")
|
||||
bone:addDisplay(p1, 0)
|
||||
bone:changeDisplayByIndex(0, true)
|
||||
bone:setIgnoreMovementBoneData(true)
|
||||
bone:setZOrder(100)
|
||||
bone:setScale(1.2)
|
||||
self.armature:addBone(bone, "bady-a3")
|
||||
|
||||
bone = cc.Bone:create("p2")
|
||||
bone:addDisplay(displayData, 0)
|
||||
bone = ccs.Bone:create("p2")
|
||||
bone:addDisplay(p2, 0)
|
||||
bone:changeDisplayByIndex(0, true)
|
||||
bone:setIgnoreMovementBoneData(true)
|
||||
bone:setZOrder(100)
|
||||
|
@ -583,7 +512,7 @@ function TestUseMutiplePicture:onEnter()
|
|||
self:setTouchEnabled(true)
|
||||
self.displayIndex = 1
|
||||
|
||||
self.armature = cc.Armature:create("Knight_f/Knight")
|
||||
self.armature = ccs.Armature:create("Knight_f/Knight")
|
||||
self.armature:getAnimation():playByIndex(0)
|
||||
self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y))
|
||||
self.armature:setScale(1.2)
|
||||
|
@ -600,11 +529,10 @@ function TestUseMutiplePicture:onEnter()
|
|||
"weapon_f-hammer.png",
|
||||
};
|
||||
|
||||
local spriteDisplayData = cc.SpriteDisplayData:create()
|
||||
local i = 1
|
||||
for i = 1,table.getn(weapon) do
|
||||
spriteDisplayData:setParam(weapon[i])
|
||||
self.armature:getBone("weapon"):addDisplay(spriteDisplayData, i - 1)
|
||||
local skin = ccs.Skin:createWithSpriteFrameName(weapon[i])
|
||||
self.armature:getBone("weapon"):addDisplay(skin, i - 1)
|
||||
end
|
||||
|
||||
local function onTouchBegan(x, y)
|
||||
|
@ -649,7 +577,7 @@ function TestBoundingBox.extend(target)
|
|||
end
|
||||
|
||||
function TestBoundingBox:onEnter()
|
||||
local armature = cc.Armature:create("Cowboy")
|
||||
local armature = ccs.Armature:create("Cowboy")
|
||||
armature:getAnimation():playByIndex(0)
|
||||
armature:setPosition(VisibleRect:center())
|
||||
armature:setScale(0.2)
|
||||
|
@ -685,7 +613,7 @@ end
|
|||
function TestAnchorPoint:onEnter()
|
||||
local i = 1
|
||||
for i = 1 , 5 do
|
||||
local armature = cc.Armature:create("Cowboy")
|
||||
local armature = ccs.Armature:create("Cowboy")
|
||||
armature:getAnimation():playByIndex(0);
|
||||
armature:setPosition(VisibleRect:center())
|
||||
armature:setScale(0.2)
|
||||
|
@ -731,7 +659,7 @@ function TestArmatureNesting:onEnter()
|
|||
self:setTouchEnabled(true)
|
||||
self.weaponIndex = 0
|
||||
|
||||
self.armature = cc.Armature:create("cyborg")
|
||||
self.armature = ccs.Armature:create("cyborg")
|
||||
self.armature:getAnimation():playByIndex(1)
|
||||
self.armature:setPosition(VisibleRect:center())
|
||||
self.armature:setScale(1.2)
|
||||
|
@ -770,7 +698,6 @@ end
|
|||
local armatureSceneArr =
|
||||
{
|
||||
TestCSWithSkeleton.create,
|
||||
TestCSWithoutSkeleton.create,
|
||||
TestDragonBones20.create,
|
||||
TestPerformance.create,
|
||||
TestChangeZorder.create,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b6f97d9fc2d3450426423583c7a6aaf4a366a99d
|
||||
Subproject commit d41959ab0b15c20aa0802ab5c9ef92be7b742bd4
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue