mirror of https://github.com/axmolengine/axmol.git
Fixes some compiler warnings
The warnings are related to: * 64-to-32-bit conversion * shadow variables
This commit is contained in:
parent
24ecbc426c
commit
ba7ed6e578
|
@ -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);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ bool Label::setText(const char *stringToRender, float lineWidth, TextHAlignment
|
|||
if (_commonLineHeight <= 0)
|
||||
return false;
|
||||
|
||||
int numLetter = 0;
|
||||
// int numLetter = 0;
|
||||
unsigned short* utf16String = cc_utf8_to_utf16(stringToRender);
|
||||
if(!utf16String)
|
||||
return false;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -188,7 +188,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
//CCLabelAtlas - LabelProtocol
|
||||
void LabelAtlas::setString(const char *label)
|
||||
{
|
||||
int len = strlen(label);
|
||||
size_t len = strlen(label);
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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<void*, 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, void* ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesBegin(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
void* id = nullptr;
|
||||
long id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
int nUnusedIndex = 0;
|
||||
|
@ -251,9 +251,9 @@ void EGLViewProtocol::handleTouchesBegin(int num, void* ids[], float xs[], float
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesMove(int num, void* ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesMove(int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
void* id = 0;
|
||||
long id = 0;
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
EventTouch touchEvent;
|
||||
|
@ -283,7 +283,7 @@ void EGLViewProtocol::handleTouchesMove(int num, void* ids[], float xs[], float
|
|||
else
|
||||
{
|
||||
// It is error, should return.
|
||||
CCLOG("Moving touches with id: %p error", id);
|
||||
CCLOG("Moving touches with id: %ld error", id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -299,9 +299,9 @@ void EGLViewProtocol::handleTouchesMove(int num, void* ids[], float xs[], float
|
|||
dispatcher->dispatchEvent(&touchEvent);
|
||||
}
|
||||
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, void* ids[], float xs[], float ys[])
|
||||
void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, long ids[], float xs[], float ys[])
|
||||
{
|
||||
void* 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, void* 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, void* 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, void* ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesMove(int num, void* ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesEnd(int num, void* ids[], float xs[], float ys[]);
|
||||
virtual void handleTouchesCancel(int num, void* 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, void* 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) */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,11 +406,11 @@ static CCEAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (void**)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesBegin(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -426,11 +426,11 @@ static CCEAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (void**)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesMove(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -447,11 +447,11 @@ static CCEAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (void**)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesEnd(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
|
@ -468,11 +468,11 @@ static CCEAGLView *view = 0;
|
|||
int i = 0;
|
||||
for (UITouch *touch in touches) {
|
||||
ids[i] = touch;
|
||||
xs[i] = [touch locationInView: [touch view]].x * view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * view.contentScaleFactor;;
|
||||
xs[i] = [touch locationInView: [touch view]].x * __view.contentScaleFactor;;
|
||||
ys[i] = [touch locationInView: [touch view]].y * __view.contentScaleFactor;;
|
||||
++i;
|
||||
}
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (void**)ids, xs, ys);
|
||||
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (long*)ids, xs, ys);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue