fixed #3, CCAtlasNode complete, CCNode is short of Action

This commit is contained in:
Walzer 2010-07-19 08:45:53 +00:00
parent 72b9b13599
commit e0b4307d30
11 changed files with 322 additions and 165 deletions

View File

@ -26,13 +26,121 @@ THE SOFTWARE.
using namespace std;
ccColor3B CCAtlasNode::getColor(void)
// implementation CCAtlasNode
// CCAtlasNode - Creation & Init
CCAtlasNode::CCAtlasNode()
{
/// @todo
}
CCAtlasNode::~CCAtlasNode()
{
/// @todo
m_pTextureAtlas->release();
}
CCAtlasNode * CCAtlasNode::atlasWithTileFile(std::string &tile, int tileWidth, int tileHeight, int itemsToRender)
{
/// @todo
CCAtlasNode * pAtlasNode = new CCAtlasNode();
pAtlasNode->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender);
pAtlasNode->autorelease();
return pAtlasNode;
}
CCAtlasNode * CCAtlasNode::initWithTileFile(std::string &tile, int tileWidth, int tileHeight, int itemsToRender)
{
m_nItemWidth = tileWidth;
m_nItemHeight = tileHeight;
m_cOpacity = 255;
m_tColor = m_tColorUnmodified = ccWHITE;
m_bOpacityModifyRGB = true;
m_tBlendFunc.src = CC_BLEND_SRC;
m_tBlendFunc.dst = CC_BLEND_DST;
// double retain to avoid the autorelease pool
// also, using: self.textureAtlas supports re-initialization without leaking
this->m_pTextureAtlas = new CCTextureAtlas();
m_pTextureAtlas->initWithFile(tile, itemsToRender);
this->updateBlendFunc();
this->updateOpacityModifyRGB();
this->calculateMaxItems();
this->calculateTexCoordsSteps();
return this;
}
// CCAtlasNode - Atlas generation
void CCAtlasNode::calculateMaxItems()
{
CGSize s = m_pTextureAtlas->getTexture()->getContentSize();
m_nItemsPerColumn = (int)(s.height / m_nItemHeight);
m_nItemsPerRow = (int)(s.width / m_nItemWidth);
}
void CCAtlasNode:: calculateTexCoordsSteps()
{
CCTexture2D *tex = m_pTextureAtlas->getTexture();
m_fTexStepX = m_nItemWidth / (float)tex->getPixelsWide();
m_fTexStepY = m_nItemHeight / (float)tex->getPixelsHigh();
}
void CCAtlasNode::updateAtlasValues()
{
NSAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overriden");
//[NSException raise:@"CCAtlasNode:Abstract" format:@"updateAtlasValue not overriden"];
}
// CCAtlasNode - draw
void CCAtlasNode::draw()
{
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY
// Unneeded states: GL_COLOR_ARRAY
glDisableClientState(GL_COLOR_ARRAY);
glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity);
bool newBlend = false;
if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST )
{
newBlend = true;
glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
}
m_pTextureAtlas->drawQuads();
if( newBlend )
glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
// is this chepear than saving/restoring color state ?
// XXX: There is no need to restore the color to (255,255,255,255). Objects should use the color
// XXX: that they need
// glColor4ub( 255, 255, 255, 255);
// restore default GL state
glEnableClientState(GL_COLOR_ARRAY);
}
// CCAtlasNode - RGBA protocol
ccColor3B CCAtlasNode:: color()
{
if(m_bOpacityModifyRGB)
{
return m_tColorUnmodified;
}
return m_tColor;
}
@ -48,20 +156,57 @@ void CCAtlasNode::setColor(ccColor3B color3)
}
}
GLubyte CCAtlasNode::getOpacity()
GLubyte CCAtlasNode::opacity()
{
return m_cOpacity;
}
void CCAtlasNode::setOpacity(GLubyte opacity)
{
// special opacity for premultiplied textures
m_cOpacity = opacity;
// special opacity for premultiplied textures
// special opacity for premultiplied textures
if( m_bOpacityModifyRGB ) //v0.99.1
setColor( m_bOpacityModifyRGB ? m_tColorUnmodified : m_tColor ); //--> win32 : alwyas used m_colorUnmodified color. "if" state no required( issue )
if( m_bOpacityModifyRGB )
this->setColor(m_bOpacityModifyRGB ? m_tColorUnmodified : m_tColor);
}
void CCAtlasNode::setOpacityModifyRGB(bool bValue)
{
ccColor3B oldColor = this->m_tColor;
m_bOpacityModifyRGB = bValue;
this->m_tColor = oldColor;
}
bool CCAtlasNode::doesOpacityModifyRGB()
{
return m_bOpacityModifyRGB;
}
void CCAtlasNode::updateOpacityModifyRGB()
{
m_bOpacityModifyRGB = m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha();
}
// CCAtlasNode - CocosNodeTexture protocol
void CCAtlasNode::updateBlendFunc()
{
if( ! m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha() ) {
m_tBlendFunc.src = GL_SRC_ALPHA;
m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
}
}
void CCAtlasNode::setTexture(CCTexture2D *texture)
{
m_pTextureAtlas->setTexture(texture);
this->updateBlendFunc();
this->updateOpacityModifyRGB();
}
CCTexture2D * CCAtlasNode::texture()
{
return m_pTextureAtlas->getTexture();
}

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
#include "CCNode.h"
#include "../support/CGPointExtension.h"
#include "../cocoa/CGGeometry.h"
using namespace std;
@ -600,44 +601,53 @@ void CCNode::draw()
void CCNode::visit()
{
/** @todo
if (!visible_)
if (!m_bIsVisible)
{
return;
}
glPushMatrix();
if ( grid_ && grid_.active) {
[grid_ beforeDraw];
[self transformAncestors];
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->beforeDraw();
this->transformAncestors();
}
[self transform];
this->transform();
ccArray *arrayData;
int i = 0, nu;
if(children_){
arrayData = children_->data;
nu = arrayData->num;
for(;i<nu; i++){
CCNode *child = arrayData->arr[i];
if ( child.zOrder < 0 )
[child visit];
if(m_pChildren && m_pChildren->count() > 0)
{
CCNode* pNode;
NSMutableArrayIterator it;
for( it = m_pChildren->begin(); it != m_pChildren->end(); it++)
{
pNode = static_cast<CCNode*>(*it);
if ( pNode && pNode->m_nZOrder < 0 )
{
pNode->visit();
}
else
{
break;
}
}
[self draw];
this->draw();
if(children_)
for (;i<nu; i++)
[arrayData->arr[i] visit];
for ( ; it!=m_pChildren->end(); it++ )
{
pNode = static_cast<CCNode*>(*it);
pNode->visit();
}
}
if (m_pGrid && m_pGrid->isActive())
{
m_pGrid->afterDraw(this);
}
if ( grid_ && grid_.active)
[grid_ afterDraw:self];
glPopMatrix();*/
glPopMatrix();
}
void CCNode::transformAncestors()
@ -842,83 +852,77 @@ void CCNode::pauseSchedulerAndActions()
[[CCActionManager sharedManager] pauseTarget:self];*/
}
/** @todo
CGAffineTransform CCNode::nodeToParentTransform(void)
{
if ( isTransformDirty_ ) {
if ( m_bIsTransformDirty ) {
transform_ = CGAffineTransformIdentity;
m_tTransform = CGAffineTransformIdentity;
if ( !isRelativeAnchorPoint_ && !CGPointEqualToPoint(anchorPointInPixels_, CGPointZero) )
transform_ = CGAffineTransformTranslate(transform_, anchorPointInPixels_.x, anchorPointInPixels_.y);
if( ! m_bIsRelativeAnchorPoint && ! CGPoint::CGPointEqualToPoint(m_tAnchorPointInPixels, CGPointZero) )
m_tTransform = CGAffineTransformTranslate(m_tTransform, m_tAnchorPointInPixels.x, m_tAnchorPointInPixels.y);
if( ! CGPointEqualToPoint(position_, CGPointZero) )
transform_ = CGAffineTransformTranslate(transform_, position_.x, position_.y);
if( rotation_ != 0 )
transform_ = CGAffineTransformRotate(transform_, -CC_DEGREES_TO_RADIANS(rotation_));
if( ! (scaleX_ == 1 && scaleY_ == 1) )
transform_ = CGAffineTransformScale(transform_, scaleX_, scaleY_);
if( ! CGPoint::CGPointEqualToPoint(m_tPosition, CGPointZero) )
m_tTransform = CGAffineTransformTranslate(m_tTransform, m_tPosition.x, m_tPosition.y);
if( m_fRotation != 0 )
m_tTransform = CGAffineTransformRotate(m_tTransform, -CC_DEGREES_TO_RADIANS(m_fRotation));
if( ! (m_fScaleX == 1 && m_fScaleY == 1) )
m_tTransform = CGAffineTransformScale(m_tTransform, m_fScaleX, m_fScaleY);
if( ! CGPointEqualToPoint(anchorPointInPixels_, CGPointZero) )
transform_ = CGAffineTransformTranslate(transform_, -anchorPointInPixels_.x, -anchorPointInPixels_.y);
if( ! CGPoint::CGPointEqualToPoint(m_tAnchorPointInPixels, CGPointZero) )
m_tTransform = CGAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPixels.x, -m_tAnchorPointInPixels.y);
isTransformDirty_ = NO;
m_bIsTransformDirty = false;
}
return transform_;
}*/
/** @todo
- (CGAffineTransform)parentToNodeTransform
{
if ( isInverseDirty_ ) {
inverse_ = CGAffineTransformInvert([self nodeToParentTransform]);
isInverseDirty_ = NO;
return m_tTransform;
}
return inverse_;
}*/
/** @todo
- (CGAffineTransform)nodeToWorldTransform
CGAffineTransform CCNode::parentToNodeTransform(void)
{
CGAffineTransform t = [self nodeToParentTransform];
if ( m_bIsInverseDirty ) {
m_tInverse = CGAffineTransformInvert(this->nodeToParentTransform());
m_bIsInverseDirty = false;
}
for (CCNode *p = parent_; p != nil; p = p.parent)
t = CGAffineTransformConcat(t, [p nodeToParentTransform]);
return m_tInverse;
}
CGAffineTransform CCNode::nodeToWorldTransform()
{
CGAffineTransform t = this->nodeToParentTransform();
for (CCNode *p = m_pParent; p != NULL; p = p->getParent())
t = CGAffineTransformConcat(t, p->nodeToParentTransform());
return t;
}*/
/** @todo
- (CGAffineTransform)worldToNodeTransform
}
/** @todo*/
CGAffineTransform CCNode::worldToNodeTransform(void)
{
return CGAffineTransformInvert([self nodeToWorldTransform]);
}*/
return CGAffineTransformInvert(this->nodeToWorldTransform());
}
CGPoint CCNode::convertToNodeSpace(CGPoint worldPoint)
{
/// @todo return CGPointApplyAffineTransform(worldPoint, [self worldToNodeTransform]);
return CGPoint(0,0);
return CGPointApplyAffineTransform(worldPoint, this->worldToNodeTransform());
}
CGPoint CCNode::convertToWorldSpace(CGPoint nodePoint)
{
/// @todo return CGPointApplyAffineTransform(nodePoint, [self nodeToWorldTransform]);
return CGPoint(0,0);
return CGPointApplyAffineTransform(nodePoint, this->nodeToWorldTransform());
}
CGPoint CCNode::convertToNodeSpaceAR(CGPoint worldPoint)
{
/** @todo
CGPoint nodePoint = [self convertToNodeSpace:worldPoint];
return ccpSub(nodePoint, anchorPointInPixels_);*/
return CGPoint(0,0);
CGPoint nodePoint = this->convertToNodeSpace(worldPoint);
return ccpSub(nodePoint, m_tAnchorPointInPixels);
}
CGPoint CCNode::convertToWorldSpaceAR(CGPoint nodePoint)
{
/** @todo
nodePoint = ccpAdd(nodePoint, anchorPointInPixels_);
return [self convertToWorldSpace:nodePoint];*/
return CGPoint(0,0);
/** @todo*/
nodePoint = ccpAdd(nodePoint, m_tAnchorPointInPixels);
return this->convertToWorldSpace(nodePoint);
}
/** @todo no declare in .h file
CGPoint CCNode::convertToWindowSpace(CGPoint nodePoint)

View File

@ -27,6 +27,7 @@ THE SOFTWARE.
#include "CCNode.h"
#include "CCProtocols.h"
#include "CCTextureAtlas.h"
/** CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and
CCTextureProtocol protocol
@ -57,66 +58,52 @@ protected:
int m_nItemHeight;
ccColor3B m_tColorUnmodified;
// protocol variables
bool m_bOpacityModifyRGB;
/** conforms to CCTextureProtocol protocol */
CCX_PROPERTY(CCTextureAtlas *, m_tTextureAtlas, TextureAtlas)
/** conforms to CCTextureProtocol protocol */
CCX_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc)
/** conforms to CCRGBAProtocol protocol */
CCX_PROPERTY(GLubyte, m_cOpacity, Opacity)
/** conforms to CCRGBAProtocol protocol */
CCX_PROPERTY(ccColor3B, m_tColor, Color)
private:
void calculateMaxItems(void);
void calculateTexCoordsSteps(void);
void updateBlendFunc(void);
void updateOpacityModifyRGB(void);
ccBlendFunc m_tBlendFunc;
GLubyte m_cOpacity;
ccColor3B m_tColor;
CCTextureAtlas * m_pTextureAtlas;
public:
CCAtlasNode();
virtual ~CCAtlasNode();
~CCAtlasNode();
/** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
static CCAtlasNode* atlasWithTileFile(NSString* tile, int tileWidth, int tileHeight, int itemsToRender);
static CCAtlasNode * atlasWithTileFile(std::string & tile,int tileWidth, int tileHeight, int itemsToRender);
/** initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
CCAtlasNode* initWithTileFile(NSString* tile, int tileWidth, int tileHeight, int itemsToRender;
CCAtlasNode * initWithTileFile(std::string & tile, int tileWidth, int tileHeight, int itemsToRender);
/** updates the Atlas (indexed vertex array).
* Shall be overriden in subclasses
*/
void updateAtlasValues(void);
void updateAtlasValues();
public: //CCNode methods
virtual void draw(void);
virtual void draw();
public:
// CC RGBA protocol
public: //CCRGBAProtocol methods
/** sets Color
@since v0.8
*/
virtual void setColor(ccColor3B color) = 0;
virtual void setColor(ccColor3B color);
/** returns the color
@since v0.8
*/
virtual ccColor3B color(void) = 0;
virtual ccColor3B color(void);
// returns the opacity
virtual GLubyte opacity(void) = 0;
virtual GLubyte opacity(void);
/** sets the opacity.
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
Values goes from 0 to 255, where 255 means fully opaque.
*/
virtual void setOpacity(GLubyte opacity) = 0;
virtual void setOpacity(GLubyte opacity);
// optional
@ -126,19 +113,34 @@ public: //CCRGBAProtocol methods
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
@since v0.8
*/
virtual void setOpacityModifyRGB(bool bValue) {}
virtual void setOpacityModifyRGB(bool bValue);
/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
@since v0.8
*/
virtual bool doesOpacityModifyRGB(void) = { return false;}
virtual bool doesOpacityModifyRGB(void);
// CC Blend protocol
// set the source blending function for the texture
virtual void setBlendFunc(ccBlendFunc blendFunc);
// returns the blending function used for the texture
virtual ccBlendFunc blendFunc(void);
// CC Texture protocol
public: // CCTextureProtocol methods
// returns the used texture
virtual CCTexture2D* texture(void) = 0;
virtual CCTexture2D* texture(void);
// sets a new texture. it will be retained
virtual void setTexture(CCTexture2D *texture) {}
virtual void setTexture(CCTexture2D *texture);
private :
void calculateMaxItems();
void calculateTexCoordsSteps();
void updateBlendFunc();
void updateOpacityModifyRGB();
};

View File

@ -32,6 +32,7 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "../CCScheduler.h"
#include "../cocoa/CGGeometry.h"
#include "../cocoa/CGAffineTransform.h"
#include "../cocoa/NSMutableArray.h"
#include "../cocoa/selector_protocol.h"
#include "../effects/CCGrid.h"
@ -97,6 +98,7 @@ Camera:
class CCNode : public NSObject, public SelectorProtocol
{
// variable property
/** The z order of the node relative to it's "brothers": children of the same parent */
@ -180,6 +182,9 @@ class CCNode : public NSObject, public SelectorProtocol
protected:
// transform
CGAffineTransform m_tTransform, m_tInverse;
#ifdef CCX_NODE_TRANSFORM_USING_AFFINE_MATRIX
GLfloat m_pTransformGL[16];
#endif
@ -438,22 +443,22 @@ public:
/** Returns the local affine transform matrix
@since v0.7.1
*/
/// @todo CGAffineTransform nodeToParentTransform(void);
CGAffineTransform nodeToParentTransform(void);
/** Returns the inverse local affine transform matrix
@since v0.7.1
*/
/// @todo CGAffineTransform parentToNodeTransform(void);
CGAffineTransform parentToNodeTransform(void);
/** Retrusn the world affine transform matrix
@since v0.7.1
*/
/// @todo CGAffineTransform nodeToWorldTransform(void);
CGAffineTransform nodeToWorldTransform(void);
/** Returns the inverse world affine transform matrix
@since v0.7.1
*/
/// @todo CGAffineTransform worldToNodeTransform(void);
CGAffineTransform worldToNodeTransform(void);
/** converts a world coordinate to local coordinate
@since v0.7.1

View File

@ -25,6 +25,8 @@ THE SOFTWARE.
#ifndef __CCPVRTEXTURE_H__
#define __CCPVRTEXTURE_H__
#include <string>
//#import <UIKit/UIKit.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
@ -45,9 +47,9 @@ public:
CCPVRTexture();
~CCPVRTexture();
CCPVRTexture * initWithContentsOfFile(NSString * path);
CCPVRTexture * initWithContentsOfFile(std::string & path);
/// @todo CCPVRTexture * initWithContentsOfURL(NSURL *url);
static CCPVRTexture * pvrTextureWithContentsOfFile(NSString *path);
static CCPVRTexture * pvrTextureWithContentsOfFile(std::string & path);
/// @todo static CCPVRTexture * pvrTextureWithContentsOfURL(NSURL *url);
CCX_PROPERTY_READONLY(GLuint, m_uName, Name)

View File

@ -59,7 +59,7 @@ public:
* if back is TRUE then the effect is reversed to appear as if the incoming
* scene is being turned from left over the outgoing scene
*/
CCPageTurnTransition* initWithDurationAndScene(ccTime t,CCScene* scene,bool backwards);
virtual CCPageTurnTransition* initWithDurationAndScene(ccTime t,CCScene* scene,bool backwards);
CCIntervalAction* actionWithSize(ccGridSize vector);

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#define __CCPROTOCOLS_H__
#include "ccTypes.h"
#include "textures/CCTexture2D.h"
#include "CCTexture2D.h"
#include <string>

View File

@ -26,13 +26,12 @@ THE SOFTWARE.
#define __CCTEXTURE2D_H__
#include <GLES/gl.h>
#include <string>
#include "Cocos2dDefine.h"
#include "../cocoa/NSObject.h"
#include "../cocoa/CGGeometry.h"
#include <iostream>
using namespace std;
//CONSTANTS:
@ -135,9 +134,9 @@ public:
Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
*/
/** Initializes a texture from a string with dimensions, alignment, font name and font size */
/// @todo CCTexture2D * initWithString(NSString* str, CGSize dimensions, UITextAlignment alignment, NSString* fontName, CGFloat fontSize);
/// @todo CCTexture2D * initWithString(string & str, CGSize dimensions, UITextAlignment alignment, string & fontName, CGFloat fontSize);
/** Initializes a texture from a string with font name and font size */
CCTexture2D * initWithString(NSString* str, NSString* fontName, GLfloat fontSize);
CCTexture2D * initWithString(std::string & str, std::string & fontName, GLfloat fontSize);
/**
Extensions to make it easy to create a CCTexture2D object from a PVRTC file
@ -146,7 +145,7 @@ public:
/** Initializes a texture from a PVRTC buffer */
CCTexture2D * initWithPVRTCData(const void* data, int level, int bpp, bool hasAlpha, int length);
/** Initializes a texture from a PVRTC file */
CCTexture2D * initWithPVRTCFile(NSString* file);
CCTexture2D * initWithPVRTCFile(std::string & file);
/** sets the min filter, mag filter, wrap s and wrap t texture parameters.
If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.

View File

@ -69,14 +69,14 @@ public:
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.
*/
static CCTextureAtlas * textureAtlasWithFile(NSString* file , UINT32 capacity);
static CCTextureAtlas * textureAtlasWithFile(std::string & file , UINT32 capacity);
/** initializes a TextureAtlas with a filename and with a certain capacity for Quads.
* The TextureAtlas capacity can be increased in runtime.
*
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
*/
CCTextureAtlas * initWithFile(NSString* file, UINT32 capacity);
CCTextureAtlas * initWithFile(std::string & file, UINT32 capacity);
/** creates a TextureAtlas with a previously initialized Texture2D object, and
* with an initial capacity for n Quads.

View File

@ -25,11 +25,11 @@ THE SOFTWARE.
#ifndef __CCTEXTURE_CACHE_H__
#define __CCTEXTURE_CACHE_H__
#include <iostream>
#include "../cocoa/NSObject.h"
#include "../cocoa/NSString.h"
/// @todo #import <Foundation/Foundation.h>
/// @todo #import <CoreGraphics/CGImage.h>
#include <string>
class CCTexture2D;
class CCAsyncObject;
@ -69,7 +69,7 @@ public:
* Otherwise it will return a reference of a previosly loaded image.
* Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
*/
CCTexture2D* addImage(NSString* fileimage);
CCTexture2D* addImage(std::string &fileimage);
/** Returns a Texture2D object given a file image
* If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it.
@ -78,7 +78,7 @@ public:
* Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
* @since v0.8
*/
/// @todo -(void) addImageAsync:(NSString*) filename target:(id)target selector:(SEL)selector;
/// @todo -(void) addImageAsync:(string & ) filename target:(id)target selector:(SEL)selector;
void addImageWithAsyncObject(CCAsyncObject* async);
@ -90,13 +90,13 @@ public:
* bpp can only be 2 or 4. 2 means more compression but lower quality.
* hasAlpha: whether or not the image contains alpha channel
*/
CCTexture2D* addPVRTCImage(NSString* fileimage, int bpp, bool hasAlpha, int width);
CCTexture2D* addPVRTCImage(std::string &fileimage, int bpp, bool hasAlpha, int width);
/** Returns a Texture2D object given an PVRTC filename
* If the file image was not previously loaded, it will create a new CCTexture2D
* object and it will return it. Otherwise it will return a reference of a previosly loaded image
*/
CCTexture2D* addPVRTCImage(NSString* fileimage);
CCTexture2D* addPVRTCImage(std::string &fileimage);
/** Returns a Texture2D object given an CGImageRef image
* If the image was not previously loaded, it will create a new CCTexture2D object and it will return it.
@ -105,7 +105,7 @@ public:
* If "key" is nil, then a new texture will be created each time.
* @since v0.8
*/
/// @todo CGImageRef CCTexture2D* addCGImage(CGImageRef image, NSString * key);
/// @todo CGImageRef CCTexture2D* addCGImage(CGImageRef image, string & key);
/** Purges the dictionary of loaded textures.
* Call this method if you receive the "Memory Warning"
@ -129,7 +129,7 @@ public:
/** Deletes a texture from the cache given a its key name
@since v0.99.4
*/
void removeTextureForKey(NSString* textureKeyName);
void removeTextureForKey(std::string & textureKeyName);
};

View File

@ -81,7 +81,7 @@ public:
static CCTransitionScene * transitionWithDurationAndScene(ccTime t, CCScene *scene);
/** initializes a transition with duration and incoming scene */
CCTransitionScene * initWithDurationAndScene(ccTime t,CCScene* scene);
virtual CCTransitionScene * initWithDurationAndScene(ccTime t,CCScene* scene);
/** called after the transition finishes */
void finish(void);
@ -111,7 +111,7 @@ public:
/** creates a base transition with duration and incoming scene */
static CCOrientedTransitionScene * transitionWithDurationAndScene(ccTime t,CCScene* scene, tOrientation orientation);
/** initializes a transition with duration and incoming scene */
CCOrientedTransitionScene * initWithDurationAndScene(ccTime t,CCScene* scene,tOrientation orientation);
virtual CCOrientedTransitionScene * initWithDurationAndScene(ccTime t,CCScene* scene,tOrientation orientation);
};
/** CCRotoZoomTransition:
@ -368,9 +368,9 @@ public:
*/
static CCFadeTransition* transitionWithDurationAndColor(ccTime duration,CCScene* scene, ccColor3B color);
/** initializes the transition with a duration and with an RGB color */
CCFadeTransition* initWithDurationAndColor(ccTime t, CCScene*scene ,ccColor3B color);
virtual CCFadeTransition* initWithDurationAndColor(ccTime t, CCScene*scene ,ccColor3B color);
CCFadeTransition * initWithDurationAndScene(ccTime t,CCScene* scene);
virtual CCFadeTransition * initWithDurationAndScene(ccTime t,CCScene* scene);
virtual void onEnter();
virtual void onExit();
};