Merge branch 'gles20' of git://github.com/cocos2d/cocos2d-x into gles20

This commit is contained in:
Nicolas Gramlich 2012-06-11 10:43:27 -07:00
commit 9c52fce5d2
43 changed files with 915 additions and 384 deletions

View File

@ -521,7 +521,7 @@ static BOOL _mixerRateSet = NO;
if (soundId >= bufferTotal) {
//Need to resize the buffers
int requiredIncrement = CD_BUFFERS_INCREMENT;
while (bufferTotal + requiredIncrement < soundId) {
while (bufferTotal + requiredIncrement <= soundId) {
requiredIncrement += CD_BUFFERS_INCREMENT;
}
CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId);

View File

@ -1 +1 @@
5e8bc2ebea93cf60f4c5992e1175c43fffffb7e8
e725a16819b832fcdbd8496ae63d0b24c76af31a

View File

@ -81,6 +81,8 @@ bool CCConfiguration::init(void)
#if CC_ENABLE_PROFILERS
bEnableProfilers = true;
#else
bEnableProfilers = false;
#endif
CCLOG("cocos2d: compiled with Profiling Support: %s",

View File

@ -120,7 +120,7 @@ bool CCDirector::init(void)
// paused ?
m_bPaused = false;
// purge ?
m_bPurgeDirecotorInNextLoop = false;
@ -267,7 +267,7 @@ void CCDirector::calculateDeltaTime(void)
return;
}
// new delta time
// new delta time. Re-fixed issue #1277
if (m_bNextDeltaTimeZero)
{
m_fDeltaTime = 0;
@ -357,12 +357,6 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
case kCCDirectorProjection3D:
{
//TODO: // reset the viewport if 3d proj & retina display
// if( CC_CONTENT_SCALE_FACTOR() != 1.0f )
// {
// glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) );
// }
float zeye = this->getZEye();
kmMat4 matrixPerspective, matrixLookup;
@ -371,19 +365,9 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
kmGLLoadIdentity();
// issue #1334
kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2);
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
//TODO: if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f)
// {
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2);
// }
// else
// {
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500);
// }
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
kmGLMultMatrix(&matrixPerspective);
kmGLMatrixMode(KM_GL_MODELVIEW);
@ -417,11 +401,12 @@ void CCDirector::purgeCachedData(void)
{
CCLabelBMFont::purgeCachedData();
CCTextureCache::sharedTextureCache()->removeUnusedTextures();
CCFileUtils::sharedFileUtils()->purgeCachedEntries();
}
float CCDirector::getZEye(void)
{
return (m_obWinSizeInPixels.height / 1.1566f);
return (m_obWinSizeInPixels.height / 1.1566f / CC_CONTENT_SCALE_FACTOR());
}
void CCDirector::setAlphaBlending(bool bOn)
@ -546,6 +531,35 @@ void CCDirector::popScene(void)
}
}
void CCDirector::popToRootScene(void)
{
CCAssert(m_pRunningScene != NULL, "A running Scene is needed");
unsigned int c = m_pobScenesStack->count();
if (c == 1)
{
m_pobScenesStack->removeLastObject();
this->end();
}
else
{
while (c > 1)
{
CCScene *current = (CCScene*)m_pobScenesStack->lastObject();
if( current->getIsRunning() )
{
current->onExit();
}
current->cleanup();
m_pobScenesStack->removeLastObject();
c--;
}
m_pNextScene = (CCScene*)m_pobScenesStack->lastObject();
m_bSendCleanupToScene = false;
}
}
void CCDirector::end()
{
m_bPurgeDirecotorInNextLoop = true;
@ -588,6 +602,7 @@ void CCDirector::purgeDirector()
CCSpriteFrameCache::purgeSharedSpriteFrameCache();
CCTextureCache::purgeSharedTextureCache();
CCShaderCache::purgeSharedShaderCache();
CCFileUtils::purgeFileUtils();
CCConfiguration::purgeConfiguration();
// cocos2d-x specific data structures
@ -719,21 +734,32 @@ void CCDirector::calculateMPF()
void CCDirector::createStatsLabel()
{
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
CC_SAFE_RELEASE_NULL(m_pSPFLabel);
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
m_pFPSLabel = CCLabelBMFont::labelWithString("00.0", "fps_images.fnt");
m_pSPFLabel = CCLabelBMFont::labelWithString("0.000", "fps_images.fnt");
m_pDrawsLabel = CCLabelBMFont::labelWithString("000", "fps_images.fnt");
m_pFPSLabel->retain();
m_pSPFLabel->retain();
m_pDrawsLabel->retain();
m_pDrawsLabel->setPosition(ccp(20, 50));
m_pSPFLabel->setPosition(ccp(25, 30));
m_pFPSLabel->setPosition(ccp(20, 10));
if( m_pFPSLabel && m_pSPFLabel )
{
CCTexture2D *texture = m_pFPSLabel->getTexture();
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
CC_SAFE_RELEASE_NULL(m_pSPFLabel);
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
CCTextureCache::sharedTextureCache()->removeTexture(texture);
CCFileUtils::sharedFileUtils()->purgeCachedEntries();
}
CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat();
CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444);
m_pFPSLabel = new CCLabelAtlas();
m_pFPSLabel->initWithString("00.0", "fps_images.png", 12, 32, '.');
m_pSPFLabel = new CCLabelAtlas();
m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.');
m_pDrawsLabel = new CCLabelAtlas();
m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.');
CCTexture2D::setDefaultAlphaPixelFormat(currentFormat);
m_pDrawsLabel->setPosition( ccpAdd( ccp(0,34), CC_DIRECTOR_STATS_POSITION ) );
m_pSPFLabel->setPosition( ccpAdd( ccp(0,17), CC_DIRECTOR_STATS_POSITION ) );
m_pFPSLabel->setPosition( CC_DIRECTOR_STATS_POSITION );
}

View File

@ -55,7 +55,7 @@ typedef enum {
} ccDirectorProjection;
/* Forward declarations. */
class CCLabelBMFont;
class CCLabelAtlas;
class CCScene;
class CCEGLView;
class CCDirectorDelegate;
@ -120,7 +120,7 @@ public:
/** Whether or not the Director is paused */
inline bool isPaused(void) { return m_bPaused; }
/** How many frames were called since the director started */
inline unsigned int getFrames(void) { return m_uFrames; }
@ -200,6 +200,13 @@ public:
*/
void popScene(void);
/**Pops out all scenes from the queue until the root scene in the queue.
* This scene will replace the running one.
* The running scene will be deleted. If there are no more scenes in the stack the execution is terminated.
* ONLY call it if there is a running scene.
*/
void popToRootScene(void);
/** Replaces the running scene with a new one. The running scene is terminated.
* ONLY call it if there is a running scene.
*/
@ -332,13 +339,13 @@ protected:
float m_fAccumDt;
float m_fFrameRate;
CCLabelBMFont *m_pFPSLabel;
CCLabelBMFont *m_pSPFLabel;
CCLabelBMFont *m_pDrawsLabel;
CCLabelAtlas *m_pFPSLabel;
CCLabelAtlas *m_pSPFLabel;
CCLabelAtlas *m_pDrawsLabel;
/* is the running scene paused */
/** Whether or not the Director is paused */
bool m_bPaused;
/* How many frames were called since the director started */
unsigned int m_uTotalFrames;
unsigned int m_uFrames;

View File

@ -36,6 +36,8 @@
#include "support/CCPointExtension.h"
#include "CCActionCatmullRom.h"
using namespace std;
NS_CC_BEGIN;
/*
@ -78,6 +80,7 @@ CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone)
}
CCPointArray *points = CCPointArray::arrayWithCapacity(10);
points->retain();
points->setControlPoints(newArray);
newArray->release();
@ -91,14 +94,30 @@ CCPointArray::~CCPointArray()
CCPointArray::CCPointArray() :m_pControlPoints(NULL){}
void CCPointArray::addControlPoint(CCPoint &controlPoint)
void CCPointArray::addControlPoint(CCPoint controlPoint)
{
m_pControlPoints->addObject(&controlPoint);
// should create a new object of CCPoint
// because developer always use this function like this
// addControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::addObject() will retain the passing object, so it
// should be an object created in heap
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->addObject(temp);
temp->release();
}
void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index)
{
m_pControlPoints->insertObject(&controlPoint, index);
// should create a new object of CCPoint
// because developer always use this function like this
// insertControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::insertObject() will retain the passing object, so it
// should be an object created in heap
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->insertObject(temp, index);
temp->release();
}
CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
@ -111,7 +130,15 @@ CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index)
{
m_pControlPoints->replaceObjectAtIndex(index, &controlPoint);
// should create a new object of CCPoint
// because developer always use this function like this
// replaceControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::insertObject() will retain the passing object, so it
// should be an object created in heap
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->replaceObjectAtIndex(index, temp);
temp->release();
}
void CCPointArray::removeControlPointAtIndex(unsigned int index)
@ -136,7 +163,6 @@ CCPointArray* CCPointArray::reverse()
newArray->release();
config->autorelease();
return config;
}
@ -150,7 +176,7 @@ void CCPointArray::reverseInline()
}
// CatmullRom Spline formula:
inline CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t)
CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t)
{
float t2 = t * t;
float t3 = t2 * t;

View File

@ -59,7 +59,7 @@ public:
bool initWithCapacity(unsigned int capacity);
/** appends a control point */
void addControlPoint(CCPoint &controlPoint);
void addControlPoint(CCPoint controlPoint);
/** inserts a controlPoint at index */
void insertControlPoint(CCPoint &controlPoint, unsigned int index);
@ -156,7 +156,7 @@ protected:
A Catmull Rom is a Cardinal Spline with a tension of 0.5.
http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline
*/
class CCCatmullRomTo : public CCCardinalSplineTo
class CC_DLL CCCatmullRomTo : public CCCardinalSplineTo
{
public:
/** creates an action with a Cardinal Spline array of points and tension */
@ -181,7 +181,7 @@ public:
};
/** Returns the Cardinal Spline position for a given set of control points, tension and time */
extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t);
extern CC_DLL CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t);
NS_CC_END;

View File

@ -134,7 +134,7 @@ bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, float duration)
if (gridSize.x != 1 || gridSize.y != 1)
{
// Grid size must be (1,1)
CCAssert(0, "");
CCAssert(0, "Grid size must be (1,1)");
return false;
}
@ -402,9 +402,6 @@ void CCLens3D::setPosition(const CCPoint& pos)
{
if( ! CCPoint::CCPointEqualToPoint(pos, m_position) ) {
m_position = pos;
m_positionInPixels.x = pos.x * CC_CONTENT_SCALE_FACTOR();
m_positionInPixels.y = pos.y * CC_CONTENT_SCALE_FACTOR();
m_bDirty = true;
}
}
@ -421,7 +418,7 @@ void CCLens3D::update(float time)
for (j = 0; j < m_sGridSize.y + 1; ++j)
{
ccVertex3F v = originalVertex(ccg(i, j));
CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x, v.y));
CCPoint vect = ccpSub(m_position, ccp(v.x, v.y));
CCFloat r = ccpLength(vect);
if (r < m_fRadius)
@ -492,8 +489,6 @@ bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float am
void CCRipple3D::setPosition(const CCPoint& position)
{
m_position = position;
m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR();
m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR();
}
CCObject* CCRipple3D::copyWithZone(CCZone *pZone)
@ -528,7 +523,7 @@ void CCRipple3D::update(float time)
for (j = 0; j < (m_sGridSize.y+1); ++j)
{
ccVertex3F v = originalVertex(ccg(i, j));
CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x,v.y));
CCPoint vect = ccpSub(m_position, ccp(v.x,v.y));
CCFloat r = ccpLength(vect);
if (r < m_fRadius)
@ -820,8 +815,6 @@ bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGri
void CCTwirl::setPosition(const CCPoint& position)
{
m_position = position;
m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR();
m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR();
}
CCObject* CCTwirl::copyWithZone(CCZone *pZone)
@ -851,7 +844,7 @@ CCObject* CCTwirl::copyWithZone(CCZone *pZone)
void CCTwirl::update(float time)
{
int i, j;
CCPoint c = m_positionInPixels;
CCPoint c = m_position;
for (i = 0; i < (m_sGridSize.x+1); ++i)
{
@ -865,10 +858,9 @@ void CCTwirl::update(float time)
CCFloat amp = 0.1f * m_fAmplitude * m_fAmplitudeRate;
CCFloat a = r * cosf( (CCFloat)M_PI/2.0f + time * (CCFloat)M_PI * m_nTwirls * 2 ) * amp;
CCPoint d;
d.x = sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x);
d.y = cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x);
CCPoint d = ccp(
sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x),
cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x));
v.x = c.x + d.x;
v.y = c.y + d.y;

View File

@ -110,9 +110,6 @@ protected:
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
float m_fLensEffect;
/* @since v0.99.5 */
// CCPoint m_lastPosition;
CCPoint m_positionInPixels;
bool m_bDirty;
};
@ -148,9 +145,6 @@ protected:
int m_nWaves;
float m_fAmplitude;
float m_fAmplitudeRate;
/*@since v0.99.5*/
CCPoint m_positionInPixels;
};
/** @brief CCShaky3D action */
@ -255,9 +249,6 @@ protected:
int m_nTwirls;
float m_fAmplitude;
float m_fAmplitudeRate;
/*@since v0.99.5 */
CCPoint m_positionInPixels;
};
NS_CC_END

View File

@ -126,7 +126,6 @@ void CCAtlasNode::calculateMaxItems()
void CCAtlasNode::updateAtlasValues()
{
CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overriden");
//[NSException raise:@"CCAtlasNode:Abstract" format:@"updateAtlasValue not overriden"];
}
// CCAtlasNode - draw

View File

@ -89,7 +89,7 @@ bool CCGridBase::initWithSize(const ccGridSize& gridSize, CCTexture2D *pTexture,
CC_SAFE_RETAIN(m_pTexture);
m_bIsTextureFlipped = bFlipped;
const CCSize& texSize = m_pTexture->getContentSizeInPixels();
const CCSize& texSize = m_pTexture->getContentSize();
m_obStep.x = texSize.width / m_sGridSize.x;
m_obStep.y = texSize.height / m_sGridSize.y;

View File

@ -85,7 +85,7 @@ default gl blend src function. Compatible with premultiplied alpha images.
#define CC_NODE_DRAW_SETUP() \
do { \
ccGLEnable( m_glServerState ); \
if (getShaderProgram() != NULL) \
CCAssert(getShaderProgram(), "No shader program set for this node"); \
{ \
getShaderProgram()->use(); \
getShaderProgram()->setUniformForModelViewProjectionMatrix(); \

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include "CCDirector.h"
#include "CCGLProgram.h"
#include "CCShaderCache.h"
#include "CCApplication.h"
NS_CC_BEGIN
@ -39,34 +40,33 @@ NS_CC_BEGIN
//CCLabelTTF
//
CCLabelTTF::CCLabelTTF()
: m_eAlignment(kCCTextAlignmentCenter)
, m_pFontName(NULL)
, m_fFontSize(0.0)
, m_pString(NULL)
: m_hAlignment(kCCTextAlignmentCenter)
, m_vAlignment(kCCVerticalTextAlignmentTop)
, m_pFontName(NULL)
, m_fFontSize(0.0)
, m_string("")
{
}
CCLabelTTF::~CCLabelTTF()
{
CC_SAFE_DELETE(m_pFontName);
CC_SAFE_DELETE(m_pString);
CC_SAFE_DELETE(m_pFontName);
}
CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize)
{
CCLabelTTF *pRet = new CCLabelTTF();
if(pRet && pRet->initWithString(label, dimensions, alignment, fontName, fontSize))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
return labelWithString(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize);
}
CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const char *fontName, float fontSize)
CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize)
{
return labelWithString(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize);
}
CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
{
CCLabelTTF *pRet = new CCLabelTTF();
if(pRet && pRet->initWithString(label, fontName, fontSize))
if(pRet && pRet->initWithString(string, dimensions, hAlignment, vAlignment, fontName, fontSize))
{
pRet->autorelease();
return pRet;
@ -82,93 +82,50 @@ bool CCLabelTTF::init()
bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
{
CCAssert(label != NULL, "");
if (CCSprite::init())
{
// shader program
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
m_eAlignment = alignment;
CC_SAFE_DELETE(m_pFontName);
m_pFontName = new std::string(fontName);
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
this->setString(label);
return true;
}
return false;
return this->initWithString(label, dimensions, alignment, kCCVerticalTextAlignmentTop, fontName, fontSize);
}
bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
{
CCAssert(label != NULL, "");
return this->initWithString(label, CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop, fontName, fontSize);
}
bool CCLabelTTF::initWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize)
{
if (CCSprite::init())
{
// shader program
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
m_tDimensions = CCSizeZero;
CC_SAFE_DELETE(m_pFontName);
this->setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
m_tDimensions = CCSizeMake(dimensions.width, dimensions.height);
m_hAlignment = hAlignment;
m_vAlignment = vAlignment;
m_pFontName = new std::string(fontName);
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
this->setString(label);
m_fFontSize = fontSize;
this->setString(string);
return true;
}
return false;
}
void CCLabelTTF::setString(const char *label)
void CCLabelTTF::setString(const char *string)
{
if (m_pString)
{
delete m_pString;
m_pString = NULL;
}
m_pString = new std::string(label);
CCAssert(string != NULL, "Invalid string");
CCTexture2D *texture;
if( CCSize::CCSizeEqualToSize( m_tDimensions, CCSizeZero ) )
if (m_string.compare(string))
{
texture = new CCTexture2D();
texture->initWithString(label, m_pFontName->c_str(), m_fFontSize);
m_string = string;
this->updateTexture();
}
else
{
texture = new CCTexture2D();
//cjh texture->initWithString(label, m_tDimensions, m_eAlignment, kCCVerticalTextAlignmentTop, m_pFontName->c_str(), m_fFontSize);
}
// TODO
// #ifdef __CC_PLATFORM_IOS
// // iPad ?
// if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
// if( CC_CONTENT_SCALE_FACTOR() == 2 )
// [tex setResolutionType:kCCResolutioniPadRetinaDisplay];
// else
// [tex setResolutionType:kCCResolutioniPad];
// }
// // iPhone ?
// else
// {
// if( CC_CONTENT_SCALE_FACTOR() == 2 )
// [tex setResolutionType:kCCResolutioniPhoneRetinaDisplay];
// else
// [tex setResolutionType:kCCResolutioniPhone];
// }
// #end
this->setTexture(texture);
texture->release();
CCRect rect = CCRectZero;
rect.size = m_pobTexture->getContentSize();
this->setTextureRect(rect);
}
const char* CCLabelTTF::getString(void)
{
return m_pString->c_str();
return m_string.c_str();
}
const char* CCLabelTTF::description()
@ -176,4 +133,152 @@ const char* CCLabelTTF::description()
return CCString::stringWithFormat("<CCLabelTTF | FontName = %s, FontSize = %.1f>", m_pFontName->c_str(), m_fFontSize)->getCString();
}
CCTextAlignment CCLabelTTF::getHorizontalAlignment()
{
return m_hAlignment;
}
void CCLabelTTF::setHorizontalAlignment(CCTextAlignment alignment)
{
if (alignment != m_hAlignment)
{
m_hAlignment = alignment;
// Force update
if (m_string.size() > 0)
{
this->updateTexture();
}
}
}
CCVerticalTextAlignment CCLabelTTF::getVerticalAlignment()
{
return m_vAlignment;
}
void CCLabelTTF::setVerticalAlignment(CCVerticalTextAlignment verticalAlignment)
{
if (verticalAlignment != m_vAlignment)
{
m_vAlignment = verticalAlignment;
// Force update
if (m_string.size() > 0)
{
this->updateTexture();
}
}
}
CCSize CCLabelTTF::getDimensions()
{
return m_tDimensions;
}
void CCLabelTTF::setDimensions(CCSize &dim)
{
if (dim.width != m_tDimensions.width || dim.height != m_tDimensions.height)
{
m_tDimensions = dim;
// Force udpate
if (m_string.size() > 0)
{
this->updateTexture();
}
}
}
float CCLabelTTF::getFontSize()
{
return m_fFontSize;
}
void CCLabelTTF::setFontSize(float fontSize)
{
if (m_fFontSize != fontSize)
{
// Force update
if (m_string.size() > 0)
{
this->updateTexture();
}
}
}
const char* CCLabelTTF::getFontName()
{
return m_pFontName->c_str();
}
void CCLabelTTF::setFontName(const char *fontName)
{
if (m_pFontName->compare(fontName))
{
delete m_pFontName;
m_pFontName = new std::string(fontName);
// Force update
if (m_string.size() > 0)
{
this->updateTexture();
}
}
}
// Helper
void CCLabelTTF::updateTexture()
{
CCTexture2D *tex;
if (m_tDimensions.width == 0 || m_tDimensions.height == 0)
{
tex = new CCTexture2D();
tex->initWithString(m_string.c_str(), m_pFontName->c_str(), m_fFontSize * CC_CONTENT_SCALE_FACTOR()) ;
}
else
{
tex = new CCTexture2D();
tex->initWithString(m_string.c_str(),
CC_SIZE_POINTS_TO_PIXELS(m_tDimensions),
m_hAlignment,
m_vAlignment,
m_pFontName->c_str(),
m_fFontSize * CC_CONTENT_SCALE_FACTOR());
}
// iPad ?
//if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
if (CCApplication::sharedApplication().isIpad())
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPadRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPad);
}
}
// iPhone ?
else
{
if (CC_CONTENT_SCALE_FACTOR() == 2)
{
tex->setResolutionType(kCCResolutioniPhoneRetinaDisplay);
}
else
{
tex->setResolutionType(kCCResolutioniPhone);
}
}
this->setTexture(tex);
tex->release();
CCRect rect = CCRectZero;
rect.size = m_pobTexture->getContentSize();
this->setTextureRect(rect);
}
NS_CC_END

View File

@ -41,33 +41,70 @@ class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol
public:
CCLabelTTF();
virtual ~CCLabelTTF();
const char* description();
/** creates a CCLabelTTF from a fontname, alignment, dimension and font size */
static CCLabelTTF * labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize);
/** creates a CCLabelTTF from a fontname and font size */
static CCLabelTTF * labelWithString(const char *label, const char *fontName, float fontSize);
const char* description();
/** creates a CCLabelTTF with a font name and font size in points*/
static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize);
/** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points.
@since v1.0
*/
static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
const char *fontName, float fontSize);
/** creates a CCLabel from a fontname, alignment, dimension in points and font size in points*/
static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize);
bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize);
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment,
CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize);
/** initializes the CCLabelTTF with a font name and font size */
bool initWithString(const char *label, const char *fontName, float fontSize);
bool initWithString(const char *string, const char *fontName, float fontSize);
/** initializes the CCLabelTTF */
bool init();
/** changes the string to render
* @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas
*/
virtual void setString(const char *label);
virtual const char* getString(void);
CCTextAlignment getHorizontalAlignment();
void setHorizontalAlignment(CCTextAlignment alignment);
CCVerticalTextAlignment getVerticalAlignment();
void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment);
CCSize getDimensions();
void setDimensions(CCSize &dim);
float getFontSize();
void setFontSize(float fontSize);
const char* getFontName();
void setFontName(const char *fontName);
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
private:
void updateTexture();
protected:
/** Dimensions of the label in Points */
CCSize m_tDimensions;
CCTextAlignment m_eAlignment;
/** The alignment of the label */
CCTextAlignment m_hAlignment;
/** The vertical alignment of the label */
CCVerticalTextAlignment m_vAlignment;
/** Font name used in the label */
std::string * m_pFontName;
/** Font size of the label */
float m_fFontSize;
std::string * m_pString;
std::string m_string;
};
NS_CC_END

View File

@ -43,6 +43,8 @@ public:
@return Current language config
*/
virtual ccLanguageType getCurrentLanguage() = 0;
virtual bool isIpad() { return false; }
};

View File

@ -55,11 +55,6 @@ CCEGLViewProtocol::~CCEGLViewProtocol()
}
bool CCEGLViewProtocol::isIpad()
{
return false;
}
void CCEGLViewProtocol::setFrameSize(float width, float height)
{
m_sSizeInPixel.setSize(width, height);

View File

@ -21,7 +21,6 @@ public:
virtual void swapBuffers() = 0;
virtual void setIMEKeyboardState(bool bOpen) = 0;
virtual bool isIpad();
virtual CCRect getViewPort();
virtual CCSize getSize();
virtual void setFrameSize(float width, float height);

View File

@ -36,6 +36,8 @@ class CC_DLL CCFileUtils
public:
static CCFileUtils* sharedFileUtils();
static void purgeFileUtils();
void purgeCachedEntries();
/**
@brief Get resource file data
@param[in] pszFileName The resource file name which contain the path

View File

@ -25,16 +25,42 @@ THE SOFTWARE.
#define __CC_PLATFORM_FILEUTILS_CPP__
#include "CCFileUtilsCommon_cpp.h"
using namespace std;
NS_CC_BEGIN
#include "CCCommon.h"
#include "jni/SystemInfoJni.h"
using namespace std;
// record the resource path
static string s_strResourcePath = "";
static CCFileUtils* s_pFileUtils = NULL;
CCFileUtils* CCFileUtils::sharedFileUtils()
{
if (s_pFileUtils == NULL)
{
s_pFileUtils = new CCFileUtils();
}
return s_pFileUtils;
}
void CCFileUtils::purgeFileUtils()
{
if (s_pFileUtils != NULL)
{
s_pFileUtils->purgeCachedEntries();
}
CC_SAFE_DELETE(s_pFileUtils);
}
void CCFileUtils::purgeCachedEntries()
{
}
/*
* This function is implemented for jni to set apk path.
*/

View File

@ -35,53 +35,55 @@ class CCRect;
class CC_DLL CCApplication : public CCApplicationProtocol
{
public:
CCApplication();
virtual ~CCApplication();
CCApplication();
virtual ~CCApplication();
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
*/
void setAnimationInterval(double interval);
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
*/
void setAnimationInterval(double interval);
typedef enum
{
/// Device oriented vertically, home button on the bottom
kOrientationPortrait = 0,
typedef enum
{
/// Device oriented vertically, home button on the bottom
kOrientationPortrait = 0,
/// Device oriented vertically, home button on the top
kOrientationPortraitUpsideDown = 1,
/// Device oriented horizontally, home button on the right
kOrientationLandscapeLeft = 2,
/// Device oriented horizontally, home button on the left
kOrientationLandscapeRight = 3,
} Orientation;
kOrientationPortraitUpsideDown = 1,
/// Device oriented horizontally, home button on the right
kOrientationLandscapeLeft = 2,
/// Device oriented horizontally, home button on the left
kOrientationLandscapeRight = 3,
} Orientation;
/**
@brief Callback by CCDirector for change device orientation.
@orientation The defination of orientation which CCDirector want change to.
@return The actual orientation of the application.
*/
Orientation setOrientation(Orientation orientation);
/**
@brief Callback by CCDirector for change device orientation.
@orientation The defination of orientation which CCDirector want change to.
@return The actual orientation of the application.
*/
Orientation setOrientation(Orientation orientation);
/**
@brief Run the message loop.
*/
int run();
/**
@brief Run the message loop.
*/
int run();
/**
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static CCApplication& sharedApplication();
/**
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static CCApplication& sharedApplication();
/**
@brief Get current language config
@return Current language config
*/
virtual ccLanguageType getCurrentLanguage();
/**
@brief Get current language config
@return Current language config
*/
virtual ccLanguageType getCurrentLanguage();
virtual bool isIpad();
protected:
static CCApplication * sm_pSharedApplication;
static CCApplication * sm_pSharedApplication;
};
NS_CC_END

View File

@ -145,4 +145,14 @@ ccLanguageType CCApplication::getCurrentLanguage()
return ret;
}
bool CCApplication::isIpad()
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
return true;
}
return false;
}
NS_CC_END

View File

@ -86,6 +86,7 @@ void CCEGLView::swapBuffers()
CCSize CCEGLView::getFrameSize()
{
assert(false);
return CCSizeMake(0, 0);
}
void CCEGLView::setIMEKeyboardState(bool bOpen)

View File

@ -212,6 +212,32 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict)
NS_CC_BEGIN
static CCFileUtils* s_pFileUtils = NULL;
CCFileUtils* CCFileUtils::sharedFileUtils()
{
if (s_pFileUtils == NULL)
{
s_pFileUtils = new CCFileUtils();
}
return s_pFileUtils;
}
void CCFileUtils::purgeFileUtils()
{
if (s_pFileUtils != NULL)
{
s_pFileUtils->purgeCachedEntries();
}
CC_SAFE_DELETE(s_pFileUtils);
}
void CCFileUtils::purgeCachedEntries()
{
}
void CCFileUtils::setResourcePath(const char *pszResourcePath)
{
assert(0);
@ -389,7 +415,7 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const
CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName)
{
const char* pszFullPath = CCFileUtils::fullPathFromRelativePath(pFileName);
const char* pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFileName);
NSString* pPath = [NSString stringWithUTF8String:pszFullPath];
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#define glDeleteVertexArrays glDeleteVertexArraysOES
#define glGenVertexArrays glGenVertexArraysOES
#define glBindVertexArray glBindVertexArrayOES
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#include <OpenGLES/ES2/gl.h>
#include <OPenGLES/ES2/glext.h>

View File

@ -348,7 +348,8 @@ CCImage::~CCImage()
bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
{
unsigned long nSize;
unsigned char *pBuffer = CCFileUtils::getFileData(CCFileUtils::fullPathFromRelativePath(strPath), "rb", &nSize);
CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils();
unsigned char *pBuffer = fileUtils->getFileData(fileUtils->fullPathFromRelativePath(strPath), "rb", &nSize);
return initWithImageData(pBuffer, nSize, eImgFmt);
}
@ -360,7 +361,7 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima
* CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease().
*/
unsigned long nSize;
unsigned char *pBuffer = CCFileUtils::getFileData(fullpath, "rb", &nSize);
unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize);
return initWithImageData(pBuffer, nSize, imageType);
}
@ -426,21 +427,25 @@ bool CCImage::_initWithRawData(void *pData, int nDatalen, int nWidth, int nHeigh
bool CCImage::_initWithJpgData(void *pData, int nDatalen)
{
assert(0);
return false;
}
bool CCImage::_initWithPngData(void *pData, int nDatalen)
{
assert(0);
return false;
}
bool CCImage::_saveImageToPNG(const char *pszFilePath, bool bIsToRGB)
{
assert(0);
return false;
}
bool CCImage::_saveImageToJPG(const char *pszFilePath)
{
assert(0);
return false;
}
bool CCImage::initWithString(

View File

@ -62,9 +62,19 @@ CCFileUtils* CCFileUtils::sharedFileUtils()
void CCFileUtils::purgeFileUtils()
{
if (s_pFileUtils != NULL)
{
s_pFileUtils->purgeCachedEntries();
}
CC_SAFE_DELETE(s_pFileUtils);
}
void CCFileUtils::purgeCachedEntries()
{
}
void CCFileUtils::setResourcePath(const char *pszResourcePath)
{
CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path");

View File

@ -88,8 +88,6 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn
m_pAtlasIndexArray = ccCArrayNew((unsigned int)totalNumberOfTiles);
this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(CCSizeMake(m_tLayerSize.width * m_tMapTileSize.width, m_tLayerSize.height * m_tMapTileSize.height)));
m_tMapTileSize.width /= m_fContentScaleFactor;
m_tMapTileSize.height /= m_fContentScaleFactor;
m_bUseAutomaticVertexZ = false;
m_nVertexZvalue = 0;

View File

@ -28,10 +28,12 @@ THE SOFTWARE.
#include "CCTextureAtlas.h"
#include "support/image_support/TGAlib.h"
#include "ccConfig.h"
#include "CCDictionary.h"
#include "CCInteger.h"
#include "CCDirector.h"
NS_CC_BEGIN
// implementation CCTileMapAtlas
CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight)
@ -45,13 +47,16 @@ CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, cons
CC_SAFE_DELETE(pRet);
return NULL;
}
bool CCTileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight)
{
this->loadTGAfile(mapFile);
this->calculateItemsToRender();
if( CCAtlasNode::initWithTileFile(tile, tileWidth, tileHeight, m_nItemsToRender) )
{
m_pPosToAtlasIndex = new StringToIntegerDictionary();
m_tColor = ccWHITE;
m_pPosToAtlasIndex = new CCDictionary();
this->updateAtlasValues();
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_uItemWidth),
(float)(m_pTGAInfo->height*m_uItemHeight)));
@ -59,25 +64,23 @@ bool CCTileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int
}
return false;
}
CCTileMapAtlas::CCTileMapAtlas()
:m_pTGAInfo(NULL)
,m_pPosToAtlasIndex(NULL)
,m_nItemsToRender(0)
{
}
CCTileMapAtlas::~CCTileMapAtlas()
{
if (m_pTGAInfo)
{
tgaDestroy(m_pTGAInfo);
}
if (m_pPosToAtlasIndex)
{
m_pPosToAtlasIndex->clear();
delete m_pPosToAtlasIndex;
m_pPosToAtlasIndex = NULL;
}
CC_SAFE_RELEASE(m_pPosToAtlasIndex);
}
void CCTileMapAtlas::releaseMap()
{
if (m_pTGAInfo)
@ -86,13 +89,9 @@ void CCTileMapAtlas::releaseMap()
}
m_pTGAInfo = NULL;
if (m_pPosToAtlasIndex)
{
m_pPosToAtlasIndex->clear();
delete m_pPosToAtlasIndex;
m_pPosToAtlasIndex = NULL;
}
CC_SAFE_RELEASE_NULL(m_pPosToAtlasIndex);
}
void CCTileMapAtlas::calculateItemsToRender()
{
CCAssert( m_pTGAInfo != NULL, "tgaInfo must be non-nil");
@ -111,6 +110,7 @@ void CCTileMapAtlas::calculateItemsToRender()
}
}
}
void CCTileMapAtlas::loadTGAfile(const char *file)
{
CCAssert( file != NULL, "file must be non-nil");
@ -150,22 +150,13 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position)
{
ptr[position.x + position.y * m_pTGAInfo->width] = tile;
// XXX: this method consumes a lot of memory
// XXX: a tree of something like that shall be impolemented
char buffer[32];
/*std::string key = itoa(position.x, buffer, 10);*/
sprintf(buffer, "%d", position.x);
std::string key = buffer;
key += ",";
/*key += itoa(position.y, buffer, 10);*/
sprintf(buffer, "%d", position.y);
key += buffer;
int num = m_pPosToAtlasIndex->find(key)->second;
this->updateAtlasValueAt(position, tile, num);
// XXX: this method consumes a lot of memory
// XXX: a tree of something like that shall be impolemented
CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::stringWithFormat("%d,%d", position.x, position.y)->getCString());
this->updateAtlasValueAt(position, tile, num->getValue());
}
}
ccColor3B CCTileMapAtlas::tileAt(const ccGridSize& position)
{
CCAssert( m_pTGAInfo != NULL, "tgaInfo must not be nil");
@ -177,6 +168,7 @@ ccColor3B CCTileMapAtlas::tileAt(const ccGridSize& position)
return value;
}
void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& value, unsigned int index)
{
ccV3F_C4B_T2F_Quad quad;
@ -189,16 +181,19 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B&
float textureWide = (float) (m_pTextureAtlas->getTexture()->getPixelsWide());
float textureHigh = (float) (m_pTextureAtlas->getTexture()->getPixelsHigh());
float itemWidthInPixels = m_uItemWidth * CC_CONTENT_SCALE_FACTOR();
float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR();
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide);
float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide);
float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh);
float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh);
float left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide);
float right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide);
float top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh);
float bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh);
#else
float left = (row * m_uItemWidth) / textureWide;
float right = left + m_uItemWidth / textureWide;
float top = (col * m_uItemHeight) / textureHigh;
float bottom = top + m_uItemHeight / textureHigh;
float left = (row * itemWidthInPixels) / textureWide;
float right = left + itemWidthInPixels / textureWide;
float top = (col * itemHeightInPixels) / textureHigh;
float bottom = top + itemHeightInPixels / textureHigh;
#endif
quad.tl.texCoords.u = left;
@ -223,8 +218,15 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B&
quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
quad.tr.vertices.z = 0.0f;
ccColor4B color = { m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity };
quad.tr.colors = color;
quad.tl.colors = color;
quad.br.colors = color;
quad.bl.colors = color;
m_pTextureAtlas->updateQuad(&quad, index);
}
void CCTileMapAtlas::updateAtlasValues()
{
CCAssert( m_pTGAInfo != NULL, "tgaInfo must be non-nil");
@ -244,28 +246,22 @@ void CCTileMapAtlas::updateAtlasValues()
{
this->updateAtlasValueAt(ccg(x,y), value, total);
char buffer[32];
/*std::string key = itoa(x, buffer, 10);*/
sprintf(buffer, "%d", x);
std::string key = buffer;
key += ",";
/*key += itoa(y, buffer, 10);*/
sprintf(buffer, "%d", y);
key += buffer;
m_pPosToAtlasIndex->insert(StringToIntegerPair(key, total));
CCString *key = CCString::stringWithFormat("%d,%d", x,y);
CCInteger *num = CCInteger::integerWithInt(total);
m_pPosToAtlasIndex->setObject(num, key->getCString());
total++;
}
}
}
}
}
void CCTileMapAtlas::setTGAInfo(struct sImageTGA* var)
{
m_pTGAInfo = var;
}
struct sImageTGA * CCTileMapAtlas::getTGAInfo()
{
return m_pTGAInfo;

View File

@ -25,15 +25,14 @@ THE SOFTWARE.
****************************************************************************/
#ifndef __CCTILE_MAP_ATLAS__
#define __CCTILE_MAP_ATLAS__
#include <string>
#include <map>
#include "CCAtlasNode.h"
NS_CC_BEGIN
typedef std::map<std::string, int> StringToIntegerDictionary;
typedef std::pair<std::string, int> StringToIntegerPair;
struct sImageTGA;
class CCDictionary;
/** @brief CCTileMapAtlas is a subclass of CCAtlasNode.
It knows how to render a map based of tiles.
@ -82,9 +81,9 @@ private:
protected:
//! x,y to altas dicctionary
StringToIntegerDictionary *m_pPosToAtlasIndex;
CCDictionary* m_pPosToAtlasIndex;
//! numbers of tiles to render
int m_nItemsToRender;
int m_nItemsToRender;
};
NS_CC_END

View File

@ -1 +1 @@
2d4adf9bb3276c7884f16637eb15bd5090ad7ca2
2ef6f502d16098ac1a18aee1ab7a64815c241af6

View File

@ -1 +1 @@
f15b1b846b94b2d2b69438899124884963fd9f09
27f42f585ea7195531f863d34fff314117000630

View File

@ -1 +1 @@
59d857c1050d96d698c58eaf20c0c3cd1a808cbf
594b0f9fe97d6f6dd1d56c71ccd7e1c61b5522b3

View File

@ -1 +1 @@
277bc57b726290085c72db62cf656b66594440dc
c16d1dddb12b5a7e7e715f234dfd031657369f96

View File

@ -90,7 +90,7 @@ void ActionManagerTest::onEnter()
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
addChild(label, 1);
label->setPosition( CCPointMake(s.width/2, s.height-50) );
label->setPosition(CCPointMake(s.width/2, s.height-50));
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) );
@ -98,10 +98,10 @@ void ActionManagerTest::onEnter()
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
item2->setPosition( CCPointMake( s.width/2, 30) );
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
menu->setPosition(CCPointZero);
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2));
item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 1);
}

View File

@ -617,8 +617,10 @@ EaseSpriteDemo::~EaseSpriteDemo(void)
void EaseSpriteDemo::positionForTwo()
{
m_grossini->setPosition( CCPointMake( 60, 120 ) );
m_tamara->setPosition( CCPointMake( 60, 220) );
CCSize s = CCDirector::sharedDirector()->getWinSize();
m_grossini->setPosition(CCPointMake(60, s.height*1/5));
m_tamara->setPosition(CCPointMake( 60, s.height*4/5));
m_kathia->setIsVisible(false);
}
@ -643,13 +645,13 @@ void EaseSpriteDemo::onEnter()
CCSize s = CCDirector::sharedDirector()->getWinSize();
m_grossini->setPosition( CCPointMake(60, 50) );
m_kathia->setPosition( CCPointMake(60, 150) );
m_tamara->setPosition( CCPointMake(60, 250) );
m_grossini->setPosition(CCPointMake(60, s.height*1/5));
m_kathia->setPosition(CCPointMake(60, s.height*2.5f/5));
m_tamara->setPosition(CCPointMake(60, s.height*4/5));
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
addChild(label);
label->setPosition( CCPointMake(s.width/2, s.height-50) );
label->setPosition(CCPointMake(s.width/2, s.height-50));
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) );
@ -657,10 +659,10 @@ void EaseSpriteDemo::onEnter()
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
item2->setPosition( CCPointMake( s.width/2, 30) );
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
menu->setPosition(CCPointZero);
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2));
item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 1);
}

View File

@ -111,10 +111,10 @@ void SpriteDemo::onEnter()
CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
item2->setPosition( CCPointMake( s.width/2, 30) );
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
menu->setPosition(CCPointZero);
item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2));
item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 1);
CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255,0,0,255));

View File

@ -1,5 +1,6 @@
#include "ActionsTest.h"
#include "../testResource.h"
#include "CCActionCatmullRom.h"
CCLayer* NextAction();
CCLayer* BackAction();
@ -13,72 +14,79 @@ CCLayer* CreateLayer(int nIndex)
switch (nIndex)
{
case ACTION_MANUAL_LAYER:
pLayer = new ActionManual(); break;
case ACTION_MOVE_LAYER:
pLayer = new ActionMove(); break;
case ACTION_SCALE_LAYER:
pLayer = new ActionScale(); break;
case ACTION_ROTATE_LAYER:
pLayer = new ActionRotate(); break;
case ACTION_SKEW_LAYER:
pLayer = new ActionSkew(); break;
case ACTION_SKEWROTATE_LAYER:
pLayer = new ActionSkewRotateScale(); break;
case ACTION_JUMP_LAYER:
pLayer = new ActionJump(); break;
case ACTION_BEZIER_LAYER:
pLayer = new ActionBezier(); break;
case ACTION_BLINK_LAYER:
pLayer = new ActionBlink(); break;
case ACTION_FADE_LAYER:
pLayer = new ActionFade(); break;
case ACTION_TINT_LAYER:
pLayer = new ActionTint(); break;
case ACTION_ANIMATE_LAYER:
pLayer = new ActionAnimate(); break;
case ACTION_SEQUENCE_LAYER:
pLayer = new ActionSequence(); break;
case ACTION_SEQUENCE2_LAYER:
pLayer = new ActionSequence2(); break;
case ACTION_SPAWN_LAYER:
pLayer = new ActionSpawn(); break;
case ACTION_REVERSE:
pLayer = new ActionReverse(); break;
case ACTION_DELAYTIME_LAYER:
pLayer = new ActionDelayTime(); break;
case ACTION_REPEAT_LAYER:
pLayer = new ActionRepeat(); break;
case ACTION_REPEATEFOREVER_LAYER:
pLayer = new ActionRepeatForever(); break;
case ACTION_ROTATETOREPEATE_LAYER:
pLayer = new ActionRotateToRepeat(); break;
case ACTION_ROTATEJERK_LAYER:
pLayer = new ActionRotateJerk(); break;
case ACTION_CALLFUNC_LAYER:
pLayer = new ActionCallFunc(); break;
case ACTION_CALLFUNCND_LAYER:
pLayer = new ActionCallFuncND(); break;
case ACTION_REVERSESEQUENCE_LAYER:
pLayer = new ActionReverseSequence(); break;
case ACTION_REVERSESEQUENCE2_LAYER:
pLayer = new ActionReverseSequence2(); break;
case ACTION_ORBIT_LAYER:
pLayer = new ActionOrbit(); break;
case ACTION_FLLOW_LAYER:
pLayer = new ActionFollow(); break;
case ACTION_TARGETED_LAYER:
pLayer = new ActionTargeted(); break;
case ACTION_ISSUE1305_LAYER:
pLayer = new Issue1305(); break;
case ACTION_ISSUE1305_2_LAYER:
pLayer = new Issue1305_2(); break;
case ACTION_ISSUE1288_LAYER:
pLayer = new Issue1288(); break;
case ACTION_ISSUE1288_2_LAYER:
pLayer = new Issue1288_2(); break;
case ACTION_ISSUE1327_LAYER:
pLayer = new Issue1327(); break;
case ACTION_MANUAL_LAYER:
pLayer = new ActionManual(); break;
case ACTION_MOVE_LAYER:
pLayer = new ActionMove(); break;
case ACTION_SCALE_LAYER:
pLayer = new ActionScale(); break;
case ACTION_ROTATE_LAYER:
pLayer = new ActionRotate(); break;
case ACTION_SKEW_LAYER:
pLayer = new ActionSkew(); break;
case ACTION_SKEWROTATE_LAYER:
pLayer = new ActionSkewRotateScale(); break;
case ACTION_JUMP_LAYER:
pLayer = new ActionJump(); break;
case ACTION_BEZIER_LAYER:
pLayer = new ActionBezier(); break;
case ACTION_BLINK_LAYER:
pLayer = new ActionBlink(); break;
case ACTION_FADE_LAYER:
pLayer = new ActionFade(); break;
case ACTION_TINT_LAYER:
pLayer = new ActionTint(); break;
case ACTION_ANIMATE_LAYER:
pLayer = new ActionAnimate(); break;
case ACTION_SEQUENCE_LAYER:
pLayer = new ActionSequence(); break;
case ACTION_SEQUENCE2_LAYER:
pLayer = new ActionSequence2(); break;
case ACTION_SPAWN_LAYER:
pLayer = new ActionSpawn(); break;
case ACTION_REVERSE:
pLayer = new ActionReverse(); break;
case ACTION_DELAYTIME_LAYER:
pLayer = new ActionDelayTime(); break;
case ACTION_REPEAT_LAYER:
pLayer = new ActionRepeat(); break;
case ACTION_REPEATEFOREVER_LAYER:
pLayer = new ActionRepeatForever(); break;
case ACTION_ROTATETOREPEATE_LAYER:
pLayer = new ActionRotateToRepeat(); break;
case ACTION_ROTATEJERK_LAYER:
pLayer = new ActionRotateJerk(); break;
case ACTION_CALLFUNC_LAYER:
pLayer = new ActionCallFunc(); break;
case ACTION_CALLFUNCND_LAYER:
pLayer = new ActionCallFuncND(); break;
case ACTION_REVERSESEQUENCE_LAYER:
pLayer = new ActionReverseSequence(); break;
case ACTION_REVERSESEQUENCE2_LAYER:
pLayer = new ActionReverseSequence2(); break;
case ACTION_ORBIT_LAYER:
pLayer = new ActionOrbit(); break;
case ACTION_FLLOW_LAYER:
pLayer = new ActionFollow(); break;
case ACTION_TARGETED_LAYER:
pLayer = new ActionTargeted(); break;
case ACTION_ISSUE1305_LAYER:
pLayer = new Issue1305(); break;
case ACTION_ISSUE1305_2_LAYER:
pLayer = new Issue1305_2(); break;
case ACTION_ISSUE1288_LAYER:
pLayer = new Issue1288(); break;
case ACTION_ISSUE1288_2_LAYER:
pLayer = new Issue1288_2(); break;
case ACTION_ISSUE1327_LAYER:
pLayer = new Issue1327(); break;
case ACTION_CARDINALSPLINE_LAYER:
pLayer = new ActionCardinalSpline(); break;
case ACTION_CATMULLROM_LAYER:
pLayer = new ActionCatmullRom(); break;
case PAUSERESUMEACTIONS_LAYER:
pLayer = new PauseResumeActions(); break;
default:
break;
}
@ -157,9 +165,9 @@ void ActionsDemo::onEnter()
CCSize s = CCDirector::sharedDirector()->getWinSize();
m_grossini->setPosition( CCPointMake(s.width/2, s.height/3));
m_tamara->setPosition( CCPointMake(s.width/2, 2*s.height/3));
m_kathia->setPosition( CCPointMake(s.width/2, s.height/2));
m_grossini->setPosition(CCPointMake(s.width/2, s.height/3));
m_tamara->setPosition(CCPointMake(s.width/2, 2*s.height/3));
m_kathia->setPosition(CCPointMake(s.width/2, s.height/2));
// add title and subtitle
std::string str = title();
@ -183,10 +191,10 @@ void ActionsDemo::onEnter()
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CCPointZero );
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
item2->setPosition( CCPointMake( s.width/2, 30) );
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
menu->setPosition(CCPointZero);
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2));
item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
addChild(menu, 1);
}
@ -1441,3 +1449,219 @@ void Issue1327::logSprRotation(CCNode* pSender)
CCLog("%f", ((CCSprite*)pSender)->getRotation());
}
/** ActionCatmullRom
*/
void ActionCatmullRom::onEnter()
{
ActionsDemo::onEnter();
this->centerSprites(2);
CCSize s = CCDirector::sharedDirector()->getWinSize();
//
// sprite 1 (By)
//
// startPosition can be any coordinate, but since the movement
// is relative to the Catmull Rom curve, it is better to start with (0,0).
//
m_tamara->setPosition(ccp(50, 50));
CCPointArray *array = CCPointArray::arrayWithCapacity(20);
array->addControlPoint(ccp(0, 0));
array->addControlPoint(ccp(80, 80));
array->addControlPoint(ccp(s.width - 80, 80));
array->addControlPoint(ccp(s.width - 80, s.height - 80));
array->addControlPoint(ccp(80, s.height - 80));
array->addControlPoint(ccp(80, 80));
array->addControlPoint(ccp(s.width / 2, s.height / 2));
CCCatmullRomBy *action = CCCatmullRomBy::actionWithDuration(3, array);
CCFiniteTimeAction *reverse = action->reverse();
CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL);
m_tamara->runAction(seq);
//
// sprite 2 (To)
//
// The startPosition is not important here, because it uses a "To" action.
// The initial position will be the 1st point of the Catmull Rom path
//
CCPointArray *array2 = CCPointArray::arrayWithCapacity(20);
array2->addControlPoint(ccp(s.width / 2, 30));
array2->addControlPoint(ccp(s.width -80, 30));
array2->addControlPoint(ccp(s.width - 80, s.height - 80));
array2->addControlPoint(ccp(s.width / 2, s.height - 80));
array2->addControlPoint(ccp(s.width / 2, 30));
CCCatmullRomTo *action2 = CCCatmullRomTo::actionWithDuration(3, array2);
CCFiniteTimeAction *reverse2 = action2->reverse();
CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL);
m_kathia->runAction(seq2);
m_pArray1 = array;
m_pArray1->retain();
m_pArray2 = array2;
m_pArray2->retain();
}
ActionCatmullRom::~ActionCatmullRom()
{
m_pArray1->release();
m_pArray2->release();
}
void ActionCatmullRom::draw()
{
ActionsDemo::draw();
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
kmGLTranslatef(50, 50, 0);
ccDrawCatmullRom(m_pArray1, 50);
kmGLPopMatrix();
ccDrawCatmullRom(m_pArray2,50);
}
string ActionCatmullRom::title()
{
return "CatmullRomBy / CatmullRomTo";
}
string ActionCatmullRom::subtitle()
{
return "Catmull Rom spline paths. Testing reverse too";
}
/** ActionCardinalSpline
*/
void ActionCardinalSpline::onEnter()
{
ActionsDemo::onEnter();
this->centerSprites(2);
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCPointArray *array = CCPointArray::arrayWithCapacity(20);
array->addControlPoint(ccp(0, 0));
array->addControlPoint(ccp(s.width/2-30, 0));
array->addControlPoint(ccp(s.width/2-30, s.height-80));
array->addControlPoint(ccp(0, s.height-80));
array->addControlPoint(ccp(0, 0));
//
// sprite 1 (By)
//
// Spline with no tension (tension==0)
//
CCCardinalSplineBy *action = CCCardinalSplineBy::actionWithDuration(3, array, 0);
CCActionInterval *reverse = action->reverse();
CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL);
m_tamara->setPosition(ccp(50, 50));
m_tamara->runAction(seq);
//
// sprite 2 (By)
//
// Spline with high tension (tension==1)
//
CCCardinalSplineBy *action2 = CCCardinalSplineBy::actionWithDuration(3, array, 1);
CCActionInterval *reverse2 = action2->reverse();
CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL);
m_kathia->setPosition(ccp(s.width/2, 50));
m_kathia->runAction(seq2);
m_pArray = array;
array->retain();
}
ActionCardinalSpline::~ActionCardinalSpline()
{
m_pArray->release();
}
void ActionCardinalSpline::draw()
{
ActionsDemo::draw();
// move to 50,50 since the "by" path will start at 50,50
kmGLPushMatrix();
kmGLTranslatef(50, 50, 0);
ccDrawCardinalSpline(m_pArray, 0, 100);
kmGLPopMatrix();
CCSize s = CCDirector::sharedDirector()->getWinSize();
kmGLPushMatrix();
kmGLTranslatef(s.width/2, 50, 0);
ccDrawCardinalSpline(m_pArray, 1, 100);
kmGLPopMatrix();
}
string ActionCardinalSpline::title()
{
return "CardinalSplineBy / CardinalSplineAt";
}
string ActionCardinalSpline::subtitle()
{
return "Cardinal Spline paths. Testing different tensions for one array";
}
/** PauseResumeActions
*/
void PauseResumeActions::onEnter()
{
ActionsDemo::onEnter();
this->centerSprites(2);
m_tamara->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360)));
m_grossini->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, -360)));
m_kathia->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360)));
this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0);
this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0);
}
string PauseResumeActions::title()
{
return "PauseResumeActions";
}
string PauseResumeActions::subtitle()
{
return "All actions pause at 3s and resume at 5s";
}
void PauseResumeActions::pause(float dt)
{
CCLog("Pausing");
CCDirector *director = CCDirector::sharedDirector();
this->m_pPausedTargets = director->getActionManager()->pauseAlllRunningActions();
}
void PauseResumeActions::resume(float dt)
{
CCLog("Resuming");
CCDirector *director = CCDirector::sharedDirector();
director->getActionManager()->resumeTargets(this->m_pPausedTargets);
}

View File

@ -16,6 +16,8 @@ enum
ACTION_SKEW_LAYER,
ACTION_SKEWROTATE_LAYER,
ACTION_JUMP_LAYER,
ACTION_CARDINALSPLINE_LAYER,
ACTION_CATMULLROM_LAYER,
ACTION_BEZIER_LAYER,
ACTION_BLINK_LAYER,
ACTION_FADE_LAYER,
@ -37,6 +39,7 @@ enum
ACTION_ORBIT_LAYER,
ACTION_FLLOW_LAYER,
ACTION_TARGETED_LAYER,
PAUSERESUMEACTIONS_LAYER,
ACTION_ISSUE1305_LAYER,
ACTION_ISSUE1305_2_LAYER,
ACTION_ISSUE1288_LAYER,
@ -334,4 +337,44 @@ public:
void logSprRotation(CCNode* pSender);
};
class ActionCatmullRom : public ActionsDemo
{
public:
~ActionCatmullRom();
virtual void onEnter();
virtual void draw();
virtual std::string subtitle();
virtual std::string title();
private:
CCPointArray *m_pArray1;
CCPointArray *m_pArray2;
};
class ActionCardinalSpline : public ActionsDemo
{
public:
~ActionCardinalSpline();
virtual void onEnter();
virtual void draw();
virtual std::string subtitle();
virtual std::string title();
private:
CCPointArray *m_pArray;
};
class PauseResumeActions : public ActionsDemo
{
public:
virtual void onEnter();
virtual std::string subtitle();
virtual std::string title();
void pause(float dt);
void resume(float dt);
private:
CCSet *m_pPausedTargets;
};
#endif

View File

@ -90,6 +90,9 @@ void DrawPrimitivesTest::draw()
ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30,s.height/2+50), ccp(s.width/2+60,s.height/2-50),ccp(s.width, s.height/2),100);
CHECK_GL_ERROR_DEBUG();
//draw a solid polygon
CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)};
ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) );
// restore original values
glLineWidth(1);

View File

@ -1104,7 +1104,7 @@ void ParticleDemo::onEnter(void)
addChild( menu, 100 );
CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.');
CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 100, kTagParticleCount);
labelAtlas->setPosition(CCPointMake(s.width-66,50));

View File

@ -95,7 +95,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles)
addChild(infoLabel, 1, kTagInfoLayer);
// particles on stage
CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.');
CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 0, kTagLabelAtlas);
labelAtlas->setPosition(ccp(s.width-66,50));

View File

@ -22,7 +22,7 @@ TileMapTest::TileMapTest()
map->getTexture()->setAntiAliasTexParameters();
CCSize s = map->getContentSize();
////----UXLOG("ContentSize: %f, %f", s.width,s.height);
CCLOG("ContentSize: %f, %f", s.width,s.height);
// If you are not going to use the Map, you can free it now
// NEW since v0.7
@ -57,12 +57,12 @@ TileMapEditTest::TileMapEditTest()
map->getTexture()->setAliasTexParameters();
CCSize s = map->getContentSize();
////----UXLOG("ContentSize: %f, %f", s.width,s.height);
CCLOG("ContentSize: %f, %f", s.width,s.height);
// If you are not going to use the Map, you can free it now
// [tilemap releaseMap);
// And if you are going to use, it you can access the data with:
schedule(schedule_selector(TileMapEditTest::updateMap), 0.2f);//:@selector(updateMap:) interval:0.2f);
schedule(schedule_selector(TileMapEditTest::updateMap), 0.2f);
addChild(map, 0, kTagTileMap);
@ -126,7 +126,7 @@ TMXOrthoTest::TMXOrthoTest()
addChild(map, 0, kTagTileMap);
CCSize s = map->getContentSize();
////----UXLOG("ContentSize: %f, %f", s.width,s.height);
CCLOG("ContentSize: %f, %f", s.width,s.height);
CCArray * pChildrenArray = map->getChildren();
CCSpriteBatchNode* child = NULL;

View File

@ -25,11 +25,13 @@ Ball* Ball::ballWithTexture(CCTexture2D* aTexture)
void Ball::move(float delta)
{
CCSize size = CCDirector::sharedDirector()->getWinSize();
this->setPosition( ccpAdd(getPosition(), ccpMult(m_velocity, delta)) );
if (getPosition().x > 320 - radius())
if (getPosition().x > size.width - radius())
{
setPosition( ccp( 320 - radius(), getPosition().y) );
setPosition( ccp( size.width - radius(), getPosition().y) );
m_velocity.x *= -1;
}
else if (getPosition().x < radius())