Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop

This commit is contained in:
zhangbin 2013-07-25 10:20:56 +08:00
commit b9eacf8517
200 changed files with 3178 additions and 2733 deletions

View File

@ -414,6 +414,7 @@ Developers:
Added some guards to prevent Eclipse to compile twice the same class.
Linux Eclipse projects updates
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
Correction of passed buffer size to readlink and verification of result return by readlink.
@ -552,6 +553,12 @@ Retired Core Developers:
michaelcontento
[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.

View File

@ -963,7 +963,7 @@ void Director::setScheduler(Scheduler* pScheduler)
}
}
Scheduler* Director::getScheduler()
Scheduler* Director::getScheduler() const
{
return _scheduler;
}
@ -978,7 +978,7 @@ void Director::setActionManager(ActionManager* pActionManager)
}
}
ActionManager* Director::getActionManager()
ActionManager* Director::getActionManager() const
{
return _actionManager;
}
@ -993,7 +993,7 @@ void Director::setTouchDispatcher(TouchDispatcher* pTouchDispatcher)
}
}
TouchDispatcher* Director::getTouchDispatcher()
TouchDispatcher* Director::getTouchDispatcher() const
{
return _touchDispatcher;
}
@ -1005,7 +1005,7 @@ void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher)
_keyboardDispatcher = pKeyboardDispatcher;
}
KeyboardDispatcher* Director::getKeyboardDispatcher()
KeyboardDispatcher* Director::getKeyboardDispatcher() const
{
return _keyboardDispatcher;
}
@ -1017,7 +1017,7 @@ void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher)
_keypadDispatcher = pKeypadDispatcher;
}
KeypadDispatcher* Director::getKeypadDispatcher()
KeypadDispatcher* Director::getKeypadDispatcher() const
{
return _keypadDispatcher;
}
@ -1031,7 +1031,7 @@ void Director::setAccelerometer(Accelerometer* pAccelerometer)
}
}
Accelerometer* Director::getAccelerometer()
Accelerometer* Director::getAccelerometer() const
{
return _accelerometer;
}

View File

@ -318,39 +318,70 @@ public:
float getContentScaleFactor(void) const;
public:
/** Scheduler associated with this director
/** Gets the Scheduler associated with this director
@since v2.0
*/
CC_PROPERTY(Scheduler*, _scheduler, Scheduler);
/** ActionManager associated with this director
Scheduler* getScheduler() const;
/** Sets the Scheduler associated with this director
@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
*/
CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher);
ActionManager* getActionManager() const;
/** 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);
/** KeyboardDispatcher associated with this director
/** Gets the KeyboardDispatcher associated with this director
@note Supported on Mac and Linux only now.
@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
*/
CC_PROPERTY(KeypadDispatcher*, _keypadDispatcher, KeypadDispatcher);
KeypadDispatcher* getKeypadDispatcher() const;
/** Accelerometer associated with this director
/** Sets the KeypadDispatcher associated with this director
@since v2.0
*/
CC_PROPERTY(Accelerometer*, _accelerometer, Accelerometer);
void setKeypadDispatcher(KeypadDispatcher* keypadDispatcher);
/** Gets Accelerometer associated with this director
@since v2.0
*/
Accelerometer* getAccelerometer() const;
/** Sets Accelerometer associated with this director
@since v2.0
*/
void setAccelerometer(Accelerometer* acc);
/* delta time since last tick to main loop */
CC_PROPERTY_READONLY(float, _deltaTime, DeltaTime);
/* Gets delta time since last tick to main loop */
float getDeltaTime() const;
protected:
void purgeDirector();
@ -367,6 +398,40 @@ protected:
void calculateDeltaTime();
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 */
EGLView *_openGLView;

View File

@ -172,10 +172,7 @@ public:
void setInnerAction(ActionInterval *pAction);
inline ActionInterval* getInnerAction() const
{
return _innerAction;
}
inline ActionInterval* getInnerAction() const { return _innerAction; }
//
// Override

View File

@ -92,7 +92,7 @@ class CC_DLL Sequence : public ActionInterval
{
public:
/** 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 */
static Sequence* create(Array *arrayOfActions);
/** helper constructor to create an array of sequence-able actions */
@ -221,7 +221,7 @@ class CC_DLL Spawn : public ActionInterval
{
public:
/** 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 */
static Spawn* createWithVariableList(FiniteTimeAction *pAction1, va_list args);

View File

@ -233,24 +233,24 @@ void AtlasNode::setTexture(Texture2D *texture)
this->updateOpacityModifyRGB();
}
Texture2D * AtlasNode::getTexture()
Texture2D * AtlasNode::getTexture() const
{
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);
_textureAtlas = var;
_textureAtlas = textureAtlas;
}
TextureAtlas * AtlasNode::getTextureAtlas()
TextureAtlas * AtlasNode::getTextureAtlas() const
{
return _textureAtlas;
}
unsigned int AtlasNode::getQuadsToDraw()
unsigned int AtlasNode::getQuadsToDraw() const
{
return _quadsToDraw;
}

View File

@ -68,15 +68,24 @@ public:
*/
virtual void updateAtlasValues();
void setTextureAtlas(TextureAtlas* textureAtlas);
TextureAtlas* getTextureAtlas() const;
void setQuadsToDraw(unsigned int quadsToDraw);
unsigned int getQuadsToDraw() const;
// Overrides
virtual void draw() override;
virtual Texture2D* getTexture() override;
virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override;
virtual bool isOpacityModifyRGB() const override;
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
virtual const Color3B& getColor(void) const override;
virtual void setColor(const Color3B& color) override;
virtual void setOpacity(GLubyte opacity) override;
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
virtual const BlendFunc& getBlendFunc() const override;
private :
void calculateMaxItems();
@ -96,18 +105,16 @@ protected:
unsigned int _itemWidth;
//! height of each char
unsigned int _itemHeight;
Color3B _colorUnmodified;
CC_PROPERTY(TextureAtlas*, _textureAtlas, TextureAtlas);
TextureAtlas* _textureAtlas;
// protocol variables
bool _isOpacityModifyRGB;
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc);
BlendFunc _blendFunc;
// quads to draw
CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw);
unsigned int _quadsToDraw;
// color uniform
GLint _uniformColor;
// This varible is only used for LabelAtlas FPS display. So plz don't modify its value.

View File

@ -117,7 +117,7 @@ public:
/** Create an array */
static Array* create();
/** 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 */
static Array* createWithObject(Object* pObject);
/** Create an array with capacity */
@ -142,7 +142,7 @@ public:
/** Initializes an array with one object */
bool initWithObject(Object* pObject);
/** Initializes an array with some objects */
bool initWithObjects(Object* pObject, ...);
bool initWithObjects(Object* pObject, ...) CC_REQUIRES_NULL_TERMINATION;
/** Initializes an array with capacity */
bool initWithCapacity(unsigned int capacity);
/** Initializes an array with an existing array */

View File

@ -162,9 +162,9 @@ public:
*
* // Get the object for key
* String* pStr1 = (String*)pDict->objectForKey("key1");
* CCLog("{ key1: %s }", pStr1->getCString());
* log("{ key1: %s }", pStr1->getCString());
* Integer* pInteger = (Integer*)pDict->objectForKey("key3");
* CCLog("{ key3: %d }", pInteger->getValue());
* log("{ key3: %d }", pInteger->getValue());
* @endcode
*
*/

View File

@ -30,7 +30,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "3.0-alpha0-pre";
return "3.0-pre-alpha0";
}
NS_CC_END

View File

@ -907,6 +907,10 @@ CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
#define kCCFlipedAll kFlipedAll
#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
/// @}

View File

@ -50,21 +50,21 @@ public:
*
* @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.
*
* @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.
*
* @return The opacity of sprite, from 0 ~ 255
*/
virtual GLubyte getDisplayedOpacity(void) const = 0;
virtual GLubyte getDisplayedOpacity() const = 0;
/**
* Returns the opacity.
*
@ -73,7 +73,7 @@ public:
*
* @return The opacity of sprite, from 0 ~ 255
*/
virtual GLubyte getOpacity(void) const = 0;
virtual GLubyte getOpacity() const = 0;
/**
* Changes the opacity.
@ -100,12 +100,12 @@ public:
*
* @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.
*/
virtual bool isCascadeColorEnabled(void) const = 0;
virtual bool isCascadeColorEnabled() const = 0;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
/**
@ -116,7 +116,7 @@ public:
/**
* 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;
/**
@ -147,7 +147,7 @@ public:
*
* @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.
*/
virtual Texture2D* getTexture(void) = 0;
virtual Texture2D* getTexture() const = 0;
/**
* Sets a new texuture. It will be retained.
@ -195,7 +195,7 @@ public:
*
* @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
*/
virtual void updateProjection(void) = 0;
virtual void updateProjection() = 0;
};
NS_CC_END

View File

@ -40,7 +40,7 @@ extern bool CC_DLL cc_assert_script_compatible(const char *msg);
#define CCASSERT(cond, msg) do { \
if (!(cond)) { \
if (!cc_assert_script_compatible(msg) && strlen(msg)) \
cocos2d::CCLog("Assert failed: %s", msg); \
cocos2d::log("Assert failed: %s", msg); \
CC_ASSERT(cond); \
} \
} while (0)
@ -238,7 +238,7 @@ It should work same as apples CFSwapInt32LittleToHost(..)
do { \
GLenum __error = glGetError(); \
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)
#endif

View File

@ -241,9 +241,6 @@ public:
*/
void changeWidthAndHeight(GLfloat w ,GLfloat h);
/** BlendFunction. Conforms to BlendProtocol protocol */
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
//
// Overrides
//
@ -251,10 +248,14 @@ public:
virtual void setColor(const Color3B &color) override;
virtual void setOpacity(GLubyte opacity) 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:
virtual void updateColor();
BlendFunc _blendFunc;
Vertex2F _squareVertices[4];
Color4F _squareColors[4];
};

View File

@ -60,7 +60,7 @@ public:
static Menu* create();
/** 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 */
static Menu* createWithArray(Array* pArrayOfItems);
@ -98,12 +98,12 @@ public:
void alignItemsHorizontallyWithPadding(float padding);
/** 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 alignItemsInColumnsWithArray(Array* 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 alignItemsInRowsWithArray(Array* columns);

View File

@ -161,18 +161,6 @@ void MenuItem::setCallback(const ccMenuCallback& callback)
//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)
{
if (var)
@ -473,11 +461,6 @@ const char* MenuItemFont::getFontNameObj() const
//CCMenuItemSprite
//
Node * MenuItemSprite::getNormalImage()
{
return _normalImage;
}
void MenuItemSprite::setNormalImage(Node* pImage)
{
if (pImage != _normalImage)
@ -499,11 +482,6 @@ void MenuItemSprite::setNormalImage(Node* pImage)
}
}
Node * MenuItemSprite::getSelectedImage()
{
return _selectedImage;
}
void MenuItemSprite::setSelectedImage(Node* pImage)
{
if (pImage != _normalImage)
@ -524,11 +502,6 @@ void MenuItemSprite::setSelectedImage(Node* pImage)
}
}
Node * MenuItemSprite::getDisabledImage()
{
return _disabledImage;
}
void MenuItemSprite::setDisabledImage(Node* pImage)
{
if (pImage != _normalImage)
@ -818,18 +791,6 @@ void MenuItemImage::setDisabledSpriteFrame(SpriteFrame * frame)
// MenuItemToggle
//
void MenuItemToggle::setSubItems(Array* var)
{
CC_SAFE_RETAIN(var);
CC_SAFE_RELEASE(_subItems);
_subItems = var;
}
Array* MenuItemToggle::getSubItems()
{
return _subItems;
}
// XXX: deprecated
MenuItemToggle * MenuItemToggle::createWithTarget(Object* target, SEL_MenuHandler selector, Array* menuItems)
{
@ -959,6 +920,7 @@ MenuItemToggle::~MenuItemToggle()
{
CC_SAFE_RELEASE(_subItems);
}
void MenuItemToggle::setSelectedIndex(unsigned int index)
{
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 ) );
}
}
unsigned int MenuItemToggle::getSelectedIndex()
{
return _selectedIndex;
}
void MenuItemToggle::selected()
{
MenuItem::selected();
((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->selected();
static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex))->selected();
}
void MenuItemToggle::unselected()
{
MenuItem::unselected();
((MenuItem*)(_subItems->objectAtIndex(_selectedIndex)))->unselected();
static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex))->unselected();
}
void MenuItemToggle::activate()
{
// update index
@ -1021,7 +982,7 @@ void MenuItemToggle::setEnabled(bool enabled)
MenuItem* MenuItemToggle::getSelectedItem()
{
return (MenuItem*)_subItems->objectAtIndex(_selectedIndex);
return static_cast<MenuItem*>(_subItems->objectAtIndex(_selectedIndex));
}
NS_CC_END

View File

@ -142,6 +142,18 @@ public:
/** sets a new string to the inner 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
virtual void activate() override;
virtual void selected() override;
@ -153,9 +165,9 @@ protected:
float _originalScale;
/** 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 */
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 */
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
*/
@ -288,11 +318,11 @@ protected:
virtual void updateImagesVisibility();
/** the image used when the item is not selected */
CC_PROPERTY(Node*, _normalImage, NormalImage);
Node* _normalImage;
/** the image used when the item is selected */
CC_PROPERTY(Node*, _selectedImage, SelectedImage);
Node* _selectedImage;
/** 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 */
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, Array* menuItems);
/** 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 */
static MenuItemToggle* create();
/** creates a menu item with a item */
@ -359,7 +389,7 @@ public:
/** creates a menu item from a Array with a target selector */
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 */
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()
: _selectedIndex(0)
@ -382,6 +412,26 @@ public:
/** @deprecated Use getSelectedItem() instead */
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
virtual void activate() override;
virtual void selected() override;
@ -390,11 +440,11 @@ public:
protected:
/** returns the selected item */
CC_PROPERTY(unsigned int, _selectedIndex, SelectedIndex);
/** MutableArray that contains the subitems. You can add/remove items in runtime, and you can replace the array with a new one.
unsigned int _selectedIndex;
/** 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
*/
CC_PROPERTY(Array*, _subItems, SubItems);
Array* _subItems;
};

View File

@ -153,7 +153,7 @@ void MotionStreak::tintWithColor(const Color3B& colors)
}
}
Texture2D* MotionStreak::getTexture(void)
Texture2D* MotionStreak::getTexture(void) const
{
return _texture;
}

View File

@ -82,7 +82,7 @@ public:
virtual void setPosition(const Point& position) override;
virtual void draw() override;
virtual void update(float delta) override;
virtual Texture2D* getTexture() 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;

View File

@ -140,68 +140,6 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj)
#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 *pRet = new RenderTexture();

View File

@ -127,27 +127,37 @@ public:
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. */
unsigned int getClearFlags() const;
void setClearFlags(unsigned int uClearFlags);
inline unsigned int getClearFlags() const { return _clearFlags; };
inline void setClearFlags(unsigned int clearFlags) { _clearFlags = clearFlags; };
/** Clear color value. Valid only when "autoDraw" is true. */
const Color4F& getClearColor() const;
void setClearColor(const Color4F &clearColor);
inline const Color4F& getClearColor() const { return _clearColor; };
inline void setClearColor(const Color4F &clearColor) { _clearColor = clearColor; };
/** Value for clearDepth. Valid only when autoDraw is true. */
float getClearDepth() const;
void setClearDepth(float fClearDepth);
inline float getClearDepth() const { return _clearDepth; };
inline void setClearDepth(float clearDepth) { _clearDepth = clearDepth; };
/** Value for clear Stencil. Valid only when autoDraw is true */
int getClearStencil() const;
void setClearStencil(float fClearStencil);
inline int getClearStencil() const { return _clearStencil; };
inline void setClearStencil(float clearStencil) { _clearStencil = clearStencil; };
/** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons.
Will be enabled in the future.
*/
bool isAutoDraw() const;
void setAutoDraw(bool bAutoDraw);
inline bool isAutoDraw() const { return _autoDraw; };
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
virtual void visit() override;
virtual void draw() override;
@ -176,7 +186,7 @@ protected:
The blending function can be changed in runtime by calling:
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
*/
CC_PROPERTY(Sprite*, _sprite, Sprite)
Sprite* _sprite;
};
// end of textures group

View File

@ -503,7 +503,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture)
}
}
Texture2D* ParticleBatchNode::getTexture(void)
Texture2D* ParticleBatchNode::getTexture(void) const
{
return _textureAtlas->getTexture();
}

View File

@ -91,6 +91,12 @@ public:
/** disables a particle by inserting a 0'd quad into the texture atlas */
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
void visit();
virtual void addChild(Node * child) override;
@ -99,7 +105,7 @@ public:
virtual void removeChild(Node* child, bool cleanup) override;
virtual void reorderChild(Node * child, int zOrder) 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 setBlendFunc(const BlendFunc &blendFunc) override;
virtual const BlendFunc& getBlendFunc(void) const override;
@ -112,7 +118,7 @@ private:
unsigned int addChildHelper(ParticleSystem* child, int z, int aTag);
void updateBlendFunc(void);
/** the texture atlas used for drawing the quads */
CC_SYNTHESIZE(TextureAtlas*, _textureAtlas, TextureAtlas);
TextureAtlas* _textureAtlas;
private:
/** the blend function used for drawing the quads */

View File

@ -821,7 +821,7 @@ void ParticleSystem::updateBlendFunc()
}
}
Texture2D * ParticleSystem::getTexture()
Texture2D * ParticleSystem::getTexture() const
{
return _texture;
}
@ -1029,211 +1029,7 @@ bool ParticleSystem::isActive() const
return _isActive;
}
unsigned int ParticleSystem::getParticleCount() 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()
unsigned int ParticleSystem::getTotalParticles() const
{
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
{
return _isAutoRemoveOnFinish;
@ -1287,20 +1063,10 @@ void ParticleSystem::setAutoRemoveOnFinish(bool var)
_isAutoRemoveOnFinish = var;
}
int ParticleSystem::getEmitterMode()
{
return _emitterMode;
}
void ParticleSystem::setEmitterMode(int var)
{
_emitterMode = var;
}
// ParticleSystem - methods for batchNode rendering
ParticleBatchNode* ParticleSystem::getBatchNode(void)
ParticleBatchNode* ParticleSystem::getBatchNode(void) const
{
return _batchNode;
}

View File

@ -262,9 +262,124 @@ public:
virtual bool isBlendAdditive() const;
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
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:
virtual void updateBlendFunc();
@ -342,10 +457,10 @@ protected:
//SEL updateParticleSel;
/** weak reference to the SpriteBatchNode that renders the Sprite */
CC_PROPERTY(ParticleBatchNode*, _batchNode, BatchNode);
ParticleBatchNode* _batchNode;
// index of system in batch node array
CC_SYNTHESIZE(int, _atlasIndex, AtlasIndex);
int _atlasIndex;
//true if scaled or rotated
bool _transformSystemDirty;
@ -356,67 +471,67 @@ protected:
bool _isActive;
/** 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' */
CC_PROPERTY(float, _duration, Duration)
float _duration;
/** sourcePosition of the emitter */
CC_PROPERTY_PASS_BY_REF(Point, _sourcePosition, SourcePosition)
Point _sourcePosition;
/** Position variance of the emitter */
CC_PROPERTY_PASS_BY_REF(Point, _posVar, PosVar)
Point _posVar;
/** life, and life variation of each particle */
CC_PROPERTY(float, _life, Life)
float _life;
/** life variance of each particle */
CC_PROPERTY(float, _lifeVar, LifeVar)
float _lifeVar;
/** angle and angle variation of each particle */
CC_PROPERTY(float, _angle, Angle)
float _angle;
/** angle variance of each particle */
CC_PROPERTY(float, _angleVar, AngleVar)
float _angleVar;
/** Switch between different kind of emitter modes:
- kParticleModeGravity: uses gravity, speed, radial and tangential acceleration
- kParticleModeRadius: uses radius movement + rotation
*/
CC_PROPERTY(int, _emitterMode, EmitterMode)
int _emitterMode;
/** start size in pixels of each particle */
CC_PROPERTY(float, _startSize, StartSize)
float _startSize;
/** size variance in pixels of each particle */
CC_PROPERTY(float, _startSizeVar, StartSizeVar)
float _startSizeVar;
/** end size in pixels of each particle */
CC_PROPERTY(float, _endSize, EndSize)
float _endSize;
/** end size variance in pixels of each particle */
CC_PROPERTY(float, _endSizeVar, EndSizeVar)
float _endSizeVar;
/** start color of each particle */
CC_PROPERTY_PASS_BY_REF(Color4F, _startColor, StartColor)
Color4F _startColor;
/** 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 */
CC_PROPERTY_PASS_BY_REF(Color4F, _endColor, EndColor)
Color4F _endColor;
/** end color variance of each particle */
CC_PROPERTY_PASS_BY_REF(Color4F, _endColorVar, EndColorVar)
Color4F _endColorVar;
//* initial angle of each particle
CC_PROPERTY(float, _startSpin, StartSpin)
float _startSpin;
//* initial angle of each particle
CC_PROPERTY(float, _startSpinVar, StartSpinVar)
float _startSpinVar;
//* initial angle of each particle
CC_PROPERTY(float, _endSpin, EndSpin)
float _endSpin;
//* initial angle of each particle
CC_PROPERTY(float, _endSpinVar, EndSpinVar)
float _endSpinVar;
/** emission rate of the particles */
CC_PROPERTY(float, _emissionRate, EmissionRate)
float _emissionRate;
/** maximum particles of the system */
CC_PROPERTY(unsigned int, _totalParticles, TotalParticles)
unsigned int _totalParticles;
/** conforms to CocosNodeTexture protocol */
CC_PROPERTY(Texture2D*, _texture, Texture)
Texture2D* _texture;
/** conforms to CocosNodeTexture protocol */
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
BlendFunc _blendFunc;
/** does the alpha value modify color */
CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB)
bool _opacityModifyRGB;
/** particles movement type: Free or Grouped
@since v0.8
*/
CC_PROPERTY(tPositionType, _positionType, PositionType)
tPositionType _positionType;
};
// end of particle_nodes group

View File

@ -52,16 +52,6 @@ Special features and Limitations:
*/
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:
/** creates a Particle Emitter */
@ -113,6 +103,16 @@ private:
void setupVBO();
#endif
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

View File

@ -40,7 +40,7 @@ static const int kMaxLogLen = 16*1024;
/**
@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 ...

View File

@ -48,7 +48,7 @@ public:
friend class TextureCache;
Image();
~Image();
virtual ~Image();
typedef enum
{
@ -145,25 +145,25 @@ public:
#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.
@param pszFilePath the file's absolute path, including file suffix.
@param bIsToRGB whether the image is saved as RGB format.
*/
@brief Save Image data to the specified file, with specified format.
@param pszFilePath the file's absolute path, including file suffix.
@param bIsToRGB whether the image is saved as RGB format.
*/
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
// Getters
inline unsigned char * getData() { return _data; }
inline int getDataLen() { return _width * _height; }
CC_SYNTHESIZE_READONLY(unsigned short, _width, Width);
CC_SYNTHESIZE_READONLY(unsigned short, _height, Height);
CC_SYNTHESIZE_READONLY(int, _bitsPerComponent, BitsPerComponent);
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:
bool _initWithJpgData(void *pData, int nDatalen);
bool _initWithPngData(void *pData, int nDatalen);
@ -173,6 +173,10 @@ protected:
bool _saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
bool _saveImageToJPG(const char *pszFilePath);
unsigned short _width;
unsigned short _height;
int _bitsPerComponent;
unsigned char *_data;
bool _hasAlpha;
bool _preMulti;

View File

@ -306,7 +306,7 @@ bool Image::_initWithJpgData(void * data, int nSize)
/* 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.
*/
CCLog("%d", bRet);
log("%d", bRet);
jpeg_destroy_decompress(&cinfo);
break;
}

View File

@ -205,7 +205,7 @@ public: virtual void set##funName(varType var) \
#define CC_BREAK_IF(cond) if(cond) break
#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
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
@ -215,15 +215,15 @@ public: virtual void set##funName(varType var) \
#define CCLOGWARN(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
#define CCLOGINFO(format,...) do {} while (0)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#elif COCOS2D_DEBUG > 1
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
#define CCLOGINFO(format,...) cocos2d::log(format, ##__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#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
#define LUALOG(...)
#else
#define LUALOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
#define LUALOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
#endif // Lua engine debug
#if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \
@ -285,4 +285,17 @@ private: \
#define CC_UNUSED
#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__

View File

@ -53,14 +53,14 @@ private:
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;
for( const tinyxml2::XMLAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
{
//CCLog("%s", attrib->Name());
//log("%s", attrib->Name());
attsVector.push_back(attrib->Name());
//CCLog("%s",attrib->Value());
//log("%s",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 )
{
//CCLog("VisitExit %s",element.Value());
//log("VisitExit %s",element.Value());
SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value());
return true;
@ -81,7 +81,7 @@ bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
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()));
return true;
}

View File

@ -32,6 +32,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char buf[MAX_LEN];
@ -44,6 +45,18 @@ void CCLog(const char * pszFormat, ...)
__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)
{
showDialogJNI(pszMsg, pszTitle);

View File

@ -28,6 +28,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char buf[MAX_LEN];
@ -40,10 +41,22 @@ void CCLog(const char * pszFormat, ...)
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)
{
// MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);
CCLog(pszMsg);
log(pszMsg);
}
void LuaLog(const char * pszFormat)

View File

@ -31,6 +31,7 @@
NS_CC_BEGIN
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
printf("Cocos2d: ");
@ -43,7 +44,19 @@ void CCLog(const char * pszFormat, ...)
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)
{
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;

View File

@ -28,6 +28,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
@ -48,9 +49,29 @@ void CCLog(const char * pszFormat, ...)
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)
{
CCLog("%s: %s", pszTitle, pszMsg);
log("%s: %s", pszTitle, pszMsg);
}
void LuaLog(const char * pszFormat)

View File

@ -325,20 +325,20 @@ bool EGLView::initGL()
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
{
CCLog("Ready for GLSL");
log("Ready for GLSL");
}
else
{
CCLog("Not totally ready :(");
log("Not totally ready :(");
}
if (glewIsSupported("GL_VERSION_2_0"))
{
CCLog("Ready for OpenGL 2.0");
log("Ready for OpenGL 2.0");
}
else
{
CCLog("OpenGL 2.0 not supported");
log("OpenGL 2.0 not supported");
}
// Enable point size by default on linux.

View File

@ -32,6 +32,7 @@
NS_CC_BEGIN
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
printf("Cocos2d: ");
@ -46,12 +47,27 @@ void CCLog(const char * pszFormat, ...)
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)
{
puts(pszFormat);
}
// ios no MessageBox, use CCLog instead
// ios no MessageBox, use log instead
void MessageBox(const char * pszMsg, const char * pszTitle)
{
NSString * title = (pszTitle) ? [NSString stringWithUTF8String : pszTitle] : nil;

View File

@ -29,6 +29,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
@ -49,14 +50,34 @@ void CCLog(const char * pszFormat, ...)
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)
{
CCLog("%s: %s", pszTitle, pszMsg);
log("%s: %s", pszTitle, pszMsg);
}
void LuaLog(const char * pszFormat)
{
CCLog("%s", pszFormat);
log("%s", pszFormat);
}
NS_CC_END

View File

@ -74,7 +74,7 @@ void CocosPepperInstance::DidChangeView(const pp::View& view)
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());
nacl_io_init_ppapi(pp_instance(),
pp::Module::Get()->get_browser_interface());

View File

@ -31,6 +31,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
@ -51,9 +52,29 @@ void CCLog(const char * pszFormat, ...)
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)
{
CCLog("%s: %s", pszTitle, pszMsg);
log("%s: %s", pszTitle, pszMsg);
}
void LuaLog(const char * pszFormat)

View File

@ -28,6 +28,7 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
@ -46,6 +47,24 @@ void CCLog(const char * pszFormat, ...)
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)
{
MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);

View File

@ -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 (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"))
{
CCLog("OpenGL: ARB_framebuffer_object is supported");
log("OpenGL: ARB_framebuffer_object is supported");
glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
@ -131,7 +131,7 @@ static bool glew_dynamic_binding()
else
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");
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
@ -152,8 +152,8 @@ static bool glew_dynamic_binding()
}
else
{
CCLog("OpenGL: No framebuffers extension is supported");
CCLog("OpenGL: Any call to Fbo will crash!");
log("OpenGL: No framebuffers extension is supported");
log("OpenGL: Any call to Fbo will crash!");
return false;
}
}
@ -228,20 +228,20 @@ bool EGLView::initGL()
if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader)
{
CCLog("Ready for GLSL");
log("Ready for GLSL");
}
else
{
CCLog("Not totally ready :(");
log("Not totally ready :(");
}
if (glewIsSupported("GL_VERSION_2_0"))
{
CCLog("Ready for OpenGL 2.0");
log("Ready for OpenGL 2.0");
}
else
{
CCLog("OpenGL 2.0 not supported");
log("OpenGL 2.0 not supported");
}
if(glew_dynamic_binding() == false)

View File

@ -383,7 +383,7 @@ bool Image::initWithString(
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

View File

@ -97,9 +97,12 @@ STATICLIBS = \
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
LIBS = -lrt -lz
HTMLTPL_DIR = $(COCOS_ROOT)/tools/emscripten-template
HTMLTPL_FILE = index.html
clean:
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
@ -108,7 +111,7 @@ clean:
ifdef 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)
cd $(dir $^) && ./$(notdir $^)

View File

@ -88,7 +88,7 @@ Animation* Animation::createWithSpriteFrames(Array *frames, float delay/* = 0.0f
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();
pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops);

View File

@ -61,18 +61,46 @@ public:
/** initializes the animation frame with a spriteframe, number of delay units and a notification user info */
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
virtual AnimationFrame *clone() const override;
protected:
/** SpriteFrameName to be used */
CC_SYNTHESIZE_RETAIN(SpriteFrame*, _spriteFrame, SpriteFrame)
SpriteFrame* _spriteFrame;
/** 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. */
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.
@since v2.0
*/
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops);
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit) {
return Animation::create(arrayOfAnimationFrameNames, delayPerUnit, 1);
}
static Animation* create(Array *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1);
Animation();
virtual ~Animation(void);
@ -140,27 +165,63 @@ public:
*/
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
virtual Animation *clone() const override;
protected:
/** total Delay units of the Animation. */
CC_SYNTHESIZE_READONLY(float, _totalDelayUnits, TotalDelayUnits)
float _totalDelayUnits;
/** 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 */
CC_PROPERTY_READONLY(float, _duration, Duration)
float _duration;
/** array of AnimationFrames */
CC_SYNTHESIZE_RETAIN(Array*, _frames, Frames)
Array* _frames;
/** 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, ... */
CC_SYNTHESIZE(unsigned int, _loops, Loops)
unsigned int _loops;
};
// end of sprite_nodes group

View File

@ -1119,7 +1119,7 @@ void Sprite::setTexture(Texture2D *texture)
}
}
Texture2D* Sprite::getTexture(void)
Texture2D* Sprite::getTexture(void) const
{
return _texture;
}

View File

@ -449,9 +449,9 @@ public:
/// @{
/// @name Functions inherited from TextureProtocol
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 const BlendFunc& getBlendFunc(void) const override { return _blendFunc; }
inline const BlendFunc& getBlendFunc() const override { return _blendFunc; }
/// @}
/// @{

View File

@ -684,7 +684,7 @@ const BlendFunc& SpriteBatchNode::getBlendFunc(void) const
return _blendFunc;
}
Texture2D* SpriteBatchNode::getTexture(void)
Texture2D* SpriteBatchNode::getTexture(void) const
{
return _textureAtlas->getTexture();
}

View File

@ -67,19 +67,13 @@ public:
/** 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.
*/
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity);
static SpriteBatchNode* createWithTexture(Texture2D* tex) {
return SpriteBatchNode::createWithTexture(tex, kDefaultSpriteBatchCapacity);
}
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = kDefaultSpriteBatchCapacity);
/** 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 file will be loaded using the TextureMgr.
*/
static SpriteBatchNode* create(const char* fileImage, int capacity);
static SpriteBatchNode* create(const char* fileImage) {
return SpriteBatchNode::create(fileImage, kDefaultSpriteBatchCapacity);
}
static SpriteBatchNode* create(const char* fileImage, int capacity = kDefaultSpriteBatchCapacity);
SpriteBatchNode();
virtual ~SpriteBatchNode();
@ -133,7 +127,7 @@ public:
// Overrides
//
// TextureProtocol
virtual Texture2D* getTexture(void) override;
virtual Texture2D* getTexture(void) const override;
virtual void setTexture(Texture2D *texture) override;
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
virtual const BlendFunc& getBlendFunc(void) const override;
@ -174,7 +168,7 @@ protected:
TextureAtlas *_textureAtlas;
BlendFunc _blendFunc;
// all descendants: children, gran children, etc...
// all descendants: children, grand children, etc...
Array* _descendants;
};

View File

@ -247,17 +247,13 @@ NotificationObserver::NotificationObserver(Object *target,
_selector = selector;
_object = obj;
_name = new char[strlen(name)+1];
memset(_name,0,strlen(name)+1);
string orig (name);
orig.copy(_name,strlen(name),0);
_name = name;
_handler = 0;
}
NotificationObserver::~NotificationObserver()
{
CC_SAFE_DELETE_ARRAY(_name);
}
void NotificationObserver::performSelector(Object *obj)
@ -282,17 +278,17 @@ SEL_CallFuncO NotificationObserver::getSelector() const
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
{
return _object;
}
int NotificationObserver::getHandler()
int NotificationObserver::getHandler() const
{
return _handler;
}

View File

@ -139,12 +139,21 @@ public:
/** Invokes the callback function of this observer */
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:
CC_PROPERTY_READONLY(Object *, _target, Target);
CC_PROPERTY_READONLY(SEL_CallFuncO, _selector, Selector);
CC_PROPERTY_READONLY(char *, _name, Name);
CC_PROPERTY_READONLY(Object *, _object, Object);
CC_PROPERTY(int, _handler,Handler);
Object* _target;
SEL_CallFuncO _selector;
std::string _name;
Object* _object;
int _handler;
};
NS_CC_END

View File

@ -91,7 +91,7 @@ void Profiler::displayTimers()
CCDICT_FOREACH(_activeTimers, pElement)
{
ProfilingTimer* timer = static_cast<ProfilingTimer*>(pElement->getObject());
CCLog("%s", timer->description());
log("%s", timer->description());
}
}

View File

@ -125,8 +125,10 @@ public:
// properties
//////////////////////////////////////////////////////////////////////////
CC_SYNTHESIZE(TextFieldDelegate *, _delegate, Delegate);
CC_SYNTHESIZE_READONLY(int, _charCount, CharCount);
inline TextFieldDelegate* getDelegate() const { return _delegate; };
inline void setDelegate(TextFieldDelegate* delegate) { _delegate = delegate; };
inline int getCharCount() const { return _charCount; };
virtual const Color3B& getColorSpaceHolder();
virtual void setColorSpaceHolder(const Color3B& color);
@ -135,6 +137,9 @@ public:
virtual void setString(const char *text);
virtual const char* getString(void) const;
protected:
TextFieldDelegate * _delegate;
int _charCount;
std::string * _inputText;
// place holder text property

View File

@ -111,7 +111,6 @@ GLuint Texture2D::getName() const
Size Texture2D::getContentSize() const
{
Size ret;
ret.width = _contentSize.width / CC_CONTENT_SCALE_FACTOR();
ret.height = _contentSize.height / CC_CONTENT_SCALE_FACTOR();
@ -124,7 +123,7 @@ const Size& Texture2D::getContentSizeInPixels()
return _contentSize;
}
GLfloat Texture2D::getMaxS()
GLfloat Texture2D::getMaxS() const
{
return _maxS;
}
@ -134,7 +133,7 @@ void Texture2D::setMaxS(GLfloat maxS)
_maxS = maxS;
}
GLfloat Texture2D::getMaxT()
GLfloat Texture2D::getMaxT() const
{
return _maxT;
}
@ -144,7 +143,7 @@ void Texture2D::setMaxT(GLfloat maxT)
_maxT = maxT;
}
GLProgram* Texture2D::getShaderProgram(void)
GLProgram* Texture2D::getShaderProgram() const
{
return _shaderProgram;
}

View File

@ -238,28 +238,60 @@ public:
bool hasPremultipliedAlpha() 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:
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
bool _PVRHaveAlphaPremultiplied;
protected:
/** pixel format of the texture */
CC_PROPERTY_READONLY(Texture2DPixelFormat, _pixelFormat, PixelFormat)
Texture2DPixelFormat _pixelFormat;
/** width in pixels */
CC_PROPERTY_READONLY(unsigned int, _pixelsWide, PixelsWide)
unsigned int _pixelsWide;
/** height in pixels */
CC_PROPERTY_READONLY(unsigned int, _pixelsHigh, PixelsHigh)
unsigned int _pixelsHigh;
/** texture name */
CC_PROPERTY_READONLY(GLuint, _name, Name)
GLuint _name;
/** texture max S */
CC_PROPERTY(GLfloat, _maxS, MaxS)
GLfloat _maxS;
/** texture max T */
CC_PROPERTY(GLfloat, _maxT, MaxT)
GLfloat _maxT;
/** content size */
CC_PROPERTY_READONLY(Size, _contentSize, ContentSize)
Size _contentSize;
/** whether or not the texture has their Alpha premultiplied */
bool _hasPremultipliedAlpha;
@ -267,7 +299,7 @@ private:
bool _hasMipmaps;
/** shader program used by drawAtPoint and drawInRect */
CC_PROPERTY(GLProgram*, _shaderProgram, ShaderProgram);
GLProgram* _shaderProgram;
};
// end of textures group

View File

@ -81,7 +81,7 @@ int TextureAtlas::getCapacity() const
return _capacity;
}
Texture2D* TextureAtlas::getTexture()
Texture2D* TextureAtlas::getTexture() const
{
return _texture;
}
@ -100,22 +100,22 @@ V3F_C4B_T2F_Quad* TextureAtlas::getQuads()
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 * TextureAtlas::create(const char* file, int capacity)
{
TextureAtlas * pTextureAtlas = new TextureAtlas();
if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity))
TextureAtlas * textureAtlas = new TextureAtlas();
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
{
pTextureAtlas->autorelease();
return pTextureAtlas;
textureAtlas->autorelease();
return textureAtlas;
}
CC_SAFE_DELETE(pTextureAtlas);
CC_SAFE_DELETE(textureAtlas);
return NULL;
}

View File

@ -187,6 +187,24 @@ public:
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:
void setupIndices();
void mapBuffers();
@ -203,16 +221,14 @@ protected:
#endif
GLuint _buffersVBO[2]; //0: vertex 1: indices
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 */
CC_PROPERTY_READONLY(int, _totalQuads, TotalQuads)
int _totalQuads;
/** 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 */
CC_PROPERTY(Texture2D *, _texture, Texture)
Texture2D* _texture;
/** Quads that are going to be rendered */
CC_PROPERTY(V3F_C4B_T2F_Quad *, _quads, Quads)
V3F_C4B_T2F_Quad* _quads;
};
// end of textures group

View File

@ -547,7 +547,7 @@ bool TexturePVR::createGLTexture()
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, &_name);
glBindTexture(GL_TEXTURE_2D, _name);
ccGLBindTexture2D(_name);
// Default: Anti alias.
if (_numberOfMipmaps == 1)

View File

@ -30,18 +30,15 @@ NS_CC_BEGIN
class PointObject : Object
{
CC_SYNTHESIZE(Point, _ratio, Ratio)
CC_SYNTHESIZE(Point, _offset, Offset)
CC_SYNTHESIZE(Node *,_child, Child) // weak ref
public:
static PointObject * pointWithPoint(Point ratio, Point offset)
static PointObject * create(Point ratio, Point offset)
{
PointObject *pRet = new PointObject();
pRet->initWithPoint(ratio, offset);
pRet->autorelease();
return pRet;
}
bool initWithPoint(Point ratio, Point offset)
{
_ratio = ratio;
@ -49,6 +46,20 @@ public:
_child = NULL;
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()
@ -56,6 +67,7 @@ ParallaxNode::ParallaxNode()
_parallaxArray = ccArrayNew(5);
_lastPosition = Point(-100,-100);
}
ParallaxNode::~ParallaxNode()
{
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)
{
CCASSERT( child != NULL, "Argument must be non-nil");
PointObject *obj = PointObject::pointWithPoint(ratio, offset);
PointObject *obj = PointObject::create(ratio, offset);
obj->setChild(child);
ccArrayAppendObjectWithResize(_parallaxArray, (Object*)obj);

View File

@ -56,6 +56,9 @@ public:
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);
/** Sets an array of layers for the Parallax node */

View File

@ -123,18 +123,6 @@ TMXLayer::~TMXLayer()
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()
{
if (_tiles)
@ -718,17 +706,5 @@ int TMXLayer::getVertexZForPos(const Point& pos)
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

View File

@ -139,6 +139,37 @@ public:
inline const char* getLayerName(){ return _layerName.c_str(); }
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
//
@ -192,19 +223,18 @@ protected:
// used for retina display
float _contentScaleFactor;
private:
/** 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) */
CC_SYNTHESIZE_PASS_BY_REF(Size, _mapTileSize, MapTileSize);
Size _mapTileSize;
/** pointer to the map of tiles */
CC_SYNTHESIZE(unsigned int*, _tiles, Tiles);
unsigned int* _tiles;
/** Tileset information for the layer */
CC_PROPERTY(TMXTilesetInfo*, _tileSet, TileSet);
TMXTilesetInfo* _tileSet;
/** 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 */
CC_PROPERTY(Dictionary*, _properties, Properties);
Dictionary* _properties;
};
// end of tilemap_parallax_nodes group

View File

@ -39,13 +39,15 @@ TMXObjectGroup::TMXObjectGroup()
_objects->retain();
_properties = new Dictionary();
}
TMXObjectGroup::~TMXObjectGroup()
{
CCLOGINFO( "cocos2d: deallocing: %p", this);
CC_SAFE_RELEASE(_objects);
CC_SAFE_RELEASE(_properties);
}
Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
Dictionary* TMXObjectGroup::getObjectNamed(const char *objectName) const
{
if (_objects && _objects->count() > 0)
{
@ -53,7 +55,7 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
CCARRAY_FOREACH(_objects, 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)
{
return pDict;
@ -63,30 +65,10 @@ Dictionary* TMXObjectGroup::objectNamed(const char *objectName)
// object not found
return NULL;
}
String* TMXObjectGroup::propertyNamed(const char* propertyName)
{
return (String*)_properties->objectForKey(propertyName);
}
Dictionary* TMXObjectGroup::getProperties()
{
return _properties;
}
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;
String* TMXObjectGroup::getPropertyNamed(const char* propertyName) const
{
return static_cast<String*>(_properties->objectForKey(propertyName));
}
NS_CC_END

View File

@ -44,12 +44,6 @@ NS_CC_BEGIN
*/
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:
TMXObjectGroup();
virtual ~TMXObjectGroup();
@ -58,15 +52,52 @@ public:
inline void setGroupName(const char *groupName){ _groupName = groupName; }
/** 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.
It will return the 1st object found on the array for the given name.
*/
Dictionary* objectNamed(const char *objectName);
protected:
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:
/** name of the group */
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

View File

@ -62,7 +62,7 @@ bool TMXTiledMap::initWithTMXFile(const char *tmxFile)
setContentSize(Size::ZERO);
TMXMapInfo *mapInfo = TMXMapInfo::formatWithTMXFile(tmxFile);
TMXMapInfo *mapInfo = TMXMapInfo::create(tmxFile);
if (! mapInfo)
{
@ -78,7 +78,7 @@ bool TMXTiledMap::initWithXML(const char* tmxString, const char* resourcePath)
{
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.");
buildWithMapInfo(mapInfo);
@ -101,30 +101,6 @@ TMXTiledMap::~TMXTiledMap()
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
TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo)
{
@ -230,7 +206,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo)
}
// public
TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
TMXLayer * TMXTiledMap::getLayer(const char *layerName) const
{
CCASSERT(layerName != NULL && strlen(layerName) > 0, "Invalid layer name!");
Object* pObj = NULL;
@ -250,7 +226,7 @@ TMXLayer * TMXTiledMap::layerNamed(const char *layerName)
return NULL;
}
TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName)
TMXObjectGroup * TMXTiledMap::getObjectGroup(const char *groupName) const
{
CCASSERT(groupName != NULL && strlen(groupName) > 0, "Invalid group name!");
@ -273,14 +249,14 @@ TMXObjectGroup * TMXTiledMap::objectGroupNamed(const char *groupName)
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));
}

View File

@ -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.
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->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.
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 property is stored as a key-value pair in an MutableDictionary.
You can obtain the properties at runtime by:
map->propertyNamed(name_of_the_property);
layer->propertyNamed(name_of_the_property);
objectGroup->propertyNamed(name_of_the_property);
object->propertyNamed(name_of_the_property);
map->getProperty(name_of_the_property);
layer->getProperty(name_of_the_property);
objectGroup->getProperty(name_of_the_property);
object->getProperty(name_of_the_property);
@since v0.8.1
*/
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:
TMXTiledMap();
virtual ~TMXTiledMap();
@ -135,22 +125,65 @@ public:
bool initWithXML(const char* tmxString, const char* resourcePath);
/** 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 */
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 */
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 */
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:
TMXLayer * parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
TMXTilesetInfo * tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo);
void buildWithMapInfo(TMXMapInfo* mapInfo);
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
Dictionary* _tileProperties;

View File

@ -35,24 +35,9 @@ THE SOFTWARE.
#include "support/base64.h"
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
/*
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)
{
if (dict)
@ -84,6 +69,7 @@ TMXLayerInfo::~TMXLayerInfo()
_tiles = NULL;
}
}
Dictionary * TMXLayerInfo::getProperties()
{
return _properties;
@ -104,10 +90,12 @@ TMXTilesetInfo::TMXTilesetInfo()
,_imageSize(Size::ZERO)
{
}
TMXTilesetInfo::~TMXTilesetInfo()
{
CCLOGINFO("cocos2d: deallocing: %p", this);
}
Rect TMXTilesetInfo::rectForGID(unsigned int gid)
{
Rect rect;
@ -123,7 +111,7 @@ Rect TMXTilesetInfo::rectForGID(unsigned int gid)
// implementation TMXMapInfo
TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile)
TMXMapInfo * TMXMapInfo::create(const char *tmxFile)
{
TMXMapInfo *pRet = new TMXMapInfo();
if(pRet->initWithTMXFile(tmxFile))
@ -135,7 +123,7 @@ TMXMapInfo * TMXMapInfo::formatWithTMXFile(const char *tmxFile)
return NULL;
}
TMXMapInfo * TMXMapInfo::formatWithXML(const char* tmxString, const char* resourcePath)
TMXMapInfo * TMXMapInfo::createWithXML(const char* tmxString, const char* resourcePath)
{
TMXMapInfo *pRet = new TMXMapInfo();
if(pRet->initWithXML(tmxString, resourcePath))
@ -214,66 +202,6 @@ TMXMapInfo::~TMXMapInfo()
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)
{
int len = strlen(xmlString);
@ -768,7 +696,7 @@ void TMXMapInfo::textHandler(void *ctx, const char *ch, int len)
TMXMapInfo *pTMXMapInfo = this;
std::string pText((char*)ch,0,len);
if (pTMXMapInfo->getStoringCharacters())
if (pTMXMapInfo->isStoringCharacters())
{
std::string currentString = pTMXMapInfo->getCurrentString();
currentString += pText;

View File

@ -151,35 +151,19 @@ This information is obtained from the TMX file.
class CC_DLL TMXMapInfo : public Object, public SAXDelegator
{
public:
/// map orientation
CC_SYNTHESIZE(int, _orientation, Orientation);
/// map width & height
CC_SYNTHESIZE_PASS_BY_REF(Size, _mapSize, MapSize);
/// tiles width & height
CC_SYNTHESIZE_PASS_BY_REF(Size, _tileSize, TileSize);
/// Layers
CC_PROPERTY(Array*, _layers, Layers);
/// tilesets
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:
/** creates a TMX Format with a tmx file */
static TMXMapInfo * create(const char *tmxFile);
/** creates a TMX Format with an XML string and a TMX resource path */
static TMXMapInfo * createWithXML(const char* tmxString, const char* resourcePath);
/** creates a TMX Format with a tmx file */
CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithTMXFile(const char *tmxFile) { return TMXMapInfo::create(tmxFile); };
/** creates a TMX Format with an XML string and a TMX resource path */
CC_DEPRECATED_ATTRIBUTE static TMXMapInfo * formatWithXML(const char* tmxString, const char* resourcePath) { return TMXMapInfo::createWithXML(tmxString, resourcePath); };
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 */
bool initWithTMXFile(const char *tmxFile);
/** initializes a TMX format with an XML string and a TMX resource path */
@ -189,9 +173,74 @@ public:
/* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
bool parseXMLString(const char *xmlString);
Dictionary* getTileProperties();
void setTileProperties(Dictionary* tileProperties);
Dictionary* getTileProperties() { return _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
void startElement(void *ctx, const char *name, const char **atts);
void endElement(void *ctx, const char *name);
@ -204,6 +253,30 @@ public:
private:
void internalInit(const char* tmxFileName, const char* resourcePath);
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
std::string _TMXFileName;
// tmx resource path

View File

@ -264,14 +264,5 @@ void TileMapAtlas::updateAtlasValues()
}
}
void TileMapAtlas::setTGAInfo(struct sImageTGA* var)
{
_TGAInfo = var;
}
struct sImageTGA * TileMapAtlas::getTGAInfo()
{
return _TGAInfo;
}
NS_CC_END

View File

@ -80,6 +80,9 @@ public:
void setTile(const Color3B& tile, const Point& position);
/** dealloc the map from memory */
void releaseMap();
inline struct sImageTGA* getTGAInfo() const { return _TGAInfo; };
inline void setTGAInfo(struct sImageTGA* TGAInfo) { _TGAInfo = TGAInfo; };
private:
void loadTGAfile(const char *file);
void calculateItemsToRender();
@ -91,10 +94,8 @@ protected:
Dictionary* _posToAtlasIndex;
//! numbers of tiles to render
int _itemsToRender;
private:
/** TileMap info */
CC_PROPERTY(struct sImageTGA*, _TGAInfo, TGAInfo);
struct sImageTGA* _TGAInfo;
};
// end of tilemap_parallax_nodes group

View File

@ -157,7 +157,7 @@ Color4B Texture2DMutable::pixelAt(const Point& pt)
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;
}

View File

@ -92,7 +92,7 @@ void SpriteFrameCacheHelper::addSpriteFrameFromDict(Dictionary *dictionary, Text
_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());
if (spriteFrame)

View File

@ -382,7 +382,7 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
}
else
{
CCLog("CCBReader: Failed to create animation for property: %s", pPropName);
log("CCBReader: Failed to create animation for property: %s", pPropName);
}
return NULL;
@ -482,7 +482,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
}
else
{
CCLog("unsupported property name is %s", pPropName);
log("unsupported property name is %s", pPropName);
CCASSERT(false, "unsupported property now");
}
}
@ -573,7 +573,7 @@ ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, int
}
else
{
CCLog("CCBReader: Unkown easing type %d", nEasingType);
log("CCBReader: Unkown easing type %d", nEasingType);
return pAction;
}
}

View File

@ -396,7 +396,7 @@ bool CCBReader::readHeader()
/* Read version. */
int version = this->readInt(false);
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;
}
@ -563,7 +563,7 @@ Node * CCBReader::readNodeGraph(Node * pParent) {
if (! ccNodeLoader)
{
CCLog("no corresponding node loader for %s", className.c_str());
log("no corresponding node loader for %s", className.c_str());
return NULL;
}

View File

@ -437,7 +437,7 @@ Size NodeLoader::parsePropTypeSize(Node * pNode, Node * pParent, CCBReader * pCC
}
default:
{
CCLog("Unknown CCB type.");
log("Unknown CCB type.");
}
break;
}

View File

@ -20,8 +20,8 @@ NS_CC_EXT_BEGIN
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
#define PROPERTY_VISIBLE "visible"
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("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_PROPERTY(PROPERTY) cocos2d::log("Unexpected property: '%s'!\n", PROPERTY); 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) { \
return T::create(); \

View File

@ -160,7 +160,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo
// If there is no specified center region
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);
}
@ -223,7 +223,7 @@ bool Scale9Sprite::updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bo
Rect rightbottombounds = Rect(x, y, right_w, bottom_h);
if (!rotated) {
// CCLog("!rotated");
// log("!rotated");
AffineTransform t = AffineTransformMakeIdentity();
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
// to handle the case where the sprite is stored rotated
// in the spritesheet
// CCLog("rotated");
// log("rotated");
AffineTransform t = AffineTransformMakeIdentity();
@ -611,7 +611,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameNam
}
CC_SAFE_DELETE(pReturn);
CCLog("Could not allocate Scale9Sprite()");
log("Could not allocate Scale9Sprite()");
return NULL;
}

View File

@ -494,18 +494,18 @@ void TableView::scrollViewDidScroll(ScrollView* view)
CCARRAY_FOREACH(_cellsUsed, 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++;
}
CCLog("---------------------------------------");
log("---------------------------------------");
i = 0;
CCARRAY_FOREACH(_cellsFreed, 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++;
}
CCLog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
#endif
if (_cellsUsed->count() > 0)

View File

@ -477,7 +477,7 @@ void HttpClient::send(HttpRequest* request)
// Poll and notify main thread if responses exists in queue
void HttpClient::dispatchResponseCallbacks(float delta)
{
// CCLog("CCHttpClient::dispatchResponseCallbacks is running");
// log("CCHttpClient::dispatchResponseCallbacks is running");
HttpResponse* response = NULL;

View File

@ -114,7 +114,7 @@ SIOClientImpl::~SIOClientImpl() {
}
void SIOClientImpl::handshake() {
CCLog("SIOClientImpl::handshake() called");
log("SIOClientImpl::handshake() called");
std::stringstream pre;
pre << "http://" << _uri << "/socket.io/1";
@ -126,7 +126,7 @@ void SIOClientImpl::handshake() {
request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse));
request->setTag("handshake");
CCLog("SIOClientImpl::handshake() waiting");
log("SIOClientImpl::handshake() waiting");
HttpClient::getInstance()->send(request);
@ -137,22 +137,22 @@ void SIOClientImpl::handshake() {
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) {
CCLog("SIOClientImpl::handshakeResponse() called");
log("SIOClientImpl::handshakeResponse() called");
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s completed", response->getHttpRequest()->getTag());
log("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
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())
{
CCLog("SIOClientImpl::handshake() failed");
CCLog("error buffer: %s", response->getErrorBuffer());
log("SIOClientImpl::handshake() failed");
log("error buffer: %s", response->getErrorBuffer());
DictElement* el = NULL;
@ -167,7 +167,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
return;
}
CCLog("SIOClientImpl::handshake() succeeded");
log("SIOClientImpl::handshake() succeeded");
std::vector<char> *buffer = response->getResponseData();
std::stringstream s;
@ -177,7 +177,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
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 sid;
@ -212,7 +212,7 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
void SIOClientImpl::openSocket() {
CCLog("SIOClientImpl::openSocket() called");
log("SIOClientImpl::openSocket() called");
std::stringstream s;
s << _uri << "/socket.io/1/websocket/" << _sid;
@ -228,7 +228,7 @@ void SIOClientImpl::openSocket() {
bool SIOClientImpl::init() {
CCLog("SIOClientImpl::init() successful");
log("SIOClientImpl::init() successful");
return true;
}
@ -247,7 +247,7 @@ void SIOClientImpl::disconnect() {
_ws->send(s);
CCLog("Disconnect sent");
log("Disconnect sent");
_ws->close();
@ -303,7 +303,7 @@ void SIOClientImpl::disconnectFromEndpoint(const std::string& 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();
@ -325,7 +325,7 @@ void SIOClientImpl::heartbeat(float dt) {
_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();
CCLog("sending message: %s", msg.c_str());
log("sending message: %s", msg.c_str());
_ws->send(msg);
@ -355,7 +355,7 @@ void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::strin
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);
@ -379,13 +379,13 @@ void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) {
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) {
CCLog("SIOClientImpl::onMessage received: %s", data.bytes);
log("SIOClientImpl::onMessage received: %s", data.bytes);
int control = atoi(&data.bytes[0]);
@ -422,31 +422,31 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
s_data = payload;
SIOClient *c = NULL;
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) {
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();
disconnectFromEndpoint(endpoint);
break;
case 1:
CCLog("Connected to endpoint: %s \n",endpoint.c_str());
log("Connected to endpoint: %s \n",endpoint.c_str());
if(c) c->onConnect();
break;
case 2:
CCLog("Heartbeat received\n");
log("Heartbeat received\n");
break;
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);
break;
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);
break;
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) {
eventname = "";
@ -463,14 +463,14 @@ void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::
break;
case 6:
CCLog("Message Ack\n");
log("Message Ack\n");
break;
case 7:
CCLog("Error\n");
log("Error\n");
if(c) c->getDelegate()->onError(c, s_data);
break;
case 8:
CCLog("Noop\n");
log("Noop\n");
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) {
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]) {
@ -601,7 +601,7 @@ void SIOClient::fireEvent(const std::string& eventName, const std::string& data)
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());
}

View File

@ -216,31 +216,31 @@ void TestAds::caseChanged(Object* pSender)
default:
break;
}
CCLog("case selected change to : %s", strLog.c_str());
log("case selected change to : %s", strLog.c_str());
}
void TestAds::typeChanged(Object* pSender)
{
int selectIndex = _typeItem->getSelectedIndex();
_type = (ProtocolAds::AdsType) selectIndex;
CCLog("type selected change to : %d", _type);
log("type selected change to : %d", _type);
}
void TestAds::posChanged(Object* pSender)
{
int selectIndex = _posItem->getSelectedIndex();
_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)
{
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)
{
CCLog("Player get points : %d", points);
log("Player get points : %d", points);
// @warning should add code to give game-money to player here

View File

@ -153,7 +153,7 @@ void TestAnalytics::eventMenuCallback(Object* pSender)
case TAG_LOG_ONLINE_CONFIG:
{
PluginParam param("abc");
CCLog("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", &param, NULL).c_str());
log("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", &param, NULL).c_str());
}
break;
case TAG_LOG_EVENT_ID_DURATION:
@ -259,7 +259,7 @@ void TestAnalytics::loadPlugins()
_pluginAnalytics->setSessionContinueMillis(10000);
const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str();
CCLog("SDK version : %s", sdkVer);
log("SDK version : %s", sdkVer);
_pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL);

View File

@ -170,6 +170,6 @@ void MyIAPOnlineResult::onPayResult(PayResultCode ret, const char* msg, TProduct
MessageBox(goodInfo , msg);
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!");
}
}

View File

@ -215,8 +215,8 @@ void MyUserActionResult::onActionResult(ProtocolUser* pPlugin, UserActionResultC
// get session ID
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";
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());
}

View File

@ -32,14 +32,14 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
Director *pDirector = Director::getInstance();
pDirector->setOpenGLView(EGLView::getInstance());
Director *director = Director::getInstance();
director->setOpenGLView(EGLView::getInstance());
// 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
pDirector->setAnimationInterval(1.0 / 60);
director->setAnimationInterval(1.0 / 60);
ScriptingCore* sc = ScriptingCore::getInstance();
sc->addRegisterCallback(register_all_cocos2dx);
@ -52,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching()
scene->addChild(updateLayer);
updateLayer->release();
pDirector->runWithScene(scene);
director->runWithScene(scene);
return true;
}

View File

@ -19,17 +19,17 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* pDirector = Director::getInstance();
EGLView* pEGLView = EGLView::getInstance();
Director* director = Director::getInstance();
EGLView* glView = EGLView::getInstance();
pDirector->setOpenGLView(pEGLView);
director->setOpenGLView(glView);
Size size = pDirector->getWinSize();
Size size = director->getWinSize();
// 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;
@ -43,37 +43,37 @@ bool AppDelegate::applicationDidFinishLaunching() {
{
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.
else if (frameSize.height > smallResource.size.height)
{
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.
else
{
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
FileUtils::getInstance()->setSearchPaths(searchPath);
// 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
pDirector->setAnimationInterval(1.0 / 60);
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
Scene *scene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
director->runWithScene(scene);
return true;
}

View File

@ -36,18 +36,18 @@ bool HelloWorld::init()
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create(
MenuItemImage *closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition(Point::ZERO);
this->addChild(pMenu, 1);
Menu* menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
@ -55,23 +55,23 @@ bool HelloWorld::init()
// add a label shows "Hello World"
// 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
pLabel->setPosition(Point(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
label->setPosition(Point(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(pLabel, 1);
this->addChild(label, 1);
// 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
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
this->addChild(pSprite, 0);
this->addChild(sprite, 0);
return true;
}

View File

@ -26,9 +26,9 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
ifeq ($(shell uname -s),Darwin)
ARIEL_TTF := /Library/Fonts/Arial.ttf
ARIAL_TTF := /Library/Fonts/Arial.ttf
else
ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
ARIAL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
endif
$(TARGET).data:
@ -39,15 +39,16 @@ $(TARGET).data:
(cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP))
(cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts)
# 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)
mv $(RESTMP)/$(EXECUTABLE).data $@
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
rm -rf $(RESTMP)
$(BIN_DIR)/index.html: index.html
$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE)
@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)
@mkdir -p $(@D)

View File

@ -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
&nbsp;&nbsp;&nbsp;
<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, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//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>

View File

@ -14,9 +14,9 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director *pDirector = Director::getInstance();
Director *director = Director::getInstance();
pDirector->setOpenGLView(EGLView::getInstance());
director->setOpenGLView(EGLView::getInstance());
Size screenSize = EGLView::getInstance()->getFrameSize();
Size designSize = Size(480, 320);
@ -26,12 +26,12 @@ bool AppDelegate::applicationDidFinishLaunching() {
{
searchPaths.push_back("hd");
searchPaths.push_back("sd");
pDirector->setContentScaleFactor(640.0f/designSize.height);
director->setContentScaleFactor(640.0f/designSize.height);
}
else
{
searchPaths.push_back("sd");
pDirector->setContentScaleFactor(320.0f/designSize.height);
director->setContentScaleFactor(320.0f/designSize.height);
}
FileUtils::getInstance()->setSearchPaths(searchPaths);
@ -39,16 +39,16 @@ bool AppDelegate::applicationDidFinishLaunching() {
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
// 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
pDirector->setAnimationInterval(1.0 / 60);
director->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
Scene *scene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
director->runWithScene(scene);
return true;
}

View File

@ -69,26 +69,26 @@ bool HelloWorld::init()
// 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.
MenuItemImage *pCloseItem = MenuItemImage::create(
MenuItemImage *closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
CC_BREAK_IF(! pCloseItem);
CC_BREAK_IF(! closeItem);
// Place the menu item bottom-right conner.
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
pCloseItem->setPosition(Point(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2,
origin.y + pCloseItem->getContentSize().height/2));
closeItem->setPosition(Point(origin.x + visibleSize.width - closeItem->getContentSize().width/2,
origin.y + closeItem->getContentSize().height/2));
// Create a menu with the "close" menu item, it's an auto release object.
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition(Point::ZERO);
CC_BREAK_IF(! pMenu);
Menu* menu = Menu::create(closeItem, NULL);
menu->setPosition(Point::ZERO);
CC_BREAK_IF(! menu);
// Add the menu to HelloWorld layer as a child layer.
this->addChild(pMenu, 1);
this->addChild(menu, 1);
/////////////////////////////
// 2. add your codes below...
@ -193,7 +193,7 @@ void HelloWorld::ccTouchesEnded(Set* touches, Event* event)
Touch* touch = (Touch*)( touches->anyObject() );
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
Size winSize = Director::getInstance()->getVisibleSize();

View File

@ -57,9 +57,10 @@ $(TARGET).data:
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js
rm -rf $(RESTMP)
$(BIN_DIR)/index.html: index.html
$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE)
@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)
@mkdir -p $(@D)

View File

@ -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
&nbsp;&nbsp;&nbsp;
<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, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//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>

View File

@ -85,9 +85,9 @@ void AccelerometerTest::didAccelerate(Acceleration* pAccelerationValue)
//------------------------------------------------------------------
void AccelerometerTestScene::runThisTest()
{
Layer* pLayer = new AccelerometerTest();
addChild(pLayer);
pLayer->release();
Layer* layer = new AccelerometerTest();
addChild(layer);
layer->release();
Director::getInstance()->replaceScene(this);
}

View File

@ -36,10 +36,10 @@ Layer* nextActionManagerAction()
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
Layer* pLayer = createActionManagerLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createActionManagerLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* backActionManagerAction()
@ -49,18 +49,18 @@ Layer* backActionManagerAction()
if( sceneIdx < 0 )
sceneIdx += total;
Layer* pLayer = createActionManagerLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createActionManagerLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* restartActionManagerAction()
{
Layer* pLayer = createActionManagerLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createActionManagerLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
//------------------------------------------------------------------
@ -117,7 +117,7 @@ void CrashTest::onEnter()
{
ActionManagerTest::onEnter();
Sprite* child = Sprite::create(s_pPathGrossini);
Sprite* child = Sprite::create(s_pathGrossini);
child->setPosition( VisibleRect::center() );
addChild(child, 1);
@ -158,7 +158,7 @@ void LogicTest::onEnter()
{
ActionManagerTest::onEnter();
Sprite* grossini = Sprite::create(s_pPathGrossini);
Sprite* grossini = Sprite::create(s_pathGrossini);
addChild(grossini, 0, 2);
grossini->setPosition(VisibleRect::center());
@ -203,14 +203,14 @@ void PauseTest::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);
grossini->setPosition(VisibleRect::center() );
Action* action = MoveBy::create(1, Point(150,0));
Director* pDirector = Director::getInstance();
pDirector->getActionManager()->addAction(action, grossini, true);
Director* director = Director::getInstance();
director->getActionManager()->addAction(action, grossini, true);
schedule( schedule_selector(PauseTest::unpause), 3);
}
@ -219,8 +219,8 @@ void PauseTest::unpause(float dt)
{
unschedule( schedule_selector(PauseTest::unpause) );
Node* node = getChildByTag( kTagGrossini );
Director* pDirector = Director::getInstance();
pDirector->getActionManager()->resumeTarget(node);
Director* director = Director::getInstance();
director->getActionManager()->resumeTarget(node);
}
std::string PauseTest::title()
@ -246,7 +246,7 @@ void RemoveTest::onEnter()
ActionInterval* pSequence = Sequence::create(pMove, pCallback, NULL);
pSequence->setTag(kTagSequence);
Sprite* pChild = Sprite::create(s_pPathGrossini);
Sprite* pChild = Sprite::create(s_pathGrossini);
pChild->setPosition( VisibleRect::center() );
addChild(pChild, 1, kTagGrossini);
@ -255,8 +255,8 @@ void RemoveTest::onEnter()
void RemoveTest::stopAction()
{
Node* pSprite = getChildByTag(kTagGrossini);
pSprite->stopActionByTag(kTagSequence);
Node* sprite = getChildByTag(kTagGrossini);
sprite->stopActionByTag(kTagSequence);
}
std::string RemoveTest::title()
@ -282,14 +282,14 @@ void ResumeTest::onEnter()
addChild(l);
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);
pGrossini->setPosition(VisibleRect::center());
pGrossini->runAction(ScaleBy::create(2, 2));
Director* pDirector = Director::getInstance();
pDirector->getActionManager()->pauseTarget(pGrossini);
Director* director = Director::getInstance();
director->getActionManager()->pauseTarget(pGrossini);
pGrossini->runAction(RotateBy::create(2, 360));
this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f);
@ -300,8 +300,8 @@ void ResumeTest::resumeGrossini(float time)
this->unschedule(schedule_selector(ResumeTest::resumeGrossini));
Node* pGrossini = getChildByTag(kTagGrossini);
Director* pDirector = Director::getInstance();
pDirector->getActionManager()->resumeTarget(pGrossini);
Director* director = Director::getInstance();
director->getActionManager()->resumeTarget(pGrossini);
}
//------------------------------------------------------------------
@ -311,8 +311,8 @@ void ResumeTest::resumeGrossini(float time)
//------------------------------------------------------------------
void ActionManagerTestScene::runThisTest()
{
Layer* pLayer = nextActionManagerAction();
addChild(pLayer);
Layer* layer = nextActionManagerAction();
addChild(layer);
Director::getInstance()->replaceScene(this);
}

View File

@ -552,10 +552,10 @@ Layer* nextEaseAction()
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
Layer* pLayer = createEaseLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createEaseLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* backEaseAction()
@ -565,18 +565,18 @@ Layer* backEaseAction()
if( sceneIdx < 0 )
sceneIdx += total;
Layer* pLayer = createEaseLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createEaseLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* restartEaseAction()
{
Layer* pLayer = createEaseLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createEaseLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
@ -609,9 +609,9 @@ void EaseSpriteDemo::onEnter()
BaseTest::onEnter();
// 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();
_tamara = Sprite::create(s_pPathSister1); _tamara->retain();
_kathia = Sprite::create(s_pPathSister2); _kathia->retain();
_grossini = Sprite::create(s_pathGrossini); _grossini->retain();
_tamara = Sprite::create(s_pathSister1); _tamara->retain();
_kathia = Sprite::create(s_pathSister2); _kathia->retain();
addChild( _grossini, 3);
addChild( _kathia, 2);
@ -649,8 +649,8 @@ void EaseSpriteDemo::backCallback(Object* pSender)
void ActionsEaseTestScene::runThisTest()
{
Layer* pLayer = nextEaseAction();
addChild(pLayer);
Layer* layer = nextEaseAction();
addChild(layer);
Director::getInstance()->replaceScene(this);
}

View File

@ -30,10 +30,10 @@ Layer* nextAction()
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
Layer* pLayer = createLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* backAction()
@ -43,18 +43,18 @@ Layer* backAction()
if( sceneIdx < 0 )
sceneIdx += total;
Layer* pLayer = createLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
Layer* restartAction()
{
Layer* pLayer = createLayer(sceneIdx);
pLayer->autorelease();
Layer* layer = createLayer(sceneIdx);
layer->autorelease();
return pLayer;
return layer;
}
@ -135,13 +135,13 @@ void SpriteProgressToRadial::onEnter()
ProgressTo *to1 = 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 );
addChild(left);
left->setPosition(Point(100, s.height/2));
left->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathBlock));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
right->setType(kProgressTimerTypeRadial);
// Makes the ridial CCW
right->setReverseProgress(true);
@ -170,7 +170,7 @@ void SpriteProgressToHorizontal::onEnter()
ProgressTo *to1 = 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);
// Setup for a bar starting from the left since the midpoint is 0 for the x
left->setMidpoint(Point(0,0));
@ -180,7 +180,7 @@ void SpriteProgressToHorizontal::onEnter()
left->setPosition(Point(100, s.height/2));
left->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar);
// Setup for a bar starting from the left since the midpoint is 1 for the x
right->setMidpoint(Point(1, 0));
@ -210,7 +210,7 @@ void SpriteProgressToVertical::onEnter()
ProgressTo *to1 = 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);
// 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->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathSister2));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0, 1));
@ -253,7 +253,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
/**
* 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);
addChild(left);
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
*/
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pPathBlock));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
right->setType(kProgressTimerTypeRadial);
right->setMidpoint(Point(0.75f, 0.25f));
@ -294,7 +294,7 @@ void SpriteProgressBarVarious::onEnter()
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);
// 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->runAction(RepeatForever::create(to->clone()));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pPathSister2));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
middle->setType(kProgressTimerTypeBar);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Point(0.5f, 0.5f));
@ -315,7 +315,7 @@ void SpriteProgressBarVarious::onEnter()
middle->setPosition(Point(s.width/2, s.height/2));
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);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0.5f, 0.5f));
@ -351,7 +351,7 @@ void SpriteProgressBarTintAndFade::onEnter()
FadeTo::create(1.0f, 255),
NULL);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pPathSister1));
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType(kProgressTimerTypeBar);
// 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));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pPathSister2));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
middle->setType(kProgressTimerTypeBar);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Point(0.5f, 0.5f));
@ -378,7 +378,7 @@ void SpriteProgressBarTintAndFade::onEnter()
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);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0.5f, 0.5f));

View File

@ -61,11 +61,11 @@ static Layer* nextAction()
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
Layer* pLayer = (createFunctions[sceneIdx])();
pLayer->init();
pLayer->autorelease();
Layer* layer = (createFunctions[sceneIdx])();
layer->init();
layer->autorelease();
return pLayer;
return layer;
}
static Layer* backAction()
@ -75,20 +75,20 @@ static Layer* backAction()
if( sceneIdx < 0 )
sceneIdx += total;
Layer* pLayer = (createFunctions[sceneIdx])();
pLayer->init();
pLayer->autorelease();
Layer* layer = (createFunctions[sceneIdx])();
layer->init();
layer->autorelease();
return pLayer;
return layer;
}
static Layer* restartAction()
{
Layer* pLayer = (createFunctions[sceneIdx])();
pLayer->init();
pLayer->autorelease();
Layer* layer = (createFunctions[sceneIdx])();
layer->init();
layer->autorelease();
return pLayer;
return layer;
}
void ActionsTestScene::runThisTest()
@ -115,13 +115,13 @@ void ActionsDemo::onEnter()
BaseTest::onEnter();
// 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();
_tamara = Sprite::create(s_pPathSister1);
_tamara = Sprite::create(s_pathSister1);
_tamara->retain();
_kathia = Sprite::create(s_pPathSister2);
_kathia = Sprite::create(s_pathSister2);
_kathia->retain();
addChild(_grossini, 1);
@ -1254,8 +1254,8 @@ void ActionOrbit::onEnter()
auto move = MoveBy::create(3, Point(100,-100));
auto move_back = move->reverse();
auto seq = Sequence::create(move, move_back, NULL);
auto rfe = RepeatForever::create(seq);
auto seq = Sequence::create(move, move_back, NULL);
auto rfe = RepeatForever::create(seq);
_kathia->runAction(rfe);
_tamara->runAction(rfe->clone() );
_grossini->runAction( rfe->clone() );
@ -1279,10 +1279,10 @@ void ActionFollow::onEnter()
auto s = Director::getInstance()->getWinSize();
_grossini->setPosition(Point(-200, s.height / 2));
auto move = MoveBy::create(2, Point(s.width * 3, 0));
auto move = MoveBy::create(2, Point(s.width * 3, 0));
auto move_back = move->reverse();
auto seq = Sequence::create(move, move_back, NULL);
auto rep = RepeatForever::create(seq);
auto seq = Sequence::create(move, move_back, NULL);
auto rep = RepeatForever::create(seq);
_grossini->runAction(rep);
@ -1313,7 +1313,7 @@ void ActionTargeted::onEnter()
auto jump1 = JumpBy::create(2,Point::ZERO,100,3);
auto jump2 = jump1->clone();
auto rot1 = RotateBy::create(1, 360);
auto rot1 = RotateBy::create(1, 360);
auto rot2 = rot1->clone();
auto t1 = TargetedAction::create(_kathia, jump2);
@ -1510,7 +1510,6 @@ void ActionCatmullRomStacked::onEnter()
_tamara->runAction(seq);
_tamara->runAction(
RepeatForever::create(
Sequence::create(
@ -1547,7 +1546,6 @@ void ActionCatmullRomStacked::onEnter()
MoveBy::create(0.05f, Point(-10,0)),
NULL)));
array->retain();
_array1 = array;
array2->retain();
@ -1704,7 +1702,7 @@ void Issue1305::onEnter()
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()
@ -1775,22 +1773,22 @@ void Issue1305_2::onEnter()
void Issue1305_2::printLog1()
{
CCLog("1st block");
log("1st block");
}
void Issue1305_2::printLog2()
{
CCLog("2nd block");
log("2nd block");
}
void Issue1305_2::printLog3()
{
CCLog("3rd block");
log("3rd block");
}
void Issue1305_2::printLog4()
{
CCLog("4th block");
log("4th block");
}
std::string Issue1305_2::title()
@ -1889,14 +1887,14 @@ std::string Issue1327::subtitle()
void Issue1327::logSprRotation(Sprite* pSender)
{
CCLog("%f", pSender->getRotation());
log("%f", pSender->getRotation());
}
//Issue1398
void Issue1398::incrementInteger()
{
_testInteger++;
CCLog("incremented to %d", _testInteger);
log("incremented to %d", _testInteger);
}
void Issue1398::onEnter()
@ -1905,7 +1903,7 @@ void Issue1398::onEnter()
this->centerSprites(0);
_testInteger = 0;
CCLog("testInt = %d", _testInteger);
log("testInt = %d", _testInteger);
this->runAction(
Sequence::create(
@ -1923,7 +1921,7 @@ void Issue1398::onEnter()
void Issue1398::incrementIntegerCallback(void* data)
{
this->incrementInteger();
CCLog("%s", (char*)data);
log("%s", (char*)data);
}
std::string Issue1398::subtitle()
@ -2153,7 +2151,7 @@ string PauseResumeActions::subtitle()
void PauseResumeActions::pause(float dt)
{
CCLog("Pausing");
log("Pausing");
Director *director = Director::getInstance();
CC_SAFE_RELEASE(_pausedTargets);
@ -2163,7 +2161,7 @@ void PauseResumeActions::pause(float dt)
void PauseResumeActions::resume(float dt)
{
CCLog("Resuming");
log("Resuming");
Director *director = Director::getInstance();
director->getActionManager()->resumeTargets(_pausedTargets);
}

View File

@ -27,8 +27,11 @@ bool AppDelegate::applicationDidFinishLaunching()
Configuration::getInstance()->loadConfigFile("configs/config-example.plist");
// initialize director
Director *pDirector = Director::getInstance();
pDirector->setOpenGLView(EGLView::getInstance());
Director *director = Director::getInstance();
director->setOpenGLView(EGLView::getInstance());
director->setDisplayStats(true);
director->setAnimationInterval(1.0 / 60);
Size screenSize = EGLView::getInstance()->getFrameSize();
@ -42,17 +45,17 @@ bool AppDelegate::applicationDidFinishLaunching()
std::vector<std::string> searchPaths;
searchPaths.push_back("hd");
pFileUtils->setSearchPaths(searchPaths);
pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
director->setContentScaleFactor(resourceSize.height/designSize.height);
}
EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);
Scene * pScene = Scene::create();
Layer * pLayer = new TestController();
pLayer->autorelease();
auto scene = Scene::create();
auto layer = new TestController();
layer->autorelease();
pScene->addChild(pLayer);
pDirector->runWithScene(pScene);
scene->addChild(layer);
director->runWithScene(scene);
return true;
}

Some files were not shown because too many files have changed in this diff Show More