mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop
This commit is contained in:
commit
b9eacf8517
7
AUTHORS
7
AUTHORS
|
@ -414,6 +414,7 @@ Developers:
|
||||||
Added some guards to prevent Eclipse to compile twice the same class.
|
Added some guards to prevent Eclipse to compile twice the same class.
|
||||||
Linux Eclipse projects updates
|
Linux Eclipse projects updates
|
||||||
Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work.
|
Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work.
|
||||||
|
Use of a single emscripten HTML template file.
|
||||||
|
|
||||||
elmiro
|
elmiro
|
||||||
Correction of passed buffer size to readlink and verification of result return by readlink.
|
Correction of passed buffer size to readlink and verification of result return by readlink.
|
||||||
|
@ -553,6 +554,12 @@ Retired Core Developers:
|
||||||
michaelcontento
|
michaelcontento
|
||||||
[Android] use onWindowFocusChanged(bool) instead of onResume()/onPause()
|
[Android] use onWindowFocusChanged(bool) instead of onResume()/onPause()
|
||||||
|
|
||||||
|
bmanGH
|
||||||
|
Use gl caching functions in TexturePVR::createGLTexture()
|
||||||
|
|
||||||
|
metadao
|
||||||
|
make create_project.py more pythonic and fix some typoes
|
||||||
|
|
||||||
|
|
||||||
Cocos2d-x can not grow so fast without the active community.
|
Cocos2d-x can not grow so fast without the active community.
|
||||||
Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!
|
Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!
|
||||||
|
|
|
@ -963,7 +963,7 @@ void Director::setScheduler(Scheduler* pScheduler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Scheduler* Director::getScheduler()
|
Scheduler* Director::getScheduler() const
|
||||||
{
|
{
|
||||||
return _scheduler;
|
return _scheduler;
|
||||||
}
|
}
|
||||||
|
@ -978,7 +978,7 @@ void Director::setActionManager(ActionManager* pActionManager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionManager* Director::getActionManager()
|
ActionManager* Director::getActionManager() const
|
||||||
{
|
{
|
||||||
return _actionManager;
|
return _actionManager;
|
||||||
}
|
}
|
||||||
|
@ -993,7 +993,7 @@ void Director::setTouchDispatcher(TouchDispatcher* pTouchDispatcher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchDispatcher* Director::getTouchDispatcher()
|
TouchDispatcher* Director::getTouchDispatcher() const
|
||||||
{
|
{
|
||||||
return _touchDispatcher;
|
return _touchDispatcher;
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1005,7 @@ void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher)
|
||||||
_keyboardDispatcher = pKeyboardDispatcher;
|
_keyboardDispatcher = pKeyboardDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardDispatcher* Director::getKeyboardDispatcher()
|
KeyboardDispatcher* Director::getKeyboardDispatcher() const
|
||||||
{
|
{
|
||||||
return _keyboardDispatcher;
|
return _keyboardDispatcher;
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher)
|
||||||
_keypadDispatcher = pKeypadDispatcher;
|
_keypadDispatcher = pKeypadDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeypadDispatcher* Director::getKeypadDispatcher()
|
KeypadDispatcher* Director::getKeypadDispatcher() const
|
||||||
{
|
{
|
||||||
return _keypadDispatcher;
|
return _keypadDispatcher;
|
||||||
}
|
}
|
||||||
|
@ -1031,7 +1031,7 @@ void Director::setAccelerometer(Accelerometer* pAccelerometer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Accelerometer* Director::getAccelerometer()
|
Accelerometer* Director::getAccelerometer() const
|
||||||
{
|
{
|
||||||
return _accelerometer;
|
return _accelerometer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,39 +318,70 @@ public:
|
||||||
float getContentScaleFactor(void) const;
|
float getContentScaleFactor(void) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Scheduler associated with this director
|
/** Gets the Scheduler associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(Scheduler*, _scheduler, Scheduler);
|
Scheduler* getScheduler() const;
|
||||||
|
|
||||||
/** ActionManager associated with this director
|
/** Sets the Scheduler associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(ActionManager*, _actionManager, ActionManager);
|
void setScheduler(Scheduler* scheduler);
|
||||||
|
|
||||||
/** TouchDispatcher associated with this director
|
/** Gets the ActionManager associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher);
|
ActionManager* getActionManager() const;
|
||||||
|
|
||||||
/** KeyboardDispatcher associated with this director
|
/** Sets the ActionManager associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
void setActionManager(ActionManager* actionManager);
|
||||||
|
|
||||||
|
/** Gets the TouchDispatcher associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
TouchDispatcher* getTouchDispatcher() const;
|
||||||
|
|
||||||
|
/** Sets the TouchDispatcher associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
void setTouchDispatcher(TouchDispatcher* touchDispatcher);
|
||||||
|
|
||||||
|
/** Gets the KeyboardDispatcher associated with this director
|
||||||
@note Supported on Mac and Linux only now.
|
@note Supported on Mac and Linux only now.
|
||||||
@since v3.0
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(KeyboardDispatcher*, _keyboardDispatcher, KeyboardDispatcher);
|
KeyboardDispatcher* getKeyboardDispatcher() const;
|
||||||
|
|
||||||
/** KeypadDispatcher associated with this director
|
/** Sets the KeyboardDispatcher associated with this director
|
||||||
|
@note Supported on Mac and Linux only now.
|
||||||
|
@since v3.0
|
||||||
|
*/
|
||||||
|
void setKeyboardDispatcher(KeyboardDispatcher* keyboardDispatcher);
|
||||||
|
|
||||||
|
/** Gets the KeypadDispatcher associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(KeypadDispatcher*, _keypadDispatcher, KeypadDispatcher);
|
KeypadDispatcher* getKeypadDispatcher() const;
|
||||||
|
|
||||||
/** Accelerometer associated with this director
|
/** Sets the KeypadDispatcher associated with this director
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(Accelerometer*, _accelerometer, Accelerometer);
|
void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher);
|
||||||
|
|
||||||
/* delta time since last tick to main loop */
|
/** Gets Accelerometer associated with this director
|
||||||
CC_PROPERTY_READONLY(float, _deltaTime, DeltaTime);
|
@since v2.0
|
||||||
|
*/
|
||||||
|
Accelerometer* getAccelerometer() const;
|
||||||
|
|
||||||
|
/** Sets Accelerometer associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
void setAccelerometer(Accelerometer* acc);
|
||||||
|
|
||||||
|
/* Gets delta time since last tick to main loop */
|
||||||
|
float getDeltaTime() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void purgeDirector();
|
void purgeDirector();
|
||||||
|
@ -367,6 +398,40 @@ protected:
|
||||||
void calculateDeltaTime();
|
void calculateDeltaTime();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/** Scheduler associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
Scheduler* _scheduler;
|
||||||
|
|
||||||
|
/** ActionManager associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
ActionManager* _actionManager;
|
||||||
|
|
||||||
|
/** TouchDispatcher associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
TouchDispatcher* _touchDispatcher;
|
||||||
|
|
||||||
|
/** KeyboardDispatcher associated with this director
|
||||||
|
@note Supported on Mac and Linux only now.
|
||||||
|
@since v3.0
|
||||||
|
*/
|
||||||
|
KeyboardDispatcher* _keyboardDispatcher;
|
||||||
|
|
||||||
|
/** KeypadDispatcher associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
KeypadDispatcher* _keypadDispatcher;
|
||||||
|
|
||||||
|
/** Accelerometer associated with this director
|
||||||
|
@since v2.0
|
||||||
|
*/
|
||||||
|
Accelerometer* _accelerometer;
|
||||||
|
|
||||||
|
/* delta time since last tick to main loop */
|
||||||
|
float _deltaTime;
|
||||||
|
|
||||||
/* The EGLView, where everything is rendered */
|
/* The EGLView, where everything is rendered */
|
||||||
EGLView *_openGLView;
|
EGLView *_openGLView;
|
||||||
|
|
||||||
|
|
|
@ -172,10 +172,7 @@ public:
|
||||||
|
|
||||||
void setInnerAction(ActionInterval *pAction);
|
void setInnerAction(ActionInterval *pAction);
|
||||||
|
|
||||||
inline ActionInterval* getInnerAction() const
|
inline ActionInterval* getInnerAction() const { return _innerAction; }
|
||||||
{
|
|
||||||
return _innerAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Override
|
// Override
|
||||||
|
|
|
@ -92,7 +92,7 @@ class CC_DLL Sequence : public ActionInterval
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** helper constructor to create an array of sequenceable actions */
|
/** helper constructor to create an array of sequenceable actions */
|
||||||
static Sequence* create(FiniteTimeAction *pAction1, ...);
|
static Sequence* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
/** helper constructor to create an array of sequenceable actions given an array */
|
/** helper constructor to create an array of sequenceable actions given an array */
|
||||||
static Sequence* create(Array *arrayOfActions);
|
static Sequence* create(Array *arrayOfActions);
|
||||||
/** helper constructor to create an array of sequence-able actions */
|
/** helper constructor to create an array of sequence-able actions */
|
||||||
|
@ -221,7 +221,7 @@ class CC_DLL Spawn : public ActionInterval
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** helper constructor to create an array of spawned actions */
|
/** helper constructor to create an array of spawned actions */
|
||||||
static Spawn* create(FiniteTimeAction *pAction1, ...);
|
static Spawn* create(FiniteTimeAction *pAction1, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
|
|
||||||
/** helper constructor to create an array of spawned actions */
|
/** helper constructor to create an array of spawned actions */
|
||||||
static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
|
static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args);
|
||||||
|
|
|
@ -233,24 +233,24 @@ void AtlasNode::setTexture(Texture2D *texture)
|
||||||
this->updateOpacityModifyRGB();
|
this->updateOpacityModifyRGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D * AtlasNode::getTexture()
|
Texture2D * AtlasNode::getTexture() const
|
||||||
{
|
{
|
||||||
return _textureAtlas->getTexture();
|
return _textureAtlas->getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasNode::setTextureAtlas(TextureAtlas* var)
|
void AtlasNode::setTextureAtlas(TextureAtlas* textureAtlas)
|
||||||
{
|
{
|
||||||
CC_SAFE_RETAIN(var);
|
CC_SAFE_RETAIN(textureAtlas);
|
||||||
CC_SAFE_RELEASE(_textureAtlas);
|
CC_SAFE_RELEASE(_textureAtlas);
|
||||||
_textureAtlas = var;
|
_textureAtlas = textureAtlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureAtlas * AtlasNode::getTextureAtlas()
|
TextureAtlas * AtlasNode::getTextureAtlas() const
|
||||||
{
|
{
|
||||||
return _textureAtlas;
|
return _textureAtlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int AtlasNode::getQuadsToDraw()
|
unsigned int AtlasNode::getQuadsToDraw() const
|
||||||
{
|
{
|
||||||
return _quadsToDraw;
|
return _quadsToDraw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,15 +68,24 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void updateAtlasValues();
|
virtual void updateAtlasValues();
|
||||||
|
|
||||||
|
void setTextureAtlas(TextureAtlas* textureAtlas);
|
||||||
|
TextureAtlas* getTextureAtlas() const;
|
||||||
|
|
||||||
|
void setQuadsToDraw(unsigned int quadsToDraw);
|
||||||
|
unsigned int getQuadsToDraw() const;
|
||||||
|
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual Texture2D* getTexture() override;
|
virtual Texture2D* getTexture() const override;
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
virtual bool isOpacityModifyRGB() const override;
|
virtual bool isOpacityModifyRGB() const override;
|
||||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
||||||
virtual const Color3B& getColor(void) const override;
|
virtual const Color3B& getColor(void) const override;
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void setColor(const Color3B& color) override;
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
virtual void setOpacity(GLubyte opacity) override;
|
||||||
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
||||||
|
virtual const BlendFunc& getBlendFunc() const override;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
void calculateMaxItems();
|
void calculateMaxItems();
|
||||||
|
@ -99,15 +108,13 @@ protected:
|
||||||
|
|
||||||
Color3B _colorUnmodified;
|
Color3B _colorUnmodified;
|
||||||
|
|
||||||
CC_PROPERTY(TextureAtlas*, _textureAtlas, TextureAtlas);
|
TextureAtlas* _textureAtlas;
|
||||||
|
|
||||||
// protocol variables
|
// protocol variables
|
||||||
bool _isOpacityModifyRGB;
|
bool _isOpacityModifyRGB;
|
||||||
|
BlendFunc _blendFunc;
|
||||||
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc);
|
|
||||||
|
|
||||||
// quads to draw
|
// quads to draw
|
||||||
CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw);
|
unsigned int _quadsToDraw;
|
||||||
// color uniform
|
// color uniform
|
||||||
GLint _uniformColor;
|
GLint _uniformColor;
|
||||||
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
|
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
/** Create an array */
|
/** Create an array */
|
||||||
static Array* create();
|
static Array* create();
|
||||||
/** Create an array with some objects */
|
/** Create an array with some objects */
|
||||||
static Array* create(Object* pObject, ...);
|
static Array* create(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
/** Create an array with one object */
|
/** Create an array with one object */
|
||||||
static Array* createWithObject(Object* pObject);
|
static Array* createWithObject(Object* pObject);
|
||||||
/** Create an array with capacity */
|
/** Create an array with capacity */
|
||||||
|
@ -142,7 +142,7 @@ public:
|
||||||
/** Initializes an array with one object */
|
/** Initializes an array with one object */
|
||||||
bool initWithObject(Object* pObject);
|
bool initWithObject(Object* pObject);
|
||||||
/** Initializes an array with some objects */
|
/** Initializes an array with some objects */
|
||||||
bool initWithObjects(Object* pObject, ...);
|
bool initWithObjects(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
/** Initializes an array with capacity */
|
/** Initializes an array with capacity */
|
||||||
bool initWithCapacity(unsigned int capacity);
|
bool initWithCapacity(unsigned int capacity);
|
||||||
/** Initializes an array with an existing array */
|
/** Initializes an array with an existing array */
|
||||||
|
|
|
@ -162,9 +162,9 @@ public:
|
||||||
*
|
*
|
||||||
* // Get the object for key
|
* // Get the object for key
|
||||||
* String* pStr1 = (String*)pDict->objectForKey("key1");
|
* String* pStr1 = (String*)pDict->objectForKey("key1");
|
||||||
* CCLog("{ key1: %s }", pStr1->getCString());
|
* log("{ key1: %s }", pStr1->getCString());
|
||||||
* Integer* pInteger = (Integer*)pDict->objectForKey("key3");
|
* Integer* pInteger = (Integer*)pDict->objectForKey("key3");
|
||||||
* CCLog("{ key3: %d }", pInteger->getValue());
|
* log("{ key3: %d }", pInteger->getValue());
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
const char* cocos2dVersion()
|
const char* cocos2dVersion()
|
||||||
{
|
{
|
||||||
return "3.0-alpha0-pre";
|
return "3.0-pre-alpha0";
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -907,6 +907,10 @@ CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
|
||||||
#define kCCFlipedAll kFlipedAll
|
#define kCCFlipedAll kFlipedAll
|
||||||
#define kCCFlippedMask kFlippedMask
|
#define kCCFlippedMask kFlippedMask
|
||||||
|
|
||||||
|
|
||||||
|
/** use log() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2);
|
||||||
|
|
||||||
// end of data_structures group
|
// end of data_structures group
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
|
@ -50,21 +50,21 @@ public:
|
||||||
*
|
*
|
||||||
* @return The Color3B contains R,G,B bytes.
|
* @return The Color3B contains R,G,B bytes.
|
||||||
*/
|
*/
|
||||||
virtual const Color3B& getColor(void) const = 0;
|
virtual const Color3B& getColor() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the displayed color.
|
* Returns the displayed color.
|
||||||
*
|
*
|
||||||
* @return The Color3B contains R,G,B bytes.
|
* @return The Color3B contains R,G,B bytes.
|
||||||
*/
|
*/
|
||||||
virtual const Color3B& getDisplayedColor(void) const = 0;
|
virtual const Color3B& getDisplayedColor() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the displayed opacity.
|
* Returns the displayed opacity.
|
||||||
*
|
*
|
||||||
* @return The opacity of sprite, from 0 ~ 255
|
* @return The opacity of sprite, from 0 ~ 255
|
||||||
*/
|
*/
|
||||||
virtual GLubyte getDisplayedOpacity(void) const = 0;
|
virtual GLubyte getDisplayedOpacity() const = 0;
|
||||||
/**
|
/**
|
||||||
* Returns the opacity.
|
* Returns the opacity.
|
||||||
*
|
*
|
||||||
|
@ -73,7 +73,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The opacity of sprite, from 0 ~ 255
|
* @return The opacity of sprite, from 0 ~ 255
|
||||||
*/
|
*/
|
||||||
virtual GLubyte getOpacity(void) const = 0;
|
virtual GLubyte getOpacity() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the opacity.
|
* Changes the opacity.
|
||||||
|
@ -100,12 +100,12 @@ public:
|
||||||
*
|
*
|
||||||
* @return Returns opacity modify flag.
|
* @return Returns opacity modify flag.
|
||||||
*/
|
*/
|
||||||
virtual bool isOpacityModifyRGB(void) const = 0;
|
virtual bool isOpacityModifyRGB() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether or not color should be propagated to its children.
|
* whether or not color should be propagated to its children.
|
||||||
*/
|
*/
|
||||||
virtual bool isCascadeColorEnabled(void) const = 0;
|
virtual bool isCascadeColorEnabled() const = 0;
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +116,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* whether or not opacity should be propagated to its children.
|
* whether or not opacity should be propagated to its children.
|
||||||
*/
|
*/
|
||||||
virtual bool isCascadeOpacityEnabled(void) const = 0;
|
virtual bool isCascadeOpacityEnabled() const = 0;
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
|
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
|
||||||
*/
|
*/
|
||||||
virtual const BlendFunc &getBlendFunc(void) const = 0;
|
virtual const BlendFunc &getBlendFunc() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The texture that is currenlty being used.
|
* @return The texture that is currenlty being used.
|
||||||
*/
|
*/
|
||||||
virtual Texture2D* getTexture(void) = 0;
|
virtual Texture2D* getTexture() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a new texuture. It will be retained.
|
* Sets a new texuture. It will be retained.
|
||||||
|
@ -195,7 +195,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The string that is currently being used in this label
|
* @return The string that is currently being used in this label
|
||||||
*/
|
*/
|
||||||
virtual const char* getString(void) const = 0;
|
virtual const char* getString() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +207,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Will be called by Director when the projection is updated, and "custom" projection is used
|
* Will be called by Director when the projection is updated, and "custom" projection is used
|
||||||
*/
|
*/
|
||||||
virtual void updateProjection(void) = 0;
|
virtual void updateProjection() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -40,7 +40,7 @@ extern bool CC_DLL cc_assert_script_compatible(const char *msg);
|
||||||
#define CCASSERT(cond, msg) do { \
|
#define CCASSERT(cond, msg) do { \
|
||||||
if (!(cond)) { \
|
if (!(cond)) { \
|
||||||
if (!cc_assert_script_compatible(msg) && strlen(msg)) \
|
if (!cc_assert_script_compatible(msg) && strlen(msg)) \
|
||||||
cocos2d::CCLog("Assert failed: %s", msg); \
|
cocos2d::log("Assert failed: %s", msg); \
|
||||||
CC_ASSERT(cond); \
|
CC_ASSERT(cond); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -238,7 +238,7 @@ It should work same as apples CFSwapInt32LittleToHost(..)
|
||||||
do { \
|
do { \
|
||||||
GLenum __error = glGetError(); \
|
GLenum __error = glGetError(); \
|
||||||
if(__error) { \
|
if(__error) { \
|
||||||
CCLog("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \
|
cocos2d::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -241,9 +241,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
||||||
|
|
||||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
|
||||||
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
|
@ -251,10 +248,14 @@ public:
|
||||||
virtual void setColor(const Color3B &color) override;
|
virtual void setColor(const Color3B &color) override;
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
virtual void setOpacity(GLubyte opacity) override;
|
||||||
virtual void setContentSize(const Size & var) override;
|
virtual void setContentSize(const Size & var) override;
|
||||||
|
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||||
|
virtual const BlendFunc& getBlendFunc() const override;
|
||||||
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateColor();
|
virtual void updateColor();
|
||||||
|
|
||||||
|
BlendFunc _blendFunc;
|
||||||
Vertex2F _squareVertices[4];
|
Vertex2F _squareVertices[4];
|
||||||
Color4F _squareColors[4];
|
Color4F _squareColors[4];
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
static Menu* create();
|
static Menu* create();
|
||||||
|
|
||||||
/** creates a Menu with MenuItem objects */
|
/** creates a Menu with MenuItem objects */
|
||||||
static Menu* create(MenuItem* item, ...);
|
static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
|
|
||||||
/** creates a Menu with a Array of MenuItem objects */
|
/** creates a Menu with a Array of MenuItem objects */
|
||||||
static Menu* createWithArray(Array* pArrayOfItems);
|
static Menu* createWithArray(Array* pArrayOfItems);
|
||||||
|
@ -98,12 +98,12 @@ public:
|
||||||
void alignItemsHorizontallyWithPadding(float padding);
|
void alignItemsHorizontallyWithPadding(float padding);
|
||||||
|
|
||||||
/** align items in rows of columns */
|
/** align items in rows of columns */
|
||||||
void alignItemsInColumns(int columns, ...);
|
void alignItemsInColumns(int columns, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
void alignItemsInColumns(int columns, va_list args);
|
void alignItemsInColumns(int columns, va_list args);
|
||||||
void alignItemsInColumnsWithArray(Array* rows);
|
void alignItemsInColumnsWithArray(Array* rows);
|
||||||
|
|
||||||
/** align items in columns of rows */
|
/** align items in columns of rows */
|
||||||
void alignItemsInRows(int rows, ...);
|
void alignItemsInRows(int rows, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
void alignItemsInRows(int rows, va_list args);
|
void alignItemsInRows(int rows, va_list args);
|
||||||
void alignItemsInRowsWithArray(Array* columns);
|
void alignItemsInRowsWithArray(Array* columns);
|
||||||
|
|
||||||
|
|
|
@ -161,18 +161,6 @@ void MenuItem::setCallback(const ccMenuCallback& callback)
|
||||||
//CCMenuItemLabel
|
//CCMenuItemLabel
|
||||||
//
|
//
|
||||||
|
|
||||||
const Color3B& MenuItemLabel::getDisabledColor() const
|
|
||||||
{
|
|
||||||
return _disabledColor;
|
|
||||||
}
|
|
||||||
void MenuItemLabel::setDisabledColor(const Color3B& var)
|
|
||||||
{
|
|
||||||
_disabledColor = var;
|
|
||||||
}
|
|
||||||
Node *MenuItemLabel::getLabel()
|
|
||||||
{
|
|
||||||
return _label;
|
|
||||||
}
|
|
||||||
void MenuItemLabel::setLabel(Node* var)
|
void MenuItemLabel::setLabel(Node* var)
|
||||||
{
|
{
|
||||||
if (var)
|
if (var)
|
||||||
|
@ -473,11 +461,6 @@ const char* MenuItemFont::getFontNameObj() const
|
||||||
//CCMenuItemSprite
|
//CCMenuItemSprite
|
||||||
//
|
//
|
||||||
|
|
||||||
Node * MenuItemSprite::getNormalImage()
|
|
||||||
{
|
|
||||||
return _normalImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuItemSprite::setNormalImage(Node* pImage)
|
void MenuItemSprite::setNormalImage(Node* pImage)
|
||||||
{
|
{
|
||||||
if (pImage != _normalImage)
|
if (pImage != _normalImage)
|
||||||
|
@ -499,11 +482,6 @@ void MenuItemSprite::setNormalImage(Node* pImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node * MenuItemSprite::getSelectedImage()
|
|
||||||
{
|
|
||||||
return _selectedImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuItemSprite::setSelectedImage(Node* pImage)
|
void MenuItemSprite::setSelectedImage(Node* pImage)
|
||||||
{
|
{
|
||||||
if (pImage != _normalImage)
|
if (pImage != _normalImage)
|
||||||
|
@ -524,11 +502,6 @@ void MenuItemSprite::setSelectedImage(Node* pImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Node * MenuItemSprite::getDisabledImage()
|
|
||||||
{
|
|
||||||
return _disabledImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuItemSprite::setDisabledImage(Node* pImage)
|
void MenuItemSprite::setDisabledImage(Node* pImage)
|
||||||
{
|
{
|
||||||
if (pImage != _normalImage)
|
if (pImage != _normalImage)
|
||||||
|
@ -818,18 +791,6 @@ void MenuItemImage::setDisabledSpriteFrame(SpriteFrame * frame)
|
||||||
// MenuItemToggle
|
// MenuItemToggle
|
||||||
//
|
//
|
||||||
|
|
||||||
void MenuItemToggle::setSubItems(Array* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_subItems);
|
|
||||||
_subItems = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Array* MenuItemToggle::getSubItems()
|
|
||||||
{
|
|
||||||
return _subItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: deprecated
|
// XXX: deprecated
|
||||||
MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems)
|
MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems)
|
||||||
{
|
{
|
||||||
|
@ -959,6 +920,7 @@ MenuItemToggle::~MenuItemToggle()
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE(_subItems);
|
CC_SAFE_RELEASE(_subItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItemToggle::setSelectedIndex(unsigned int index)
|
void MenuItemToggle::setSelectedIndex(unsigned int index)
|
||||||
{
|
{
|
||||||
if( index != _selectedIndex && _subItems->count() > 0 )
|
if( index != _selectedIndex && _subItems->count() > 0 )
|
||||||
|
@ -977,20 +939,19 @@ void MenuItemToggle::setSelectedIndex(unsigned int index)
|
||||||
item->setPosition( Point( s.width/2, s.height/2 ) );
|
item->setPosition( Point( s.width/2, s.height/2 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned int MenuItemToggle::getSelectedIndex()
|
|
||||||
{
|
|
||||||
return _selectedIndex;
|
|
||||||
}
|
|
||||||
void MenuItemToggle::selected()
|
void MenuItemToggle::selected()
|
||||||
{
|
{
|
||||||
MenuItem::selected();
|
MenuItem::selected();
|
||||||
((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->selected();
|
static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex))->selected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItemToggle::unselected()
|
void MenuItemToggle::unselected()
|
||||||
{
|
{
|
||||||
MenuItem::unselected();
|
MenuItem::unselected();
|
||||||
((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->unselected();
|
static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex))->unselected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItemToggle::activate()
|
void MenuItemToggle::activate()
|
||||||
{
|
{
|
||||||
// update index
|
// update index
|
||||||
|
@ -1021,7 +982,7 @@ void MenuItemToggle::setEnabled(bool enabled)
|
||||||
|
|
||||||
MenuItem* MenuItemToggle::getSelectedItem()
|
MenuItem* MenuItemToggle::getSelectedItem()
|
||||||
{
|
{
|
||||||
return (MenuItem*)_subItems->objectAtIndex(_selectedIndex);
|
return static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -142,6 +142,18 @@ public:
|
||||||
/** sets a new string to the inner label */
|
/** sets a new string to the inner label */
|
||||||
void setString(const char * label);
|
void setString(const char * label);
|
||||||
|
|
||||||
|
/** Gets the color that will be used to disable the item */
|
||||||
|
inline const Color3B& getDisabledColor() const { return _disabledColor; };
|
||||||
|
|
||||||
|
/** Sets the color that will be used to disable the item */
|
||||||
|
inline void setDisabledColor(const Color3B& color) { _disabledColor = color; };
|
||||||
|
|
||||||
|
/** Gets the label that is rendered. */
|
||||||
|
inline Node* getLabel() const { return _label; };
|
||||||
|
|
||||||
|
/** Sets the label that is rendered. */
|
||||||
|
void setLabel(Node* node);
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void activate() override;
|
virtual void activate() override;
|
||||||
virtual void selected() override;
|
virtual void selected() override;
|
||||||
|
@ -153,9 +165,9 @@ protected:
|
||||||
float _originalScale;
|
float _originalScale;
|
||||||
|
|
||||||
/** the color that will be used to disable the item */
|
/** the color that will be used to disable the item */
|
||||||
CC_PROPERTY_PASS_BY_REF(Color3B, _disabledColor, DisabledColor);
|
Color3B _disabledColor;
|
||||||
/** Label that is rendered. It can be any Node that implements the LabelProtocol */
|
/** Label that is rendered. It can be any Node that implements the LabelProtocol */
|
||||||
CC_PROPERTY(Node*, _label, Label);
|
Node* _label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,6 +289,24 @@ public:
|
||||||
/** initializes a menu item with a normal, selected and disabled image with a callable object */
|
/** initializes a menu item with a normal, selected and disabled image with a callable object */
|
||||||
bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback);
|
bool initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback);
|
||||||
|
|
||||||
|
/** Gets the image used when the item is not selected */
|
||||||
|
inline Node* getNormalImage() const { return _normalImage; };
|
||||||
|
|
||||||
|
/** Sets the image used when the item is not selected */
|
||||||
|
void setNormalImage(Node* image);
|
||||||
|
|
||||||
|
/** Gets the image used when the item is selected */
|
||||||
|
inline Node* getSelectedImage() const { return _selectedImage; };
|
||||||
|
|
||||||
|
/** Sets the image used when the item is selected */
|
||||||
|
void setSelectedImage(Node* image);
|
||||||
|
|
||||||
|
/** Gets the image used when the item is disabled */
|
||||||
|
inline Node* getDisabledImage() const { return _disabledImage; };
|
||||||
|
|
||||||
|
/** Sets the image used when the item is disabled */
|
||||||
|
void setDisabledImage(Node* image);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@since v0.99.5
|
@since v0.99.5
|
||||||
*/
|
*/
|
||||||
|
@ -288,11 +318,11 @@ protected:
|
||||||
virtual void updateImagesVisibility();
|
virtual void updateImagesVisibility();
|
||||||
|
|
||||||
/** the image used when the item is not selected */
|
/** the image used when the item is not selected */
|
||||||
CC_PROPERTY(Node*, _normalImage, NormalImage);
|
Node* _normalImage;
|
||||||
/** the image used when the item is selected */
|
/** the image used when the item is selected */
|
||||||
CC_PROPERTY(Node*, _selectedImage, SelectedImage);
|
Node* _selectedImage;
|
||||||
/** the image used when the item is disabled */
|
/** the image used when the item is disabled */
|
||||||
CC_PROPERTY(Node*, _disabledImage, DisabledImage);
|
Node* _disabledImage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,7 +381,7 @@ public:
|
||||||
/** creates a menu item from a Array with a callable object */
|
/** creates a menu item from a Array with a callable object */
|
||||||
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, Array* menuItems);
|
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, Array* menuItems);
|
||||||
/** creates a menu item from a list of items with a callable object */
|
/** creates a menu item from a list of items with a callable object */
|
||||||
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...);
|
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
|
||||||
/** creates a menu item with no target/selector and no items */
|
/** creates a menu item with no target/selector and no items */
|
||||||
static MenuItemToggle* create();
|
static MenuItemToggle* create();
|
||||||
/** creates a menu item with a item */
|
/** creates a menu item with a item */
|
||||||
|
@ -359,7 +389,7 @@ public:
|
||||||
/** creates a menu item from a Array with a target selector */
|
/** creates a menu item from a Array with a target selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle * createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems);
|
||||||
/** creates a menu item from a list of items with a target/selector */
|
/** creates a menu item from a list of items with a target/selector */
|
||||||
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...);
|
CC_DEPRECATED_ATTRIBUTE static MenuItemToggle* createWithTarget(Object* target, SEL_MenuHandler selector, MenuItem* item, ...)CC_REQUIRES_NULL_TERMINATION;
|
||||||
|
|
||||||
MenuItemToggle()
|
MenuItemToggle()
|
||||||
: _selectedIndex(0)
|
: _selectedIndex(0)
|
||||||
|
@ -382,6 +412,26 @@ public:
|
||||||
/** @deprecated Use getSelectedItem() instead */
|
/** @deprecated Use getSelectedItem() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE MenuItem* selectedItem() { return getSelectedItem(); }
|
CC_DEPRECATED_ATTRIBUTE MenuItem* selectedItem() { return getSelectedItem(); }
|
||||||
|
|
||||||
|
/** Gets the index of the selected item */
|
||||||
|
inline unsigned int getSelectedIndex() const { return _selectedIndex; };
|
||||||
|
|
||||||
|
/** Sets the index of the selected item */
|
||||||
|
void setSelectedIndex(unsigned int index);
|
||||||
|
|
||||||
|
/** Gets the array that contains the subitems.
|
||||||
|
You can add/remove items in runtime, and you can replace the array with a new one.
|
||||||
|
@since v0.7.2
|
||||||
|
*/
|
||||||
|
|
||||||
|
inline Array* getSubItems() const { return _subItems; };
|
||||||
|
|
||||||
|
/** Sets the array that contains the subitems. */
|
||||||
|
inline void setSubItems(Array* items) {
|
||||||
|
CC_SAFE_RETAIN(items);
|
||||||
|
CC_SAFE_RELEASE(_subItems);
|
||||||
|
_subItems = items;
|
||||||
|
}
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void activate() override;
|
virtual void activate() override;
|
||||||
virtual void selected() override;
|
virtual void selected() override;
|
||||||
|
@ -390,11 +440,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** returns the selected item */
|
/** returns the selected item */
|
||||||
CC_PROPERTY(unsigned int, _selectedIndex, SelectedIndex);
|
unsigned int _selectedIndex;
|
||||||
/** MutableArray that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one.
|
/** Array that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one.
|
||||||
@since v0.7.2
|
@since v0.7.2
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(Array*, _subItems, SubItems);
|
Array* _subItems;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ void MotionStreak::tintWithColor(const Color3B& colors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* MotionStreak::getTexture(void)
|
Texture2D* MotionStreak::getTexture(void) const
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
virtual void setPosition(const Point& position) override;
|
virtual void setPosition(const Point& position) override;
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void update(float delta) override;
|
virtual void update(float delta) override;
|
||||||
virtual Texture2D* getTexture() override;
|
virtual Texture2D* getTexture() const override;
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||||
virtual const BlendFunc& getBlendFunc() const override;
|
virtual const BlendFunc& getBlendFunc() const override;
|
||||||
|
|
|
@ -140,68 +140,6 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite * RenderTexture::getSprite()
|
|
||||||
{
|
|
||||||
return _sprite;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setSprite(Sprite* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RELEASE(_sprite);
|
|
||||||
_sprite = var;
|
|
||||||
CC_SAFE_RETAIN(_sprite);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int RenderTexture::getClearFlags() const
|
|
||||||
{
|
|
||||||
return _clearFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setClearFlags(unsigned int uClearFlags)
|
|
||||||
{
|
|
||||||
_clearFlags = uClearFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color4F& RenderTexture::getClearColor() const
|
|
||||||
{
|
|
||||||
return _clearColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setClearColor(const Color4F &clearColor)
|
|
||||||
{
|
|
||||||
_clearColor = clearColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
float RenderTexture::getClearDepth() const
|
|
||||||
{
|
|
||||||
return _clearDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setClearDepth(float fClearDepth)
|
|
||||||
{
|
|
||||||
_clearDepth = fClearDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RenderTexture::getClearStencil() const
|
|
||||||
{
|
|
||||||
return _clearStencil;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setClearStencil(float fClearStencil)
|
|
||||||
{
|
|
||||||
_clearStencil = fClearStencil;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderTexture::isAutoDraw() const
|
|
||||||
{
|
|
||||||
return _autoDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderTexture::setAutoDraw(bool bAutoDraw)
|
|
||||||
{
|
|
||||||
_autoDraw = bAutoDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat)
|
RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat)
|
||||||
{
|
{
|
||||||
RenderTexture *pRet = new RenderTexture();
|
RenderTexture *pRet = new RenderTexture();
|
||||||
|
|
|
@ -127,26 +127,36 @@ public:
|
||||||
void listenToForeground(Object *obj);
|
void listenToForeground(Object *obj);
|
||||||
|
|
||||||
/** Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw is YES. */
|
/** Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw is YES. */
|
||||||
unsigned int getClearFlags() const;
|
inline unsigned int getClearFlags() const { return _clearFlags; };
|
||||||
void setClearFlags(unsigned int uClearFlags);
|
inline void setClearFlags(unsigned int clearFlags) { _clearFlags = clearFlags; };
|
||||||
|
|
||||||
/** Clear color value. Valid only when "autoDraw" is true. */
|
/** Clear color value. Valid only when "autoDraw" is true. */
|
||||||
const Color4F& getClearColor() const;
|
inline const Color4F& getClearColor() const { return _clearColor; };
|
||||||
void setClearColor(const Color4F &clearColor);
|
inline void setClearColor(const Color4F &clearColor) { _clearColor = clearColor; };
|
||||||
|
|
||||||
/** Value for clearDepth. Valid only when autoDraw is true. */
|
/** Value for clearDepth. Valid only when autoDraw is true. */
|
||||||
float getClearDepth() const;
|
inline float getClearDepth() const { return _clearDepth; };
|
||||||
void setClearDepth(float fClearDepth);
|
inline void setClearDepth(float clearDepth) { _clearDepth = clearDepth; };
|
||||||
|
|
||||||
/** Value for clear Stencil. Valid only when autoDraw is true */
|
/** Value for clear Stencil. Valid only when autoDraw is true */
|
||||||
int getClearStencil() const;
|
inline int getClearStencil() const { return _clearStencil; };
|
||||||
void setClearStencil(float fClearStencil);
|
inline void setClearStencil(float clearStencil) { _clearStencil = clearStencil; };
|
||||||
|
|
||||||
/** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons.
|
/** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons.
|
||||||
Will be enabled in the future.
|
Will be enabled in the future.
|
||||||
*/
|
*/
|
||||||
bool isAutoDraw() const;
|
inline bool isAutoDraw() const { return _autoDraw; };
|
||||||
void setAutoDraw(bool bAutoDraw);
|
inline void setAutoDraw(bool isAutoDraw) { _autoDraw = isAutoDraw; };
|
||||||
|
|
||||||
|
/** Gets the Sprite being used. */
|
||||||
|
inline Sprite* getSprite() const { return _sprite; };
|
||||||
|
|
||||||
|
/** Sets the Sprite being used. */
|
||||||
|
inline void setSprite(Sprite* sprite) {
|
||||||
|
CC_SAFE_RETAIN(sprite);
|
||||||
|
CC_SAFE_RELEASE(_sprite);
|
||||||
|
_sprite = sprite;
|
||||||
|
};
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void visit() override;
|
virtual void visit() override;
|
||||||
|
@ -176,7 +186,7 @@ protected:
|
||||||
The blending function can be changed in runtime by calling:
|
The blending function can be changed in runtime by calling:
|
||||||
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
|
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(Sprite*, _sprite, Sprite)
|
Sprite* _sprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of textures group
|
// end of textures group
|
||||||
|
|
|
@ -503,7 +503,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* ParticleBatchNode::getTexture(void)
|
Texture2D* ParticleBatchNode::getTexture(void) const
|
||||||
{
|
{
|
||||||
return _textureAtlas->getTexture();
|
return _textureAtlas->getTexture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,12 @@ public:
|
||||||
/** disables a particle by inserting a 0'd quad into the texture atlas */
|
/** disables a particle by inserting a 0'd quad into the texture atlas */
|
||||||
void disableParticle(unsigned int particleIndex);
|
void disableParticle(unsigned int particleIndex);
|
||||||
|
|
||||||
|
/** Gets the texture atlas used for drawing the quads */
|
||||||
|
inline TextureAtlas* getTextureAtlas() const { return _textureAtlas; };
|
||||||
|
|
||||||
|
/** Sets the texture atlas used for drawing the quads */
|
||||||
|
inline void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; };
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
void visit();
|
void visit();
|
||||||
virtual void addChild(Node * child) override;
|
virtual void addChild(Node * child) override;
|
||||||
|
@ -99,7 +105,7 @@ public:
|
||||||
virtual void removeChild(Node* child, bool cleanup) override;
|
virtual void removeChild(Node* child, bool cleanup) override;
|
||||||
virtual void reorderChild(Node * child, int zOrder) override;
|
virtual void reorderChild(Node * child, int zOrder) override;
|
||||||
virtual void draw(void) override;
|
virtual void draw(void) override;
|
||||||
virtual Texture2D* getTexture(void) override;
|
virtual Texture2D* getTexture(void) const override;
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||||
virtual const BlendFunc& getBlendFunc(void) const override;
|
virtual const BlendFunc& getBlendFunc(void) const override;
|
||||||
|
@ -112,7 +118,7 @@ private:
|
||||||
unsigned int addChildHelper(ParticleSystem* child, int z, int aTag);
|
unsigned int addChildHelper(ParticleSystem* child, int z, int aTag);
|
||||||
void updateBlendFunc(void);
|
void updateBlendFunc(void);
|
||||||
/** the texture atlas used for drawing the quads */
|
/** the texture atlas used for drawing the quads */
|
||||||
CC_SYNTHESIZE(TextureAtlas*, _textureAtlas, TextureAtlas);
|
TextureAtlas* _textureAtlas;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** the blend function used for drawing the quads */
|
/** the blend function used for drawing the quads */
|
||||||
|
|
|
@ -821,7 +821,7 @@ void ParticleSystem::updateBlendFunc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D * ParticleSystem::getTexture()
|
Texture2D * ParticleSystem::getTexture() const
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
@ -1029,211 +1029,7 @@ bool ParticleSystem::isActive() const
|
||||||
return _isActive;
|
return _isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ParticleSystem::getParticleCount() const
|
unsigned int ParticleSystem::getTotalParticles() const
|
||||||
{
|
|
||||||
return _particleCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getDuration()
|
|
||||||
{
|
|
||||||
return _duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setDuration(float var)
|
|
||||||
{
|
|
||||||
_duration = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Point& ParticleSystem::getSourcePosition() const
|
|
||||||
{
|
|
||||||
return _sourcePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setSourcePosition(const Point& var)
|
|
||||||
{
|
|
||||||
_sourcePosition = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Point& ParticleSystem::getPosVar() const
|
|
||||||
{
|
|
||||||
return _posVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setPosVar(const Point& var)
|
|
||||||
{
|
|
||||||
_posVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getLife()
|
|
||||||
{
|
|
||||||
return _life;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setLife(float var)
|
|
||||||
{
|
|
||||||
_life = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getLifeVar()
|
|
||||||
{
|
|
||||||
return _lifeVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setLifeVar(float var)
|
|
||||||
{
|
|
||||||
_lifeVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getAngle()
|
|
||||||
{
|
|
||||||
return _angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setAngle(float var)
|
|
||||||
{
|
|
||||||
_angle = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getAngleVar()
|
|
||||||
{
|
|
||||||
return _angleVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setAngleVar(float var)
|
|
||||||
{
|
|
||||||
_angleVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getStartSize()
|
|
||||||
{
|
|
||||||
return _startSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartSize(float var)
|
|
||||||
{
|
|
||||||
_startSize = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getStartSizeVar()
|
|
||||||
{
|
|
||||||
return _startSizeVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartSizeVar(float var)
|
|
||||||
{
|
|
||||||
_startSizeVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getEndSize()
|
|
||||||
{
|
|
||||||
return _endSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndSize(float var)
|
|
||||||
{
|
|
||||||
_endSize = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getEndSizeVar()
|
|
||||||
{
|
|
||||||
return _endSizeVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndSizeVar(float var)
|
|
||||||
{
|
|
||||||
_endSizeVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color4F& ParticleSystem::getStartColor() const
|
|
||||||
{
|
|
||||||
return _startColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartColor(const Color4F& var)
|
|
||||||
{
|
|
||||||
_startColor = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color4F& ParticleSystem::getStartColorVar() const
|
|
||||||
{
|
|
||||||
return _startColorVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartColorVar(const Color4F& var)
|
|
||||||
{
|
|
||||||
_startColorVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color4F& ParticleSystem::getEndColor() const
|
|
||||||
{
|
|
||||||
return _endColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndColor(const Color4F& var)
|
|
||||||
{
|
|
||||||
_endColor = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color4F& ParticleSystem::getEndColorVar() const
|
|
||||||
{
|
|
||||||
return _endColorVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndColorVar(const Color4F& var)
|
|
||||||
{
|
|
||||||
_endColorVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getStartSpin()
|
|
||||||
{
|
|
||||||
return _startSpin;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartSpin(float var)
|
|
||||||
{
|
|
||||||
_startSpin = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getStartSpinVar()
|
|
||||||
{
|
|
||||||
return _startSpinVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setStartSpinVar(float var)
|
|
||||||
{
|
|
||||||
_startSpinVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getEndSpin()
|
|
||||||
{
|
|
||||||
return _endSpin;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndSpin(float var)
|
|
||||||
{
|
|
||||||
_endSpin = var;
|
|
||||||
}
|
|
||||||
float ParticleSystem::getEndSpinVar()
|
|
||||||
{
|
|
||||||
return _endSpinVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEndSpinVar(float var)
|
|
||||||
{
|
|
||||||
_endSpinVar = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ParticleSystem::getEmissionRate()
|
|
||||||
{
|
|
||||||
return _emissionRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEmissionRate(float var)
|
|
||||||
{
|
|
||||||
_emissionRate = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int ParticleSystem::getTotalParticles()
|
|
||||||
{
|
{
|
||||||
return _totalParticles;
|
return _totalParticles;
|
||||||
}
|
}
|
||||||
|
@ -1257,26 +1053,6 @@ void ParticleSystem::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParticleSystem::getOpacityModifyRGB()
|
|
||||||
{
|
|
||||||
return _opacityModifyRGB;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setOpacityModifyRGB(bool bOpacityModifyRGB)
|
|
||||||
{
|
|
||||||
_opacityModifyRGB = bOpacityModifyRGB;
|
|
||||||
}
|
|
||||||
|
|
||||||
tPositionType ParticleSystem::getPositionType()
|
|
||||||
{
|
|
||||||
return _positionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setPositionType(tPositionType var)
|
|
||||||
{
|
|
||||||
_positionType = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ParticleSystem::isAutoRemoveOnFinish() const
|
bool ParticleSystem::isAutoRemoveOnFinish() const
|
||||||
{
|
{
|
||||||
return _isAutoRemoveOnFinish;
|
return _isAutoRemoveOnFinish;
|
||||||
|
@ -1287,20 +1063,10 @@ void ParticleSystem::setAutoRemoveOnFinish(bool var)
|
||||||
_isAutoRemoveOnFinish = var;
|
_isAutoRemoveOnFinish = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ParticleSystem::getEmitterMode()
|
|
||||||
{
|
|
||||||
return _emitterMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ParticleSystem::setEmitterMode(int var)
|
|
||||||
{
|
|
||||||
_emitterMode = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ParticleSystem - methods for batchNode rendering
|
// ParticleSystem - methods for batchNode rendering
|
||||||
|
|
||||||
ParticleBatchNode* ParticleSystem::getBatchNode(void)
|
ParticleBatchNode* ParticleSystem::getBatchNode(void) const
|
||||||
{
|
{
|
||||||
return _batchNode;
|
return _batchNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,9 +262,124 @@ public:
|
||||||
virtual bool isBlendAdditive() const;
|
virtual bool isBlendAdditive() const;
|
||||||
virtual void setBlendAdditive(bool value);
|
virtual void setBlendAdditive(bool value);
|
||||||
|
|
||||||
|
virtual ParticleBatchNode* getBatchNode() const;
|
||||||
|
virtual void setBatchNode(ParticleBatchNode* batchNode);
|
||||||
|
|
||||||
|
// index of system in batch node array
|
||||||
|
inline int getAtlasIndex() const { return _atlasIndex; };
|
||||||
|
inline void setAtlasIndex(int index) { _atlasIndex = index; };
|
||||||
|
|
||||||
|
/** Quantity of particles that are being simulated at the moment */
|
||||||
|
inline unsigned int getParticleCount() const { return _particleCount; };
|
||||||
|
|
||||||
|
/** How many seconds the emitter will run. -1 means 'forever' */
|
||||||
|
inline float getDuration() const { return _duration; };
|
||||||
|
inline void setDuration(float duration) { _duration = duration; };
|
||||||
|
|
||||||
|
/** sourcePosition of the emitter */
|
||||||
|
inline const Point& getSourcePosition() const { return _sourcePosition; };
|
||||||
|
inline void setSourcePosition(const Point& pos) { _sourcePosition = pos; };
|
||||||
|
|
||||||
|
/** Position variance of the emitter */
|
||||||
|
inline const Point& getPosVar() const { return _posVar; };
|
||||||
|
inline void setPosVar(const Point& pos) { _posVar = pos; };
|
||||||
|
|
||||||
|
/** life, and life variation of each particle */
|
||||||
|
inline float getLife() const { return _life; };
|
||||||
|
inline void setLife(float life) { _life = life; };
|
||||||
|
|
||||||
|
/** life variance of each particle */
|
||||||
|
inline float getLifeVar() const { return _lifeVar; };
|
||||||
|
inline void setLifeVar(float lifeVar) { _lifeVar = lifeVar; };
|
||||||
|
|
||||||
|
/** angle and angle variation of each particle */
|
||||||
|
inline float getAngle() const { return _angle; };
|
||||||
|
inline void setAngle(float angle) { _angle = angle; };
|
||||||
|
|
||||||
|
/** angle variance of each particle */
|
||||||
|
inline float getAngleVar() const { return _angleVar; };
|
||||||
|
inline void setAngleVar(float angleVar) { _angleVar = angleVar; };
|
||||||
|
|
||||||
|
/** Switch between different kind of emitter modes:
|
||||||
|
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration
|
||||||
|
- kParticleModeRadius: uses radius movement + rotation
|
||||||
|
*/
|
||||||
|
inline int getEmitterMode() const { return _emitterMode; };
|
||||||
|
inline void setEmitterMode(int mode) { _emitterMode = mode; };
|
||||||
|
|
||||||
|
/** start size in pixels of each particle */
|
||||||
|
inline float getStartSize() const { return _startSize; };
|
||||||
|
inline void setStartSize(float startSize) { _startSize = startSize; };
|
||||||
|
|
||||||
|
/** size variance in pixels of each particle */
|
||||||
|
inline float getStartSizeVar() const { return _startSizeVar; };
|
||||||
|
inline void setStartSizeVar(float sizeVar) { _startSizeVar = sizeVar; };
|
||||||
|
|
||||||
|
/** end size in pixels of each particle */
|
||||||
|
inline float getEndSize() const { return _endSize; };
|
||||||
|
inline void setEndSize(float endSize) { _endSize = endSize; };
|
||||||
|
|
||||||
|
/** end size variance in pixels of each particle */
|
||||||
|
inline float getEndSizeVar() const { return _endSizeVar; };
|
||||||
|
inline void setEndSizeVar(float sizeVar) { _endSizeVar = sizeVar; };
|
||||||
|
|
||||||
|
/** start color of each particle */
|
||||||
|
inline const Color4F& getStartColor() const { return _startColor; };
|
||||||
|
inline void setStartColor(const Color4F& color) { _startColor = color; };
|
||||||
|
|
||||||
|
/** start color variance of each particle */
|
||||||
|
inline const Color4F& getStartColorVar() const { return _startColorVar; };
|
||||||
|
inline void setStartColorVar(const Color4F& color) { _startColorVar = color; };
|
||||||
|
|
||||||
|
/** end color and end color variation of each particle */
|
||||||
|
inline const Color4F& getEndColor() const { return _endColor; };
|
||||||
|
inline void setEndColor(const Color4F& color) { _endColor = color; };
|
||||||
|
|
||||||
|
/** end color variance of each particle */
|
||||||
|
inline const Color4F& getEndColorVar() const { return _endColorVar; };
|
||||||
|
inline void setEndColorVar(const Color4F& color) { _endColorVar = color; };
|
||||||
|
|
||||||
|
//* initial angle of each particle
|
||||||
|
inline float getStartSpin() const { return _startSpin; };
|
||||||
|
inline void setStartSpin(float spin) { _startSpin = spin; };
|
||||||
|
|
||||||
|
//* initial angle of each particle
|
||||||
|
inline float getStartSpinVar() const { return _startSpinVar; };
|
||||||
|
inline void setStartSpinVar(float pinVar) { _startSpinVar = pinVar; };
|
||||||
|
|
||||||
|
//* initial angle of each particle
|
||||||
|
inline float getEndSpin() const { return _endSpin; };
|
||||||
|
inline void setEndSpin(float endSpin) { _endSpin = endSpin; };
|
||||||
|
|
||||||
|
//* initial angle of each particle
|
||||||
|
inline float getEndSpinVar() const { return _endSpinVar; };
|
||||||
|
inline void setEndSpinVar(float endSpinVar) { _endSpinVar = endSpinVar; };
|
||||||
|
|
||||||
|
/** emission rate of the particles */
|
||||||
|
inline float getEmissionRate() const { return _emissionRate; };
|
||||||
|
inline void setEmissionRate(float rate) { _emissionRate = rate; };
|
||||||
|
|
||||||
|
/** maximum particles of the system */
|
||||||
|
virtual unsigned int getTotalParticles() const;
|
||||||
|
virtual void setTotalParticles(unsigned int totalParticles);
|
||||||
|
|
||||||
|
/** does the alpha value modify color */
|
||||||
|
inline void setOpacityModifyRGB(bool opacityModifyRGB) { _opacityModifyRGB = opacityModifyRGB; };
|
||||||
|
inline bool isOpacityModifyRGB() const { return _opacityModifyRGB; };
|
||||||
|
CC_DEPRECATED_ATTRIBUTE inline bool getOpacityModifyRGB() const { return isOpacityModifyRGB(); }
|
||||||
|
|
||||||
|
/** particles movement type: Free or Grouped
|
||||||
|
@since v0.8
|
||||||
|
*/
|
||||||
|
inline tPositionType getPositionType() const { return _positionType; };
|
||||||
|
inline void setPositionType(tPositionType type) { _positionType = type; };
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void update(float dt) override;
|
virtual void update(float dt) override;
|
||||||
|
virtual Texture2D* getTexture() const override;
|
||||||
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||||
|
virtual const BlendFunc &getBlendFunc() const override;
|
||||||
protected:
|
protected:
|
||||||
virtual void updateBlendFunc();
|
virtual void updateBlendFunc();
|
||||||
|
|
||||||
|
@ -342,10 +457,10 @@ protected:
|
||||||
//SEL updateParticleSel;
|
//SEL updateParticleSel;
|
||||||
|
|
||||||
/** weak reference to the SpriteBatchNode that renders the Sprite */
|
/** weak reference to the SpriteBatchNode that renders the Sprite */
|
||||||
CC_PROPERTY(ParticleBatchNode*, _batchNode, BatchNode);
|
ParticleBatchNode* _batchNode;
|
||||||
|
|
||||||
// index of system in batch node array
|
// index of system in batch node array
|
||||||
CC_SYNTHESIZE(int, _atlasIndex, AtlasIndex);
|
int _atlasIndex;
|
||||||
|
|
||||||
//true if scaled or rotated
|
//true if scaled or rotated
|
||||||
bool _transformSystemDirty;
|
bool _transformSystemDirty;
|
||||||
|
@ -356,67 +471,67 @@ protected:
|
||||||
bool _isActive;
|
bool _isActive;
|
||||||
|
|
||||||
/** Quantity of particles that are being simulated at the moment */
|
/** Quantity of particles that are being simulated at the moment */
|
||||||
CC_PROPERTY_READONLY(unsigned int, _particleCount, ParticleCount)
|
unsigned int _particleCount;
|
||||||
/** How many seconds the emitter will run. -1 means 'forever' */
|
/** How many seconds the emitter will run. -1 means 'forever' */
|
||||||
CC_PROPERTY(float, _duration, Duration)
|
float _duration;
|
||||||
/** sourcePosition of the emitter */
|
/** sourcePosition of the emitter */
|
||||||
CC_PROPERTY_PASS_BY_REF(Point, _sourcePosition, SourcePosition)
|
Point _sourcePosition;
|
||||||
/** Position variance of the emitter */
|
/** Position variance of the emitter */
|
||||||
CC_PROPERTY_PASS_BY_REF(Point, _posVar, PosVar)
|
Point _posVar;
|
||||||
/** life, and life variation of each particle */
|
/** life, and life variation of each particle */
|
||||||
CC_PROPERTY(float, _life, Life)
|
float _life;
|
||||||
/** life variance of each particle */
|
/** life variance of each particle */
|
||||||
CC_PROPERTY(float, _lifeVar, LifeVar)
|
float _lifeVar;
|
||||||
/** angle and angle variation of each particle */
|
/** angle and angle variation of each particle */
|
||||||
CC_PROPERTY(float, _angle, Angle)
|
float _angle;
|
||||||
/** angle variance of each particle */
|
/** angle variance of each particle */
|
||||||
CC_PROPERTY(float, _angleVar, AngleVar)
|
float _angleVar;
|
||||||
|
|
||||||
/** Switch between different kind of emitter modes:
|
/** Switch between different kind of emitter modes:
|
||||||
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration
|
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration
|
||||||
- kParticleModeRadius: uses radius movement + rotation
|
- kParticleModeRadius: uses radius movement + rotation
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(int, _emitterMode, EmitterMode)
|
int _emitterMode;
|
||||||
|
|
||||||
/** start size in pixels of each particle */
|
/** start size in pixels of each particle */
|
||||||
CC_PROPERTY(float, _startSize, StartSize)
|
float _startSize;
|
||||||
/** size variance in pixels of each particle */
|
/** size variance in pixels of each particle */
|
||||||
CC_PROPERTY(float, _startSizeVar, StartSizeVar)
|
float _startSizeVar;
|
||||||
/** end size in pixels of each particle */
|
/** end size in pixels of each particle */
|
||||||
CC_PROPERTY(float, _endSize, EndSize)
|
float _endSize;
|
||||||
/** end size variance in pixels of each particle */
|
/** end size variance in pixels of each particle */
|
||||||
CC_PROPERTY(float, _endSizeVar, EndSizeVar)
|
float _endSizeVar;
|
||||||
/** start color of each particle */
|
/** start color of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(Color4F, _startColor, StartColor)
|
Color4F _startColor;
|
||||||
/** start color variance of each particle */
|
/** start color variance of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(Color4F, _startColorVar, StartColorVar)
|
Color4F _startColorVar;
|
||||||
/** end color and end color variation of each particle */
|
/** end color and end color variation of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(Color4F, _endColor, EndColor)
|
Color4F _endColor;
|
||||||
/** end color variance of each particle */
|
/** end color variance of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(Color4F, _endColorVar, EndColorVar)
|
Color4F _endColorVar;
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
CC_PROPERTY(float, _startSpin, StartSpin)
|
float _startSpin;
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
CC_PROPERTY(float, _startSpinVar, StartSpinVar)
|
float _startSpinVar;
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
CC_PROPERTY(float, _endSpin, EndSpin)
|
float _endSpin;
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
CC_PROPERTY(float, _endSpinVar, EndSpinVar)
|
float _endSpinVar;
|
||||||
/** emission rate of the particles */
|
/** emission rate of the particles */
|
||||||
CC_PROPERTY(float, _emissionRate, EmissionRate)
|
float _emissionRate;
|
||||||
/** maximum particles of the system */
|
/** maximum particles of the system */
|
||||||
CC_PROPERTY(unsigned int, _totalParticles, TotalParticles)
|
unsigned int _totalParticles;
|
||||||
/** conforms to CocosNodeTexture protocol */
|
/** conforms to CocosNodeTexture protocol */
|
||||||
CC_PROPERTY(Texture2D*, _texture, Texture)
|
Texture2D* _texture;
|
||||||
/** conforms to CocosNodeTexture protocol */
|
/** conforms to CocosNodeTexture protocol */
|
||||||
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
|
BlendFunc _blendFunc;
|
||||||
/** does the alpha value modify color */
|
/** does the alpha value modify color */
|
||||||
CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB)
|
bool _opacityModifyRGB;
|
||||||
|
|
||||||
/** particles movement type: Free or Grouped
|
/** particles movement type: Free or Grouped
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(tPositionType, _positionType, PositionType)
|
tPositionType _positionType;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of particle_nodes group
|
// end of particle_nodes group
|
||||||
|
|
|
@ -52,16 +52,6 @@ Special features and Limitations:
|
||||||
*/
|
*/
|
||||||
class CC_DLL ParticleSystemQuad : public ParticleSystem
|
class CC_DLL ParticleSystemQuad : public ParticleSystem
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
V3F_C4B_T2F_Quad *_quads; // quads to be rendered
|
|
||||||
GLushort *_indices; // indices
|
|
||||||
|
|
||||||
#if CC_TEXTURE_ATLAS_USE_VAO
|
|
||||||
GLuint _VAOname;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** creates a Particle Emitter */
|
/** creates a Particle Emitter */
|
||||||
|
@ -113,6 +103,16 @@ private:
|
||||||
void setupVBO();
|
void setupVBO();
|
||||||
#endif
|
#endif
|
||||||
bool allocMemory();
|
bool allocMemory();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
V3F_C4B_T2F_Quad *_quads; // quads to be rendered
|
||||||
|
GLushort *_indices; // indices
|
||||||
|
|
||||||
|
#if CC_TEXTURE_ATLAS_USE_VAO
|
||||||
|
GLuint _VAOname;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of particle_nodes group
|
// end of particle_nodes group
|
||||||
|
|
|
@ -40,7 +40,7 @@ static const int kMaxLogLen = 16*1024;
|
||||||
/**
|
/**
|
||||||
@brief Output Debug message.
|
@brief Output Debug message.
|
||||||
*/
|
*/
|
||||||
void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2);
|
void CC_DLL log(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lua can not deal with ...
|
* lua can not deal with ...
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
friend class TextureCache;
|
friend class TextureCache;
|
||||||
|
|
||||||
Image();
|
Image();
|
||||||
~Image();
|
virtual ~Image();
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -145,14 +145,6 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
unsigned char * getData() { return _data; }
|
|
||||||
int getDataLen() { return _width * _height; }
|
|
||||||
|
|
||||||
|
|
||||||
bool hasAlpha() { return _hasAlpha; }
|
|
||||||
bool isPremultipliedAlpha() { return _preMulti; }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Save Image data to the specified file, with specified format.
|
@brief Save Image data to the specified file, with specified format.
|
||||||
@param pszFilePath the file's absolute path, including file suffix.
|
@param pszFilePath the file's absolute path, including file suffix.
|
||||||
|
@ -160,9 +152,17 @@ public:
|
||||||
*/
|
*/
|
||||||
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
|
|
||||||
CC_SYNTHESIZE_READONLY(unsigned short, _width, Width);
|
// Getters
|
||||||
CC_SYNTHESIZE_READONLY(unsigned short, _height, Height);
|
inline unsigned char * getData() { return _data; }
|
||||||
CC_SYNTHESIZE_READONLY(int, _bitsPerComponent, BitsPerComponent);
|
inline int getDataLen() { return _width * _height; }
|
||||||
|
|
||||||
|
inline bool hasAlpha() { return _hasAlpha; }
|
||||||
|
inline bool isPremultipliedAlpha() { return _preMulti; }
|
||||||
|
|
||||||
|
inline unsigned short getWidth() { return _width; };
|
||||||
|
inline unsigned short getHeight() { return _height; };
|
||||||
|
inline int getBitsPerComponent() { return _bitsPerComponent; };
|
||||||
|
//
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _initWithJpgData(void *pData, int nDatalen);
|
bool _initWithJpgData(void *pData, int nDatalen);
|
||||||
|
@ -173,6 +173,10 @@ protected:
|
||||||
bool _saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
bool _saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
bool _saveImageToJPG(const char *pszFilePath);
|
bool _saveImageToJPG(const char *pszFilePath);
|
||||||
|
|
||||||
|
unsigned short _width;
|
||||||
|
unsigned short _height;
|
||||||
|
int _bitsPerComponent;
|
||||||
|
|
||||||
unsigned char *_data;
|
unsigned char *_data;
|
||||||
bool _hasAlpha;
|
bool _hasAlpha;
|
||||||
bool _preMulti;
|
bool _preMulti;
|
||||||
|
|
|
@ -306,7 +306,7 @@ bool Image::_initWithJpgData(void * data, int nSize)
|
||||||
/* If we get here, the JPEG code has signaled an error.
|
/* If we get here, the JPEG code has signaled an error.
|
||||||
* We need to clean up the JPEG object, close the input file, and return.
|
* We need to clean up the JPEG object, close the input file, and return.
|
||||||
*/
|
*/
|
||||||
CCLog("%d", bRet);
|
log("%d", bRet);
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ public: virtual void set##funName(varType var) \
|
||||||
#define CC_BREAK_IF(cond) if(cond) break
|
#define CC_BREAK_IF(cond) if(cond) break
|
||||||
|
|
||||||
#define __CCLOGWITHFUNCTION(s, ...) \
|
#define __CCLOGWITHFUNCTION(s, ...) \
|
||||||
CCLog("%s : %s",__FUNCTION__, String::createWithFormat(s, ##__VA_ARGS__)->getCString())
|
log("%s : %s",__FUNCTION__, String::createWithFormat(s, ##__VA_ARGS__)->getCString())
|
||||||
|
|
||||||
// cocos2d debug
|
// cocos2d debug
|
||||||
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
|
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
|
||||||
|
@ -215,15 +215,15 @@ public: virtual void set##funName(varType var) \
|
||||||
#define CCLOGWARN(...) do {} while (0)
|
#define CCLOGWARN(...) do {} while (0)
|
||||||
|
|
||||||
#elif COCOS2D_DEBUG == 1
|
#elif COCOS2D_DEBUG == 1
|
||||||
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#define CCLOGINFO(format,...) do {} while (0)
|
#define CCLOGINFO(format,...) do {} while (0)
|
||||||
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
|
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
|
||||||
|
|
||||||
#elif COCOS2D_DEBUG > 1
|
#elif COCOS2D_DEBUG > 1
|
||||||
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define CCLOGINFO(format,...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
|
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
|
||||||
#endif // COCOS2D_DEBUG
|
#endif // COCOS2D_DEBUG
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public: virtual void set##funName(varType var) \
|
||||||
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0
|
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0
|
||||||
#define LUALOG(...)
|
#define LUALOG(...)
|
||||||
#else
|
#else
|
||||||
#define LUALOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
#define LUALOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
|
||||||
#endif // Lua engine debug
|
#endif // Lua engine debug
|
||||||
|
|
||||||
#if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \
|
#if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \
|
||||||
|
@ -285,4 +285,17 @@ private: \
|
||||||
#define CC_UNUSED
|
#define CC_UNUSED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// CC_REQUIRES_NULL_TERMINATION
|
||||||
|
//
|
||||||
|
#if !defined(CC_REQUIRES_NULL_TERMINATION)
|
||||||
|
#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549)
|
||||||
|
#define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel(0,1)))
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel))
|
||||||
|
#else
|
||||||
|
#define CC_REQUIRES_NULL_TERMINATION
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __CC_PLATFORM_MACROS_H__
|
#endif // __CC_PLATFORM_MACROS_H__
|
||||||
|
|
|
@ -53,14 +53,14 @@ private:
|
||||||
|
|
||||||
bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute )
|
bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* firstAttribute )
|
||||||
{
|
{
|
||||||
//CCLog(" VisitEnter %s",element.Value());
|
//log(" VisitEnter %s",element.Value());
|
||||||
|
|
||||||
std::vector<const char*> attsVector;
|
std::vector<const char*> attsVector;
|
||||||
for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
|
for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
|
||||||
{
|
{
|
||||||
//CCLog("%s", attrib->Name());
|
//log("%s", attrib->Name());
|
||||||
attsVector.push_back(attrib->Name());
|
attsVector.push_back(attrib->Name());
|
||||||
//CCLog("%s",attrib->Value());
|
//log("%s",attrib->Value());
|
||||||
attsVector.push_back(attrib->Value());
|
attsVector.push_back(attrib->Value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ bool XmlSaxHander::VisitEnter( const tinyxml2::XMLElement& element, const tinyxm
|
||||||
}
|
}
|
||||||
bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
|
bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
|
||||||
{
|
{
|
||||||
//CCLog("VisitExit %s",element.Value());
|
//log("VisitExit %s",element.Value());
|
||||||
|
|
||||||
SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value());
|
SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value());
|
||||||
return true;
|
return true;
|
||||||
|
@ -81,7 +81,7 @@ bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
|
||||||
|
|
||||||
bool XmlSaxHander::Visit( const tinyxml2::XMLText& text )
|
bool XmlSaxHander::Visit( const tinyxml2::XMLText& text )
|
||||||
{
|
{
|
||||||
//CCLog("Visit %s",text.Value());
|
//log("Visit %s",text.Value());
|
||||||
SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), strlen(text.Value()));
|
SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), strlen(text.Value()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char buf[MAX_LEN];
|
char buf[MAX_LEN];
|
||||||
|
@ -44,6 +45,18 @@ void CCLog(const char * pszFormat, ...)
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char buf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, pszFormat);
|
||||||
|
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
showDialogJNI(pszMsg, pszTitle);
|
showDialogJNI(pszMsg, pszTitle);
|
||||||
|
|
|
@ -28,6 +28,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char buf[MAX_LEN];
|
char buf[MAX_LEN];
|
||||||
|
@ -40,10 +41,22 @@ void CCLog(const char * pszFormat, ...)
|
||||||
fprintf(stderr, "cocos2d-x debug info %s\n", buf);
|
fprintf(stderr, "cocos2d-x debug info %s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char buf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, pszFormat);
|
||||||
|
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info %s\n", buf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
// MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
|
// MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
|
||||||
CCLog(pszMsg);
|
log(pszMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
printf("Cocos2d: ");
|
printf("Cocos2d: ");
|
||||||
|
@ -43,7 +44,19 @@ void CCLog(const char * pszFormat, ...)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ios no MessageBox, use CCLog instead
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
printf("Cocos2d: ");
|
||||||
|
char szBuf[kMaxLogLen+1] = {0};
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
printf("%s", szBuf);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ios no MessageBox, use log instead
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;
|
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;
|
||||||
|
|
|
@ -28,6 +28,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
@ -48,9 +49,29 @@ void CCLog(const char * pszFormat, ...)
|
||||||
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
CCLog("%s: %s", pszTitle, pszMsg);
|
log("%s: %s", pszTitle, pszMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
|
|
|
@ -325,20 +325,20 @@ bool EGLView::initGL()
|
||||||
|
|
||||||
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
|
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
|
||||||
{
|
{
|
||||||
CCLog("Ready for GLSL");
|
log("Ready for GLSL");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("Not totally ready :(");
|
log("Not totally ready :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glewIsSupported("GL_VERSION_2_0"))
|
if (glewIsSupported("GL_VERSION_2_0"))
|
||||||
{
|
{
|
||||||
CCLog("Ready for OpenGL 2.0");
|
log("Ready for OpenGL 2.0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("OpenGL 2.0 not supported");
|
log("OpenGL 2.0 not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable point size by default on linux.
|
// Enable point size by default on linux.
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
printf("Cocos2d: ");
|
printf("Cocos2d: ");
|
||||||
|
@ -46,12 +47,27 @@ void CCLog(const char * pszFormat, ...)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
printf("Cocos2d: ");
|
||||||
|
char szBuf[kMaxLogLen];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, kMaxLogLen, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
printf("%s", szBuf);
|
||||||
|
printf("\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
{
|
{
|
||||||
puts(pszFormat);
|
puts(pszFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ios no MessageBox, use CCLog instead
|
// ios no MessageBox, use log instead
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;
|
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;
|
||||||
|
|
|
@ -29,6 +29,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
@ -49,14 +50,34 @@ void CCLog(const char * pszFormat, ...)
|
||||||
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf( szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
CCLog("%s: %s", pszTitle, pszMsg);
|
log("%s: %s", pszTitle, pszMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
{
|
{
|
||||||
CCLog("%s", pszFormat);
|
log("%s", pszFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -74,7 +74,7 @@ void CocosPepperInstance::DidChangeView(const pp::View& view)
|
||||||
|
|
||||||
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
|
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
|
||||||
{
|
{
|
||||||
CCLog("CocosPepperInstance::Init: %x %p", pp_instance(),
|
log("CocosPepperInstance::Init: %x %p", pp_instance(),
|
||||||
pp::Module::Get()->get_browser_interface());
|
pp::Module::Get()->get_browser_interface());
|
||||||
nacl_io_init_ppapi(pp_instance(),
|
nacl_io_init_ppapi(pp_instance(),
|
||||||
pp::Module::Get()->get_browser_interface());
|
pp::Module::Get()->get_browser_interface());
|
||||||
|
|
|
@ -31,6 +31,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
@ -51,9 +52,29 @@ void CCLog(const char * pszFormat, ...)
|
||||||
AppLog("cocos2d-x debug info [%s]\n", szBuf);
|
AppLog("cocos2d-x debug info [%s]\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppLog("cocos2d-x debug info [%s]\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
CCLog("%s: %s", pszTitle, pszMsg);
|
log("%s: %s", pszTitle, pszMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
|
|
|
@ -28,6 +28,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char szBuf[MAX_LEN];
|
char szBuf[MAX_LEN];
|
||||||
|
@ -46,6 +47,24 @@ void CCLog(const char * pszFormat, ...)
|
||||||
printf("%s\n", szBuf);
|
printf("%s\n", szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
WCHAR wszBuf[MAX_LEN] = {0};
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf));
|
||||||
|
OutputDebugStringW(wszBuf);
|
||||||
|
OutputDebugStringA("\n");
|
||||||
|
|
||||||
|
WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE);
|
||||||
|
printf("%s\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
{
|
{
|
||||||
MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
|
MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
|
||||||
|
|
|
@ -105,10 +105,10 @@ static bool glew_dynamic_binding()
|
||||||
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
|
// If the current opengl driver doesn't have framebuffers methods, check if an extension exists
|
||||||
if (glGenFramebuffers == NULL)
|
if (glGenFramebuffers == NULL)
|
||||||
{
|
{
|
||||||
CCLog("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
|
log("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
|
||||||
if (strstr(gl_extensions, "ARB_framebuffer_object"))
|
if (strstr(gl_extensions, "ARB_framebuffer_object"))
|
||||||
{
|
{
|
||||||
CCLog("OpenGL: ARB_framebuffer_object is supported");
|
log("OpenGL: ARB_framebuffer_object is supported");
|
||||||
|
|
||||||
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
|
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
|
||||||
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
|
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
|
||||||
|
@ -131,7 +131,7 @@ static bool glew_dynamic_binding()
|
||||||
else
|
else
|
||||||
if (strstr(gl_extensions, "EXT_framebuffer_object"))
|
if (strstr(gl_extensions, "EXT_framebuffer_object"))
|
||||||
{
|
{
|
||||||
CCLog("OpenGL: EXT_framebuffer_object is supported");
|
log("OpenGL: EXT_framebuffer_object is supported");
|
||||||
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
|
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
|
||||||
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
|
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
|
||||||
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
|
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
|
||||||
|
@ -152,8 +152,8 @@ static bool glew_dynamic_binding()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("OpenGL: No framebuffers extension is supported");
|
log("OpenGL: No framebuffers extension is supported");
|
||||||
CCLog("OpenGL: Any call to Fbo will crash!");
|
log("OpenGL: Any call to Fbo will crash!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,20 +228,20 @@ bool EGLView::initGL()
|
||||||
|
|
||||||
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
|
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
|
||||||
{
|
{
|
||||||
CCLog("Ready for GLSL");
|
log("Ready for GLSL");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("Not totally ready :(");
|
log("Not totally ready :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glewIsSupported("GL_VERSION_2_0"))
|
if (glewIsSupported("GL_VERSION_2_0"))
|
||||||
{
|
{
|
||||||
CCLog("Ready for OpenGL 2.0");
|
log("Ready for OpenGL 2.0");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("OpenGL 2.0 not supported");
|
log("OpenGL 2.0 not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(glew_dynamic_binding() == false)
|
if(glew_dynamic_binding() == false)
|
||||||
|
|
|
@ -383,7 +383,7 @@ bool Image::initWithString(
|
||||||
|
|
||||||
if (! dc.setFont(pFontName, nSize))
|
if (! dc.setFont(pFontName, nSize))
|
||||||
{
|
{
|
||||||
CCLog("Can't found font(%s), use system default", pFontName);
|
log("Can't found font(%s), use system default", pFontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
|
|
|
@ -97,9 +97,12 @@ STATICLIBS = \
|
||||||
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
|
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
|
||||||
LIBS = -lrt -lz
|
LIBS = -lrt -lz
|
||||||
|
|
||||||
|
HTMLTPL_DIR = $(COCOS_ROOT)/tools/emscripten-template
|
||||||
|
HTMLTPL_FILE = index.html
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJ_DIR)
|
rm -rf $(OBJ_DIR)
|
||||||
rm -f $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR)/index.html core
|
rm -rf $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR) core
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
|
@ -108,7 +111,7 @@ clean:
|
||||||
ifdef EXECUTABLE
|
ifdef EXECUTABLE
|
||||||
TARGET := $(BIN_DIR)/$(EXECUTABLE)
|
TARGET := $(BIN_DIR)/$(EXECUTABLE)
|
||||||
|
|
||||||
all: $(TARGET).js $(TARGET).data $(BIN_DIR)/index.html
|
all: $(TARGET).js $(TARGET).data $(BIN_DIR)/$(HTMLTPL_FILE)
|
||||||
|
|
||||||
run: $(TARGET)
|
run: $(TARGET)
|
||||||
cd $(dir $^) && ./$(notdir $^)
|
cd $(dir $^) && ./$(notdir $^)
|
||||||
|
|
|
@ -88,7 +88,7 @@ Animation* Animation::createWithSpriteFrames(Array *frames, float delay/* = 0.0f
|
||||||
return pAnimation;
|
return pAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation* Animation::create(Array* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops)
|
Animation* Animation::create(Array* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops /* = 1 */)
|
||||||
{
|
{
|
||||||
Animation *pAnimation = new Animation();
|
Animation *pAnimation = new Animation();
|
||||||
pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops);
|
pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops);
|
||||||
|
|
|
@ -61,18 +61,46 @@ public:
|
||||||
/** initializes the animation frame with a spriteframe, number of delay units and a notification user info */
|
/** initializes the animation frame with a spriteframe, number of delay units and a notification user info */
|
||||||
bool initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, Dictionary* userInfo);
|
bool initWithSpriteFrame(SpriteFrame* spriteFrame, float delayUnits, Dictionary* userInfo);
|
||||||
|
|
||||||
|
SpriteFrame* getSpriteFrame() const { return _spriteFrame; };
|
||||||
|
|
||||||
|
void setSpriteFrame(SpriteFrame* frame)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(frame);
|
||||||
|
CC_SAFE_RELEASE(_spriteFrame);
|
||||||
|
_spriteFrame = frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the units of time the frame takes */
|
||||||
|
float getDelayUnits() const { return _delayUnits; };
|
||||||
|
|
||||||
|
/** Sets the units of time the frame takes */
|
||||||
|
void setDelayUnits(float delayUnits) { _delayUnits = delayUnits; };
|
||||||
|
|
||||||
|
/** @brief Gets user infomation
|
||||||
|
A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast.
|
||||||
|
*/
|
||||||
|
Dictionary* getUserInfo() const { return _userInfo; };
|
||||||
|
|
||||||
|
/** Sets user infomation */
|
||||||
|
void setUserInfo(Dictionary* userInfo)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(userInfo);
|
||||||
|
CC_SAFE_RELEASE(_userInfo);
|
||||||
|
_userInfo = userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual AnimationFrame *clone() const override;
|
virtual AnimationFrame *clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** SpriteFrameName to be used */
|
/** SpriteFrameName to be used */
|
||||||
CC_SYNTHESIZE_RETAIN(SpriteFrame*, _spriteFrame, SpriteFrame)
|
SpriteFrame* _spriteFrame;
|
||||||
|
|
||||||
/** how many units of time the frame takes */
|
/** how many units of time the frame takes */
|
||||||
CC_SYNTHESIZE(float, _delayUnits, DelayUnits)
|
float _delayUnits;
|
||||||
|
|
||||||
/** A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */
|
/** A AnimationFrameDisplayedNotification notification will be broadcast when the frame is displayed with this dictionary as UserInfo. If UserInfo is nil, then no notification will be broadcast. */
|
||||||
CC_SYNTHESIZE_RETAIN(Dictionary*, _userInfo, UserInfo)
|
Dictionary* _userInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,10 +131,7 @@ public:
|
||||||
/* Creates an animation with an array of AnimationFrame, the delay per units in seconds and and how many times it should be executed.
|
/* Creates an animation with an array of AnimationFrame, the delay per units in seconds and and how many times it should be executed.
|
||||||
@since v2.0
|
@since v2.0
|
||||||
*/
|
*/
|
||||||
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops);
|
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1);
|
||||||
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit) {
|
|
||||||
return Animation::create(arrayOfAnimationFrameNames, delayPerUnit, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation();
|
Animation();
|
||||||
virtual ~Animation(void);
|
virtual ~Animation(void);
|
||||||
|
@ -140,27 +165,63 @@ public:
|
||||||
*/
|
*/
|
||||||
void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect);
|
void addSpriteFrameWithTexture(Texture2D* pobTexture, const Rect& rect);
|
||||||
|
|
||||||
|
/** Gets the total Delay units of the Animation. */
|
||||||
|
float getTotalDelayUnits() const { return _totalDelayUnits; };
|
||||||
|
|
||||||
|
/** Sets the delay in seconds of the "delay unit" */
|
||||||
|
void setDelayPerUnit(float delayPerUnit) { _delayPerUnit = delayPerUnit; };
|
||||||
|
|
||||||
|
/** Gets the delay in seconds of the "delay unit" */
|
||||||
|
float getDelayPerUnit() const { return _delayPerUnit; };
|
||||||
|
|
||||||
|
|
||||||
|
/** Gets the duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */
|
||||||
|
float getDuration() const;
|
||||||
|
|
||||||
|
/** Gets the array of AnimationFrames */
|
||||||
|
Array* getFrames() const { return _frames; };
|
||||||
|
|
||||||
|
/** Sets the array of AnimationFrames */
|
||||||
|
void setFrames(Array* frames)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(frames);
|
||||||
|
CC_SAFE_RELEASE(_frames);
|
||||||
|
_frames = frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Checks whether to restore the original frame when animation finishes. */
|
||||||
|
bool getRestoreOriginalFrame() const { return _restoreOriginalFrame; };
|
||||||
|
|
||||||
|
/** Sets whether to restore the original frame when animation finishes */
|
||||||
|
void setRestoreOriginalFrame(bool restoreOriginalFrame) { _restoreOriginalFrame = restoreOriginalFrame; };
|
||||||
|
|
||||||
|
/** Gets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
|
||||||
|
unsigned int getLoops() const { return _loops; };
|
||||||
|
|
||||||
|
/** Sets the times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
|
||||||
|
void setLoops(unsigned int loops) { _loops = loops; };
|
||||||
|
|
||||||
// overrides
|
// overrides
|
||||||
virtual Animation *clone() const override;
|
virtual Animation *clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** total Delay units of the Animation. */
|
/** total Delay units of the Animation. */
|
||||||
CC_SYNTHESIZE_READONLY(float, _totalDelayUnits, TotalDelayUnits)
|
float _totalDelayUnits;
|
||||||
|
|
||||||
/** Delay in seconds of the "delay unit" */
|
/** Delay in seconds of the "delay unit" */
|
||||||
CC_SYNTHESIZE(float, _delayPerUnit, DelayPerUnit)
|
float _delayPerUnit;
|
||||||
|
|
||||||
/** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */
|
/** duration in seconds of the whole animation. It is the result of totalDelayUnits * delayPerUnit */
|
||||||
CC_PROPERTY_READONLY(float, _duration, Duration)
|
float _duration;
|
||||||
|
|
||||||
/** array of AnimationFrames */
|
/** array of AnimationFrames */
|
||||||
CC_SYNTHESIZE_RETAIN(Array*, _frames, Frames)
|
Array* _frames;
|
||||||
|
|
||||||
/** whether or not it shall restore the original frame when the animation finishes */
|
/** whether or not it shall restore the original frame when the animation finishes */
|
||||||
CC_SYNTHESIZE(bool, _restoreOriginalFrame, RestoreOriginalFrame)
|
bool _restoreOriginalFrame;
|
||||||
|
|
||||||
/** how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
|
/** how many times the animation is going to loop. 0 means animation is not animated. 1, animation is executed one time, ... */
|
||||||
CC_SYNTHESIZE(unsigned int, _loops, Loops)
|
unsigned int _loops;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of sprite_nodes group
|
// end of sprite_nodes group
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ void Sprite::setTexture(Texture2D *texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* Sprite::getTexture(void)
|
Texture2D* Sprite::getTexture(void) const
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,9 +449,9 @@ public:
|
||||||
/// @{
|
/// @{
|
||||||
/// @name Functions inherited from TextureProtocol
|
/// @name Functions inherited from TextureProtocol
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
virtual Texture2D* getTexture(void) override;
|
virtual Texture2D* getTexture() const override;
|
||||||
inline void setBlendFunc(const BlendFunc &blendFunc) override { _blendFunc = blendFunc; }
|
inline void setBlendFunc(const BlendFunc &blendFunc) override { _blendFunc = blendFunc; }
|
||||||
inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; }
|
inline const BlendFunc& getBlendFunc() const override { return _blendFunc; }
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @{
|
/// @{
|
||||||
|
|
|
@ -684,7 +684,7 @@ const BlendFunc& SpriteBatchNode::getBlendFunc(void) const
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* SpriteBatchNode::getTexture(void)
|
Texture2D* SpriteBatchNode::getTexture(void) const
|
||||||
{
|
{
|
||||||
return _textureAtlas->getTexture();
|
return _textureAtlas->getTexture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,19 +67,13 @@ public:
|
||||||
/** creates a SpriteBatchNode with a texture2d and capacity of children.
|
/** creates a SpriteBatchNode with a texture2d and capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
*/
|
*/
|
||||||
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity);
|
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = kDefaultSpriteBatchCapacity);
|
||||||
static SpriteBatchNode* createWithTexture(Texture2D* tex) {
|
|
||||||
return SpriteBatchNode::createWithTexture(tex, kDefaultSpriteBatchCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
|
/** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
The file will be loaded using the TextureMgr.
|
The file will be loaded using the TextureMgr.
|
||||||
*/
|
*/
|
||||||
static SpriteBatchNode* create(const char* fileImage, int capacity);
|
static SpriteBatchNode* create(const char* fileImage, int capacity = kDefaultSpriteBatchCapacity);
|
||||||
static SpriteBatchNode* create(const char* fileImage) {
|
|
||||||
return SpriteBatchNode::create(fileImage, kDefaultSpriteBatchCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpriteBatchNode();
|
SpriteBatchNode();
|
||||||
virtual ~SpriteBatchNode();
|
virtual ~SpriteBatchNode();
|
||||||
|
@ -133,7 +127,7 @@ public:
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
// TextureProtocol
|
// TextureProtocol
|
||||||
virtual Texture2D* getTexture(void) override;
|
virtual Texture2D* getTexture(void) const override;
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||||
virtual const BlendFunc& getBlendFunc(void) const override;
|
virtual const BlendFunc& getBlendFunc(void) const override;
|
||||||
|
@ -174,7 +168,7 @@ protected:
|
||||||
TextureAtlas *_textureAtlas;
|
TextureAtlas *_textureAtlas;
|
||||||
BlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
|
|
||||||
// all descendants: children, gran children, etc...
|
// all descendants: children, grand children, etc...
|
||||||
Array* _descendants;
|
Array* _descendants;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -247,17 +247,13 @@ NotificationObserver::NotificationObserver(Object *target,
|
||||||
_selector = selector;
|
_selector = selector;
|
||||||
_object = obj;
|
_object = obj;
|
||||||
|
|
||||||
_name = new char[strlen(name)+1];
|
_name = name;
|
||||||
memset(_name,0,strlen(name)+1);
|
|
||||||
|
|
||||||
string orig (name);
|
|
||||||
orig.copy(_name,strlen(name),0);
|
|
||||||
_handler = 0;
|
_handler = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationObserver::~NotificationObserver()
|
NotificationObserver::~NotificationObserver()
|
||||||
{
|
{
|
||||||
CC_SAFE_DELETE_ARRAY(_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationObserver::performSelector(Object *obj)
|
void NotificationObserver::performSelector(Object *obj)
|
||||||
|
@ -282,9 +278,9 @@ SEL_CallFuncO NotificationObserver::getSelector() const
|
||||||
return _selector;
|
return _selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *NotificationObserver::getName() const
|
const char* NotificationObserver::getName() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object* NotificationObserver::getObject() const
|
Object* NotificationObserver::getObject() const
|
||||||
|
@ -292,7 +288,7 @@ Object *NotificationObserver::getObject() const
|
||||||
return _object;
|
return _object;
|
||||||
}
|
}
|
||||||
|
|
||||||
int NotificationObserver::getHandler()
|
int NotificationObserver::getHandler() const
|
||||||
{
|
{
|
||||||
return _handler;
|
return _handler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,12 +139,21 @@ public:
|
||||||
|
|
||||||
/** Invokes the callback function of this observer */
|
/** Invokes the callback function of this observer */
|
||||||
void performSelector(Object *obj);
|
void performSelector(Object *obj);
|
||||||
|
|
||||||
|
// Getters / Setters
|
||||||
|
Object* getTarget() const;
|
||||||
|
SEL_CallFuncO getSelector() const;
|
||||||
|
const char* getName() const;
|
||||||
|
Object* getObject() const;
|
||||||
|
int getHandler() const;
|
||||||
|
void setHandler(int handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_PROPERTY_READONLY(Object *, _target, Target);
|
Object* _target;
|
||||||
CC_PROPERTY_READONLY(SEL_CallFuncO, _selector, Selector);
|
SEL_CallFuncO _selector;
|
||||||
CC_PROPERTY_READONLY(char *, _name, Name);
|
std::string _name;
|
||||||
CC_PROPERTY_READONLY(Object *, _object, Object);
|
Object* _object;
|
||||||
CC_PROPERTY(int, _handler,Handler);
|
int _handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -91,7 +91,7 @@ void Profiler::displayTimers()
|
||||||
CCDICT_FOREACH(_activeTimers, pElement)
|
CCDICT_FOREACH(_activeTimers, pElement)
|
||||||
{
|
{
|
||||||
ProfilingTimer* timer = static_cast<ProfilingTimer*>(pElement->getObject());
|
ProfilingTimer* timer = static_cast<ProfilingTimer*>(pElement->getObject());
|
||||||
CCLog("%s", timer->description());
|
log("%s", timer->description());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,8 +125,10 @@ public:
|
||||||
// properties
|
// properties
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CC_SYNTHESIZE(TextFieldDelegate *, _delegate, Delegate);
|
inline TextFieldDelegate* getDelegate() const { return _delegate; };
|
||||||
CC_SYNTHESIZE_READONLY(int, _charCount, CharCount);
|
inline void setDelegate(TextFieldDelegate* delegate) { _delegate = delegate; };
|
||||||
|
|
||||||
|
inline int getCharCount() const { return _charCount; };
|
||||||
virtual const Color3B& getColorSpaceHolder();
|
virtual const Color3B& getColorSpaceHolder();
|
||||||
virtual void setColorSpaceHolder(const Color3B& color);
|
virtual void setColorSpaceHolder(const Color3B& color);
|
||||||
|
|
||||||
|
@ -135,6 +137,9 @@ public:
|
||||||
virtual void setString(const char *text);
|
virtual void setString(const char *text);
|
||||||
virtual const char* getString(void) const;
|
virtual const char* getString(void) const;
|
||||||
protected:
|
protected:
|
||||||
|
TextFieldDelegate * _delegate;
|
||||||
|
int _charCount;
|
||||||
|
|
||||||
std::string * _inputText;
|
std::string * _inputText;
|
||||||
|
|
||||||
// place holder text property
|
// place holder text property
|
||||||
|
|
|
@ -111,7 +111,6 @@ GLuint Texture2D::getName() const
|
||||||
|
|
||||||
Size Texture2D::getContentSize() const
|
Size Texture2D::getContentSize() const
|
||||||
{
|
{
|
||||||
|
|
||||||
Size ret;
|
Size ret;
|
||||||
ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR();
|
ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR();
|
||||||
ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR();
|
ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR();
|
||||||
|
@ -124,7 +123,7 @@ const Size& Texture2D::getContentSizeInPixels()
|
||||||
return _contentSize;
|
return _contentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLfloat Texture2D::getMaxS()
|
GLfloat Texture2D::getMaxS() const
|
||||||
{
|
{
|
||||||
return _maxS;
|
return _maxS;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +133,7 @@ void Texture2D::setMaxS(GLfloat maxS)
|
||||||
_maxS = maxS;
|
_maxS = maxS;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLfloat Texture2D::getMaxT()
|
GLfloat Texture2D::getMaxT() const
|
||||||
{
|
{
|
||||||
return _maxT;
|
return _maxT;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +143,7 @@ void Texture2D::setMaxT(GLfloat maxT)
|
||||||
_maxT = maxT;
|
_maxT = maxT;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLProgram* Texture2D::getShaderProgram(void)
|
GLProgram* Texture2D::getShaderProgram() const
|
||||||
{
|
{
|
||||||
return _shaderProgram;
|
return _shaderProgram;
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,28 +238,60 @@ public:
|
||||||
bool hasPremultipliedAlpha() const;
|
bool hasPremultipliedAlpha() const;
|
||||||
bool hasMipmaps() const;
|
bool hasMipmaps() const;
|
||||||
|
|
||||||
|
/** Gets the pixel format of the texture */
|
||||||
|
Texture2DPixelFormat getPixelFormat() const;
|
||||||
|
|
||||||
|
/** Gets the width of the texture in pixels */
|
||||||
|
unsigned int getPixelsWide() const;
|
||||||
|
|
||||||
|
/** Gets the height of the texture in pixels */
|
||||||
|
unsigned int getPixelsHigh() const;
|
||||||
|
|
||||||
|
/** Gets the texture name */
|
||||||
|
GLuint getName() const;
|
||||||
|
|
||||||
|
/** Gets max S */
|
||||||
|
GLfloat getMaxS() const;
|
||||||
|
/** Sets max S */
|
||||||
|
void setMaxS(GLfloat maxS);
|
||||||
|
|
||||||
|
/** Gets max T */
|
||||||
|
GLfloat getMaxT() const;
|
||||||
|
/** Sets max T */
|
||||||
|
void setMaxT(GLfloat maxT);
|
||||||
|
|
||||||
|
Size getContentSize() const;
|
||||||
|
|
||||||
|
void setShaderProgram(GLProgram* program);
|
||||||
|
GLProgram* getShaderProgram() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||||
|
|
||||||
// By default PVR images are treated as if they don't have the alpha channel premultiplied
|
// By default PVR images are treated as if they don't have the alpha channel premultiplied
|
||||||
bool _PVRHaveAlphaPremultiplied;
|
bool _PVRHaveAlphaPremultiplied;
|
||||||
|
|
||||||
|
protected:
|
||||||
/** pixel format of the texture */
|
/** pixel format of the texture */
|
||||||
CC_PROPERTY_READONLY(Texture2DPixelFormat, _pixelFormat, PixelFormat)
|
Texture2DPixelFormat _pixelFormat;
|
||||||
|
|
||||||
/** width in pixels */
|
/** width in pixels */
|
||||||
CC_PROPERTY_READONLY(unsigned int, _pixelsWide, PixelsWide)
|
unsigned int _pixelsWide;
|
||||||
|
|
||||||
/** height in pixels */
|
/** height in pixels */
|
||||||
CC_PROPERTY_READONLY(unsigned int, _pixelsHigh, PixelsHigh)
|
unsigned int _pixelsHigh;
|
||||||
|
|
||||||
/** texture name */
|
/** texture name */
|
||||||
CC_PROPERTY_READONLY(GLuint, _name, Name)
|
GLuint _name;
|
||||||
|
|
||||||
/** texture max S */
|
/** texture max S */
|
||||||
CC_PROPERTY(GLfloat, _maxS, MaxS)
|
GLfloat _maxS;
|
||||||
|
|
||||||
/** texture max T */
|
/** texture max T */
|
||||||
CC_PROPERTY(GLfloat, _maxT, MaxT)
|
GLfloat _maxT;
|
||||||
|
|
||||||
/** content size */
|
/** content size */
|
||||||
CC_PROPERTY_READONLY(Size, _contentSize, ContentSize)
|
Size _contentSize;
|
||||||
|
|
||||||
/** whether or not the texture has their Alpha premultiplied */
|
/** whether or not the texture has their Alpha premultiplied */
|
||||||
bool _hasPremultipliedAlpha;
|
bool _hasPremultipliedAlpha;
|
||||||
|
@ -267,7 +299,7 @@ private:
|
||||||
bool _hasMipmaps;
|
bool _hasMipmaps;
|
||||||
|
|
||||||
/** shader program used by drawAtPoint and drawInRect */
|
/** shader program used by drawAtPoint and drawInRect */
|
||||||
CC_PROPERTY(GLProgram*, _shaderProgram, ShaderProgram);
|
GLProgram* _shaderProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of textures group
|
// end of textures group
|
||||||
|
|
|
@ -81,7 +81,7 @@ int TextureAtlas::getCapacity() const
|
||||||
return _capacity;
|
return _capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D* TextureAtlas::getTexture()
|
Texture2D* TextureAtlas::getTexture() const
|
||||||
{
|
{
|
||||||
return _texture;
|
return _texture;
|
||||||
}
|
}
|
||||||
|
@ -100,22 +100,22 @@ V3F_C4B_T2F_Quad* TextureAtlas::getQuads()
|
||||||
return _quads;
|
return _quads;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::setQuads(V3F_C4B_T2F_Quad *var)
|
void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
|
||||||
{
|
{
|
||||||
_quads = var;
|
_quads = quads;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureAtlas - alloc & init
|
// TextureAtlas - alloc & init
|
||||||
|
|
||||||
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
||||||
{
|
{
|
||||||
TextureAtlas * pTextureAtlas = new TextureAtlas();
|
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||||
if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity))
|
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||||
{
|
{
|
||||||
pTextureAtlas->autorelease();
|
textureAtlas->autorelease();
|
||||||
return pTextureAtlas;
|
return textureAtlas;
|
||||||
}
|
}
|
||||||
CC_SAFE_DELETE(pTextureAtlas);
|
CC_SAFE_DELETE(textureAtlas);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,24 @@ public:
|
||||||
|
|
||||||
const char* description() const;
|
const char* description() const;
|
||||||
|
|
||||||
|
/** Gets the quantity of quads that are going to be drawn */
|
||||||
|
int getTotalQuads() const;
|
||||||
|
|
||||||
|
/** Gets the quantity of quads that can be stored with the current texture atlas size */
|
||||||
|
int getCapacity() const;
|
||||||
|
|
||||||
|
/** Gets the texture of the texture atlas */
|
||||||
|
Texture2D* getTexture() const;
|
||||||
|
|
||||||
|
/** Sets the texture for the texture atlas */
|
||||||
|
void setTexture(Texture2D* texture);
|
||||||
|
|
||||||
|
/** Gets the quads that are going to be rendered */
|
||||||
|
V3F_C4B_T2F_Quad* getQuads();
|
||||||
|
|
||||||
|
/** Sets the quads that are going to be rendered */
|
||||||
|
void setQuads(V3F_C4B_T2F_Quad* quads);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupIndices();
|
void setupIndices();
|
||||||
void mapBuffers();
|
void mapBuffers();
|
||||||
|
@ -203,16 +221,14 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
||||||
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
|
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
|
||||||
|
|
||||||
|
|
||||||
/** quantity of quads that are going to be drawn */
|
/** quantity of quads that are going to be drawn */
|
||||||
CC_PROPERTY_READONLY(int, _totalQuads, TotalQuads)
|
int _totalQuads;
|
||||||
/** quantity of quads that can be stored with the current texture atlas size */
|
/** quantity of quads that can be stored with the current texture atlas size */
|
||||||
CC_PROPERTY_READONLY(int, _capacity, Capacity)
|
int _capacity;
|
||||||
/** Texture of the texture atlas */
|
/** Texture of the texture atlas */
|
||||||
CC_PROPERTY(Texture2D *, _texture, Texture)
|
Texture2D* _texture;
|
||||||
/** Quads that are going to be rendered */
|
/** Quads that are going to be rendered */
|
||||||
CC_PROPERTY(V3F_C4B_T2F_Quad *, _quads, Quads)
|
V3F_C4B_T2F_Quad* _quads;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of textures group
|
// end of textures group
|
||||||
|
|
|
@ -547,7 +547,7 @@ bool TexturePVR::createGLTexture()
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||||
|
|
||||||
glGenTextures(1, &_name);
|
glGenTextures(1, &_name);
|
||||||
glBindTexture(GL_TEXTURE_2D, _name);
|
ccGLBindTexture2D(_name);
|
||||||
|
|
||||||
// Default: Anti alias.
|
// Default: Anti alias.
|
||||||
if (_numberOfMipmaps == 1)
|
if (_numberOfMipmaps == 1)
|
||||||
|
|
|
@ -30,18 +30,15 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class PointObject : Object
|
class PointObject : Object
|
||||||
{
|
{
|
||||||
CC_SYNTHESIZE(Point, _ratio, Ratio)
|
|
||||||
CC_SYNTHESIZE(Point, _offset, Offset)
|
|
||||||
CC_SYNTHESIZE(Node *,_child, Child) // weak ref
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PointObject * pointWithPoint(Point ratio, Point offset)
|
static PointObject * create(Point ratio, Point offset)
|
||||||
{
|
{
|
||||||
PointObject *pRet = new PointObject();
|
PointObject *pRet = new PointObject();
|
||||||
pRet->initWithPoint(ratio, offset);
|
pRet->initWithPoint(ratio, offset);
|
||||||
pRet->autorelease();
|
pRet->autorelease();
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool initWithPoint(Point ratio, Point offset)
|
bool initWithPoint(Point ratio, Point offset)
|
||||||
{
|
{
|
||||||
_ratio = ratio;
|
_ratio = ratio;
|
||||||
|
@ -49,6 +46,20 @@ public:
|
||||||
_child = NULL;
|
_child = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Point& getRatio() const { return _ratio; };
|
||||||
|
inline void setRatio(const Point& ratio) { _ratio = ratio; };
|
||||||
|
|
||||||
|
inline const Point& getOffset() const { return _offset; };
|
||||||
|
inline void setOffset(const Point& offset) { _offset = offset; };
|
||||||
|
|
||||||
|
inline Node* getChild() const { return _child; };
|
||||||
|
inline void setChild(Node* child) { _child = child; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
Point _ratio;
|
||||||
|
Point _offset;
|
||||||
|
Node *_child; // weak ref
|
||||||
};
|
};
|
||||||
|
|
||||||
ParallaxNode::ParallaxNode()
|
ParallaxNode::ParallaxNode()
|
||||||
|
@ -56,6 +67,7 @@ ParallaxNode::ParallaxNode()
|
||||||
_parallaxArray = ccArrayNew(5);
|
_parallaxArray = ccArrayNew(5);
|
||||||
_lastPosition = Point(-100,-100);
|
_lastPosition = Point(-100,-100);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallaxNode::~ParallaxNode()
|
ParallaxNode::~ParallaxNode()
|
||||||
{
|
{
|
||||||
if( _parallaxArray )
|
if( _parallaxArray )
|
||||||
|
@ -83,7 +95,7 @@ void ParallaxNode::addChild(Node * child, int zOrder, int tag)
|
||||||
void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset)
|
void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset)
|
||||||
{
|
{
|
||||||
CCASSERT( child != NULL, "Argument must be non-nil");
|
CCASSERT( child != NULL, "Argument must be non-nil");
|
||||||
PointObject *obj = PointObject::pointWithPoint(ratio, offset);
|
PointObject *obj = PointObject::create(ratio, offset);
|
||||||
obj->setChild(child);
|
obj->setChild(child);
|
||||||
ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj);
|
ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj);
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ public:
|
||||||
ParallaxNode();
|
ParallaxNode();
|
||||||
virtual ~ParallaxNode();
|
virtual ~ParallaxNode();
|
||||||
|
|
||||||
|
// prevents compiler warning: "Included function hides overloaded virtual functions"
|
||||||
|
using Node::addChild;
|
||||||
|
|
||||||
void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset);
|
void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset);
|
||||||
|
|
||||||
/** Sets an array of layers for the Parallax node */
|
/** Sets an array of layers for the Parallax node */
|
||||||
|
|
|
@ -123,18 +123,6 @@ TMXLayer::~TMXLayer()
|
||||||
CC_SAFE_DELETE_ARRAY(_tiles);
|
CC_SAFE_DELETE_ARRAY(_tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXTilesetInfo * TMXLayer::getTileSet()
|
|
||||||
{
|
|
||||||
return _tileSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXLayer::setTileSet(TMXTilesetInfo* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_tileSet);
|
|
||||||
_tileSet = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXLayer::releaseMap()
|
void TMXLayer::releaseMap()
|
||||||
{
|
{
|
||||||
if (_tiles)
|
if (_tiles)
|
||||||
|
@ -718,17 +706,5 @@ int TMXLayer::getVertexZForPos(const Point& pos)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary * TMXLayer::getProperties()
|
|
||||||
{
|
|
||||||
return _properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXLayer::setProperties(Dictionary* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_properties);
|
|
||||||
_properties = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,37 @@ public:
|
||||||
inline const char* getLayerName(){ return _layerName.c_str(); }
|
inline const char* getLayerName(){ return _layerName.c_str(); }
|
||||||
inline void setLayerName(const char *layerName){ _layerName = layerName; }
|
inline void setLayerName(const char *layerName){ _layerName = layerName; }
|
||||||
|
|
||||||
|
/** size of the layer in tiles */
|
||||||
|
inline const Size& getLayerSize() const { return _layerSize; };
|
||||||
|
inline void setLayerSize(const Size& size) { _layerSize = size; };
|
||||||
|
|
||||||
|
/** size of the map's tile (could be different from the tile's size) */
|
||||||
|
inline const Size& getMapTileSize() const { return _mapTileSize; };
|
||||||
|
inline void setMapTileSize(const Size& size) { _mapTileSize = size; };
|
||||||
|
|
||||||
|
/** pointer to the map of tiles */
|
||||||
|
inline unsigned int* getTiles() const { return _tiles; };
|
||||||
|
inline void setTiles(unsigned int* tiles) { _tiles = tiles; };
|
||||||
|
|
||||||
|
/** Tileset information for the layer */
|
||||||
|
inline TMXTilesetInfo* getTileSet() const { return _tileSet; };
|
||||||
|
inline void setTileSet(TMXTilesetInfo* info) {
|
||||||
|
CC_SAFE_RETAIN(info);
|
||||||
|
CC_SAFE_RELEASE(_tileSet);
|
||||||
|
_tileSet = info;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Layer orientation, which is the same as the map orientation */
|
||||||
|
inline unsigned int getLayerOrientation() const { return _layerOrientation; };
|
||||||
|
inline void setLayerOrientation(unsigned int orientation) { _layerOrientation = orientation; };
|
||||||
|
|
||||||
|
/** properties from the layer. They can be added using Tiled */
|
||||||
|
inline Dictionary* getProperties() const { return _properties; };
|
||||||
|
inline void setProperties(Dictionary* properties) {
|
||||||
|
CC_SAFE_RETAIN(properties);
|
||||||
|
CC_SAFE_RELEASE(_properties);
|
||||||
|
_properties = properties;
|
||||||
|
};
|
||||||
//
|
//
|
||||||
// Override
|
// Override
|
||||||
//
|
//
|
||||||
|
@ -192,19 +223,18 @@ protected:
|
||||||
// used for retina display
|
// used for retina display
|
||||||
float _contentScaleFactor;
|
float _contentScaleFactor;
|
||||||
|
|
||||||
private:
|
|
||||||
/** size of the layer in tiles */
|
/** size of the layer in tiles */
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _layerSize, LayerSize);
|
Size _layerSize;
|
||||||
/** size of the map's tile (could be different from the tile's size) */
|
/** size of the map's tile (could be different from the tile's size) */
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _mapTileSize, MapTileSize);
|
Size _mapTileSize;
|
||||||
/** pointer to the map of tiles */
|
/** pointer to the map of tiles */
|
||||||
CC_SYNTHESIZE(unsigned int*, _tiles, Tiles);
|
unsigned int* _tiles;
|
||||||
/** Tileset information for the layer */
|
/** Tileset information for the layer */
|
||||||
CC_PROPERTY(TMXTilesetInfo*, _tileSet, TileSet);
|
TMXTilesetInfo* _tileSet;
|
||||||
/** Layer orientation, which is the same as the map orientation */
|
/** Layer orientation, which is the same as the map orientation */
|
||||||
CC_SYNTHESIZE(unsigned int, _layerOrientation, LayerOrientation);
|
unsigned int _layerOrientation;
|
||||||
/** properties from the layer. They can be added using Tiled */
|
/** properties from the layer. They can be added using Tiled */
|
||||||
CC_PROPERTY(Dictionary*, _properties, Properties);
|
Dictionary* _properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of tilemap_parallax_nodes group
|
// end of tilemap_parallax_nodes group
|
||||||
|
|
|
@ -39,13 +39,15 @@ TMXObjectGroup::TMXObjectGroup()
|
||||||
_objects->retain();
|
_objects->retain();
|
||||||
_properties = new Dictionary();
|
_properties = new Dictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXObjectGroup::~TMXObjectGroup()
|
TMXObjectGroup::~TMXObjectGroup()
|
||||||
{
|
{
|
||||||
CCLOGINFO( "cocos2d: deallocing: %p", this);
|
CCLOGINFO( "cocos2d: deallocing: %p", this);
|
||||||
CC_SAFE_RELEASE(_objects);
|
CC_SAFE_RELEASE(_objects);
|
||||||
CC_SAFE_RELEASE(_properties);
|
CC_SAFE_RELEASE(_properties);
|
||||||
}
|
}
|
||||||
Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
|
|
||||||
|
Dictionary* TMXObjectGroup::getObjectNamed(const char *objectName) const
|
||||||
{
|
{
|
||||||
if (_objects && _objects->count() > 0)
|
if (_objects && _objects->count() > 0)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +55,7 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
|
||||||
CCARRAY_FOREACH(_objects, pObj)
|
CCARRAY_FOREACH(_objects, pObj)
|
||||||
{
|
{
|
||||||
Dictionary* pDict = static_cast<Dictionary*>(pObj);
|
Dictionary* pDict = static_cast<Dictionary*>(pObj);
|
||||||
String *name = (String*)pDict->objectForKey("name");
|
String *name = static_cast<String*>(pDict->objectForKey("name"));
|
||||||
if (name && name->_string == objectName)
|
if (name && name->_string == objectName)
|
||||||
{
|
{
|
||||||
return pDict;
|
return pDict;
|
||||||
|
@ -63,30 +65,10 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
|
||||||
// object not found
|
// object not found
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
String* TMXObjectGroup::propertyNamed(const char* propertyName)
|
|
||||||
{
|
|
||||||
return (String*)_properties->objectForKey(propertyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary* TMXObjectGroup::getProperties()
|
String* TMXObjectGroup::getPropertyNamed(const char* propertyName) const
|
||||||
{
|
{
|
||||||
return _properties;
|
return static_cast<String*>(_properties->objectForKey(propertyName));
|
||||||
}
|
|
||||||
void TMXObjectGroup::setProperties(Dictionary * properties)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(properties);
|
|
||||||
CC_SAFE_RELEASE(_properties);
|
|
||||||
_properties = properties;
|
|
||||||
}
|
|
||||||
Array* TMXObjectGroup::getObjects()
|
|
||||||
{
|
|
||||||
return _objects;
|
|
||||||
}
|
|
||||||
void TMXObjectGroup::setObjects(Array* objects)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(objects);
|
|
||||||
CC_SAFE_RELEASE(_objects);
|
|
||||||
_objects = objects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -44,12 +44,6 @@ NS_CC_BEGIN
|
||||||
*/
|
*/
|
||||||
class CC_DLL TMXObjectGroup : public Object
|
class CC_DLL TMXObjectGroup : public Object
|
||||||
{
|
{
|
||||||
/** offset position of child objects */
|
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Point, _positionOffset, PositionOffset);
|
|
||||||
/** list of properties stored in a dictionary */
|
|
||||||
CC_PROPERTY(Dictionary*, _properties, Properties);
|
|
||||||
/** array of the objects */
|
|
||||||
CC_PROPERTY(Array*, _objects, Objects);
|
|
||||||
public:
|
public:
|
||||||
TMXObjectGroup();
|
TMXObjectGroup();
|
||||||
virtual ~TMXObjectGroup();
|
virtual ~TMXObjectGroup();
|
||||||
|
@ -58,15 +52,52 @@ public:
|
||||||
inline void setGroupName(const char *groupName){ _groupName = groupName; }
|
inline void setGroupName(const char *groupName){ _groupName = groupName; }
|
||||||
|
|
||||||
/** return the value for the specific property name */
|
/** return the value for the specific property name */
|
||||||
String *propertyNamed(const char* propertyName);
|
String* getPropertyNamed(const char* propertyName) const;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char* propertyName) const { return getPropertyNamed(propertyName); };
|
||||||
|
|
||||||
/** return the dictionary for the specific object name.
|
/** return the dictionary for the specific object name.
|
||||||
It will return the 1st object found on the array for the given name.
|
It will return the 1st object found on the array for the given name.
|
||||||
*/
|
*/
|
||||||
Dictionary* objectNamed(const char *objectName);
|
Dictionary* getObjectNamed(const char *objectName) const;
|
||||||
|
|
||||||
|
CC_DEPRECATED_ATTRIBUTE Dictionary* objectNamed(const char *objectName) const { return getObjectNamed(objectName); };
|
||||||
|
|
||||||
|
/** Gets the offset position of child objects */
|
||||||
|
inline const Point& getPositionOffset() const { return _positionOffset; };
|
||||||
|
|
||||||
|
/** Sets the offset position of child objects */
|
||||||
|
inline void setPositionOffset(const Point& offset) { _positionOffset = offset; };
|
||||||
|
|
||||||
|
/** Gets the list of properties stored in a dictionary */
|
||||||
|
inline Dictionary* getProperties() const { return _properties; };
|
||||||
|
|
||||||
|
/** Sets the list of properties */
|
||||||
|
inline void setProperties(Dictionary* properties) {
|
||||||
|
CC_SAFE_RETAIN(properties);
|
||||||
|
CC_SAFE_RELEASE(_properties);
|
||||||
|
_properties = properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Gets the array of the objects */
|
||||||
|
inline Array* getObjects() const { return _objects; };
|
||||||
|
|
||||||
|
/** Sets the array of the objects */
|
||||||
|
inline void setObjects(Array* objects) {
|
||||||
|
CC_SAFE_RETAIN(objects);
|
||||||
|
CC_SAFE_RELEASE(_objects);
|
||||||
|
_objects = objects;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** name of the group */
|
/** name of the group */
|
||||||
std::string _groupName;
|
std::string _groupName;
|
||||||
|
/** offset position of child objects */
|
||||||
|
Point _positionOffset;
|
||||||
|
/** list of properties stored in a dictionary */
|
||||||
|
Dictionary* _properties;
|
||||||
|
/** array of the objects */
|
||||||
|
Array* _objects;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of tilemap_parallax_nodes group
|
// end of tilemap_parallax_nodes group
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool TMXTiledMap::initWithTMXFile(const char *tmxFile)
|
||||||
|
|
||||||
setContentSize(Size::ZERO);
|
setContentSize(Size::ZERO);
|
||||||
|
|
||||||
TMXMapInfo *mapInfo = TMXMapInfo::formatWithTMXFile(tmxFile);
|
TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile);
|
||||||
|
|
||||||
if (! mapInfo)
|
if (! mapInfo)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ bool TMXTiledMap::initWithXML(const char* tmxString, const char* resourcePath)
|
||||||
{
|
{
|
||||||
setContentSize(Size::ZERO);
|
setContentSize(Size::ZERO);
|
||||||
|
|
||||||
TMXMapInfo *mapInfo = TMXMapInfo::formatWithXML(tmxString, resourcePath);
|
TMXMapInfo *mapInfo = TMXMapInfo::createWithXML(tmxString, resourcePath);
|
||||||
|
|
||||||
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
|
CCASSERT( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
|
||||||
buildWithMapInfo(mapInfo);
|
buildWithMapInfo(mapInfo);
|
||||||
|
@ -101,30 +101,6 @@ TMXTiledMap::~TMXTiledMap()
|
||||||
CC_SAFE_RELEASE(_tileProperties);
|
CC_SAFE_RELEASE(_tileProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* TMXTiledMap::getObjectGroups()
|
|
||||||
{
|
|
||||||
return _objectGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXTiledMap::setObjectGroups(Array* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_objectGroups);
|
|
||||||
_objectGroups = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary * TMXTiledMap::getProperties()
|
|
||||||
{
|
|
||||||
return _properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXTiledMap::setProperties(Dictionary* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_properties);
|
|
||||||
_properties = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private
|
// private
|
||||||
TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
|
TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +206,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// public
|
// public
|
||||||
TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
|
TMXLayer * TMXTiledMap::getLayer(const char *layerName) const
|
||||||
{
|
{
|
||||||
CCASSERT(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!");
|
CCASSERT(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!");
|
||||||
Object* pObj = NULL;
|
Object* pObj = NULL;
|
||||||
|
@ -250,7 +226,7 @@ TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName)
|
TMXObjectGroup * TMXTiledMap::getObjectGroup(const char *groupName) const
|
||||||
{
|
{
|
||||||
CCASSERT(groupName != NULL && strlen(groupName) > 0, "Invalid group name!");
|
CCASSERT(groupName != NULL && strlen(groupName) > 0, "Invalid group name!");
|
||||||
|
|
||||||
|
@ -273,14 +249,14 @@ TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
String* TMXTiledMap::propertyNamed(const char *propertyName)
|
String* TMXTiledMap::getProperty(const char *propertyName) const
|
||||||
{
|
{
|
||||||
return (String*)_properties->objectForKey(propertyName);
|
return static_cast<String*>(_properties->objectForKey(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary* TMXTiledMap::propertiesForGID(int GID)
|
Dictionary* TMXTiledMap::getPropertiesForGID(int GID) const
|
||||||
{
|
{
|
||||||
return (Dictionary*)_tileProperties->objectForKey(GID);
|
return static_cast<Dictionary*>(_tileProperties->objectForKey(GID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,36 +88,26 @@ Each layer is created using an TMXLayer (subclass of SpriteBatchNode). If you ha
|
||||||
unless the layer visibility is off. In that case, the layer won't be created at all.
|
unless the layer visibility is off. In that case, the layer won't be created at all.
|
||||||
You can obtain the layers (TMXLayer objects) at runtime by:
|
You can obtain the layers (TMXLayer objects) at runtime by:
|
||||||
- map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
|
- map->getChildByTag(tag_number); // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
|
||||||
- map->layerNamed(name_of_the_layer);
|
- map->getLayer(name_of_the_layer);
|
||||||
|
|
||||||
Each object group is created using a TMXObjectGroup which is a subclass of MutableArray.
|
Each object group is created using a TMXObjectGroup which is a subclass of MutableArray.
|
||||||
You can obtain the object groups at runtime by:
|
You can obtain the object groups at runtime by:
|
||||||
- map->objectGroupNamed(name_of_the_object_group);
|
- map->getObjectGroup(name_of_the_object_group);
|
||||||
|
|
||||||
Each object is a TMXObject.
|
Each object is a TMXObject.
|
||||||
|
|
||||||
Each property is stored as a key-value pair in an MutableDictionary.
|
Each property is stored as a key-value pair in an MutableDictionary.
|
||||||
You can obtain the properties at runtime by:
|
You can obtain the properties at runtime by:
|
||||||
|
|
||||||
map->propertyNamed(name_of_the_property);
|
map->getProperty(name_of_the_property);
|
||||||
layer->propertyNamed(name_of_the_property);
|
layer->getProperty(name_of_the_property);
|
||||||
objectGroup->propertyNamed(name_of_the_property);
|
objectGroup->getProperty(name_of_the_property);
|
||||||
object->propertyNamed(name_of_the_property);
|
object->getProperty(name_of_the_property);
|
||||||
|
|
||||||
@since v0.8.1
|
@since v0.8.1
|
||||||
*/
|
*/
|
||||||
class CC_DLL TMXTiledMap : public Node
|
class CC_DLL TMXTiledMap : public Node
|
||||||
{
|
{
|
||||||
/** the map's size property measured in tiles */
|
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _mapSize, MapSize);
|
|
||||||
/** the tiles's size property measured in pixels */
|
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _tileSize, TileSize);
|
|
||||||
/** map orientation */
|
|
||||||
CC_SYNTHESIZE(int, _mapOrientation, MapOrientation);
|
|
||||||
/** object groups */
|
|
||||||
CC_PROPERTY(Array*, _objectGroups, ObjectGroups);
|
|
||||||
/** properties */
|
|
||||||
CC_PROPERTY(Dictionary*, _properties, Properties);
|
|
||||||
public:
|
public:
|
||||||
TMXTiledMap();
|
TMXTiledMap();
|
||||||
virtual ~TMXTiledMap();
|
virtual ~TMXTiledMap();
|
||||||
|
@ -135,22 +125,65 @@ public:
|
||||||
bool initWithXML(const char* tmxString, const char* resourcePath);
|
bool initWithXML(const char* tmxString, const char* resourcePath);
|
||||||
|
|
||||||
/** return the TMXLayer for the specific layer */
|
/** return the TMXLayer for the specific layer */
|
||||||
TMXLayer* layerNamed(const char *layerName);
|
TMXLayer* getLayer(const char *layerName) const;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE TMXLayer* layerNamed(const char *layerName) const { return getLayer(layerName); };
|
||||||
|
|
||||||
/** return the TMXObjectGroup for the specific group */
|
/** return the TMXObjectGroup for the specific group */
|
||||||
TMXObjectGroup* objectGroupNamed(const char *groupName);
|
TMXObjectGroup* getObjectGroup(const char *groupName) const;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE TMXObjectGroup* objectGroupNamed(const char *groupName) const { return getObjectGroup(groupName); };
|
||||||
|
|
||||||
/** return the value for the specific property name */
|
/** return the value for the specific property name */
|
||||||
String *propertyNamed(const char *propertyName);
|
String *getProperty(const char *propertyName) const;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char *propertyName) const { return getProperty(propertyName); };
|
||||||
|
|
||||||
/** return properties dictionary for tile GID */
|
/** return properties dictionary for tile GID */
|
||||||
Dictionary* propertiesForGID(int GID);
|
Dictionary* getPropertiesForGID(int GID) const;
|
||||||
|
CC_DEPRECATED_ATTRIBUTE Dictionary* propertiesForGID(int GID) const { return getPropertiesForGID(GID); };
|
||||||
|
|
||||||
|
/** the map's size property measured in tiles */
|
||||||
|
inline const Size& getMapSize() const { return _mapSize; };
|
||||||
|
inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; };
|
||||||
|
|
||||||
|
/** the tiles's size property measured in pixels */
|
||||||
|
inline const Size& getTileSize() const { return _tileSize; };
|
||||||
|
inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; };
|
||||||
|
|
||||||
|
/** map orientation */
|
||||||
|
inline int getMapOrientation() const { return _mapOrientation; };
|
||||||
|
inline void setMapOrientation(int mapOrientation) { _mapOrientation = mapOrientation; };
|
||||||
|
|
||||||
|
/** object groups */
|
||||||
|
inline Array* getObjectGroups() const { return _objectGroups; };
|
||||||
|
inline void setObjectGroups(Array* groups) {
|
||||||
|
CC_SAFE_RETAIN(groups);
|
||||||
|
CC_SAFE_RELEASE(_objectGroups);
|
||||||
|
_objectGroups = groups;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** properties */
|
||||||
|
inline Dictionary* getProperties() const { return _properties; };
|
||||||
|
inline void setProperties(Dictionary* properties) {
|
||||||
|
CC_SAFE_RETAIN(properties);
|
||||||
|
CC_SAFE_RELEASE(_properties);
|
||||||
|
_properties = properties;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
|
TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
|
||||||
TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
|
TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
|
||||||
void buildWithMapInfo(TMXMapInfo* mapInfo);
|
void buildWithMapInfo(TMXMapInfo* mapInfo);
|
||||||
protected:
|
protected:
|
||||||
|
/** the map's size property measured in tiles */
|
||||||
|
Size _mapSize;
|
||||||
|
/** the tiles's size property measured in pixels */
|
||||||
|
Size _tileSize;
|
||||||
|
/** map orientation */
|
||||||
|
int _mapOrientation;
|
||||||
|
/** object groups */
|
||||||
|
Array* _objectGroups;
|
||||||
|
/** properties */
|
||||||
|
Dictionary* _properties;
|
||||||
|
|
||||||
//! tile properties
|
//! tile properties
|
||||||
Dictionary* _tileProperties;
|
Dictionary* _tileProperties;
|
||||||
|
|
||||||
|
|
|
@ -35,24 +35,9 @@ THE SOFTWARE.
|
||||||
#include "support/base64.h"
|
#include "support/base64.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
/*
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
|
|
||||||
#include "expat.h"
|
|
||||||
#else
|
|
||||||
#include <libxml/parser.h>
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
#include <libxml/xmlmemory.h>
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
/*
|
|
||||||
void tmx_startElement(void *ctx, const xmlChar *name, const xmlChar **atts);
|
|
||||||
void tmx_endElement(void *ctx, const xmlChar *name);
|
|
||||||
void tmx_characters(void *ctx, const xmlChar *ch, int len);
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const char* valueForKey(const char *key, std::map<std::string, std::string>* dict)
|
static const char* valueForKey(const char *key, std::map<std::string, std::string>* dict)
|
||||||
{
|
{
|
||||||
if (dict)
|
if (dict)
|
||||||
|
@ -84,6 +69,7 @@ TMXLayerInfo::~TMXLayerInfo()
|
||||||
_tiles = NULL;
|
_tiles = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary * TMXLayerInfo::getProperties()
|
Dictionary * TMXLayerInfo::getProperties()
|
||||||
{
|
{
|
||||||
return _properties;
|
return _properties;
|
||||||
|
@ -104,10 +90,12 @@ TMXTilesetInfo::TMXTilesetInfo()
|
||||||
,_imageSize(Size::ZERO)
|
,_imageSize(Size::ZERO)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXTilesetInfo::~TMXTilesetInfo()
|
TMXTilesetInfo::~TMXTilesetInfo()
|
||||||
{
|
{
|
||||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect TMXTilesetInfo::rectForGID(unsigned int gid)
|
Rect TMXTilesetInfo::rectForGID(unsigned int gid)
|
||||||
{
|
{
|
||||||
Rect rect;
|
Rect rect;
|
||||||
|
@ -123,7 +111,7 @@ Rect TMXTilesetInfo::rectForGID(unsigned int gid)
|
||||||
|
|
||||||
// implementation TMXMapInfo
|
// implementation TMXMapInfo
|
||||||
|
|
||||||
TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile)
|
TMXMapInfo * TMXMapInfo::create(const char *tmxFile)
|
||||||
{
|
{
|
||||||
TMXMapInfo *pRet = new TMXMapInfo();
|
TMXMapInfo *pRet = new TMXMapInfo();
|
||||||
if(pRet->initWithTMXFile(tmxFile))
|
if(pRet->initWithTMXFile(tmxFile))
|
||||||
|
@ -135,7 +123,7 @@ TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXMapInfo * TMXMapInfo::formatWithXML(const char* tmxString, const char* resourcePath)
|
TMXMapInfo * TMXMapInfo::createWithXML(const char* tmxString, const char* resourcePath)
|
||||||
{
|
{
|
||||||
TMXMapInfo *pRet = new TMXMapInfo();
|
TMXMapInfo *pRet = new TMXMapInfo();
|
||||||
if(pRet->initWithXML(tmxString, resourcePath))
|
if(pRet->initWithXML(tmxString, resourcePath))
|
||||||
|
@ -214,66 +202,6 @@ TMXMapInfo::~TMXMapInfo()
|
||||||
CC_SAFE_RELEASE(_objectGroups);
|
CC_SAFE_RELEASE(_objectGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* TMXMapInfo::getLayers()
|
|
||||||
{
|
|
||||||
return _layers;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXMapInfo::setLayers(Array* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_layers);
|
|
||||||
_layers = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Array* TMXMapInfo::getTilesets()
|
|
||||||
{
|
|
||||||
return _tilesets;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXMapInfo::setTilesets(Array* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_tilesets);
|
|
||||||
_tilesets = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Array* TMXMapInfo::getObjectGroups()
|
|
||||||
{
|
|
||||||
return _objectGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXMapInfo::setObjectGroups(Array* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_objectGroups);
|
|
||||||
_objectGroups = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary * TMXMapInfo::getProperties()
|
|
||||||
{
|
|
||||||
return _properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXMapInfo::setProperties(Dictionary* var)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(var);
|
|
||||||
CC_SAFE_RELEASE(_properties);
|
|
||||||
_properties = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary* TMXMapInfo::getTileProperties()
|
|
||||||
{
|
|
||||||
return _tileProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMXMapInfo::setTileProperties(Dictionary* tileProperties)
|
|
||||||
{
|
|
||||||
CC_SAFE_RETAIN(tileProperties);
|
|
||||||
CC_SAFE_RELEASE(_tileProperties);
|
|
||||||
_tileProperties = tileProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TMXMapInfo::parseXMLString(const char *xmlString)
|
bool TMXMapInfo::parseXMLString(const char *xmlString)
|
||||||
{
|
{
|
||||||
int len = strlen(xmlString);
|
int len = strlen(xmlString);
|
||||||
|
@ -768,7 +696,7 @@ void TMXMapInfo::textHandler(void *ctx, const char *ch, int len)
|
||||||
TMXMapInfo *pTMXMapInfo = this;
|
TMXMapInfo *pTMXMapInfo = this;
|
||||||
std::string pText((char*)ch,0,len);
|
std::string pText((char*)ch,0,len);
|
||||||
|
|
||||||
if (pTMXMapInfo->getStoringCharacters())
|
if (pTMXMapInfo->isStoringCharacters())
|
||||||
{
|
{
|
||||||
std::string currentString = pTMXMapInfo->getCurrentString();
|
std::string currentString = pTMXMapInfo->getCurrentString();
|
||||||
currentString += pText;
|
currentString += pText;
|
||||||
|
|
|
@ -151,35 +151,19 @@ This information is obtained from the TMX file.
|
||||||
class CC_DLL TMXMapInfo : public Object, public SAXDelegator
|
class CC_DLL TMXMapInfo : public Object, public SAXDelegator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// map orientation
|
/** creates a TMX Format with a tmx file */
|
||||||
CC_SYNTHESIZE(int, _orientation, Orientation);
|
static TMXMapInfo * create(const char *tmxFile);
|
||||||
/// map width & height
|
/** creates a TMX Format with an XML string and a TMX resource path */
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _mapSize, MapSize);
|
static TMXMapInfo * createWithXML(const char* tmxString, const char* resourcePath);
|
||||||
/// tiles width & height
|
|
||||||
CC_SYNTHESIZE_PASS_BY_REF(Size, _tileSize, TileSize);
|
/** creates a TMX Format with a tmx file */
|
||||||
/// Layers
|
CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithTMXFile(const char *tmxFile) { return TMXMapInfo::create(tmxFile); };
|
||||||
CC_PROPERTY(Array*, _layers, Layers);
|
/** creates a TMX Format with an XML string and a TMX resource path */
|
||||||
/// tilesets
|
CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath) { return TMXMapInfo::createWithXML(tmxString, resourcePath); };
|
||||||
CC_PROPERTY(Array*, _tilesets, Tilesets);
|
|
||||||
/// ObjectGroups
|
|
||||||
CC_PROPERTY(Array*, _objectGroups, ObjectGroups);
|
|
||||||
/// parent element
|
|
||||||
CC_SYNTHESIZE(int, _parentElement, ParentElement);
|
|
||||||
/// parent GID
|
|
||||||
CC_SYNTHESIZE(unsigned int, _parentGID, ParentGID);
|
|
||||||
/// layer attribs
|
|
||||||
CC_SYNTHESIZE(int, _layerAttribs, LayerAttribs);
|
|
||||||
/// is storing characters?
|
|
||||||
CC_SYNTHESIZE(bool, _storingCharacters, StoringCharacters);
|
|
||||||
/// properties
|
|
||||||
CC_PROPERTY(Dictionary*, _properties, Properties);
|
|
||||||
public:
|
|
||||||
TMXMapInfo();
|
TMXMapInfo();
|
||||||
virtual ~TMXMapInfo();
|
virtual ~TMXMapInfo();
|
||||||
/** creates a TMX Format with a tmx file */
|
|
||||||
static TMXMapInfo * formatWithTMXFile(const char *tmxFile);
|
|
||||||
/** creates a TMX Format with an XML string and a TMX resource path */
|
|
||||||
static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath);
|
|
||||||
/** initializes a TMX format with a tmx file */
|
/** initializes a TMX format with a tmx file */
|
||||||
bool initWithTMXFile(const char *tmxFile);
|
bool initWithTMXFile(const char *tmxFile);
|
||||||
/** initializes a TMX format with an XML string and a TMX resource path */
|
/** initializes a TMX format with an XML string and a TMX resource path */
|
||||||
|
@ -189,8 +173,73 @@ public:
|
||||||
/* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
|
/* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
|
||||||
bool parseXMLString(const char *xmlString);
|
bool parseXMLString(const char *xmlString);
|
||||||
|
|
||||||
Dictionary* getTileProperties();
|
Dictionary* getTileProperties() { return _tileProperties; };
|
||||||
void setTileProperties(Dictionary* tileProperties);
|
void setTileProperties(Dictionary* tileProperties) {
|
||||||
|
CC_SAFE_RETAIN(tileProperties);
|
||||||
|
CC_SAFE_RELEASE(_tileProperties);
|
||||||
|
_tileProperties = tileProperties;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// map orientation
|
||||||
|
inline int getOrientation() const { return _orientation; };
|
||||||
|
inline void setOrientation(int orientation) { _orientation = orientation; };
|
||||||
|
|
||||||
|
/// map width & height
|
||||||
|
inline const Size& getMapSize() const { return _mapSize; };
|
||||||
|
inline void setMapSize(const Size& mapSize) { _mapSize = mapSize; };
|
||||||
|
|
||||||
|
/// tiles width & height
|
||||||
|
inline const Size& getTileSize() const { return _tileSize; };
|
||||||
|
inline void setTileSize(const Size& tileSize) { _tileSize = tileSize; };
|
||||||
|
|
||||||
|
/// Layers
|
||||||
|
inline Array* getLayers() const { return _layers; };
|
||||||
|
inline void setLayers(Array* layers) {
|
||||||
|
CC_SAFE_RETAIN(layers);
|
||||||
|
CC_SAFE_RELEASE(_layers);
|
||||||
|
_layers = layers;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// tilesets
|
||||||
|
inline Array* getTilesets() const { return _tilesets; };
|
||||||
|
inline void setTilesets(Array* tilesets) {
|
||||||
|
CC_SAFE_RETAIN(tilesets);
|
||||||
|
CC_SAFE_RELEASE(_tilesets);
|
||||||
|
_tilesets = tilesets;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// ObjectGroups
|
||||||
|
inline Array* getObjectGroups() const { return _objectGroups; };
|
||||||
|
inline void setObjectGroups(Array* groups) {
|
||||||
|
CC_SAFE_RETAIN(groups);
|
||||||
|
CC_SAFE_RELEASE(_objectGroups);
|
||||||
|
_objectGroups = groups;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// parent element
|
||||||
|
inline int getParentElement() const { return _parentElement; };
|
||||||
|
inline void setParentElement(int element) { _parentElement = element; };
|
||||||
|
|
||||||
|
/// parent GID
|
||||||
|
inline unsigned int getParentGID() const { return _parentGID; };
|
||||||
|
inline void setParentGID(unsigned int gid) { _parentGID = gid; };
|
||||||
|
|
||||||
|
/// layer attribs
|
||||||
|
inline int getLayerAttribs() const { return _layerAttribs; };
|
||||||
|
inline void setLayerAttribs(int layerAttribs) { _layerAttribs = layerAttribs; };
|
||||||
|
|
||||||
|
/// is storing characters?
|
||||||
|
inline bool isStoringCharacters() const { return _storingCharacters; };
|
||||||
|
CC_DEPRECATED_ATTRIBUTE inline bool getStoringCharacters() const { return isStoringCharacters(); };
|
||||||
|
inline void setStoringCharacters(bool storingCharacters) { _storingCharacters = storingCharacters; };
|
||||||
|
|
||||||
|
/// properties
|
||||||
|
inline Dictionary* getProperties() const { return _properties; };
|
||||||
|
inline void setProperties(Dictionary* properties) {
|
||||||
|
CC_SAFE_RETAIN(properties);
|
||||||
|
CC_SAFE_RELEASE(_properties);
|
||||||
|
_properties = properties;
|
||||||
|
};
|
||||||
|
|
||||||
// implement pure virtual methods of SAXDelegator
|
// implement pure virtual methods of SAXDelegator
|
||||||
void startElement(void *ctx, const char *name, const char **atts);
|
void startElement(void *ctx, const char *name, const char **atts);
|
||||||
|
@ -204,6 +253,30 @@ public:
|
||||||
private:
|
private:
|
||||||
void internalInit(const char* tmxFileName, const char* resourcePath);
|
void internalInit(const char* tmxFileName, const char* resourcePath);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// map orientation
|
||||||
|
int _orientation;
|
||||||
|
/// map width & height
|
||||||
|
Size _mapSize;
|
||||||
|
/// tiles width & height
|
||||||
|
Size _tileSize;
|
||||||
|
/// Layers
|
||||||
|
Array* _layers;
|
||||||
|
/// tilesets
|
||||||
|
Array* _tilesets;
|
||||||
|
/// ObjectGroups
|
||||||
|
Array* _objectGroups;
|
||||||
|
/// parent element
|
||||||
|
int _parentElement;
|
||||||
|
/// parent GID
|
||||||
|
unsigned int _parentGID;
|
||||||
|
/// layer attribs
|
||||||
|
int _layerAttribs;
|
||||||
|
/// is storing characters?
|
||||||
|
bool _storingCharacters;
|
||||||
|
/// properties
|
||||||
|
Dictionary* _properties;
|
||||||
|
|
||||||
//! tmx filename
|
//! tmx filename
|
||||||
std::string _TMXFileName;
|
std::string _TMXFileName;
|
||||||
// tmx resource path
|
// tmx resource path
|
||||||
|
|
|
@ -264,14 +264,5 @@ void TileMapAtlas::updateAtlasValues()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileMapAtlas::setTGAInfo(struct sImageTGA* var)
|
|
||||||
{
|
|
||||||
_TGAInfo = var;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct sImageTGA * TileMapAtlas::getTGAInfo()
|
|
||||||
{
|
|
||||||
return _TGAInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -80,6 +80,9 @@ public:
|
||||||
void setTile(const Color3B& tile, const Point& position);
|
void setTile(const Color3B& tile, const Point& position);
|
||||||
/** dealloc the map from memory */
|
/** dealloc the map from memory */
|
||||||
void releaseMap();
|
void releaseMap();
|
||||||
|
|
||||||
|
inline struct sImageTGA* getTGAInfo() const { return _TGAInfo; };
|
||||||
|
inline void setTGAInfo(struct sImageTGA* TGAInfo) { _TGAInfo = TGAInfo; };
|
||||||
private:
|
private:
|
||||||
void loadTGAfile(const char *file);
|
void loadTGAfile(const char *file);
|
||||||
void calculateItemsToRender();
|
void calculateItemsToRender();
|
||||||
|
@ -91,10 +94,8 @@ protected:
|
||||||
Dictionary* _posToAtlasIndex;
|
Dictionary* _posToAtlasIndex;
|
||||||
//! numbers of tiles to render
|
//! numbers of tiles to render
|
||||||
int _itemsToRender;
|
int _itemsToRender;
|
||||||
|
|
||||||
private:
|
|
||||||
/** TileMap info */
|
/** TileMap info */
|
||||||
CC_PROPERTY(struct sImageTGA*, _TGAInfo, TGAInfo);
|
struct sImageTGA* _TGAInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of tilemap_parallax_nodes group
|
// end of tilemap_parallax_nodes group
|
||||||
|
|
|
@ -157,7 +157,7 @@ Color4B Texture2DMutable::pixelAt(const Point& pt)
|
||||||
c.b = 255;
|
c.b = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
//CCLog("color : %i, %i, %i, %i", c.r, c.g, c.b, c.a);
|
//log("color : %i, %i, %i, %i", c.r, c.g, c.b, c.a);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text
|
||||||
|
|
||||||
_display2ImageMap[spriteFrameName] = imagePath;
|
_display2ImageMap[spriteFrameName] = imagePath;
|
||||||
|
|
||||||
//CCLog("spriteFrameName : %s, imagePath : %s", spriteFrameName.c_str(), _imagePath);
|
//log("spriteFrameName : %s, imagePath : %s", spriteFrameName.c_str(), _imagePath);
|
||||||
|
|
||||||
SpriteFrame *spriteFrame = (SpriteFrame *)SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName.c_str());
|
SpriteFrame *spriteFrame = (SpriteFrame *)SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName.c_str());
|
||||||
if (spriteFrame)
|
if (spriteFrame)
|
||||||
|
|
|
@ -382,7 +382,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("CCBReader: Failed to create animation for property: %s", pPropName);
|
log("CCBReader: Failed to create animation for property: %s", pPropName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -482,7 +482,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("unsupported property name is %s", pPropName);
|
log("unsupported property name is %s", pPropName);
|
||||||
CCASSERT(false, "unsupported property now");
|
CCASSERT(false, "unsupported property now");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,7 +573,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, int
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLog("CCBReader: Unkown easing type %d", nEasingType);
|
log("CCBReader: Unkown easing type %d", nEasingType);
|
||||||
return pAction;
|
return pAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,7 +396,7 @@ bool CCBReader::readHeader()
|
||||||
/* Read version. */
|
/* Read version. */
|
||||||
int version = this->readInt(false);
|
int version = this->readInt(false);
|
||||||
if(version != kCCBVersion) {
|
if(version != kCCBVersion) {
|
||||||
CCLog("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion);
|
log("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
|
||||||
|
|
||||||
if (! ccNodeLoader)
|
if (! ccNodeLoader)
|
||||||
{
|
{
|
||||||
CCLog("no corresponding node loader for %s", className.c_str());
|
log("no corresponding node loader for %s", className.c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -437,7 +437,7 @@ Size NodeLoader::parsePropTypeSize(Node * pNode, Node * pParent, CCBReader * pCC
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
CCLog("Unknown CCB type.");
|
log("Unknown CCB type.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ NS_CC_EXT_BEGIN
|
||||||
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
|
||||||
#define PROPERTY_VISIBLE "visible"
|
#define PROPERTY_VISIBLE "visible"
|
||||||
|
|
||||||
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY); assert(false)
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) cocos2d::log("Unexpected property: '%s'!\n", PROPERTY); assert(false)
|
||||||
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
|
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) cocos2d::log("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
|
||||||
|
|
||||||
#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createNode(cocos2d::Node * pParent, cocos2d::extension::CCBReader * pCCBReader) { \
|
#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createNode(cocos2d::Node * pParent, cocos2d::extension::CCBReader * pCCBReader) { \
|
||||||
return T::create(); \
|
return T::create(); \
|
||||||
|
|
|
@ -160,7 +160,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo
|
||||||
// If there is no specified center region
|
// If there is no specified center region
|
||||||
if ( _capInsetsInternal.equals(Rect::ZERO) )
|
if ( _capInsetsInternal.equals(Rect::ZERO) )
|
||||||
{
|
{
|
||||||
// CCLog("... cap insets not specified : using default cap insets ...");
|
// log("... cap insets not specified : using default cap insets ...");
|
||||||
_capInsetsInternal = Rect(w/3, h/3, w/3, h/3);
|
_capInsetsInternal = Rect(w/3, h/3, w/3, h/3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo
|
||||||
Rect rightbottombounds = Rect(x, y, right_w, bottom_h);
|
Rect rightbottombounds = Rect(x, y, right_w, bottom_h);
|
||||||
|
|
||||||
if (!rotated) {
|
if (!rotated) {
|
||||||
// CCLog("!rotated");
|
// log("!rotated");
|
||||||
|
|
||||||
AffineTransform t = AffineTransformMakeIdentity();
|
AffineTransform t = AffineTransformMakeIdentity();
|
||||||
t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y);
|
t = AffineTransformTranslate(t, rect.origin.x, rect.origin.y);
|
||||||
|
@ -286,7 +286,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo
|
||||||
// set up transformation of coordinates
|
// set up transformation of coordinates
|
||||||
// to handle the case where the sprite is stored rotated
|
// to handle the case where the sprite is stored rotated
|
||||||
// in the spritesheet
|
// in the spritesheet
|
||||||
// CCLog("rotated");
|
// log("rotated");
|
||||||
|
|
||||||
AffineTransform t = AffineTransformMakeIdentity();
|
AffineTransform t = AffineTransformMakeIdentity();
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameNam
|
||||||
}
|
}
|
||||||
CC_SAFE_DELETE(pReturn);
|
CC_SAFE_DELETE(pReturn);
|
||||||
|
|
||||||
CCLog("Could not allocate Scale9Sprite()");
|
log("Could not allocate Scale9Sprite()");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,18 +494,18 @@ void TableView::scrollViewDidScroll(ScrollView* view)
|
||||||
CCARRAY_FOREACH(_cellsUsed, pObj)
|
CCARRAY_FOREACH(_cellsUsed, pObj)
|
||||||
{
|
{
|
||||||
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
|
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
|
||||||
CCLog("cells Used index %d, value = %d", i, pCell->getIdx());
|
log("cells Used index %d, value = %d", i, pCell->getIdx());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
CCLog("---------------------------------------");
|
log("---------------------------------------");
|
||||||
i = 0;
|
i = 0;
|
||||||
CCARRAY_FOREACH(_cellsFreed, pObj)
|
CCARRAY_FOREACH(_cellsFreed, pObj)
|
||||||
{
|
{
|
||||||
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
|
TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
|
||||||
CCLog("cells freed index %d, value = %d", i, pCell->getIdx());
|
log("cells freed index %d, value = %d", i, pCell->getIdx());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
CCLog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (_cellsUsed->count() > 0)
|
if (_cellsUsed->count() > 0)
|
||||||
|
|
|
@ -477,7 +477,7 @@ void HttpClient::send(HttpRequest* request)
|
||||||
// Poll and notify main thread if responses exists in queue
|
// Poll and notify main thread if responses exists in queue
|
||||||
void HttpClient::dispatchResponseCallbacks(float delta)
|
void HttpClient::dispatchResponseCallbacks(float delta)
|
||||||
{
|
{
|
||||||
// CCLog("CCHttpClient::dispatchResponseCallbacks is running");
|
// log("CCHttpClient::dispatchResponseCallbacks is running");
|
||||||
|
|
||||||
HttpResponse* response = NULL;
|
HttpResponse* response = NULL;
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ SIOClientImpl::~SIOClientImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::handshake() {
|
void SIOClientImpl::handshake() {
|
||||||
CCLog("SIOClientImpl::handshake() called");
|
log("SIOClientImpl::handshake() called");
|
||||||
|
|
||||||
std::stringstream pre;
|
std::stringstream pre;
|
||||||
pre << "http://" << _uri << "/socket.io/1";
|
pre << "http://" << _uri << "/socket.io/1";
|
||||||
|
@ -126,7 +126,7 @@ void SIOClientImpl::handshake() {
|
||||||
request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse));
|
request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse));
|
||||||
request->setTag("handshake");
|
request->setTag("handshake");
|
||||||
|
|
||||||
CCLog("SIOClientImpl::handshake() waiting");
|
log("SIOClientImpl::handshake() waiting");
|
||||||
|
|
||||||
HttpClient::getInstance()->send(request);
|
HttpClient::getInstance()->send(request);
|
||||||
|
|
||||||
|
@ -137,22 +137,22 @@ void SIOClientImpl::handshake() {
|
||||||
|
|
||||||
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) {
|
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) {
|
||||||
|
|
||||||
CCLog("SIOClientImpl::handshakeResponse() called");
|
log("SIOClientImpl::handshakeResponse() called");
|
||||||
|
|
||||||
if (0 != strlen(response->getHttpRequest()->getTag()))
|
if (0 != strlen(response->getHttpRequest()->getTag()))
|
||||||
{
|
{
|
||||||
CCLog("%s completed", response->getHttpRequest()->getTag());
|
log("%s completed", response->getHttpRequest()->getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
int statusCode = response->getResponseCode();
|
int statusCode = response->getResponseCode();
|
||||||
char statusString[64] = {};
|
char statusString[64] = {};
|
||||||
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
||||||
CCLog("response code: %d", statusCode);
|
log("response code: %d", statusCode);
|
||||||
|
|
||||||
if (!response->isSucceed())
|
if (!response->isSucceed())
|
||||||
{
|
{
|
||||||
CCLog("SIOClientImpl::handshake() failed");
|
log("SIOClientImpl::handshake() failed");
|
||||||
CCLog("error buffer: %s", response->getErrorBuffer());
|
log("error buffer: %s", response->getErrorBuffer());
|
||||||
|
|
||||||
DictElement* el = NULL;
|
DictElement* el = NULL;
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLog("SIOClientImpl::handshake() succeeded");
|
log("SIOClientImpl::handshake() succeeded");
|
||||||
|
|
||||||
std::vector<char> *buffer = response->getResponseData();
|
std::vector<char> *buffer = response->getResponseData();
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
|
@ -177,7 +177,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
|
||||||
s << (*buffer)[i];
|
s << (*buffer)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLog("SIOClientImpl::handshake() dump data: %s", s.str().c_str());
|
log("SIOClientImpl::handshake() dump data: %s", s.str().c_str());
|
||||||
|
|
||||||
std::string res = s.str();
|
std::string res = s.str();
|
||||||
std::string sid;
|
std::string sid;
|
||||||
|
@ -212,7 +212,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
|
||||||
|
|
||||||
void SIOClientImpl::openSocket() {
|
void SIOClientImpl::openSocket() {
|
||||||
|
|
||||||
CCLog("SIOClientImpl::openSocket() called");
|
log("SIOClientImpl::openSocket() called");
|
||||||
|
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << _uri << "/socket.io/1/websocket/" << _sid;
|
s << _uri << "/socket.io/1/websocket/" << _sid;
|
||||||
|
@ -228,7 +228,7 @@ void SIOClientImpl::openSocket() {
|
||||||
|
|
||||||
bool SIOClientImpl::init() {
|
bool SIOClientImpl::init() {
|
||||||
|
|
||||||
CCLog("SIOClientImpl::init() successful");
|
log("SIOClientImpl::init() successful");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ void SIOClientImpl::disconnect() {
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
|
||||||
CCLog("Disconnect sent");
|
log("Disconnect sent");
|
||||||
|
|
||||||
_ws->close();
|
_ws->close();
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) {
|
||||||
|
|
||||||
if(_clients->count() == 0 || endpoint == "/") {
|
if(_clients->count() == 0 || endpoint == "/") {
|
||||||
|
|
||||||
CCLog("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect");
|
log("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect");
|
||||||
|
|
||||||
if(_connected) this->disconnect();
|
if(_connected) this->disconnect();
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ void SIOClientImpl::heartbeat(float dt) {
|
||||||
|
|
||||||
_ws->send(s);
|
_ws->send(s);
|
||||||
|
|
||||||
CCLog("Heartbeat sent");
|
log("Heartbeat sent");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ void SIOClientImpl::send(std::string endpoint, std::string s) {
|
||||||
|
|
||||||
std::string msg = pre.str();
|
std::string msg = pre.str();
|
||||||
|
|
||||||
CCLog("sending message: %s", msg.c_str());
|
log("sending message: %s", msg.c_str());
|
||||||
|
|
||||||
_ws->send(msg);
|
_ws->send(msg);
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::strin
|
||||||
|
|
||||||
std::string msg = pre.str();
|
std::string msg = pre.str();
|
||||||
|
|
||||||
CCLog("emitting event with data: %s", msg.c_str());
|
log("emitting event with data: %s", msg.c_str());
|
||||||
|
|
||||||
_ws->send(msg);
|
_ws->send(msg);
|
||||||
|
|
||||||
|
@ -379,13 +379,13 @@ void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) {
|
||||||
|
|
||||||
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
|
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
|
||||||
|
|
||||||
CCLog("SIOClientImpl::onOpen socket connected!");
|
log("SIOClientImpl::onOpen socket connected!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) {
|
void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) {
|
||||||
|
|
||||||
CCLog("SIOClientImpl::onMessage received: %s", data.bytes);
|
log("SIOClientImpl::onMessage received: %s", data.bytes);
|
||||||
|
|
||||||
int control = atoi(&data.bytes[0]);
|
int control = atoi(&data.bytes[0]);
|
||||||
|
|
||||||
|
@ -422,31 +422,31 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
|
||||||
s_data = payload;
|
s_data = payload;
|
||||||
SIOClient *c = NULL;
|
SIOClient *c = NULL;
|
||||||
c = getClient(endpoint);
|
c = getClient(endpoint);
|
||||||
if(c == NULL) CCLog("SIOClientImpl::onMessage client lookup returned NULL");
|
if(c == NULL) log("SIOClientImpl::onMessage client lookup returned NULL");
|
||||||
|
|
||||||
switch(control) {
|
switch(control) {
|
||||||
case 0:
|
case 0:
|
||||||
CCLog("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str());
|
log("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str());
|
||||||
if(c) c->receivedDisconnect();
|
if(c) c->receivedDisconnect();
|
||||||
disconnectFromEndpoint(endpoint);
|
disconnectFromEndpoint(endpoint);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
CCLog("Connected to endpoint: %s \n",endpoint.c_str());
|
log("Connected to endpoint: %s \n",endpoint.c_str());
|
||||||
if(c) c->onConnect();
|
if(c) c->onConnect();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
CCLog("Heartbeat received\n");
|
log("Heartbeat received\n");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
CCLog("Message received: %s \n", s_data.c_str());
|
log("Message received: %s \n", s_data.c_str());
|
||||||
if(c) c->getDelegate()->onMessage(c, s_data);
|
if(c) c->getDelegate()->onMessage(c, s_data);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
CCLog("JSON Message Received: %s \n", s_data.c_str());
|
log("JSON Message Received: %s \n", s_data.c_str());
|
||||||
if(c) c->getDelegate()->onMessage(c, s_data);
|
if(c) c->getDelegate()->onMessage(c, s_data);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
CCLog("Event Received with data: %s \n", s_data.c_str());
|
log("Event Received with data: %s \n", s_data.c_str());
|
||||||
|
|
||||||
if(c) {
|
if(c) {
|
||||||
eventname = "";
|
eventname = "";
|
||||||
|
@ -463,14 +463,14 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
CCLog("Message Ack\n");
|
log("Message Ack\n");
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
CCLog("Error\n");
|
log("Error\n");
|
||||||
if(c) c->getDelegate()->onError(c, s_data);
|
if(c) c->getDelegate()->onError(c, s_data);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
CCLog("Noop\n");
|
log("Noop\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ void SIOClient::on(const std::string& eventName, SIOEvent e) {
|
||||||
|
|
||||||
void SIOClient::fireEvent(const std::string& eventName, const std::string& data) {
|
void SIOClient::fireEvent(const std::string& eventName, const std::string& data) {
|
||||||
|
|
||||||
CCLog("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str());
|
log("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str());
|
||||||
|
|
||||||
if(_eventRegistry[eventName]) {
|
if(_eventRegistry[eventName]) {
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCLog("SIOClient::fireEvent no event with name %s found", eventName.c_str());
|
log("SIOClient::fireEvent no event with name %s found", eventName.c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,31 +216,31 @@ void TestAds::caseChanged(Object* pSender)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CCLog("case selected change to : %s", strLog.c_str());
|
log("case selected change to : %s", strLog.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAds::typeChanged(Object* pSender)
|
void TestAds::typeChanged(Object* pSender)
|
||||||
{
|
{
|
||||||
int selectIndex = _typeItem->getSelectedIndex();
|
int selectIndex = _typeItem->getSelectedIndex();
|
||||||
_type = (ProtocolAds::AdsType) selectIndex;
|
_type = (ProtocolAds::AdsType) selectIndex;
|
||||||
CCLog("type selected change to : %d", _type);
|
log("type selected change to : %d", _type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAds::posChanged(Object* pSender)
|
void TestAds::posChanged(Object* pSender)
|
||||||
{
|
{
|
||||||
int selectIndex = _posItem->getSelectedIndex();
|
int selectIndex = _posItem->getSelectedIndex();
|
||||||
_pos = (ProtocolAds::AdsPos) selectIndex;
|
_pos = (ProtocolAds::AdsPos) selectIndex;
|
||||||
CCLog("pos selected change to : %d", _pos);
|
log("pos selected change to : %d", _pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAdsListener::onAdsResult(AdsResultCode code, const char* msg)
|
void MyAdsListener::onAdsResult(AdsResultCode code, const char* msg)
|
||||||
{
|
{
|
||||||
CCLog("OnAdsResult, code : %d, msg : %s", code, msg);
|
log("OnAdsResult, code : %d, msg : %s", code, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAdsListener::onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points)
|
void MyAdsListener::onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points)
|
||||||
{
|
{
|
||||||
CCLog("Player get points : %d", points);
|
log("Player get points : %d", points);
|
||||||
|
|
||||||
// @warning should add code to give game-money to player here
|
// @warning should add code to give game-money to player here
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ void TestAnalytics::eventMenuCallback(Object* pSender)
|
||||||
case TAG_LOG_ONLINE_CONFIG:
|
case TAG_LOG_ONLINE_CONFIG:
|
||||||
{
|
{
|
||||||
PluginParam param("abc");
|
PluginParam param("abc");
|
||||||
CCLog("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str());
|
log("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", ¶m, NULL).c_str());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TAG_LOG_EVENT_ID_DURATION:
|
case TAG_LOG_EVENT_ID_DURATION:
|
||||||
|
@ -259,7 +259,7 @@ void TestAnalytics::loadPlugins()
|
||||||
_pluginAnalytics->setSessionContinueMillis(10000);
|
_pluginAnalytics->setSessionContinueMillis(10000);
|
||||||
|
|
||||||
const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str();
|
const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str();
|
||||||
CCLog("SDK version : %s", sdkVer);
|
log("SDK version : %s", sdkVer);
|
||||||
|
|
||||||
_pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL);
|
_pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL);
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,6 @@ void MyIAPOnlineResult::onPayResult(PayResultCode ret, const char* msg, TProduct
|
||||||
MessageBox(goodInfo , msg);
|
MessageBox(goodInfo , msg);
|
||||||
|
|
||||||
if (ret == kPaySuccess) {
|
if (ret == kPaySuccess) {
|
||||||
CCLog("Pay success locally, should check the real result by game server!");
|
log("Pay success locally, should check the real result by game server!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,8 +215,8 @@ void MyUserActionResult::onActionResult(ProtocolUser* pPlugin, UserActionResultC
|
||||||
|
|
||||||
// get session ID
|
// get session ID
|
||||||
std::string sessionID = pPlugin->getSessionID();
|
std::string sessionID = pPlugin->getSessionID();
|
||||||
CCLog("User Session ID of plugin %s is : %s", pPlugin->getPluginName(), sessionID.c_str());
|
log("User Session ID of plugin %s is : %s", pPlugin->getPluginName(), sessionID.c_str());
|
||||||
|
|
||||||
std::string strStatus = pPlugin->isLogined() ? "online" : "offline";
|
std::string strStatus = pPlugin->isLogined() ? "online" : "offline";
|
||||||
CCLog("User status of plugin %s is : %s", pPlugin->getPluginName(), strStatus.c_str());
|
log("User status of plugin %s is : %s", pPlugin->getPluginName(), strStatus.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ AppDelegate::~AppDelegate()
|
||||||
bool AppDelegate::applicationDidFinishLaunching()
|
bool AppDelegate::applicationDidFinishLaunching()
|
||||||
{
|
{
|
||||||
// initialize director
|
// initialize director
|
||||||
Director *pDirector = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
pDirector->setOpenGLView(EGLView::getInstance());
|
director->setOpenGLView(EGLView::getInstance());
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
//pDirector->setDisplayStats(true);
|
//director->setDisplayStats(true);
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
// set FPS. the default value is 1.0/60 if you don't call this
|
||||||
pDirector->setAnimationInterval(1.0 / 60);
|
director->setAnimationInterval(1.0 / 60);
|
||||||
|
|
||||||
ScriptingCore* sc = ScriptingCore::getInstance();
|
ScriptingCore* sc = ScriptingCore::getInstance();
|
||||||
sc->addRegisterCallback(register_all_cocos2dx);
|
sc->addRegisterCallback(register_all_cocos2dx);
|
||||||
|
@ -52,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
scene->addChild(updateLayer);
|
scene->addChild(updateLayer);
|
||||||
updateLayer->release();
|
updateLayer->release();
|
||||||
|
|
||||||
pDirector->runWithScene(scene);
|
director->runWithScene(scene);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,17 @@ AppDelegate::~AppDelegate()
|
||||||
|
|
||||||
bool AppDelegate::applicationDidFinishLaunching() {
|
bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
// initialize director
|
// initialize director
|
||||||
Director* pDirector = Director::getInstance();
|
Director* director = Director::getInstance();
|
||||||
EGLView* pEGLView = EGLView::getInstance();
|
EGLView* glView = EGLView::getInstance();
|
||||||
|
|
||||||
pDirector->setOpenGLView(pEGLView);
|
director->setOpenGLView(glView);
|
||||||
|
|
||||||
Size size = pDirector->getWinSize();
|
Size size = director->getWinSize();
|
||||||
|
|
||||||
// Set the design resolution
|
// Set the design resolution
|
||||||
pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
|
glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);
|
||||||
|
|
||||||
Size frameSize = pEGLView->getFrameSize();
|
Size frameSize = glView->getFrameSize();
|
||||||
|
|
||||||
vector<string> searchPath;
|
vector<string> searchPath;
|
||||||
|
|
||||||
|
@ -43,37 +43,37 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
{
|
{
|
||||||
searchPath.push_back(largeResource.directory);
|
searchPath.push_back(largeResource.directory);
|
||||||
|
|
||||||
pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
|
director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
|
||||||
}
|
}
|
||||||
// if the frame's height is larger than the height of small resource size, select medium resource.
|
// if the frame's height is larger than the height of small resource size, select medium resource.
|
||||||
else if (frameSize.height > smallResource.size.height)
|
else if (frameSize.height > smallResource.size.height)
|
||||||
{
|
{
|
||||||
searchPath.push_back(mediumResource.directory);
|
searchPath.push_back(mediumResource.directory);
|
||||||
|
|
||||||
pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
|
director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
|
||||||
}
|
}
|
||||||
// if the frame's height is smaller than the height of medium resource size, select small resource.
|
// if the frame's height is smaller than the height of medium resource size, select small resource.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
searchPath.push_back(smallResource.directory);
|
searchPath.push_back(smallResource.directory);
|
||||||
|
|
||||||
pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
|
director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set searching path
|
// set searching path
|
||||||
FileUtils::getInstance()->setSearchPaths(searchPath);
|
FileUtils::getInstance()->setSearchPaths(searchPath);
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayStats(true);
|
director->setDisplayStats(true);
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
// set FPS. the default value is 1.0/60 if you don't call this
|
||||||
pDirector->setAnimationInterval(1.0 / 60);
|
director->setAnimationInterval(1.0 / 60);
|
||||||
|
|
||||||
// create a scene. it's an autorelease object
|
// create a scene. it's an autorelease object
|
||||||
Scene *pScene = HelloWorld::scene();
|
Scene *scene = HelloWorld::scene();
|
||||||
|
|
||||||
// run
|
// run
|
||||||
pDirector->runWithScene(pScene);
|
director->runWithScene(scene);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,18 +36,18 @@ bool HelloWorld::init()
|
||||||
// you may modify it.
|
// you may modify it.
|
||||||
|
|
||||||
// add a "close" icon to exit the progress. it's an autorelease object
|
// add a "close" icon to exit the progress. it's an autorelease object
|
||||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
MenuItemImage *closeItem = MenuItemImage::create(
|
||||||
"CloseNormal.png",
|
"CloseNormal.png",
|
||||||
"CloseSelected.png",
|
"CloseSelected.png",
|
||||||
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
|
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
|
||||||
|
|
||||||
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
|
closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
|
||||||
origin.y + pCloseItem->getContentSize().height/2));
|
origin.y + closeItem->getContentSize().height/2));
|
||||||
|
|
||||||
// create menu, it's an autorelease object
|
// create menu, it's an autorelease object
|
||||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
Menu* menu = Menu::create(closeItem, NULL);
|
||||||
pMenu->setPosition(Point::ZERO);
|
menu->setPosition(Point::ZERO);
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(menu, 1);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// 3. add your codes below...
|
// 3. add your codes below...
|
||||||
|
@ -55,23 +55,23 @@ bool HelloWorld::init()
|
||||||
// add a label shows "Hello World"
|
// add a label shows "Hello World"
|
||||||
// create and initialize a label
|
// create and initialize a label
|
||||||
|
|
||||||
LabelTTF* pLabel = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE);
|
LabelTTF* label = LabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE);
|
||||||
|
|
||||||
// position the label on the center of the screen
|
// position the label on the center of the screen
|
||||||
pLabel->setPosition(Point(origin.x + visibleSize.width/2,
|
label->setPosition(Point(origin.x + visibleSize.width/2,
|
||||||
origin.y + visibleSize.height - pLabel->getContentSize().height));
|
origin.y + visibleSize.height - label->getContentSize().height));
|
||||||
|
|
||||||
// add the label as a child to this layer
|
// add the label as a child to this layer
|
||||||
this->addChild(pLabel, 1);
|
this->addChild(label, 1);
|
||||||
|
|
||||||
// add "HelloWorld" splash screen"
|
// add "HelloWorld" splash screen"
|
||||||
Sprite* pSprite = Sprite::create("HelloWorld.png");
|
Sprite* sprite = Sprite::create("HelloWorld.png");
|
||||||
|
|
||||||
// position the sprite on the center of the screen
|
// position the sprite on the center of the screen
|
||||||
pSprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
|
sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
|
||||||
|
|
||||||
// add the sprite as a child to this layer
|
// add the sprite as a child to this layer
|
||||||
this->addChild(pSprite, 0);
|
this->addChild(sprite, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,9 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(shell uname -s),Darwin)
|
ifeq ($(shell uname -s),Darwin)
|
||||||
ARIEL_TTF := /Library/Fonts/Arial.ttf
|
ARIAL_TTF := /Library/Fonts/Arial.ttf
|
||||||
else
|
else
|
||||||
ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
|
ARIAL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(TARGET).data:
|
$(TARGET).data:
|
||||||
|
@ -39,15 +39,16 @@ $(TARGET).data:
|
||||||
(cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP))
|
(cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP))
|
||||||
(cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts)
|
(cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts)
|
||||||
# NOTE: we copy the system arial.ttf so that there is always a fallback.
|
# NOTE: we copy the system arial.ttf so that there is always a fallback.
|
||||||
cp $(ARIEL_TTF) $(RESTMP)/fonts/arial.ttf
|
cp $(ARIAL_TTF) $(RESTMP)/fonts/arial.ttf
|
||||||
(cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(RESOURCES)) --preload fonts --pre-run > $(EXECUTABLE).data.js)
|
(cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(RESOURCES)) --preload fonts --pre-run > $(EXECUTABLE).data.js)
|
||||||
mv $(RESTMP)/$(EXECUTABLE).data $@
|
mv $(RESTMP)/$(EXECUTABLE).data $@
|
||||||
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
|
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
|
||||||
rm -rf $(RESTMP)
|
rm -rf $(RESTMP)
|
||||||
|
|
||||||
$(BIN_DIR)/index.html: index.html
|
$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
cp index.html $(@D)
|
@cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR)
|
||||||
|
@sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
|
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en-us">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Emscripten-Generated Code</title>
|
|
||||||
<style>
|
|
||||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
|
||||||
textarea.emscripten { font-family: monospace; width: 80%; }
|
|
||||||
div.emscripten { text-align: center; }
|
|
||||||
div.emscripten_border { border: 1px solid black; }
|
|
||||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
|
||||||
canvas.emscripten { border: 0px none; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<hr/>
|
|
||||||
<div class="emscripten" id="status">Downloading...</div>
|
|
||||||
<div class="emscripten">
|
|
||||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
|
||||||
</div>
|
|
||||||
<div class="emscripten_border">
|
|
||||||
<canvas width="1024" height="768" class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="emscripten">
|
|
||||||
<input type="checkbox" id="resize">Resize canvas
|
|
||||||
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
|
|
||||||
|
|
||||||
<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked,
|
|
||||||
document.getElementById('resize').checked)">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
<textarea class="emscripten" id="output" rows="8"></textarea>
|
|
||||||
<hr>
|
|
||||||
<script type='text/javascript'>
|
|
||||||
// connect to canvas
|
|
||||||
var Module = {
|
|
||||||
preRun: [],
|
|
||||||
postRun: [],
|
|
||||||
print: (function() {
|
|
||||||
var element = document.getElementById('output');
|
|
||||||
element.value = ''; // clear browser cache
|
|
||||||
return function(text) {
|
|
||||||
text = Array.prototype.slice.call(arguments).join(' ');
|
|
||||||
// These replacements are necessary if you render to raw HTML
|
|
||||||
//text = text.replace(/&/g, "&");
|
|
||||||
//text = text.replace(/</g, "<");
|
|
||||||
//text = text.replace(/>/g, ">");
|
|
||||||
//text = text.replace('\n', '<br>', 'g');
|
|
||||||
element.value += text + "\n";
|
|
||||||
element.scrollTop = 99999; // focus on bottom
|
|
||||||
};
|
|
||||||
})(),
|
|
||||||
printErr: function(text) {
|
|
||||||
text = Array.prototype.slice.call(arguments).join(' ');
|
|
||||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
|
||||||
dump(text + '\n'); // fast, straight to the real console
|
|
||||||
} else {
|
|
||||||
console.log(text);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canvas: document.getElementById('canvas'),
|
|
||||||
setStatus: function(text) {
|
|
||||||
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
|
|
||||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
|
||||||
var statusElement = document.getElementById('status');
|
|
||||||
var progressElement = document.getElementById('progress');
|
|
||||||
if (m) {
|
|
||||||
text = m[1];
|
|
||||||
progressElement.value = parseInt(m[2])*100;
|
|
||||||
progressElement.max = parseInt(m[4])*100;
|
|
||||||
progressElement.hidden = false;
|
|
||||||
} else {
|
|
||||||
progressElement.value = null;
|
|
||||||
progressElement.max = null;
|
|
||||||
progressElement.hidden = true;
|
|
||||||
}
|
|
||||||
statusElement.innerHTML = text;
|
|
||||||
},
|
|
||||||
totalDependencies: 0,
|
|
||||||
monitorRunDependencies: function(left) {
|
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
|
||||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Module.setStatus('Downloading...');
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="HelloCpp.data.js"></script>
|
|
||||||
<script type="text/javascript" src="HelloCpp.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -14,9 +14,9 @@ AppDelegate::~AppDelegate()
|
||||||
|
|
||||||
bool AppDelegate::applicationDidFinishLaunching() {
|
bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
// initialize director
|
// initialize director
|
||||||
Director *pDirector = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
|
|
||||||
pDirector->setOpenGLView(EGLView::getInstance());
|
director->setOpenGLView(EGLView::getInstance());
|
||||||
|
|
||||||
Size screenSize = EGLView::getInstance()->getFrameSize();
|
Size screenSize = EGLView::getInstance()->getFrameSize();
|
||||||
Size designSize = Size(480, 320);
|
Size designSize = Size(480, 320);
|
||||||
|
@ -26,12 +26,12 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
{
|
{
|
||||||
searchPaths.push_back("hd");
|
searchPaths.push_back("hd");
|
||||||
searchPaths.push_back("sd");
|
searchPaths.push_back("sd");
|
||||||
pDirector->setContentScaleFactor(640.0f/designSize.height);
|
director->setContentScaleFactor(640.0f/designSize.height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
searchPaths.push_back("sd");
|
searchPaths.push_back("sd");
|
||||||
pDirector->setContentScaleFactor(320.0f/designSize.height);
|
director->setContentScaleFactor(320.0f/designSize.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
||||||
|
@ -39,16 +39,16 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayStats(true);
|
director->setDisplayStats(true);
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
// set FPS. the default value is 1.0/60 if you don't call this
|
||||||
pDirector->setAnimationInterval(1.0 / 60);
|
director->setAnimationInterval(1.0 / 60);
|
||||||
|
|
||||||
// create a scene. it's an autorelease object
|
// create a scene. it's an autorelease object
|
||||||
Scene *pScene = HelloWorld::scene();
|
Scene *scene = HelloWorld::scene();
|
||||||
|
|
||||||
// run
|
// run
|
||||||
pDirector->runWithScene(pScene);
|
director->runWithScene(scene);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,26 +69,26 @@ bool HelloWorld::init()
|
||||||
// 1. Add a menu item with "X" image, which is clicked to quit the program.
|
// 1. Add a menu item with "X" image, which is clicked to quit the program.
|
||||||
|
|
||||||
// Create a "close" menu item with close icon, it's an auto release object.
|
// Create a "close" menu item with close icon, it's an auto release object.
|
||||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
MenuItemImage *closeItem = MenuItemImage::create(
|
||||||
"CloseNormal.png",
|
"CloseNormal.png",
|
||||||
"CloseSelected.png",
|
"CloseSelected.png",
|
||||||
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
|
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
|
||||||
CC_BREAK_IF(! pCloseItem);
|
CC_BREAK_IF(! closeItem);
|
||||||
|
|
||||||
// Place the menu item bottom-right conner.
|
// Place the menu item bottom-right conner.
|
||||||
Size visibleSize = Director::getInstance()->getVisibleSize();
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
||||||
Point origin = Director::getInstance()->getVisibleOrigin();
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
|
|
||||||
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2,
|
closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2,
|
||||||
origin.y + pCloseItem->getContentSize().height/2));
|
origin.y + closeItem->getContentSize().height/2));
|
||||||
|
|
||||||
// Create a menu with the "close" menu item, it's an auto release object.
|
// Create a menu with the "close" menu item, it's an auto release object.
|
||||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
Menu* menu = Menu::create(closeItem, NULL);
|
||||||
pMenu->setPosition(Point::ZERO);
|
menu->setPosition(Point::ZERO);
|
||||||
CC_BREAK_IF(! pMenu);
|
CC_BREAK_IF(! menu);
|
||||||
|
|
||||||
// Add the menu to HelloWorld layer as a child layer.
|
// Add the menu to HelloWorld layer as a child layer.
|
||||||
this->addChild(pMenu, 1);
|
this->addChild(menu, 1);
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// 2. add your codes below...
|
// 2. add your codes below...
|
||||||
|
@ -193,7 +193,7 @@ void HelloWorld::ccTouchesEnded(Set* touches, Event* event)
|
||||||
Touch* touch = (Touch*)( touches->anyObject() );
|
Touch* touch = (Touch*)( touches->anyObject() );
|
||||||
Point location = touch->getLocation();
|
Point location = touch->getLocation();
|
||||||
|
|
||||||
CCLog("++++++++after x:%f, y:%f", location.x, location.y);
|
log("++++++++after x:%f, y:%f", location.x, location.y);
|
||||||
|
|
||||||
// Set up initial location of projectile
|
// Set up initial location of projectile
|
||||||
Size winSize = Director::getInstance()->getVisibleSize();
|
Size winSize = Director::getInstance()->getVisibleSize();
|
||||||
|
|
|
@ -57,9 +57,10 @@ $(TARGET).data:
|
||||||
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
|
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
|
||||||
rm -rf $(RESTMP)
|
rm -rf $(RESTMP)
|
||||||
|
|
||||||
$(BIN_DIR)/index.html: index.html
|
$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
cp index.html $(@D)
|
@cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR)
|
||||||
|
@sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
|
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html lang="en-us">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>SimpleGame</title>
|
|
||||||
<style>
|
|
||||||
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
|
||||||
textarea.emscripten { font-family: monospace; width: 80%; }
|
|
||||||
div.emscripten { text-align: center; }
|
|
||||||
div.emscripten_border { border: 1px solid black; }
|
|
||||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
|
||||||
canvas.emscripten { border: 0px none; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<hr/>
|
|
||||||
<div class="emscripten" id="status">Downloading...</div>
|
|
||||||
<div class="emscripten">
|
|
||||||
<progress value="0" max="100" id="progress" hidden=1></progress>
|
|
||||||
</div>
|
|
||||||
<div class="emscripten_border">
|
|
||||||
<canvas width="1024" height="768" class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="emscripten">
|
|
||||||
<input type="checkbox" id="resize">Resize canvas
|
|
||||||
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
|
|
||||||
|
|
||||||
<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked,
|
|
||||||
document.getElementById('resize').checked)">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
|
||||||
<textarea class="emscripten" id="output" rows="8"></textarea>
|
|
||||||
<hr>
|
|
||||||
<script type='text/javascript'>
|
|
||||||
// connect to canvas
|
|
||||||
var Module = {
|
|
||||||
preRun: [],
|
|
||||||
postRun: [],
|
|
||||||
print: (function() {
|
|
||||||
var element = document.getElementById('output');
|
|
||||||
element.value = ''; // clear browser cache
|
|
||||||
return function(text) {
|
|
||||||
text = Array.prototype.slice.call(arguments).join(' ');
|
|
||||||
// These replacements are necessary if you render to raw HTML
|
|
||||||
//text = text.replace(/&/g, "&");
|
|
||||||
//text = text.replace(/</g, "<");
|
|
||||||
//text = text.replace(/>/g, ">");
|
|
||||||
//text = text.replace('\n', '<br>', 'g');
|
|
||||||
element.value += text + "\n";
|
|
||||||
element.scrollTop = 99999; // focus on bottom
|
|
||||||
};
|
|
||||||
})(),
|
|
||||||
printErr: function(text) {
|
|
||||||
text = Array.prototype.slice.call(arguments).join(' ');
|
|
||||||
if (0) { // XXX disabled for safety typeof dump == 'function') {
|
|
||||||
dump(text + '\n'); // fast, straight to the real console
|
|
||||||
} else {
|
|
||||||
console.log(text);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
canvas: document.getElementById('canvas'),
|
|
||||||
setStatus: function(text) {
|
|
||||||
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
|
|
||||||
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
|
|
||||||
var statusElement = document.getElementById('status');
|
|
||||||
var progressElement = document.getElementById('progress');
|
|
||||||
if (m) {
|
|
||||||
text = m[1];
|
|
||||||
progressElement.value = parseInt(m[2])*100;
|
|
||||||
progressElement.max = parseInt(m[4])*100;
|
|
||||||
progressElement.hidden = false;
|
|
||||||
} else {
|
|
||||||
progressElement.value = null;
|
|
||||||
progressElement.max = null;
|
|
||||||
progressElement.hidden = true;
|
|
||||||
}
|
|
||||||
statusElement.innerHTML = text;
|
|
||||||
},
|
|
||||||
totalDependencies: 0,
|
|
||||||
monitorRunDependencies: function(left) {
|
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
|
||||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Module.setStatus('Downloading...');
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="SimpleGame.data.js"></script>
|
|
||||||
<script type="text/javascript" src="SimpleGame.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -85,9 +85,9 @@ void AccelerometerTest::didAccelerate(Acceleration* pAccelerationValue)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
void AccelerometerTestScene::runThisTest()
|
void AccelerometerTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
Layer* pLayer = new AccelerometerTest();
|
Layer* layer = new AccelerometerTest();
|
||||||
addChild(pLayer);
|
addChild(layer);
|
||||||
pLayer->release();
|
layer->release();
|
||||||
|
|
||||||
Director::getInstance()->replaceScene(this);
|
Director::getInstance()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@ Layer* nextActionManagerAction()
|
||||||
sceneIdx++;
|
sceneIdx++;
|
||||||
sceneIdx = sceneIdx % MAX_LAYER;
|
sceneIdx = sceneIdx % MAX_LAYER;
|
||||||
|
|
||||||
Layer* pLayer = createActionManagerLayer(sceneIdx);
|
Layer* layer = createActionManagerLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* backActionManagerAction()
|
Layer* backActionManagerAction()
|
||||||
|
@ -49,18 +49,18 @@ Layer* backActionManagerAction()
|
||||||
if( sceneIdx < 0 )
|
if( sceneIdx < 0 )
|
||||||
sceneIdx += total;
|
sceneIdx += total;
|
||||||
|
|
||||||
Layer* pLayer = createActionManagerLayer(sceneIdx);
|
Layer* layer = createActionManagerLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* restartActionManagerAction()
|
Layer* restartActionManagerAction()
|
||||||
{
|
{
|
||||||
Layer* pLayer = createActionManagerLayer(sceneIdx);
|
Layer* layer = createActionManagerLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
@ -117,7 +117,7 @@ void CrashTest::onEnter()
|
||||||
{
|
{
|
||||||
ActionManagerTest::onEnter();
|
ActionManagerTest::onEnter();
|
||||||
|
|
||||||
Sprite* child = Sprite::create(s_pPathGrossini);
|
Sprite* child = Sprite::create(s_pathGrossini);
|
||||||
child->setPosition( VisibleRect::center() );
|
child->setPosition( VisibleRect::center() );
|
||||||
addChild(child, 1);
|
addChild(child, 1);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void LogicTest::onEnter()
|
||||||
{
|
{
|
||||||
ActionManagerTest::onEnter();
|
ActionManagerTest::onEnter();
|
||||||
|
|
||||||
Sprite* grossini = Sprite::create(s_pPathGrossini);
|
Sprite* grossini = Sprite::create(s_pathGrossini);
|
||||||
addChild(grossini, 0, 2);
|
addChild(grossini, 0, 2);
|
||||||
grossini->setPosition(VisibleRect::center());
|
grossini->setPosition(VisibleRect::center());
|
||||||
|
|
||||||
|
@ -203,14 +203,14 @@ void PauseTest::onEnter()
|
||||||
//
|
//
|
||||||
// Also, this test MUST be done, after [super onEnter]
|
// Also, this test MUST be done, after [super onEnter]
|
||||||
//
|
//
|
||||||
Sprite* grossini = Sprite::create(s_pPathGrossini);
|
Sprite* grossini = Sprite::create(s_pathGrossini);
|
||||||
addChild(grossini, 0, kTagGrossini);
|
addChild(grossini, 0, kTagGrossini);
|
||||||
grossini->setPosition(VisibleRect::center() );
|
grossini->setPosition(VisibleRect::center() );
|
||||||
|
|
||||||
Action* action = MoveBy::create(1, Point(150,0));
|
Action* action = MoveBy::create(1, Point(150,0));
|
||||||
|
|
||||||
Director* pDirector = Director::getInstance();
|
Director* director = Director::getInstance();
|
||||||
pDirector->getActionManager()->addAction(action, grossini, true);
|
director->getActionManager()->addAction(action, grossini, true);
|
||||||
|
|
||||||
schedule( schedule_selector(PauseTest::unpause), 3);
|
schedule( schedule_selector(PauseTest::unpause), 3);
|
||||||
}
|
}
|
||||||
|
@ -219,8 +219,8 @@ void PauseTest::unpause(float dt)
|
||||||
{
|
{
|
||||||
unschedule( schedule_selector(PauseTest::unpause) );
|
unschedule( schedule_selector(PauseTest::unpause) );
|
||||||
Node* node = getChildByTag( kTagGrossini );
|
Node* node = getChildByTag( kTagGrossini );
|
||||||
Director* pDirector = Director::getInstance();
|
Director* director = Director::getInstance();
|
||||||
pDirector->getActionManager()->resumeTarget(node);
|
director->getActionManager()->resumeTarget(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PauseTest::title()
|
std::string PauseTest::title()
|
||||||
|
@ -246,7 +246,7 @@ void RemoveTest::onEnter()
|
||||||
ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL);
|
ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL);
|
||||||
pSequence->setTag(kTagSequence);
|
pSequence->setTag(kTagSequence);
|
||||||
|
|
||||||
Sprite* pChild = Sprite::create(s_pPathGrossini);
|
Sprite* pChild = Sprite::create(s_pathGrossini);
|
||||||
pChild->setPosition( VisibleRect::center() );
|
pChild->setPosition( VisibleRect::center() );
|
||||||
|
|
||||||
addChild(pChild, 1, kTagGrossini);
|
addChild(pChild, 1, kTagGrossini);
|
||||||
|
@ -255,8 +255,8 @@ void RemoveTest::onEnter()
|
||||||
|
|
||||||
void RemoveTest::stopAction()
|
void RemoveTest::stopAction()
|
||||||
{
|
{
|
||||||
Node* pSprite = getChildByTag(kTagGrossini);
|
Node* sprite = getChildByTag(kTagGrossini);
|
||||||
pSprite->stopActionByTag(kTagSequence);
|
sprite->stopActionByTag(kTagSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RemoveTest::title()
|
std::string RemoveTest::title()
|
||||||
|
@ -282,14 +282,14 @@ void ResumeTest::onEnter()
|
||||||
addChild(l);
|
addChild(l);
|
||||||
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75));
|
l->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 75));
|
||||||
|
|
||||||
Sprite* pGrossini = Sprite::create(s_pPathGrossini);
|
Sprite* pGrossini = Sprite::create(s_pathGrossini);
|
||||||
addChild(pGrossini, 0, kTagGrossini);
|
addChild(pGrossini, 0, kTagGrossini);
|
||||||
pGrossini->setPosition(VisibleRect::center());
|
pGrossini->setPosition(VisibleRect::center());
|
||||||
|
|
||||||
pGrossini->runAction(ScaleBy::create(2, 2));
|
pGrossini->runAction(ScaleBy::create(2, 2));
|
||||||
|
|
||||||
Director* pDirector = Director::getInstance();
|
Director* director = Director::getInstance();
|
||||||
pDirector->getActionManager()->pauseTarget(pGrossini);
|
director->getActionManager()->pauseTarget(pGrossini);
|
||||||
pGrossini->runAction(RotateBy::create(2, 360));
|
pGrossini->runAction(RotateBy::create(2, 360));
|
||||||
|
|
||||||
this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f);
|
this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f);
|
||||||
|
@ -300,8 +300,8 @@ void ResumeTest::resumeGrossini(float time)
|
||||||
this->unschedule(schedule_selector(ResumeTest::resumeGrossini));
|
this->unschedule(schedule_selector(ResumeTest::resumeGrossini));
|
||||||
|
|
||||||
Node* pGrossini = getChildByTag(kTagGrossini);
|
Node* pGrossini = getChildByTag(kTagGrossini);
|
||||||
Director* pDirector = Director::getInstance();
|
Director* director = Director::getInstance();
|
||||||
pDirector->getActionManager()->resumeTarget(pGrossini);
|
director->getActionManager()->resumeTarget(pGrossini);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
@ -311,8 +311,8 @@ void ResumeTest::resumeGrossini(float time)
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
void ActionManagerTestScene::runThisTest()
|
void ActionManagerTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
Layer* pLayer = nextActionManagerAction();
|
Layer* layer = nextActionManagerAction();
|
||||||
addChild(pLayer);
|
addChild(layer);
|
||||||
|
|
||||||
Director::getInstance()->replaceScene(this);
|
Director::getInstance()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,10 +552,10 @@ Layer* nextEaseAction()
|
||||||
sceneIdx++;
|
sceneIdx++;
|
||||||
sceneIdx = sceneIdx % MAX_LAYER;
|
sceneIdx = sceneIdx % MAX_LAYER;
|
||||||
|
|
||||||
Layer* pLayer = createEaseLayer(sceneIdx);
|
Layer* layer = createEaseLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* backEaseAction()
|
Layer* backEaseAction()
|
||||||
|
@ -565,18 +565,18 @@ Layer* backEaseAction()
|
||||||
if( sceneIdx < 0 )
|
if( sceneIdx < 0 )
|
||||||
sceneIdx += total;
|
sceneIdx += total;
|
||||||
|
|
||||||
Layer* pLayer = createEaseLayer(sceneIdx);
|
Layer* layer = createEaseLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* restartEaseAction()
|
Layer* restartEaseAction()
|
||||||
{
|
{
|
||||||
Layer* pLayer = createEaseLayer(sceneIdx);
|
Layer* layer = createEaseLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -609,9 +609,9 @@ void EaseSpriteDemo::onEnter()
|
||||||
BaseTest::onEnter();
|
BaseTest::onEnter();
|
||||||
|
|
||||||
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
|
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
|
||||||
_grossini = Sprite::create(s_pPathGrossini); _grossini->retain();
|
_grossini = Sprite::create(s_pathGrossini); _grossini->retain();
|
||||||
_tamara = Sprite::create(s_pPathSister1); _tamara->retain();
|
_tamara = Sprite::create(s_pathSister1); _tamara->retain();
|
||||||
_kathia = Sprite::create(s_pPathSister2); _kathia->retain();
|
_kathia = Sprite::create(s_pathSister2); _kathia->retain();
|
||||||
|
|
||||||
addChild( _grossini, 3);
|
addChild( _grossini, 3);
|
||||||
addChild( _kathia, 2);
|
addChild( _kathia, 2);
|
||||||
|
@ -649,8 +649,8 @@ void EaseSpriteDemo::backCallback(Object* pSender)
|
||||||
|
|
||||||
void ActionsEaseTestScene::runThisTest()
|
void ActionsEaseTestScene::runThisTest()
|
||||||
{
|
{
|
||||||
Layer* pLayer = nextEaseAction();
|
Layer* layer = nextEaseAction();
|
||||||
addChild(pLayer);
|
addChild(layer);
|
||||||
|
|
||||||
Director::getInstance()->replaceScene(this);
|
Director::getInstance()->replaceScene(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ Layer* nextAction()
|
||||||
sceneIdx++;
|
sceneIdx++;
|
||||||
sceneIdx = sceneIdx % MAX_LAYER;
|
sceneIdx = sceneIdx % MAX_LAYER;
|
||||||
|
|
||||||
Layer* pLayer = createLayer(sceneIdx);
|
Layer* layer = createLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* backAction()
|
Layer* backAction()
|
||||||
|
@ -43,18 +43,18 @@ Layer* backAction()
|
||||||
if( sceneIdx < 0 )
|
if( sceneIdx < 0 )
|
||||||
sceneIdx += total;
|
sceneIdx += total;
|
||||||
|
|
||||||
Layer* pLayer = createLayer(sceneIdx);
|
Layer* layer = createLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer* restartAction()
|
Layer* restartAction()
|
||||||
{
|
{
|
||||||
Layer* pLayer = createLayer(sceneIdx);
|
Layer* layer = createLayer(sceneIdx);
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,13 +135,13 @@ void SpriteProgressToRadial::onEnter()
|
||||||
ProgressTo *to1 = ProgressTo::create(2, 100);
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
||||||
ProgressTo *to2 = ProgressTo::create(2, 100);
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
||||||
|
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||||
left->setType( kProgressTimerTypeRadial );
|
left->setType( kProgressTimerTypeRadial );
|
||||||
addChild(left);
|
addChild(left);
|
||||||
left->setPosition(Point(100, s.height/2));
|
left->setPosition(Point(100, s.height/2));
|
||||||
left->runAction( RepeatForever::create(to1));
|
left->runAction( RepeatForever::create(to1));
|
||||||
|
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathBlock));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||||
right->setType(kProgressTimerTypeRadial);
|
right->setType(kProgressTimerTypeRadial);
|
||||||
// Makes the ridial CCW
|
// Makes the ridial CCW
|
||||||
right->setReverseProgress(true);
|
right->setReverseProgress(true);
|
||||||
|
@ -170,7 +170,7 @@ void SpriteProgressToHorizontal::onEnter()
|
||||||
ProgressTo *to1 = ProgressTo::create(2, 100);
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
||||||
ProgressTo *to2 = ProgressTo::create(2, 100);
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
||||||
|
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||||
left->setType(kProgressTimerTypeBar);
|
left->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the left since the midpoint is 0 for the x
|
// Setup for a bar starting from the left since the midpoint is 0 for the x
|
||||||
left->setMidpoint(Point(0,0));
|
left->setMidpoint(Point(0,0));
|
||||||
|
@ -180,7 +180,7 @@ void SpriteProgressToHorizontal::onEnter()
|
||||||
left->setPosition(Point(100, s.height/2));
|
left->setPosition(Point(100, s.height/2));
|
||||||
left->runAction( RepeatForever::create(to1));
|
left->runAction( RepeatForever::create(to1));
|
||||||
|
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
right->setType(kProgressTimerTypeBar);
|
right->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the left since the midpoint is 1 for the x
|
// Setup for a bar starting from the left since the midpoint is 1 for the x
|
||||||
right->setMidpoint(Point(1, 0));
|
right->setMidpoint(Point(1, 0));
|
||||||
|
@ -210,7 +210,7 @@ void SpriteProgressToVertical::onEnter()
|
||||||
ProgressTo *to1 = ProgressTo::create(2, 100);
|
ProgressTo *to1 = ProgressTo::create(2, 100);
|
||||||
ProgressTo *to2 = ProgressTo::create(2, 100);
|
ProgressTo *to2 = ProgressTo::create(2, 100);
|
||||||
|
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||||
left->setType(kProgressTimerTypeBar);
|
left->setType(kProgressTimerTypeBar);
|
||||||
|
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
@ -221,7 +221,7 @@ void SpriteProgressToVertical::onEnter()
|
||||||
left->setPosition(Point(100, s.height/2));
|
left->setPosition(Point(100, s.height/2));
|
||||||
left->runAction( RepeatForever::create(to1));
|
left->runAction( RepeatForever::create(to1));
|
||||||
|
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
right->setType(kProgressTimerTypeBar);
|
right->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
right->setMidpoint(Point(0, 1));
|
right->setMidpoint(Point(0, 1));
|
||||||
|
@ -253,7 +253,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
|
||||||
/**
|
/**
|
||||||
* Our image on the left should be a radial progress indicator, clockwise
|
* Our image on the left should be a radial progress indicator, clockwise
|
||||||
*/
|
*/
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathBlock));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||||
left->setType(kProgressTimerTypeRadial);
|
left->setType(kProgressTimerTypeRadial);
|
||||||
addChild(left);
|
addChild(left);
|
||||||
left->setMidpoint(Point(0.25f, 0.75f));
|
left->setMidpoint(Point(0.25f, 0.75f));
|
||||||
|
@ -263,7 +263,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
|
||||||
/**
|
/**
|
||||||
* Our image on the left should be a radial progress indicator, counter clockwise
|
* Our image on the left should be a radial progress indicator, counter clockwise
|
||||||
*/
|
*/
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathBlock));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||||
right->setType(kProgressTimerTypeRadial);
|
right->setType(kProgressTimerTypeRadial);
|
||||||
right->setMidpoint(Point(0.75f, 0.25f));
|
right->setMidpoint(Point(0.75f, 0.25f));
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ void SpriteProgressBarVarious::onEnter()
|
||||||
|
|
||||||
ProgressTo *to = ProgressTo::create(2, 100);
|
ProgressTo *to = ProgressTo::create(2, 100);
|
||||||
|
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||||
left->setType(kProgressTimerTypeBar);
|
left->setType(kProgressTimerTypeBar);
|
||||||
|
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
@ -305,7 +305,7 @@ void SpriteProgressBarVarious::onEnter()
|
||||||
left->setPosition(Point(100, s.height/2));
|
left->setPosition(Point(100, s.height/2));
|
||||||
left->runAction(RepeatForever::create(to->clone()));
|
left->runAction(RepeatForever::create(to->clone()));
|
||||||
|
|
||||||
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
middle->setType(kProgressTimerTypeBar);
|
middle->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
middle->setMidpoint(Point(0.5f, 0.5f));
|
middle->setMidpoint(Point(0.5f, 0.5f));
|
||||||
|
@ -315,7 +315,7 @@ void SpriteProgressBarVarious::onEnter()
|
||||||
middle->setPosition(Point(s.width/2, s.height/2));
|
middle->setPosition(Point(s.width/2, s.height/2));
|
||||||
middle->runAction(RepeatForever::create(to->clone()));
|
middle->runAction(RepeatForever::create(to->clone()));
|
||||||
|
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
right->setType(kProgressTimerTypeBar);
|
right->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
right->setMidpoint(Point(0.5f, 0.5f));
|
right->setMidpoint(Point(0.5f, 0.5f));
|
||||||
|
@ -351,7 +351,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
||||||
FadeTo::create(1.0f, 255),
|
FadeTo::create(1.0f, 255),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
|
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||||
left->setType(kProgressTimerTypeBar);
|
left->setType(kProgressTimerTypeBar);
|
||||||
|
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
@ -365,7 +365,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
||||||
|
|
||||||
left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f));
|
left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f));
|
||||||
|
|
||||||
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
middle->setType(kProgressTimerTypeBar);
|
middle->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
middle->setMidpoint(Point(0.5f, 0.5f));
|
middle->setMidpoint(Point(0.5f, 0.5f));
|
||||||
|
@ -378,7 +378,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
||||||
|
|
||||||
middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f));
|
middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f));
|
||||||
|
|
||||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
|
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
|
||||||
right->setType(kProgressTimerTypeBar);
|
right->setType(kProgressTimerTypeBar);
|
||||||
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
right->setMidpoint(Point(0.5f, 0.5f));
|
right->setMidpoint(Point(0.5f, 0.5f));
|
||||||
|
|
|
@ -61,11 +61,11 @@ static Layer* nextAction()
|
||||||
sceneIdx++;
|
sceneIdx++;
|
||||||
sceneIdx = sceneIdx % MAX_LAYER;
|
sceneIdx = sceneIdx % MAX_LAYER;
|
||||||
|
|
||||||
Layer* pLayer = (createFunctions[sceneIdx])();
|
Layer* layer = (createFunctions[sceneIdx])();
|
||||||
pLayer->init();
|
layer->init();
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Layer* backAction()
|
static Layer* backAction()
|
||||||
|
@ -75,20 +75,20 @@ static Layer* backAction()
|
||||||
if( sceneIdx < 0 )
|
if( sceneIdx < 0 )
|
||||||
sceneIdx += total;
|
sceneIdx += total;
|
||||||
|
|
||||||
Layer* pLayer = (createFunctions[sceneIdx])();
|
Layer* layer = (createFunctions[sceneIdx])();
|
||||||
pLayer->init();
|
layer->init();
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Layer* restartAction()
|
static Layer* restartAction()
|
||||||
{
|
{
|
||||||
Layer* pLayer = (createFunctions[sceneIdx])();
|
Layer* layer = (createFunctions[sceneIdx])();
|
||||||
pLayer->init();
|
layer->init();
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
return pLayer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionsTestScene::runThisTest()
|
void ActionsTestScene::runThisTest()
|
||||||
|
@ -115,13 +115,13 @@ void ActionsDemo::onEnter()
|
||||||
BaseTest::onEnter();
|
BaseTest::onEnter();
|
||||||
|
|
||||||
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
|
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
|
||||||
_grossini = Sprite::create(s_pPathGrossini);
|
_grossini = Sprite::create(s_pathGrossini);
|
||||||
_grossini->retain();
|
_grossini->retain();
|
||||||
|
|
||||||
_tamara = Sprite::create(s_pPathSister1);
|
_tamara = Sprite::create(s_pathSister1);
|
||||||
_tamara->retain();
|
_tamara->retain();
|
||||||
|
|
||||||
_kathia = Sprite::create(s_pPathSister2);
|
_kathia = Sprite::create(s_pathSister2);
|
||||||
_kathia->retain();
|
_kathia->retain();
|
||||||
|
|
||||||
addChild(_grossini, 1);
|
addChild(_grossini, 1);
|
||||||
|
@ -1510,7 +1510,6 @@ void ActionCatmullRomStacked::onEnter()
|
||||||
|
|
||||||
_tamara->runAction(seq);
|
_tamara->runAction(seq);
|
||||||
|
|
||||||
|
|
||||||
_tamara->runAction(
|
_tamara->runAction(
|
||||||
RepeatForever::create(
|
RepeatForever::create(
|
||||||
Sequence::create(
|
Sequence::create(
|
||||||
|
@ -1547,7 +1546,6 @@ void ActionCatmullRomStacked::onEnter()
|
||||||
MoveBy::create(0.05f, Point(-10,0)),
|
MoveBy::create(0.05f, Point(-10,0)),
|
||||||
NULL)));
|
NULL)));
|
||||||
|
|
||||||
|
|
||||||
array->retain();
|
array->retain();
|
||||||
_array1 = array;
|
_array1 = array;
|
||||||
array2->retain();
|
array2->retain();
|
||||||
|
@ -1704,7 +1702,7 @@ void Issue1305::onEnter()
|
||||||
|
|
||||||
void Issue1305::log(Node* pSender)
|
void Issue1305::log(Node* pSender)
|
||||||
{
|
{
|
||||||
CCLog("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
cocos2d::log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Issue1305::onExit()
|
void Issue1305::onExit()
|
||||||
|
@ -1775,22 +1773,22 @@ void Issue1305_2::onEnter()
|
||||||
|
|
||||||
void Issue1305_2::printLog1()
|
void Issue1305_2::printLog1()
|
||||||
{
|
{
|
||||||
CCLog("1st block");
|
log("1st block");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Issue1305_2::printLog2()
|
void Issue1305_2::printLog2()
|
||||||
{
|
{
|
||||||
CCLog("2nd block");
|
log("2nd block");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Issue1305_2::printLog3()
|
void Issue1305_2::printLog3()
|
||||||
{
|
{
|
||||||
CCLog("3rd block");
|
log("3rd block");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Issue1305_2::printLog4()
|
void Issue1305_2::printLog4()
|
||||||
{
|
{
|
||||||
CCLog("4th block");
|
log("4th block");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Issue1305_2::title()
|
std::string Issue1305_2::title()
|
||||||
|
@ -1889,14 +1887,14 @@ std::string Issue1327::subtitle()
|
||||||
|
|
||||||
void Issue1327::logSprRotation(Sprite* pSender)
|
void Issue1327::logSprRotation(Sprite* pSender)
|
||||||
{
|
{
|
||||||
CCLog("%f", pSender->getRotation());
|
log("%f", pSender->getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Issue1398
|
//Issue1398
|
||||||
void Issue1398::incrementInteger()
|
void Issue1398::incrementInteger()
|
||||||
{
|
{
|
||||||
_testInteger++;
|
_testInteger++;
|
||||||
CCLog("incremented to %d", _testInteger);
|
log("incremented to %d", _testInteger);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Issue1398::onEnter()
|
void Issue1398::onEnter()
|
||||||
|
@ -1905,7 +1903,7 @@ void Issue1398::onEnter()
|
||||||
this->centerSprites(0);
|
this->centerSprites(0);
|
||||||
|
|
||||||
_testInteger = 0;
|
_testInteger = 0;
|
||||||
CCLog("testInt = %d", _testInteger);
|
log("testInt = %d", _testInteger);
|
||||||
|
|
||||||
this->runAction(
|
this->runAction(
|
||||||
Sequence::create(
|
Sequence::create(
|
||||||
|
@ -1923,7 +1921,7 @@ void Issue1398::onEnter()
|
||||||
void Issue1398::incrementIntegerCallback(void* data)
|
void Issue1398::incrementIntegerCallback(void* data)
|
||||||
{
|
{
|
||||||
this->incrementInteger();
|
this->incrementInteger();
|
||||||
CCLog("%s", (char*)data);
|
log("%s", (char*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Issue1398::subtitle()
|
std::string Issue1398::subtitle()
|
||||||
|
@ -2153,7 +2151,7 @@ string PauseResumeActions::subtitle()
|
||||||
|
|
||||||
void PauseResumeActions::pause(float dt)
|
void PauseResumeActions::pause(float dt)
|
||||||
{
|
{
|
||||||
CCLog("Pausing");
|
log("Pausing");
|
||||||
Director *director = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
|
|
||||||
CC_SAFE_RELEASE(_pausedTargets);
|
CC_SAFE_RELEASE(_pausedTargets);
|
||||||
|
@ -2163,7 +2161,7 @@ void PauseResumeActions::pause(float dt)
|
||||||
|
|
||||||
void PauseResumeActions::resume(float dt)
|
void PauseResumeActions::resume(float dt)
|
||||||
{
|
{
|
||||||
CCLog("Resuming");
|
log("Resuming");
|
||||||
Director *director = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
director->getActionManager()->resumeTargets(_pausedTargets);
|
director->getActionManager()->resumeTargets(_pausedTargets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,11 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
Configuration::getInstance()->loadConfigFile("configs/config-example.plist");
|
Configuration::getInstance()->loadConfigFile("configs/config-example.plist");
|
||||||
|
|
||||||
// initialize director
|
// initialize director
|
||||||
Director *pDirector = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
pDirector->setOpenGLView(EGLView::getInstance());
|
director->setOpenGLView(EGLView::getInstance());
|
||||||
|
|
||||||
|
director->setDisplayStats(true);
|
||||||
|
director->setAnimationInterval(1.0 / 60);
|
||||||
|
|
||||||
Size screenSize = EGLView::getInstance()->getFrameSize();
|
Size screenSize = EGLView::getInstance()->getFrameSize();
|
||||||
|
|
||||||
|
@ -42,17 +45,17 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
std::vector<std::string> searchPaths;
|
std::vector<std::string> searchPaths;
|
||||||
searchPaths.push_back("hd");
|
searchPaths.push_back("hd");
|
||||||
pFileUtils->setSearchPaths(searchPaths);
|
pFileUtils->setSearchPaths(searchPaths);
|
||||||
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
|
director->setContentScaleFactor(resourceSize.height/designSize.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
|
||||||
|
|
||||||
Scene * pScene = Scene::create();
|
auto scene = Scene::create();
|
||||||
Layer * pLayer = new TestController();
|
auto layer = new TestController();
|
||||||
pLayer->autorelease();
|
layer->autorelease();
|
||||||
|
|
||||||
pScene->addChild(pLayer);
|
scene->addChild(layer);
|
||||||
pDirector->runWithScene(pScene);
|
director->runWithScene(scene);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue