mirror of https://github.com/axmolengine/axmol.git
Array & Dictionary fixes
In many places `Dictionary` and `Array` are not being initialized. In fact `Dictionary` doesn't have the `init()` method creating potential leaks. Also in objects like `Armature` and the new `LabelTTF`, the `Array` object is not being used a pointer. So it doesn't use the 2 phase initialization, creating potential leaks. This patch fixes all those issues. Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
This commit is contained in:
parent
4104cdc20e
commit
2e221ee6cc
|
@ -115,7 +115,7 @@ bool Director::init(void)
|
|||
_notificationNode = nullptr;
|
||||
|
||||
_scenesStack = new Array();
|
||||
_scenesStack->init();
|
||||
_scenesStack->initWithCapacity(15);
|
||||
|
||||
// projection delegate if "Custom" projection is used
|
||||
_projectionDelegate = nullptr;
|
||||
|
|
|
@ -359,12 +359,18 @@ Object* Dictionary::randomObject()
|
|||
|
||||
Dictionary* Dictionary::create()
|
||||
{
|
||||
Dictionary* pRet = new Dictionary();
|
||||
if (pRet != NULL)
|
||||
Dictionary* ret = new Dictionary();
|
||||
if (ret && ret->init() )
|
||||
{
|
||||
pRet->autorelease();
|
||||
ret->autorelease();
|
||||
}
|
||||
return pRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Dictionary::init()
|
||||
{
|
||||
retain();
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary* Dictionary::createWithDictionary(Dictionary* srcDict)
|
||||
|
@ -396,8 +402,7 @@ bool Dictionary::writeToFile(const char *fullPath)
|
|||
|
||||
Dictionary* Dictionary::clone() const
|
||||
{
|
||||
Dictionary* newDict = new Dictionary();
|
||||
newDict->autorelease();
|
||||
Dictionary* newDict = Dictionary::create();
|
||||
|
||||
DictElement* element = NULL;
|
||||
Object* tmpObj = NULL;
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
class CC_DLL Dictionary : public Object, public Clonable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
* The constructor of Dictionary.
|
||||
*/
|
||||
Dictionary();
|
||||
|
@ -182,6 +182,8 @@ public:
|
|||
*/
|
||||
~Dictionary();
|
||||
|
||||
/** Initializes the dictionary. It returns true if the initializations was successful. */
|
||||
bool init();
|
||||
/**
|
||||
* Get the count of elements in Dictionary.
|
||||
*
|
||||
|
|
|
@ -31,13 +31,13 @@ NS_CC_BEGIN
|
|||
|
||||
Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fontSize, int lineSize, TextHAlignment alignment, GlyphCollection glyphs, const char *customGlyphs )
|
||||
{
|
||||
FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasTTF(fontFilePath, fontSize, glyphs, customGlyphs);
|
||||
|
||||
if (!tempAtlas)
|
||||
if (!tmpAtlas)
|
||||
return nullptr;
|
||||
|
||||
// create the actual label
|
||||
Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize);
|
||||
Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize);
|
||||
|
||||
if (templabel)
|
||||
{
|
||||
|
@ -53,12 +53,12 @@ Label* Label::createWithTTF( const char* label, const char* fontFilePath, int fo
|
|||
Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, TextHAlignment alignment, int lineSize)
|
||||
{
|
||||
|
||||
FontAtlas *tempAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
|
||||
FontAtlas *tmpAtlas = FontAtlasCache::getFontAtlasFNT(bmfontFilePath);
|
||||
|
||||
if (!tempAtlas)
|
||||
if (!tmpAtlas)
|
||||
return 0;
|
||||
|
||||
Label* templabel = Label::createWithAtlas(tempAtlas, alignment, lineSize);
|
||||
Label* templabel = Label::createWithAtlas(tmpAtlas, alignment, lineSize);
|
||||
|
||||
if (templabel)
|
||||
{
|
||||
|
@ -73,9 +73,9 @@ Label* Label::createWithBMFont( const char* label, const char* bmfontFilePath, T
|
|||
return 0;
|
||||
}
|
||||
|
||||
Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int lineSize)
|
||||
Label* Label::createWithAtlas(FontAtlas *atlas, TextHAlignment alignment, int lineSize)
|
||||
{
|
||||
Label *ret = new Label(pAtlas, alignment);
|
||||
Label *ret = new Label(atlas, alignment);
|
||||
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
@ -94,24 +94,28 @@ Label* Label::createWithAtlas(FontAtlas *pAtlas, TextHAlignment alignment, int l
|
|||
return ret;
|
||||
}
|
||||
|
||||
Label::Label(FontAtlas *pAtlas, TextHAlignment alignment): _currentUTF8String(0),
|
||||
_originalUTF8String(0),
|
||||
_fontAtlas(pAtlas),
|
||||
_alignment(alignment),
|
||||
_lineBreakWithoutSpaces(false),
|
||||
_advances(0),
|
||||
_displayedColor(Color3B::WHITE),
|
||||
_realColor(Color3B::WHITE),
|
||||
_cascadeColorEnabled(true),
|
||||
_cascadeOpacityEnabled(true),
|
||||
_displayedOpacity(255),
|
||||
_realOpacity(255),
|
||||
_isOpacityModifyRGB(false)
|
||||
Label::Label(FontAtlas *atlas, TextHAlignment alignment)
|
||||
: _currentUTF8String(0)
|
||||
, _originalUTF8String(0)
|
||||
, _fontAtlas(atlas)
|
||||
, _alignment(alignment)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
, _advances(0)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(true)
|
||||
, _cascadeOpacityEnabled(true)
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _isOpacityModifyRGB(false)
|
||||
{
|
||||
}
|
||||
|
||||
Label::~Label()
|
||||
{
|
||||
CC_SAFE_RELEASE(_spriteArray);
|
||||
CC_SAFE_RELEASE(_spriteArrayCache);
|
||||
|
||||
if (_currentUTF8String)
|
||||
delete [] _currentUTF8String;
|
||||
|
||||
|
@ -124,6 +128,12 @@ Label::~Label()
|
|||
|
||||
bool Label::init()
|
||||
{
|
||||
_spriteArray = Array::createWithCapacity(30);
|
||||
_spriteArrayCache = Array::createWithCapacity(30);
|
||||
|
||||
_spriteArray->retain();
|
||||
_spriteArrayCache->retain();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -253,12 +263,12 @@ void Label::alignText()
|
|||
void Label::hideAllLetters()
|
||||
{
|
||||
Object* Obj = NULL;
|
||||
CCARRAY_FOREACH(&_spriteArray, Obj)
|
||||
CCARRAY_FOREACH(_spriteArray, Obj)
|
||||
{
|
||||
((Sprite *)Obj)->setVisible(false);
|
||||
}
|
||||
|
||||
CCARRAY_FOREACH(&_spriteArrayCache, Obj)
|
||||
CCARRAY_FOREACH(_spriteArrayCache, Obj)
|
||||
{
|
||||
((Sprite *)Obj)->setVisible(false);
|
||||
}
|
||||
|
@ -431,21 +441,21 @@ Sprite * Label::updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int
|
|||
void Label::moveAllSpritesToCache()
|
||||
{
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(&_spriteArray, pObj)
|
||||
CCARRAY_FOREACH(_spriteArray, pObj)
|
||||
{
|
||||
((Sprite *)pObj)->removeFromParent();
|
||||
_spriteArrayCache.addObject(pObj);
|
||||
_spriteArrayCache->addObject(pObj);
|
||||
}
|
||||
|
||||
_spriteArray.removeAllObjects();
|
||||
_spriteArray->removeAllObjects();
|
||||
}
|
||||
|
||||
Sprite * Label::getSprite()
|
||||
{
|
||||
if (_spriteArrayCache.count())
|
||||
if (_spriteArrayCache->count())
|
||||
{
|
||||
Sprite *retSprite = (Sprite *) _spriteArrayCache.lastObject();
|
||||
_spriteArrayCache.removeLastObject();
|
||||
Sprite *retSprite = static_cast<Sprite *>( _spriteArrayCache->lastObject() );
|
||||
_spriteArrayCache->removeLastObject();
|
||||
return retSprite;
|
||||
}
|
||||
else
|
||||
|
@ -460,7 +470,7 @@ Sprite * Label::getSprite()
|
|||
Sprite * Label::getSpriteChild(int ID)
|
||||
{
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(&_spriteArray, pObj)
|
||||
CCARRAY_FOREACH(_spriteArray, pObj)
|
||||
{
|
||||
Sprite *pSprite = (Sprite *)pObj;
|
||||
if ( pSprite->getTag() == ID)
|
||||
|
@ -471,9 +481,9 @@ Sprite * Label::getSpriteChild(int ID)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Array * Label::getChildrenLetters()
|
||||
Array* Label::getChildrenLetters()
|
||||
{
|
||||
return &_spriteArray;
|
||||
return _spriteArray;
|
||||
}
|
||||
|
||||
Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint)
|
||||
|
@ -493,7 +503,7 @@ Sprite * Label::getSpriteForChar(unsigned short int theChar, int spriteIndexHint
|
|||
if (retSprite)
|
||||
retSprite->setTag(spriteIndexHint);
|
||||
|
||||
_spriteArray.addObject(retSprite);
|
||||
_spriteArray->addObject(retSprite);
|
||||
}
|
||||
|
||||
// the sprite is now visible
|
||||
|
|
|
@ -139,8 +139,8 @@ private:
|
|||
Sprite * getSpriteForLetter(unsigned short int newLetter);
|
||||
Sprite * updateSpriteForLetter(Sprite *spriteToUpdate, unsigned short int newLetter);
|
||||
|
||||
Array _spriteArray;
|
||||
Array _spriteArrayCache;
|
||||
Array * _spriteArray;
|
||||
Array * _spriteArrayCache;
|
||||
float _commonLineHeight;
|
||||
bool _lineBreakWithoutSpaces;
|
||||
float _width;
|
||||
|
|
|
@ -69,6 +69,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
|||
if( s_pConfigurations == NULL )
|
||||
{
|
||||
s_pConfigurations = new Dictionary();
|
||||
s_pConfigurations->init();
|
||||
}
|
||||
|
||||
pRet = static_cast<CCBMFontConfiguration*>( s_pConfigurations->objectForKey(fntFile) );
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
#ifndef __CCACCELEROMETER_DELEGATE_H__
|
||||
#define __CCACCELEROMETER_DELEGATE_H__
|
||||
|
||||
#include "CCCommon.h"
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ extern "C"
|
|||
#endif
|
||||
|
||||
#include "ccMacros.h"
|
||||
#include "CCCommon.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "CCStdC.h"
|
||||
#include "CCFileUtils.h"
|
||||
#include "CCConfiguration.h"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define __CCSAXPARSER_H__
|
||||
|
||||
#include "CCPlatformConfig.h"
|
||||
#include "CCCommon.h"
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
#ifndef __CC_PLATFORM_THREAD_H__
|
||||
#define __CC_PLATFORM_THREAD_H__
|
||||
|
||||
#include "CCCommon.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "CCPlatformMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCCommon.h"
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -65,6 +65,7 @@ static void addItemToArray(id item, Array *pArray)
|
|||
// add dictionary value into array
|
||||
if ([item isKindOfClass:[NSDictionary class]]) {
|
||||
Dictionary* pDictItem = new Dictionary();
|
||||
pDictItem->init();
|
||||
for (id subKey in [item allKeys]) {
|
||||
id subValue = [item objectForKey:subKey];
|
||||
addValueToDict(subKey, subValue, pDictItem);
|
||||
|
@ -130,6 +131,7 @@ static void addValueToDict(id key, id value, Dictionary* pDict)
|
|||
// the value is a new dictionary
|
||||
if ([value isKindOfClass:[NSDictionary class]]) {
|
||||
Dictionary* pSubDict = new Dictionary();
|
||||
pSubDict->init();
|
||||
for (id subKey in [value allKeys]) {
|
||||
id subValue = [value objectForKey:subKey];
|
||||
addValueToDict(subKey, subValue, pSubDict);
|
||||
|
@ -314,7 +316,7 @@ Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string&
|
|||
|
||||
if (pDict != nil)
|
||||
{
|
||||
Dictionary* pRet = new Dictionary();
|
||||
Dictionary* pRet = Dictionary::create();
|
||||
for (id key in [pDict allKeys]) {
|
||||
id value = [pDict objectForKey:key];
|
||||
addValueToDict(key, value, pRet);
|
||||
|
|
|
@ -25,7 +25,7 @@ THE SOFTWARE.
|
|||
|
||||
#import "CCImage.h"
|
||||
#import "CCFileUtils.h"
|
||||
#import "CCCommon.h"
|
||||
#import "platform/CCCommon.h"
|
||||
#import <string>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
|
|
@ -38,13 +38,13 @@ NS_CC_BEGIN
|
|||
static void addValueToDict(id key, id value, Dictionary* pDict);
|
||||
static void addObjectToNSDict(const char*key, Object* object, NSMutableDictionary *dict);
|
||||
|
||||
static void addItemToArray(id item, Array *pArray)
|
||||
static void addItemToArray(id item, Array *array)
|
||||
{
|
||||
// add string value into array
|
||||
if ([item isKindOfClass:[NSString class]]) {
|
||||
String* pValue = new String([item UTF8String]);
|
||||
|
||||
pArray->addObject(pValue);
|
||||
array->addObject(pValue);
|
||||
pValue->release();
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ static void addItemToArray(id item, Array *pArray)
|
|||
NSString* pStr = [item stringValue];
|
||||
String* pValue = new String([pStr UTF8String]);
|
||||
|
||||
pArray->addObject(pValue);
|
||||
array->addObject(pValue);
|
||||
pValue->release();
|
||||
return;
|
||||
}
|
||||
|
@ -62,24 +62,25 @@ static void addItemToArray(id item, Array *pArray)
|
|||
// add dictionary value into array
|
||||
if ([item isKindOfClass:[NSDictionary class]]) {
|
||||
Dictionary* pDictItem = new Dictionary();
|
||||
pDictItem->init();
|
||||
for (id subKey in [item allKeys]) {
|
||||
id subValue = [item objectForKey:subKey];
|
||||
addValueToDict(subKey, subValue, pDictItem);
|
||||
}
|
||||
pArray->addObject(pDictItem);
|
||||
array->addObject(pDictItem);
|
||||
pDictItem->release();
|
||||
return;
|
||||
}
|
||||
|
||||
// add array value into array
|
||||
if ([item isKindOfClass:[NSArray class]]) {
|
||||
Array *pArrayItem = new Array();
|
||||
pArrayItem->init();
|
||||
Array *arrayItem = new Array();
|
||||
arrayItem->initWithCapacity( [item count] );
|
||||
for (id subItem in item) {
|
||||
addItemToArray(subItem, pArrayItem);
|
||||
addItemToArray(subItem, arrayItem);
|
||||
}
|
||||
pArray->addObject(pArrayItem);
|
||||
pArrayItem->release();
|
||||
array->addObject(arrayItem);
|
||||
arrayItem->release();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -157,13 +158,13 @@ static void addValueToDict(id key, id value, Dictionary* pDict)
|
|||
|
||||
// the value is a array
|
||||
if ([value isKindOfClass:[NSArray class]]) {
|
||||
Array *pArray = new Array();
|
||||
pArray->init();
|
||||
Array *array = new Array();
|
||||
array->initWithCapacity([value count]);
|
||||
for (id item in value) {
|
||||
addItemToArray(item, pArray);
|
||||
addItemToArray(item, array);
|
||||
}
|
||||
pDict->setObject(pArray, pKey.c_str());
|
||||
pArray->release();
|
||||
pDict->setObject(array, pKey.c_str());
|
||||
array->release();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -304,7 +305,7 @@ Dictionary* FileUtilsMac::createDictionaryWithContentsOfFile(const std::string&
|
|||
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
|
||||
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
|
||||
|
||||
Dictionary* pRet = new Dictionary();
|
||||
Dictionary* pRet = Dictionary::create();
|
||||
for (id key in [pDict allKeys]) {
|
||||
id value = [pDict objectForKey:key];
|
||||
addValueToDict(key, value, pRet);
|
||||
|
@ -338,10 +339,10 @@ Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename)
|
|||
// fixing cannot read data using Array::createWithContentsOfFile
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
|
||||
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
|
||||
NSArray* pArray = [NSArray arrayWithContentsOfFile:pPath];
|
||||
NSArray* array = [NSArray arrayWithContentsOfFile:pPath];
|
||||
|
||||
Array* pRet = new Array();
|
||||
for (id value in pArray) {
|
||||
Array* pRet = Array::createWithCapacity( [array count] );
|
||||
for (id value in array) {
|
||||
addItemToArray(value, pRet);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,13 +83,15 @@ ShaderCache::ShaderCache()
|
|||
|
||||
ShaderCache::~ShaderCache()
|
||||
{
|
||||
CCLOGINFO("cocos2d deallocing %p", this);
|
||||
CCLOGINFO("deallocing ShaderCache: %p", this);
|
||||
_programs->release();
|
||||
}
|
||||
|
||||
bool ShaderCache::init()
|
||||
{
|
||||
_programs = new Dictionary();
|
||||
_programs = Dictionary::create();
|
||||
_programs->retain();
|
||||
|
||||
loadDefaultShaders();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ void AnimationCache::destroyInstance()
|
|||
|
||||
bool AnimationCache::init()
|
||||
{
|
||||
_animations = new Dictionary();
|
||||
_animations = new Dictionary;
|
||||
_animations->init();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,7 +67,7 @@ AnimationCache::AnimationCache()
|
|||
|
||||
AnimationCache::~AnimationCache()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing %p", this);
|
||||
CCLOGINFO("deallocing AnimationCache: %p", this);
|
||||
CC_SAFE_RELEASE(_animations);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,9 @@ void SpriteFrameCache::destroyInstance()
|
|||
bool SpriteFrameCache::init(void)
|
||||
{
|
||||
_spriteFrames= new Dictionary();
|
||||
_spriteFrames->init();
|
||||
_spriteFramesAliases = new Dictionary();
|
||||
_spriteFramesAliases->init();
|
||||
_loadedFileNames = new std::set<std::string>();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ void Profiler::releaseAllTimers()
|
|||
bool Profiler::init()
|
||||
{
|
||||
_activeTimers = new Dictionary();
|
||||
_activeTimers->init();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,14 +72,17 @@ TextureCache::TextureCache()
|
|||
, _imageInfoQueue(nullptr)
|
||||
, _needQuit(false)
|
||||
, _asyncRefCount(0)
|
||||
, _textures(new Dictionary())
|
||||
{
|
||||
CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton.");
|
||||
|
||||
_textures = new Dictionary();
|
||||
_textures->init();
|
||||
|
||||
}
|
||||
|
||||
TextureCache::~TextureCache()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing TextureCache: %p", this);
|
||||
CCLOGINFO("deallocing TextureCache: %p", this);
|
||||
|
||||
CC_SAFE_RELEASE(_textures);
|
||||
|
||||
|
|
|
@ -38,11 +38,12 @@ TMXObjectGroup::TMXObjectGroup()
|
|||
_objects = Array::create();
|
||||
_objects->retain();
|
||||
_properties = new Dictionary();
|
||||
_properties->init();
|
||||
}
|
||||
|
||||
TMXObjectGroup::~TMXObjectGroup()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing: %p", this);
|
||||
CCLOGINFO("deallocing TMXObjectGroup: %p", this);
|
||||
CC_SAFE_RELEASE(_objects);
|
||||
CC_SAFE_RELEASE(_properties);
|
||||
}
|
||||
|
|
|
@ -56,12 +56,13 @@ TMXLayerInfo::TMXLayerInfo()
|
|||
, _maxGID(0)
|
||||
, _offset(Point::ZERO)
|
||||
{
|
||||
_properties= new Dictionary();;
|
||||
_properties = new Dictionary();
|
||||
_properties->init();
|
||||
}
|
||||
|
||||
TMXLayerInfo::~TMXLayerInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||
CCLOGINFO("deallocing TMXLayerInfo: %p", this);
|
||||
CC_SAFE_RELEASE(_properties);
|
||||
if( _ownTiles && _tiles )
|
||||
{
|
||||
|
@ -157,7 +158,9 @@ void TMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePath)
|
|||
_objectGroups->retain();
|
||||
|
||||
_properties = new Dictionary();
|
||||
_properties->init();
|
||||
_tileProperties = new Dictionary();
|
||||
_tileProperties->init();
|
||||
|
||||
// tmp vars
|
||||
_currentString = "";
|
||||
|
@ -194,7 +197,7 @@ TMXMapInfo::TMXMapInfo()
|
|||
|
||||
TMXMapInfo::~TMXMapInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||
CCLOGINFO("deallocing TMXMapInfo: %p", this);
|
||||
CC_SAFE_RELEASE(_tilesets);
|
||||
CC_SAFE_RELEASE(_layers);
|
||||
CC_SAFE_RELEASE(_properties);
|
||||
|
@ -368,6 +371,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
{
|
||||
TMXTilesetInfo* info = (TMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject();
|
||||
Dictionary *dict = new Dictionary();
|
||||
dict->init();
|
||||
pTMXMapInfo->setParentGID(info->_firstGid + atoi(valueForKey("id", attributeDict)));
|
||||
pTMXMapInfo->getTileProperties()->setObject(dict, pTMXMapInfo->getParentGID());
|
||||
CC_SAFE_RELEASE(dict);
|
||||
|
@ -502,6 +506,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
// The value for "type" was blank or not a valid class name
|
||||
// Create an instance of TMXObjectInfo to store the object and its properties
|
||||
Dictionary *dict = new Dictionary();
|
||||
dict->init();
|
||||
// Parse everything automatically
|
||||
const char* pArray[] = {"name", "type", "width", "height", "gid"};
|
||||
|
||||
|
@ -618,7 +623,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
const char* value = valueForKey("points", attributeDict);
|
||||
if(value)
|
||||
{
|
||||
Array* pPointsArray = new Array;
|
||||
Array* pointsArray = Array::createWithCapacity(10);
|
||||
|
||||
// parse points string into a space-separated set of points
|
||||
stringstream pointsStream(value);
|
||||
|
@ -630,7 +635,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
string xStr,yStr;
|
||||
char buffer[32] = {0};
|
||||
|
||||
Dictionary* pPointDict = new Dictionary;
|
||||
Dictionary* pointDict = new Dictionary;
|
||||
pointDict->init();
|
||||
|
||||
// set x
|
||||
if(std::getline(pointStream, xStr, ','))
|
||||
|
@ -639,7 +645,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
sprintf(buffer, "%d", x);
|
||||
String* pStr = new String(buffer);
|
||||
pStr->autorelease();
|
||||
pPointDict->setObject(pStr, "x");
|
||||
pointDict->setObject(pStr, "x");
|
||||
}
|
||||
|
||||
// set y
|
||||
|
@ -649,16 +655,15 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
sprintf(buffer, "%d", y);
|
||||
String* pStr = new String(buffer);
|
||||
pStr->autorelease();
|
||||
pPointDict->setObject(pStr, "y");
|
||||
pointDict->setObject(pStr, "y");
|
||||
}
|
||||
|
||||
// add to points array
|
||||
pPointsArray->addObject(pPointDict);
|
||||
pPointDict->release();
|
||||
pointsArray->addObject(pointDict);
|
||||
pointDict->release();
|
||||
}
|
||||
|
||||
dict->setObject(pPointsArray, "points");
|
||||
pPointsArray->release();
|
||||
dict->setObject(pointsArray, "points");
|
||||
}
|
||||
}
|
||||
else if (elementName == "polyline")
|
||||
|
|
|
@ -56,6 +56,7 @@ bool TileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int t
|
|||
if( AtlasNode::initWithTileFile(tile, tileWidth, tileHeight, _itemsToRender) )
|
||||
{
|
||||
_posToAtlasIndex = new Dictionary();
|
||||
_posToAtlasIndex->init();
|
||||
this->updateAtlasValues();
|
||||
this->setContentSize(Size((float)(_TGAInfo->width*_itemWidth),
|
||||
(float)(_TGAInfo->height*_itemHeight)));
|
||||
|
|
|
@ -306,8 +306,8 @@ TouchHandler* TouchDispatcher::findHandler(Array* pArray, TouchDelegate *pDelega
|
|||
|
||||
void TouchDispatcher::rearrangeHandlers(Array *array)
|
||||
{
|
||||
std::sort(array->data->arr, array->data->arr + array->data->num, less);
|
||||
// std::sort( std::begin(*array), std::end(*array), less);
|
||||
// std::sort(array->data->arr, array->data->arr + array->data->num, less);
|
||||
std::sort( std::begin(*array), std::end(*array), less);
|
||||
}
|
||||
|
||||
void TouchDispatcher::setPriority(int nPriority, TouchDelegate *pDelegate)
|
||||
|
|
|
@ -84,10 +84,12 @@ Armature::Armature()
|
|||
|
||||
Armature::~Armature(void)
|
||||
{
|
||||
CCLOGINFO("deallocing Armature: %p", this);
|
||||
|
||||
if(NULL != _boneDic)
|
||||
{
|
||||
_boneDic->removeAllObjects();
|
||||
CC_SAFE_DELETE(_boneDic);
|
||||
CC_SAFE_RELEASE(_boneDic);
|
||||
}
|
||||
if (NULL != _topBoneList)
|
||||
{
|
||||
|
@ -115,12 +117,13 @@ bool Armature::init(const char *name)
|
|||
_animation = new ArmatureAnimation();
|
||||
_animation->init(this);
|
||||
|
||||
CC_SAFE_DELETE(_boneDic);
|
||||
CC_SAFE_RELEASE(_boneDic);
|
||||
_boneDic = new Dictionary();
|
||||
_boneDic->init();
|
||||
|
||||
CC_SAFE_DELETE(_topBoneList);
|
||||
_topBoneList = new Array();
|
||||
_topBoneList->init();
|
||||
_topBoneList = Array::create();
|
||||
_topBoneList->retain();
|
||||
|
||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
|
||||
|
@ -145,7 +148,7 @@ bool Armature::init(const char *name)
|
|||
|
||||
|
||||
DictElement *_element = NULL;
|
||||
Dictionary *boneDataDic = &armatureData->boneDataDic;
|
||||
Dictionary *boneDataDic = armatureData->boneDataDic;
|
||||
CCDICT_FOREACH(boneDataDic, _element)
|
||||
{
|
||||
Bone *bone = createBone(_element->getStrKey());
|
||||
|
@ -158,7 +161,7 @@ bool Armature::init(const char *name)
|
|||
CC_BREAK_IF(!movData);
|
||||
|
||||
MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str());
|
||||
CC_BREAK_IF(!movBoneData || movBoneData->frameList.count() <= 0);
|
||||
CC_BREAK_IF(!movBoneData || movBoneData->frameList->count() <= 0);
|
||||
|
||||
FrameData *frameData = movBoneData->getFrameData(0);
|
||||
CC_BREAK_IF(!frameData);
|
||||
|
|
|
@ -57,6 +57,8 @@ ArmatureAnimation::ArmatureAnimation()
|
|||
|
||||
ArmatureAnimation::~ArmatureAnimation(void)
|
||||
{
|
||||
CCLOGINFO("deallocing ArmatureAnimation: %p", this);
|
||||
|
||||
CC_SAFE_RELEASE_NULL(_tweenList);
|
||||
CC_SAFE_RELEASE_NULL(_animationData);
|
||||
}
|
||||
|
@ -185,10 +187,10 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
CCDICT_FOREACH(dict, element)
|
||||
{
|
||||
Bone *bone = (Bone *)element->getObject();
|
||||
movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic.objectForKey(bone->getName());
|
||||
movementBoneData = (MovementBoneData *)_movementData->movBoneDataDic->objectForKey(bone->getName());
|
||||
|
||||
Tween *tween = bone->getTween();
|
||||
if(movementBoneData && movementBoneData->frameList.count() > 0)
|
||||
if(movementBoneData && movementBoneData->frameList->count() > 0)
|
||||
{
|
||||
_tweenList->addObject(tween);
|
||||
tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing);
|
||||
|
|
|
@ -110,7 +110,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
|
|||
setMovementBoneData(movementBoneData);
|
||||
|
||||
|
||||
if (_movementBoneData->frameList.count() == 1)
|
||||
if (_movementBoneData->frameList->count() == 1)
|
||||
{
|
||||
_loopType = SINGLE_FRAME;
|
||||
FrameData *_nextKeyFrame = _movementBoneData->getFrameData(0);
|
||||
|
@ -128,7 +128,7 @@ void Tween::play(MovementBoneData *movementBoneData, int durationTo, int duratio
|
|||
_rawDuration = _movementBoneData->duration;
|
||||
_fromIndex = _toIndex = 0;
|
||||
}
|
||||
else if (_movementBoneData->frameList.count() > 1)
|
||||
else if (_movementBoneData->frameList->count() > 1)
|
||||
{
|
||||
if (loop)
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ float Tween::updateFrameData(float currentPrecent, bool activeFrame)
|
|||
* Get frame length, if _toIndex >= _length, then set _toIndex to 0, start anew.
|
||||
* _toIndex is next index will play
|
||||
*/
|
||||
int length = _movementBoneData->frameList.count();
|
||||
int length = _movementBoneData->frameList->count();
|
||||
do
|
||||
{
|
||||
betweenDuration = _movementBoneData->getFrameData(_toIndex)->duration;
|
||||
|
|
|
@ -209,22 +209,24 @@ BoneData::BoneData(void)
|
|||
|
||||
BoneData::~BoneData(void)
|
||||
{
|
||||
CC_SAFE_RELEASE(displayDataList);
|
||||
}
|
||||
|
||||
bool BoneData::init()
|
||||
{
|
||||
displayDataList.init();
|
||||
displayDataList = new Array;
|
||||
displayDataList->init();
|
||||
return true;
|
||||
}
|
||||
|
||||
void BoneData::addDisplayData(DisplayData *displayData)
|
||||
{
|
||||
displayDataList.addObject(displayData);
|
||||
displayDataList->addObject(displayData);
|
||||
}
|
||||
|
||||
DisplayData *BoneData::getDisplayData(int index)
|
||||
{
|
||||
return (DisplayData *)displayDataList.objectAtIndex(index);
|
||||
return static_cast<DisplayData *>( displayDataList->objectAtIndex(index) );
|
||||
}
|
||||
|
||||
ArmatureData::ArmatureData()
|
||||
|
@ -233,22 +235,30 @@ ArmatureData::ArmatureData()
|
|||
|
||||
ArmatureData::~ArmatureData()
|
||||
{
|
||||
CC_SAFE_RELEASE(boneList);
|
||||
CC_SAFE_RELEASE(boneDataDic);
|
||||
}
|
||||
|
||||
bool ArmatureData::init()
|
||||
{
|
||||
return boneList.init();
|
||||
boneList = new Array;
|
||||
boneList->init();
|
||||
|
||||
boneDataDic = new Dictionary;
|
||||
boneDataDic->init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ArmatureData::addBoneData(BoneData *boneData)
|
||||
{
|
||||
boneDataDic.setObject(boneData, boneData->name);
|
||||
boneList.addObject(boneData);
|
||||
boneDataDic->setObject(boneData, boneData->name);
|
||||
boneList->addObject(boneData);
|
||||
}
|
||||
|
||||
BoneData *ArmatureData::getBoneData(const char *boneName)
|
||||
{
|
||||
return (BoneData *)boneDataDic.objectForKey(boneName);
|
||||
return static_cast<BoneData *>( boneDataDic->objectForKey(boneName) );
|
||||
}
|
||||
|
||||
FrameData::FrameData(void)
|
||||
|
@ -282,30 +292,31 @@ MovementBoneData::MovementBoneData()
|
|||
, duration(0)
|
||||
, name("")
|
||||
{
|
||||
frameList = new Array;
|
||||
frameList->init();
|
||||
}
|
||||
|
||||
MovementBoneData::~MovementBoneData(void)
|
||||
{
|
||||
CC_SAFE_RELEASE(frameList);
|
||||
}
|
||||
|
||||
bool MovementBoneData::init()
|
||||
{
|
||||
return frameList.init();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MovementBoneData::addFrameData(FrameData *frameData)
|
||||
{
|
||||
frameList.addObject(frameData);
|
||||
frameList->addObject(frameData);
|
||||
duration += frameData->duration;
|
||||
}
|
||||
|
||||
FrameData *MovementBoneData::getFrameData(int index)
|
||||
{
|
||||
return (FrameData *)frameList.objectAtIndex(index);
|
||||
return static_cast<FrameData *>( frameList->objectAtIndex(index) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
MovementData::MovementData(void)
|
||||
: name("")
|
||||
, duration(0)
|
||||
|
@ -314,30 +325,36 @@ MovementData::MovementData(void)
|
|||
, loop(true)
|
||||
, tweenEasing(Linear)
|
||||
{
|
||||
movBoneDataDic = new Dictionary;
|
||||
movBoneDataDic->init();
|
||||
}
|
||||
|
||||
MovementData::~MovementData(void)
|
||||
{
|
||||
CC_SAFE_RELEASE(movBoneDataDic);
|
||||
}
|
||||
|
||||
void MovementData::addMovementBoneData(MovementBoneData *movBoneData)
|
||||
{
|
||||
movBoneDataDic.setObject(movBoneData, movBoneData->name);
|
||||
movBoneDataDic->setObject(movBoneData, movBoneData->name);
|
||||
}
|
||||
|
||||
MovementBoneData *MovementData::getMovementBoneData(const char *boneName)
|
||||
{
|
||||
return (MovementBoneData *)movBoneDataDic.objectForKey(boneName);
|
||||
return static_cast<MovementBoneData *>( movBoneDataDic->objectForKey(boneName) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
AnimationData::AnimationData(void)
|
||||
{
|
||||
movementDataDic = new Dictionary;
|
||||
movementDataDic->init();
|
||||
}
|
||||
|
||||
AnimationData::~AnimationData(void)
|
||||
{
|
||||
CC_SAFE_RELEASE(movementDataDic);
|
||||
}
|
||||
|
||||
void AnimationData::release()
|
||||
|
@ -352,33 +369,36 @@ void AnimationData::retain()
|
|||
|
||||
void AnimationData::addMovement(MovementData *movData)
|
||||
{
|
||||
movementDataDic.setObject(movData, movData->name);
|
||||
movementDataDic->setObject(movData, movData->name);
|
||||
movementNames.push_back(movData->name);
|
||||
}
|
||||
|
||||
MovementData *AnimationData::getMovement(const char *movementName)
|
||||
{
|
||||
return (MovementData *)movementDataDic.objectForKey(movementName);
|
||||
return (MovementData *)movementDataDic->objectForKey(movementName);
|
||||
}
|
||||
|
||||
int AnimationData::getMovementCount()
|
||||
{
|
||||
return movementDataDic.count();
|
||||
return movementDataDic->count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ContourData::ContourData()
|
||||
{
|
||||
vertexList = new Array;
|
||||
vertexList->init();
|
||||
}
|
||||
|
||||
ContourData::~ContourData()
|
||||
{
|
||||
CC_SAFE_RELEASE(vertexList);
|
||||
}
|
||||
|
||||
bool ContourData::init()
|
||||
{
|
||||
return vertexList.init();
|
||||
return true;
|
||||
}
|
||||
|
||||
TextureData::TextureData()
|
||||
|
@ -388,25 +408,28 @@ TextureData::TextureData()
|
|||
, pivotY(0.5f)
|
||||
, name("")
|
||||
{
|
||||
contourDataList = new Array;
|
||||
contourDataList->init();
|
||||
}
|
||||
|
||||
TextureData::~TextureData()
|
||||
{
|
||||
CC_SAFE_RELEASE(contourDataList);
|
||||
}
|
||||
|
||||
bool TextureData::init()
|
||||
{
|
||||
return contourDataList.init();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextureData::addContourData(ContourData *contourData)
|
||||
{
|
||||
contourDataList.addObject(contourData);
|
||||
contourDataList->addObject(contourData);
|
||||
}
|
||||
|
||||
ContourData *TextureData::getContourData(int index)
|
||||
{
|
||||
return (ContourData *)contourDataList.objectAtIndex(index);
|
||||
return static_cast<ContourData *>( contourDataList->objectAtIndex(index) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ public:
|
|||
public:
|
||||
std::string name; //! the bone's name
|
||||
std::string parentName; //! the bone parent's name
|
||||
Array displayDataList; //! save DisplayData informations for the Bone
|
||||
Array *displayDataList; //! save DisplayData informations for the Bone
|
||||
};
|
||||
|
||||
|
||||
|
@ -266,8 +266,8 @@ public:
|
|||
BoneData *getBoneData(const char *boneName);
|
||||
public:
|
||||
std::string name;
|
||||
Dictionary boneDataDic;
|
||||
Array boneList;
|
||||
Dictionary *boneDataDic;
|
||||
Array *boneList;
|
||||
};
|
||||
|
||||
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
float duration; //! this Bone in this movement will last _duration frames
|
||||
std::string name; //! bone name
|
||||
|
||||
Array frameList;
|
||||
Array *frameList;
|
||||
};
|
||||
|
||||
|
||||
|
@ -363,7 +363,7 @@ public:
|
|||
* Dictionary to save movment bone data.
|
||||
* Key type is std::string, value type is MovementBoneData *.
|
||||
*/
|
||||
Dictionary movBoneDataDic;
|
||||
Dictionary *movBoneDataDic;
|
||||
};
|
||||
|
||||
|
||||
|
@ -388,7 +388,7 @@ public:
|
|||
int getMovementCount();
|
||||
public:
|
||||
std::string name;
|
||||
Dictionary movementDataDic;
|
||||
Dictionary *movementDataDic;
|
||||
std::vector<std::string> movementNames;
|
||||
};
|
||||
|
||||
|
@ -418,7 +418,7 @@ public:
|
|||
|
||||
virtual bool init();
|
||||
public:
|
||||
Array vertexList; //! Save contour vertex info, vertex saved in a Point
|
||||
Array *vertexList; //! Save contour vertex info, vertex saved in a Point
|
||||
};
|
||||
|
||||
|
||||
|
@ -449,7 +449,7 @@ public:
|
|||
|
||||
std::string name; //! The texture's name
|
||||
|
||||
Array contourDataList;
|
||||
Array *contourDataList;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -153,12 +153,12 @@ void DisplayFactory::createSpriteDisplay(Bone *bone, DecorativeDisplay *decoDisp
|
|||
decoDisplay->setDisplay(skin);
|
||||
|
||||
#if ENABLE_PHYSICS_DETECT
|
||||
if (textureData && textureData->contourDataList.count() > 0)
|
||||
if (textureData && textureData->contourDataList->count() > 0)
|
||||
{
|
||||
|
||||
//! create ContourSprite
|
||||
ColliderDetector *colliderDetector = ColliderDetector::create(bone);
|
||||
colliderDetector->addContourDataList(&textureData->contourDataList);
|
||||
colliderDetector->addContourDataList(textureData->contourDataList);
|
||||
|
||||
decoDisplay->setColliderDetector(colliderDetector);
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay()
|
|||
|
||||
DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index)
|
||||
{
|
||||
return (DecorativeDisplay *)_decoDisplayList->objectAtIndex(index);
|
||||
return static_cast<DecorativeDisplay *>( _decoDisplayList->objectAtIndex(index) );
|
||||
}
|
||||
|
||||
void DisplayManager::initDisplayList(BoneData *boneData)
|
||||
|
@ -222,7 +222,7 @@ void DisplayManager::initDisplayList(BoneData *boneData)
|
|||
CS_RETURN_IF(!boneData);
|
||||
|
||||
Object *object = NULL;
|
||||
Array *displayDataList = &boneData->displayDataList;
|
||||
Array *displayDataList = boneData->displayDataList;
|
||||
CCARRAY_FOREACH(displayDataList, object)
|
||||
{
|
||||
DisplayData *displayData = static_cast<DisplayData *>(object);
|
||||
|
|
|
@ -93,10 +93,10 @@ bool ColliderDetector::init(Bone *bone)
|
|||
|
||||
void ColliderDetector::addContourData(ContourData *contourData)
|
||||
{
|
||||
const Array *array = &contourData->vertexList;
|
||||
const Array *array = contourData->vertexList;
|
||||
Object *object = NULL;
|
||||
|
||||
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList.count()];
|
||||
b2Vec2 *b2bv = new b2Vec2[contourData->vertexList->count()];
|
||||
|
||||
int i = 0;
|
||||
CCARRAY_FOREACH(array, object)
|
||||
|
@ -107,7 +107,7 @@ void ColliderDetector::addContourData(ContourData *contourData)
|
|||
}
|
||||
|
||||
b2PolygonShape polygon;
|
||||
polygon.Set(b2bv, contourData->vertexList.count());
|
||||
polygon.Set(b2bv, contourData->vertexList->count());
|
||||
|
||||
CC_SAFE_DELETE(b2bv);
|
||||
|
||||
|
@ -183,7 +183,7 @@ void ColliderDetector::updateTransform(AffineTransform &t)
|
|||
b2PolygonShape *shape = (b2PolygonShape *)body->GetFixtureList()->GetShape();
|
||||
|
||||
//! update every vertex
|
||||
const Array *array = &contourData->vertexList;
|
||||
const Array *array = contourData->vertexList;
|
||||
Object *object = NULL;
|
||||
int i = 0;
|
||||
CCARRAY_FOREACH(array, object)
|
||||
|
|
|
@ -57,11 +57,13 @@ ArmatureDataManager::ArmatureDataManager(void)
|
|||
|
||||
ArmatureDataManager::~ArmatureDataManager(void)
|
||||
{
|
||||
CCLOGINFO("deallocing ArmatureDataManager: %p", this);
|
||||
|
||||
removeAll();
|
||||
|
||||
CC_SAFE_DELETE(_animationDatas);
|
||||
CC_SAFE_DELETE(_armarureDatas);
|
||||
CC_SAFE_DELETE(_textureDatas);
|
||||
CC_SAFE_RELEASE(_animationDatas);
|
||||
CC_SAFE_RELEASE(_armarureDatas);
|
||||
CC_SAFE_RELEASE(_textureDatas);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::purgeArmatureSystem()
|
||||
|
@ -77,17 +79,17 @@ bool ArmatureDataManager::init()
|
|||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
_armarureDatas = Dictionary::create();
|
||||
_armarureDatas = new Dictionary;
|
||||
CCASSERT(_armarureDatas, "create ArmatureDataManager::_armarureDatas fail!");
|
||||
_armarureDatas->retain();
|
||||
_armarureDatas->init();
|
||||
|
||||
_animationDatas = Dictionary::create();
|
||||
_animationDatas = new Dictionary;
|
||||
CCASSERT(_animationDatas, "create ArmatureDataManager::_animationDatas fail!");
|
||||
_animationDatas->retain();
|
||||
_animationDatas->init();
|
||||
|
||||
_textureDatas = Dictionary::create();
|
||||
_textureDatas = new Dictionary;
|
||||
CCASSERT(_textureDatas, "create ArmatureDataManager::_textureDatas fail!");
|
||||
_textureDatas->retain();
|
||||
_textureDatas->init();
|
||||
|
||||
bRet = true;
|
||||
}
|
||||
|
|
|
@ -785,7 +785,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML)
|
|||
vertexDataXML->QueryFloatAttribute(A_Y, &vertex->y);
|
||||
|
||||
vertex->y = -vertex->y;
|
||||
contourData->vertexList.addObject(vertex);
|
||||
contourData->vertexList->addObject(vertex);
|
||||
|
||||
vertexDataXML = vertexDataXML->NextSiblingElement(CONTOUR_VERTEX);
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json)
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
cs::CSJsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i);
|
||||
textureData->contourDataList.addObject(decodeContour(*dic));
|
||||
textureData->contourDataList->addObject(decodeContour(*dic));
|
||||
|
||||
delete dic;
|
||||
}
|
||||
|
@ -1101,7 +1101,7 @@ ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json)
|
|||
vertex->x = dic->getItemFloatValue(A_X, 0);
|
||||
vertex->y = dic->getItemFloatValue(A_Y, 0);
|
||||
|
||||
contourData->vertexList.addObject(vertex);
|
||||
contourData->vertexList->addObject(vertex);
|
||||
vertex->release();
|
||||
|
||||
delete dic;
|
||||
|
|
|
@ -173,6 +173,7 @@ TextureAtlas *SpriteFrameCacheHelper::getTextureAtlas(const char *displayName)
|
|||
SpriteFrameCacheHelper::SpriteFrameCacheHelper()
|
||||
{
|
||||
_display2TextureAtlas = new Dictionary();
|
||||
_display2TextureAtlas->init();
|
||||
}
|
||||
|
||||
SpriteFrameCacheHelper::~SpriteFrameCacheHelper()
|
||||
|
|
|
@ -34,17 +34,27 @@ CCBAnimationManager::CCBAnimationManager()
|
|||
|
||||
bool CCBAnimationManager::init()
|
||||
{
|
||||
_sequences = new Array();
|
||||
_sequences = Array::createWithCapacity(15);
|
||||
_sequences->retain();
|
||||
_nodeSequences = new Dictionary();
|
||||
_nodeSequences->init();
|
||||
_baseValues = new Dictionary();
|
||||
_baseValues->init();
|
||||
|
||||
_documentOutletNames = new Array();
|
||||
_documentOutletNodes = new Array();
|
||||
_documentCallbackNames = new Array();
|
||||
_documentCallbackNodes = new Array();
|
||||
_documentCallbackControlEvents = new Array();
|
||||
_keyframeCallbacks = new Array();
|
||||
_documentOutletNames = Array::createWithCapacity(5);
|
||||
_documentOutletNames->retain();
|
||||
_documentOutletNodes = Array::createWithCapacity(5);
|
||||
_documentOutletNodes->retain();
|
||||
_documentCallbackNames = Array::createWithCapacity(5);
|
||||
_documentCallbackNames->retain();
|
||||
_documentCallbackNodes = Array::createWithCapacity(5);
|
||||
_documentCallbackNodes->retain();
|
||||
_documentCallbackControlEvents = Array::createWithCapacity(5);
|
||||
_documentCallbackControlEvents->retain();
|
||||
_keyframeCallbacks = Array::createWithCapacity(5);
|
||||
_keyframeCallbacks->retain();
|
||||
_keyframeCallFuncs = new Dictionary();
|
||||
_keyframeCallFuncs->init();
|
||||
|
||||
_target = NULL;
|
||||
_animationCompleteCallbackFunc = NULL;
|
||||
|
|
|
@ -153,9 +153,12 @@ const std::string& CCBReader::getCCBRootPath() const
|
|||
|
||||
bool CCBReader::init()
|
||||
{
|
||||
_ownerOutletNodes = new Array();
|
||||
_ownerCallbackNodes = new Array();
|
||||
_ownerOwnerCallbackControlEvents = new Array();
|
||||
_ownerOutletNodes = Array::create();
|
||||
_ownerOutletNodes->retain();
|
||||
_ownerCallbackNodes = Array::create();
|
||||
_ownerCallbackNodes->retain();
|
||||
_ownerOwnerCallbackControlEvents = Array::create();
|
||||
_ownerOwnerCallbackControlEvents->retain();
|
||||
|
||||
// Setup action manager
|
||||
CCBAnimationManager *pActionManager = new CCBAnimationManager();
|
||||
|
@ -277,8 +280,10 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
|||
// Assign actionManagers to userObject
|
||||
if(_jsControlled)
|
||||
{
|
||||
_nodesWithAnimationManagers = new Array();
|
||||
_animationManagersForNodes = new Array();
|
||||
_nodesWithAnimationManagers = Array::create();
|
||||
_nodesWithAnimationManagers->retain();
|
||||
_animationManagersForNodes = Array::create();
|
||||
_animationManagersForNodes->retain();
|
||||
}
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
|
|
|
@ -14,7 +14,8 @@ CCBSequenceProperty::CCBSequenceProperty()
|
|||
|
||||
bool CCBSequenceProperty::init()
|
||||
{
|
||||
_keyframes = new Array();
|
||||
_keyframes = Array::createWithCapacity(5);
|
||||
_keyframes->retain();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ NS_CC_EXT_BEGIN
|
|||
NodeLoader::NodeLoader()
|
||||
{
|
||||
_customProperties = new Dictionary();
|
||||
_customProperties->init();
|
||||
}
|
||||
|
||||
NodeLoader::~NodeLoader()
|
||||
|
|
|
@ -78,7 +78,8 @@ bool Control::init()
|
|||
// Set the touch dispatcher priority by default to 1
|
||||
this->setTouchPriority(1);
|
||||
// Initialise the tables
|
||||
_dispatchTable = new Dictionary();
|
||||
_dispatchTable = new Dictionary();
|
||||
_dispatchTable->init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,8 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/)
|
|||
this->setViewSize(size);
|
||||
|
||||
setTouchEnabled(true);
|
||||
_touches = new Array();
|
||||
_touches = Array::create();
|
||||
_touches->retain();
|
||||
_delegate = NULL;
|
||||
_bounceable = true;
|
||||
_clippingToBounds = true;
|
||||
|
@ -183,7 +184,8 @@ void ScrollView::setTouchEnabled(bool e)
|
|||
{
|
||||
_dragging = false;
|
||||
_touchMoved = false;
|
||||
if(_touches)_touches->removeAllObjects();
|
||||
if(_touches)
|
||||
_touches->removeAllObjects();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ SIOClientImpl::~SIOClientImpl()
|
|||
{
|
||||
if (_connected) disconnect();
|
||||
|
||||
CC_SAFE_DELETE(_clients);
|
||||
CC_SAFE_RELEASE(_clients);
|
||||
CC_SAFE_DELETE(_ws);
|
||||
}
|
||||
|
||||
|
@ -600,7 +600,7 @@ SocketIO::SocketIO()
|
|||
|
||||
SocketIO::~SocketIO(void)
|
||||
{
|
||||
CC_SAFE_DELETE(_sockets);
|
||||
CC_SAFE_RELEASE(_sockets);
|
||||
delete _inst;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void ProjectileController::update(float delta)
|
|||
projectile->getContentSize().width,
|
||||
projectile->getContentSize().height);
|
||||
|
||||
auto targetsToDelete =new Array;
|
||||
auto targetsToDelete = Array::createWithCapacity(20);
|
||||
Object* jt = NULL;
|
||||
CCARRAY_FOREACH(_targets, jt)
|
||||
{
|
||||
|
@ -71,8 +71,6 @@ void ProjectileController::update(float delta)
|
|||
|
||||
bool isDied = targetsToDelete->count() > 0;
|
||||
|
||||
targetsToDelete->release();
|
||||
|
||||
if (isDied)
|
||||
{
|
||||
die();
|
||||
|
|
|
@ -18,17 +18,8 @@ SceneController::SceneController(void)
|
|||
|
||||
SceneController::~SceneController(void)
|
||||
{
|
||||
if (_targets)
|
||||
{
|
||||
_targets->release();
|
||||
_targets = NULL;
|
||||
}
|
||||
|
||||
if (_projectiles)
|
||||
{
|
||||
_projectiles->release();
|
||||
_projectiles = NULL;
|
||||
}
|
||||
CC_SAFE_RELEASE(_targets);
|
||||
CC_SAFE_RELEASE(_projectiles);
|
||||
}
|
||||
|
||||
bool SceneController::init()
|
||||
|
@ -40,8 +31,11 @@ void SceneController::onEnter()
|
|||
{
|
||||
_fAddTargetTime = 1.0f;
|
||||
|
||||
_targets = new Array;
|
||||
_projectiles = new Array;
|
||||
_targets = Array::createWithCapacity(10);
|
||||
_projectiles = Array::createWithCapacity(10);
|
||||
|
||||
_targets->retain();
|
||||
_projectiles->retain();
|
||||
|
||||
((ComAudio*)(_owner->getComponent("Audio")))->playBackgroundMusic("background-music-aac.wav", true);
|
||||
((ComAttribute*)(_owner->getComponent("ComAttribute")))->setInt("KillCount", 0);
|
||||
|
@ -49,8 +43,6 @@ void SceneController::onEnter()
|
|||
|
||||
void SceneController::onExit()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SceneController::update(float delta)
|
||||
|
|
Loading…
Reference in New Issue