From 96a177bd37be15118c1dd40095aba33d8e7fdc13 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 09:34:42 +0800 Subject: [PATCH 1/8] issue #1190: updated some pkg files for lua binding. --- HelloLua/Resources/hello.lua | 16 +-- HelloLua/proj.win32/HelloLua.win32.vcproj | 4 +- HelloLua/proj.win32/main.cpp | 40 +++++--- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 2 +- cocos2dx/CCScheduler.cpp | 8 ++ cocos2dx/include/ccConfig.h | 2 +- cocos2dx/platform/win32/CCCommon.cpp | 5 + .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCAction.pkg | 2 - tools/tolua++/CCActionManager.pkg | 20 ++-- tools/tolua++/CCAffineTransform.pkg | 12 +-- tools/tolua++/CCAnimation.pkg | 59 ++++++++--- tools/tolua++/CCApplication.pkg | 2 +- tools/tolua++/CCArray.pkg | 98 ++++++++++++------- tools/tolua++/CCDictionary.pkg | 29 ++++++ tools/tolua++/CCDirector.pkg | 6 ++ tools/tolua++/CCMotionStreak.pkg | 28 ++++-- tools/tolua++/CCMutableArray.pkg | 39 -------- tools/tolua++/CCMutableDictionary.pkg | 26 ----- tools/tolua++/CCParticleSystem.pkg | 3 - tools/tolua++/CCRenderTexture.pkg | 10 +- tools/tolua++/CCScheduler.pkg | 1 - tools/tolua++/CCSpriteBatchNode.pkg | 2 - tools/tolua++/CCString.pkg | 43 ++++++-- tools/tolua++/CCTouch.pkg | 6 +- tools/tolua++/Cocos2d.pkg | 37 ++++--- tools/tolua++/basic.lua | 3 +- 27 files changed, 300 insertions(+), 205 deletions(-) create mode 100644 tools/tolua++/CCDictionary.pkg delete mode 100644 tools/tolua++/CCMutableArray.pkg delete mode 100644 tools/tolua++/CCMutableDictionary.pkg diff --git a/HelloLua/Resources/hello.lua b/HelloLua/Resources/hello.lua index 7126baced9..83501cdaf6 100644 --- a/HelloLua/Resources/hello.lua +++ b/HelloLua/Resources/hello.lua @@ -30,12 +30,13 @@ local function creatDog() spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) - local animFrames = CCMutableArray_CCSpriteFrame__:new(2) + local animFrames = CCArray:new(2) + animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:animationWithFrames(animFrames, 0.5) - local animate = CCAnimate:actionWithAnimation(animation, false); + local animation = CCAnimation:animationWithSpriteFrames(animFrames, 0.5) + local animate = CCAnimate:actionWithAnimation(animation); spriteDog:runAction(CCRepeatForever:actionWithAction(animate)) -- moving dog at every frame @@ -47,10 +48,11 @@ local function creatDog() else x = x + 1 end + spriteDog:setPositionX(x) end - CCScheduler:sharedScheduler():scheduleScriptFunc(tick, 0, false) + CCDirector:sharedDirector():getScheduler():scheduleScriptFunc(tick, 0, false) return spriteDog end @@ -110,7 +112,7 @@ local function createLayerFram() end local function onTouchEnded(x, y) - cclog("onTouchEnded") + cclog("onTouchEnded: %0.2f, %0.2f", x, y) touchBeginPoint = nil spriteDog.isPaused = false end @@ -151,7 +153,7 @@ local function createLayerMenu() end -- add a popup menu - local menuPopupItem = CCMenuItemImage:itemFromNormalImage("menu2.png", "menu2.png") + local menuPopupItem = CCMenuItemImage:itemWithNormalImage("menu2.png", "menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptHandler(menuCallbackClosePopup) menuPopup = CCMenu:menuWithItem(menuPopupItem) @@ -160,7 +162,7 @@ local function createLayerMenu() layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:itemFromNormalImage("menu1.png", "menu1.png") + local menuToolsItem = CCMenuItemImage:itemWithNormalImage("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptHandler(menuCallbackOpenPopup) menuTools = CCMenu:menuWithItem(menuToolsItem) diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index 739943ab50..b6eb719bba 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -49,7 +49,7 @@ *m_pfnSelector)(m_fElapsed); } + if (m_nScriptHandler) + { + CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed); + } m_fElapsed = m_fElapsed - m_fDelay; m_nTimesExecuted+=1; m_bUseDelay = false; @@ -192,6 +196,10 @@ void CCTimer::update(ccTime dt) { (m_pTarget->*m_pfnSelector)(m_fElapsed); } + if (m_nScriptHandler) + { + CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed); + } m_fElapsed = 0; m_nTimesExecuted += 1; diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index b1eead860b..e17899a57a 100755 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -256,7 +256,7 @@ To enable set it to a value different than 0. Disabled by default. /** Enable Lua engine debug log */ #ifndef CC_LUA_ENGINE_DEBUG -#define CC_LUA_ENGINE_DEBUG 0 +#define CC_LUA_ENGINE_DEBUG 1 #endif #endif // __CCCONFIG_H__ diff --git a/cocos2dx/platform/win32/CCCommon.cpp b/cocos2dx/platform/win32/CCCommon.cpp index 15b97d4810..f8b4f0cf97 100644 --- a/cocos2dx/platform/win32/CCCommon.cpp +++ b/cocos2dx/platform/win32/CCCommon.cpp @@ -51,5 +51,10 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle) MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); } +void CCLuaLog(const char * pszFormat) +{ + CCLog(pszFormat); +} + NS_CC_END diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 700590dad4..88f0917237 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -c9ab8cdd41e8b3e0089e5a0eb2ce2477b2eed786 \ No newline at end of file +1349cf00abd1e4f70f37c6406837a33684223962 \ No newline at end of file diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index e70f0fb32b..dcffb9e2e5 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -185,8 +185,6 @@ class CCAnimate : public CCActionInterval void setAnimation(CCAnimation *pAnimation); static CCAction* actionWithAnimation(CCAnimation *pAnimation); - static CCAction* actionWithAnimation(CCAnimation *pAnimation, bool bRestoreOriginalFrame); - static CCAction* actionWithDuration(ccTime duration, CCAnimation *pAnimation, bool bRestoreOriginalFrame); }; class CCProgressTo : public CCAction diff --git a/tools/tolua++/CCActionManager.pkg b/tools/tolua++/CCActionManager.pkg index 0a5c55c735..5314b85fe2 100644 --- a/tools/tolua++/CCActionManager.pkg +++ b/tools/tolua++/CCActionManager.pkg @@ -1,15 +1,21 @@ class CCActionManager : public CCObject { - void removeAllActions(void); - void removeAllActionsFromTarget(CCObject *pTarget); - void removeAction(CCAction *pAction); - void removeActionByTag(int tag, CCObject *pTarget); + void addAction(CCAction *pAction, CCNode *pTarget, bool paused); - int numberOfRunningActionsInTarget(CCObject *pTarget); + void removeAllActions(void); + + void removeAllActionsFromTarget(CCObject *pTarget); + + void removeAction(CCAction *pAction); + + void removeActionByTag(unsigned int tag, CCObject *pTarget); + + CCAction* getActionByTag(unsigned int tag, CCObject *pTarget); + + unsigned int numberOfRunningActionsInTarget(CCObject *pTarget); void pauseTarget(CCObject *pTarget); - void resumeTarget(CCObject *pTarget); - static CCActionManager* sharedManager(void); + void resumeTarget(CCObject *pTarget); }; diff --git a/tools/tolua++/CCAffineTransform.pkg b/tools/tolua++/CCAffineTransform.pkg index 91c4791dd1..3bfcc39abb 100644 --- a/tools/tolua++/CCAffineTransform.pkg +++ b/tools/tolua++/CCAffineTransform.pkg @@ -1,11 +1,11 @@ struct CCAffineTransform { - CGFloat a, b, c, d; - CGFloat tx, ty; + CCFloat a, b, c, d; + CCFloat tx, ty; }; -CCAffineTransform __CCAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty); -CCAffineTransform CCAffineTransformMake(CGFloat a, CGFloat b, CGFloat c, CGFloat d, CGFloat tx, CGFloat ty); +CCAffineTransform __CCAffineTransformMake(CCFloat a, CCFloat b, CCFloat c, CCFloat d, CCFloat tx, CCFloat ty); +CCAffineTransform CCAffineTransformMake(CCFloat a, CCFloat b, CCFloat c, CCFloat d, CCFloat tx, CCFloat ty); CCPoint __CCPointApplyAffineTransform(CCPoint point, CCAffineTransform t); CCPoint CCPointApplyAffineTransform(CCPoint point, CCAffineTransform t); @@ -17,8 +17,8 @@ CCAffineTransform CCAffineTransformMakeIdentity(); CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform); CCAffineTransform CCAffineTransformTranslate(CCAffineTransform t, float tx, float ty); -CCAffineTransform CCAffineTransformRotate(CCAffineTransform aTransform, CGFloat anAngle); -CCAffineTransform CCAffineTransformScale(CCAffineTransform t, CGFloat sx, CGFloat sy); +CCAffineTransform CCAffineTransformRotate(CCAffineTransform aTransform, CCFloat anAngle); +CCAffineTransform CCAffineTransformScale(CCAffineTransform t, CCFloat sx, CCFloat sy); CCAffineTransform CCAffineTransformConcat(CCAffineTransform t1,CCAffineTransform t2); bool CCAffineTransformEqualToTransform(CCAffineTransform t1,CCAffineTransform t2); CCAffineTransform CCAffineTransformInvert(CCAffineTransform t); diff --git a/tools/tolua++/CCAnimation.pkg b/tools/tolua++/CCAnimation.pkg index 7eadb54ae3..cb65a9fd38 100644 --- a/tools/tolua++/CCAnimation.pkg +++ b/tools/tolua++/CCAnimation.pkg @@ -1,20 +1,51 @@ +class CCAnimationFrame : public CCObject +{ + CCAnimationFrame(); + ~CCAnimationFrame(); + + bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo); + + CCSpriteFrame* getSpriteFrame(); + void setSpriteFrame(CCSpriteFrame* pSpFrame); + + float getDelayUnits(); + void setDelayUnits(float fDelayUnits); + + CCDictionary* getUserInfo(); + void setUserInfo(CCDictionary* pDict); +}; + + class CCAnimation : public CCObject { - const char* getName(void); - void setName(const char *pszName); - - float getDelay(void); - void setDelay(float fDelay); - - CCMutableArray* getFrames(void); - void setFrames(CCMutableArray *pFrames); - - void addFrame(CCSpriteFrame *pFrame); - void addFrameWithFileName(const char *pszFileName); - void addFrameWithTexture(CCTexture2D* pobTexture, CCRect rect); + CCAnimation(); + ~CCAnimation(void); static CCAnimation* animation(void); - static CCAnimation* animationWithFrames(CCMutableArray *frames); - static CCAnimation* animationWithFrames(CCMutableArray *frames, float delay); + static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); + static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops); + + void addSpriteFrame(CCSpriteFrame *pFrame); + void addSpriteFrameWithFileName(const char *pszFileName); + void addSpriteFrameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); + + float getTotalDelayUnits(); + + float getDelayPerUnit(); + void setDelayPerUnit(float fDelayPerUnits); + + float getDuration(); + + + CCArray* getFrames(); + void setFrames(CCArray* pFrames); + + + bool getRestoreOriginalFrame(); + void setRestoreOriginalFrame(bool bRestoreFrame); + + unsigned int getLoops(); + void setLoops(unsigned int uLoops); }; diff --git a/tools/tolua++/CCApplication.pkg b/tools/tolua++/CCApplication.pkg index d1c026b553..a83da8ae77 100644 --- a/tools/tolua++/CCApplication.pkg +++ b/tools/tolua++/CCApplication.pkg @@ -13,5 +13,5 @@ typedef enum LanguageType class CCApplication { static CCApplication& sharedApplication(); - static ccLanguageType getCurrentLanguage(); + ccLanguageType getCurrentLanguage(); }; diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg index 30381b60d4..a11cdbd0c8 100644 --- a/tools/tolua++/CCArray.pkg +++ b/tools/tolua++/CCArray.pkg @@ -1,34 +1,64 @@ - -class CCArray : public CCObject -{ - unsigned int count(); - unsigned int capacity(); - - unsigned int indexOfObject(CCObject* object); - CCObject* objectAtIndex(unsigned int index); - CCObject* lastObject(); - CCObject* randomObject(); - - bool containsObject(CCObject* object); - - void addObject(CCObject* object); - void addObjectsFromArray(CCArray* otherArray); - void insertObject(CCObject* object, unsigned int index); - - void removeLastObject(); - void removeObject(CCObject* object); - void removeObjectAtIndex(unsigned int index); - void removeObjectsInArray(CCArray* otherArray); - void removeAllObjects(); - void fastRemoveObject(CCObject* object); - void fastRemoveObjectAtIndex(unsigned int index); - - void exchangeObject(CCObject* object1, CCObject* object2); - void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); - void reverseObjects(); - void reduceMemoryFootprint(); - - static CCArray* array(); - static CCArray* arrayWithCapacity(unsigned int capacity); - static CCArray* arrayWithArray(CCArray* otherArray); -}; +class CCArray : public CCObject +{ +public: + ~CCArray(); + + static CCArray* array(); + static CCArray* arrayWithObject(CCObject* pObject); + static CCArray* arrayWithCapacity(unsigned int capacity); + static CCArray* arrayWithArray(CCArray* otherArray); + static CCArray* arrayWithContentsOfFile(const char* pFileName); + static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + + bool init(); + bool initWithObject(CCObject* pObject); + bool initWithCapacity(unsigned int capacity); + bool initWithArray(CCArray* otherArray); + + unsigned int count(); + + unsigned int capacity(); + + unsigned int indexOfObject(CCObject* object); + + CCObject* objectAtIndex(unsigned int index); + + CCObject* lastObject(); + + CCObject* randomObject(); + + bool containsObject(CCObject* object); + + void addObject(CCObject* object); + + void addObjectsFromArray(CCArray* otherArray); + + void insertObject(CCObject* object, unsigned int index); + + void removeLastObject(bool bReleaseObj = true); + + void removeObject(CCObject* object, bool bReleaseObj = true); + + void removeObjectAtIndex(unsigned int index, bool bReleaseObj = true); + + void removeObjectsInArray(CCArray* otherArray); + + void removeAllObjects(); + + void fastRemoveObject(CCObject* object); + + void fastRemoveObjectAtIndex(unsigned int index); + + void exchangeObject(CCObject* object1, CCObject* object2); + + void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); + + void reverseObjects(); + + void reduceMemoryFootprint(); + + void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); + + CCArray(); + CCArray(unsigned int capacity); +}; \ No newline at end of file diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg new file mode 100644 index 0000000000..b20977c600 --- /dev/null +++ b/tools/tolua++/CCDictionary.pkg @@ -0,0 +1,29 @@ +class CCDictionary : public CCObject +{ + CCDictionary(); + ~CCDictionary(); + + unsigned int count(); + CCArray* allKeys(); + CCArray* allKeysForObject(CCObject* object); + + CCObject* objectForKey(const CCString& key); + CCObject* objectForKey(int key); + const CCString* valueForKey(const CCString& key); + const CCString* valueForKey(int key); + + + void setObject(CCObject* pObject, const CCString& key); + void setObject(CCObject* pObject, int key); + + void removeObjectForKey(const CCString& key); + void removeObjectForKey(int key); + void removeObjectsForKeys(CCArray* pKeyArray); + void removeObjectForElememt(CCDictElement* pElement); + void removeAllObjects(); + + static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + +}; + diff --git a/tools/tolua++/CCDirector.pkg b/tools/tolua++/CCDirector.pkg index 37506a1894..9313e80af1 100644 --- a/tools/tolua++/CCDirector.pkg +++ b/tools/tolua++/CCDirector.pkg @@ -24,5 +24,11 @@ class CCDirector : public CCObject CCFloat getContentScaleFactor(void); + CCScheduler* getScheduler(); + CCActionManager* getActionManager(); + CCTouchDispatcher* getTouchDispatcher(); + CCKeypadDispatcher* getKeypadDispatcher(); + CCAccelerometer* getAccelerometer(); + static CCDirector* sharedDirector(void); }; diff --git a/tools/tolua++/CCMotionStreak.pkg b/tools/tolua++/CCMotionStreak.pkg index f50f2bb46e..97e0f890d1 100644 --- a/tools/tolua++/CCMotionStreak.pkg +++ b/tools/tolua++/CCMotionStreak.pkg @@ -1,11 +1,23 @@ - class CCMotionStreak : public CCNode { - CCRibbon* getRibbon(void); - void setTexture(CCTexture2D* var); - CCTexture2D* getTexture(void); - void setBlendFunc(ccBlendFunc var); - ccBlendFunc getBlendFunc(void); + static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); - static CCMotionStreak * streakWithFade(float fade, float seg, const char *imagePath, float width, float length, ccColor4B color); -}; + void tintWithColor(ccColor3B colors); + void reset(); + + void setPosition(CCPoint& position); + + CCTexture2D* getTexture(void); + void setTexture(CCTexture2D *texture); + void setBlendFunc(ccBlendFunc blendFunc); + ccBlendFunc getBlendFunc(void); + void setColor(const ccColor3B& color); + const ccColor3B& getColor(void); + GLubyte getOpacity(void); + void setOpacity(GLubyte opacity); + void setIsOpacityModifyRGB(bool bValue); + bool getIsOpacityModifyRGB(void); + bool getIsFastMode(); + void setIsFastMode(bool mode); +}; \ No newline at end of file diff --git a/tools/tolua++/CCMutableArray.pkg b/tools/tolua++/CCMutableArray.pkg deleted file mode 100644 index 580c2d51ee..0000000000 --- a/tools/tolua++/CCMutableArray.pkg +++ /dev/null @@ -1,39 +0,0 @@ - -class CCMutableArray : public CCObject -{ - TOLUA_TEMPLATE_BIND(T, CCObject*, CCSpriteFrame*, CCFiniteTimeAction*) - - CCMutableArray(unsigned int uSize = 0); - - unsigned int count(void); - - bool containsObject(T pObject); - - T getLastObject(void); - T getObjectAtIndex(unsigned int uIndex); - - void addObject(T pObject); - void addObjectsFromArray(CCMutableArray *pArray); - - void insertObjectAtIndex(T pObject, unsigned int uIndex); - void removeLastObject(bool bDeleteObject = true); - - void removeObject(T pObject, bool bDeleteObject = true); - - void removeObjectsInArray(CCMutableArray* pDeleteArray); - - void removeObjectAtIndex(unsigned int uIndex, bool bDeleteObject = true); - void removeAllObjects(bool bDeleteObject = true); - - void replaceObjectAtIndex(unsigned int uIndex, T pObject, bool bDeleteObject = true); - - std::vector::iterator begin(void); - - std::vector::reverse_iterator rbegin(void); - - std::vector::iterator endToLua(void); - std::vector::reverse_iterator rend(void); - CCMutableArray* copy(void); - - static CCMutableArray* arrayWithArray(CCMutableArray *pArray); -}; diff --git a/tools/tolua++/CCMutableDictionary.pkg b/tools/tolua++/CCMutableDictionary.pkg deleted file mode 100644 index 2feb143931..0000000000 --- a/tools/tolua++/CCMutableDictionary.pkg +++ /dev/null @@ -1,26 +0,0 @@ - -class CCMutableDictionary : public CCObject -{ - TOLUA_TEMPLATE_BIND(K V, std::string CCObject*) - - unsigned int count(); - std::vector allKeys(); - std::vector allKeysForObject(V object); - - V objectForKey(K key); - - bool setObject(V pObject, K key); - void removeObjectForKey(K key); - bool begin(); - void endToLua(); - - V next(K* key = NULL); - - void endToLua(); - - void removeAllObjects(); - - static CCMutableDictionary* dictionaryWithDictionary(CCMutableDictionary* srcDict); -}; - -typedef CCMutableDictionary CCStringToStringDictionary; diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg index 2729cbb9eb..ff8dd16c28 100644 --- a/tools/tolua++/CCParticleSystem.pkg +++ b/tools/tolua++/CCParticleSystem.pkg @@ -53,6 +53,3 @@ class CCParticleSystemQuad : public CCParticleSystem { static CCParticleSystemQuad * particleWithFile(const char *plistFile); }; -class CCParticleSystemPoint : public CCParticleSystem { - static CCParticleSystemPoint * particleWithFile(const char *plistFile); -}; diff --git a/tools/tolua++/CCRenderTexture.pkg b/tools/tolua++/CCRenderTexture.pkg index cae4e1fac1..99f79277bf 100644 --- a/tools/tolua++/CCRenderTexture.pkg +++ b/tools/tolua++/CCRenderTexture.pkg @@ -1,9 +1,8 @@ typedef enum eImageFormat { - kCCImageFormatJPG = 0, + kCCImageFormatJPEG = 0, kCCImageFormatPNG = 1, - kCCImageFormatRawData = 2 } tImageFormat; class CCRenderTexture : public CCNode @@ -16,8 +15,11 @@ class CCRenderTexture : public CCNode void beginWithClear(float r, float g, float b, float a); void clear(float r, float g, float b, float a); - bool saveBuffer(const char *name); - bool saveBuffer(const char *name, int format); + + CCImage* newCCImage(); + + bool saveToFile(const char *szFilePath); + bool saveToFile(const char *name, tCCImageFormat format); static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); diff --git a/tools/tolua++/CCScheduler.pkg b/tools/tolua++/CCScheduler.pkg index dc37fa733d..0caed4128c 100644 --- a/tools/tolua++/CCScheduler.pkg +++ b/tools/tolua++/CCScheduler.pkg @@ -25,5 +25,4 @@ class CCScheduler : public CCObject void resumeTarget(CCObject *pTarget); bool isTargetPaused(CCObject *pTarget); - static CCScheduler* sharedScheduler(void); }; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg index d6b17951d5..7ffd73ac28 100644 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ b/tools/tolua++/CCSpriteBatchNode.pkg @@ -22,6 +22,4 @@ class CCSpriteBatchNode : public CCNode static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D *tex); static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity); - static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage); - static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity); }; diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg index 5a1e0c66bb..b87e223f4c 100644 --- a/tools/tolua++/CCString.pkg +++ b/tools/tolua++/CCString.pkg @@ -1,12 +1,35 @@ -class CCString : public CCObject -{ - CCString(); - CCString(const char * str); - ~CCString(); - - int toInt(); - unsigned int toUInt(); - float toFloat(); - bool isEmpty(); +class CCString : public CCObject +{ +public: + CCString(); + CCString(const char* str); + CCString(const std::string& str); + CCString(const CCString& str); + ~CCString(); + +// CCString& operator= (const CCString& other); + + // bool initWithFormat(const char* format, ...); + + int intValue() const; + + unsigned int uintValue() const; + + float floatValue() const; + + double doubleValue() const; + + bool boolValue() const; + + const char* getCString() const; + + unsigned int length() const; + + bool isEqual(const CCObject* pObject); + + static CCString* stringWithCString(const char* pStr); + // static CCString* stringWithFormat(const char* format, ...); + static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + static CCString* stringWithContentsOfFile(const char* pszFileName); }; diff --git a/tools/tolua++/CCTouch.pkg b/tools/tolua++/CCTouch.pkg index 38039f9ff8..4f6c9577d5 100644 --- a/tools/tolua++/CCTouch.pkg +++ b/tools/tolua++/CCTouch.pkg @@ -8,9 +8,9 @@ enum { class CCTouch : public CCObject { - CCPoint locationInView(int nViewId); - CCPoint previousLocationInView(int nViewId); - int view(); + CCPoint locationInView(); + CCPoint previousLocationInView(); + int getID(); }; class CCEvent : public CCObject diff --git a/tools/tolua++/Cocos2d.pkg b/tools/tolua++/Cocos2d.pkg index c4bef872dc..53e9f34398 100644 --- a/tools/tolua++/Cocos2d.pkg +++ b/tools/tolua++/Cocos2d.pkg @@ -1,17 +1,17 @@ $#include "LuaCocos2d.h" -//$pfile "CCAction.pkg" -//$pfile "CCActionCamera.pkg" -//$pfile "CCActionEase.pkg" -//$pfile "CCActionGrid.pkg" -//$pfile "CCActionGrid3D.pkg" -//$pfile "CCActionManager.pkg" -//$pfile "CCActionPageTurn3D.pkg" -//$pfile "CCActionTiledGrid.pkg" -//$pfile "CCAffineTransform.pkg" -//$pfile "CCAnimation.pkg" -//$pfile "CCAnimationCache.pkg" +$pfile "CCAction.pkg" +$pfile "CCActionCamera.pkg" +$pfile "CCActionEase.pkg" +$pfile "CCActionGrid.pkg" +$pfile "CCActionGrid3D.pkg" +$pfile "CCActionManager.pkg" +$pfile "CCActionPageTurn3D.pkg" +$pfile "CCActionTiledGrid.pkg" +$pfile "CCAffineTransform.pkg" +$pfile "CCAnimation.pkg" +$pfile "CCAnimationCache.pkg" $pfile "CCApplication.pkg" $pfile "CCArray.pkg" $pfile "CCAtlasNode.pkg" @@ -27,21 +27,20 @@ $pfile "CCLabelTTF.pkg" $pfile "CCLayer.pkg" $pfile "CCMenu.pkg" $pfile "CCMenuItem.pkg" -//$pfile "CCMotionStreak.pkg" -//$pfile "CCMutableArray.pkg" -//$pfile "CCMutableDictionary.pkg" +$pfile "CCMotionStreak.pkg" +$pfile "CCDictionary.pkg" $pfile "CCNode.pkg" $pfile "CCObject.pkg" $pfile "CCParallaxNode.pkg" -//$pfile "CCParticleSystem.pkg" +$pfile "CCParticleSystem.pkg" $pfile "CCPointExtension.pkg" //$pfile "CCProgressTimer.pkg" -//$pfile "CCRenderTexture.pkg" +$pfile "CCRenderTexture.pkg" //$pfile "CCRibbon.pkg" $pfile "CCScene.pkg" -//$pfile "CCScheduler.pkg" +$pfile "CCScheduler.pkg" $pfile "CCSprite.pkg" -//$pfile "CCSpriteBatchNode.pkg" +$pfile "CCSpriteBatchNode.pkg" $pfile "CCSpriteFrame.pkg" $pfile "CCSpriteFrameCache.pkg" $pfile "CCString.pkg" @@ -54,7 +53,7 @@ $pfile "CCTileMapAtlas.pkg" //$pfile "CCTMXObjectGroup.pkg" //$pfile "CCTMXTiledMap.pkg" //$pfile "CCTMXXMLParser.pkg" -//$pfile "CCTouch.pkg" +$pfile "CCTouch.pkg" $pfile "CCTransition.pkg" $pfile "ccTypes.pkg" $pfile "CCUserDefault.pkg" diff --git a/tools/tolua++/basic.lua b/tools/tolua++/basic.lua index 04ee00200b..ccc153f707 100644 --- a/tools/tolua++/basic.lua +++ b/tools/tolua++/basic.lua @@ -85,8 +85,7 @@ local CCObjectTypes = { "CCTiledGrid3D", "CCKeypadDispatcher", "CCKeypadHandler", - "CCMutableArray", - "CCMutableDictionary", + "CCDictionary", "CCNode", "CCAtlasNode", "CCLabelAtlas", From edfb8c1f9c0186f9025247fb86e05cdd52ab1e29 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 11:39:49 +0800 Subject: [PATCH 2/8] issue #1190: used std::string as key of CCDictionary. Updated CCString.pkg, CCArray.pkg, CCDictionary.pkg. --- HelloLua/Resources/hello.lua | 2 +- cocos2dx/cocoa/CCDictionary.cpp | 30 ++++++++++++------- cocos2dx/cocoa/CCDictionary.h | 13 ++++---- cocos2dx/platform/CCEGLViewProtocol.cpp | 4 +-- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 6 ++-- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCArray.pkg | 9 ------ tools/tolua++/CCDictionary.pkg | 13 ++++---- tools/tolua++/CCString.pkg | 23 ++------------ 9 files changed, 43 insertions(+), 59 deletions(-) diff --git a/HelloLua/Resources/hello.lua b/HelloLua/Resources/hello.lua index 83501cdaf6..3fa0545712 100644 --- a/HelloLua/Resources/hello.lua +++ b/HelloLua/Resources/hello.lua @@ -30,7 +30,7 @@ local function creatDog() spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) - local animFrames = CCArray:new(2) + local animFrames = CCArray:arrayWithCapacity(2) animFrames:addObject(frame0) animFrames:addObject(frame1) diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 6522beec66..53545d907b 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -88,14 +88,14 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) return pArray; } -CCObject* CCDictionary::objectForKey(const CCString& key) +CCObject* CCDictionary::objectForKey(const std::string& key) { if (m_eDictType == kCCDictUnknown && m_eDictType == kCCDictUnknown) return NULL; CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as key."); CCObject* pRetObject = NULL; CCDictElement *pElement = NULL; - HASH_FIND_STR(m_pElements, key.getCString(), pElement); + HASH_FIND_STR(m_pElements, key.c_str(), pElement); if (pElement != NULL) { pRetObject = pElement->m_pObject; @@ -118,7 +118,7 @@ CCObject* CCDictionary::objectForKey(int key) return pRetObject; } -const CCString* CCDictionary::valueForKey(const CCString& key) +const CCString* CCDictionary::valueForKey(const std::string& key) { CCString* pStr = (CCString*)objectForKey(key); if (pStr == NULL) @@ -138,7 +138,7 @@ const CCString* CCDictionary::valueForKey(int key) return pStr; } -void CCDictionary::setObject(CCObject* pObject, const CCString& key) +void CCDictionary::setObject(CCObject* pObject, const std::string& key) { CCAssert(key.length() > 0 && pObject != NULL, "Invalid Argument!"); if (m_eOldDictType == kCCDictUnknown) @@ -149,7 +149,7 @@ void CCDictionary::setObject(CCObject* pObject, const CCString& key) CCAssert(m_eDictType == m_eOldDictType, "this dictionary does not use string as key."); CCDictElement *pElement = NULL; - HASH_FIND_STR(m_pElements, key.getCString(), pElement); + HASH_FIND_STR(m_pElements, key.c_str(), pElement); if (pElement == NULL) { setObjectUnSafe(pObject, key); @@ -191,7 +191,7 @@ void CCDictionary::setObject(CCObject* pObject, int key) } -void CCDictionary::removeObjectForKey(const CCString& key) +void CCDictionary::removeObjectForKey(const std::string& key) { if (m_eOldDictType == kCCDictUnknown) { @@ -200,7 +200,7 @@ void CCDictionary::removeObjectForKey(const CCString& key) CCAssert(m_eDictType == kCCDictStr, "this dictionary does not use string as its key"); CCAssert(key.length() > 0, "Invalid Argument!"); CCDictElement *pElement = NULL; - HASH_FIND_STR(m_pElements, key.getCString(), pElement); + HASH_FIND_STR(m_pElements, key.c_str(), pElement); removeObjectForElememt(pElement); } @@ -216,10 +216,10 @@ void CCDictionary::removeObjectForKey(int key) removeObjectForElememt(pElement); } -void CCDictionary::setObjectUnSafe(CCObject* pObject, const CCString& key) +void CCDictionary::setObjectUnSafe(CCObject* pObject, const std::string& key) { pObject->retain(); - CCDictElement* pElement = new CCDictElement(key.getCString(), pObject); + CCDictElement* pElement = new CCDictElement(key.c_str(), pObject); HASH_ADD_STR(m_pElements, m_szKey, pElement); } @@ -236,7 +236,7 @@ void CCDictionary::removeObjectsForKeys(CCArray* pKeyArray) CCARRAY_FOREACH(pKeyArray, pObj) { CCString* pStr = (CCString*)pObj; - removeObjectForKey(*pStr); + removeObjectForKey(pStr->getCString()); } } @@ -285,6 +285,16 @@ CCObject* CCDictionary::copyWithZone(CCZone* pZone) return pNewDict; } +CCDictionary* CCDictionary::dictionary() +{ + CCDictionary* pRet = new CCDictionary(); + if (pRet != NULL) + { + pRet->autorelease(); + } + return pRet; +} + CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) { CCDictionary* pNewDict = (CCDictionary*)srcDict->copy(); diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index cdce54a2eb..c4d22030c0 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -118,16 +118,16 @@ public: /** @warning : We use '==' to compare two objects*/ CCArray* allKeysForObject(CCObject* object); - CCObject* objectForKey(const CCString& key); + CCObject* objectForKey(const std::string& key); CCObject* objectForKey(int key); - const CCString* valueForKey(const CCString& key); + const CCString* valueForKey(const std::string& key); const CCString* valueForKey(int key); - void setObject(CCObject* pObject, const CCString& key); + void setObject(CCObject* pObject, const std::string& key); void setObject(CCObject* pObject, int key); - void removeObjectForKey(const CCString& key); + void removeObjectForKey(const std::string& key); void removeObjectForKey(int key); void removeObjectsForKeys(CCArray* pKeyArray); void removeObjectForElememt(CCDictElement* pElement); @@ -135,6 +135,9 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); + /* static functions */ + static CCDictionary* dictionary(); + static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @@ -150,7 +153,7 @@ public: static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); private: - void setObjectUnSafe(CCObject* pObject, const CCString& key); + void setObjectUnSafe(CCObject* pObject, const std::string& key); void setObjectUnSafe(CCObject* pObject, const int key); public: diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index 8a7bcaf54d..ee80157bdd 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -235,7 +235,7 @@ void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float return; } - CCLOG("Moving touches with id: %d, x=%f, y=%f", id, x, y); + CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y); CCTouch* pTouch = s_pTouches[pIndex->getValue()]; if (pTouch) { @@ -285,7 +285,7 @@ void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[ CCTouch* pTouch = s_pTouches[pIndex->getValue()]; if (pTouch) { - CCLOG("Ending touches with id: %d, x=%f, y=%f", id, x, y); + CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y); if (m_bNeedScale) { diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 949a7e63d5..f3fde8f3d9 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -309,8 +309,8 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) if (key) { - m_pSpriteFrames->removeObjectForKey(*key); - m_pSpriteFramesAliases->removeObjectForKey(*key); + m_pSpriteFrames->removeObjectForKey(key->getCString()); + m_pSpriteFramesAliases->removeObjectForKey(key->getCString()); } else { @@ -372,7 +372,7 @@ CCSpriteFrame* CCSpriteFrameCache::spriteFrameByName(const char *pszName) CCString *key = (CCString*)m_pSpriteFramesAliases->objectForKey(pszName); if (key) { - frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(*key); + frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key->getCString()); if (! frame) { CCLOG("cocos2d: CCSpriteFrameCahce: Frame '%s' not found", pszName); diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 88f0917237..5d2bb86aae 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -1349cf00abd1e4f70f37c6406837a33684223962 \ No newline at end of file +a0c234a2d1f002f0166f256737cd5a3167597a2e \ No newline at end of file diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg index a11cdbd0c8..1e3fa5819b 100644 --- a/tools/tolua++/CCArray.pkg +++ b/tools/tolua++/CCArray.pkg @@ -1,19 +1,12 @@ class CCArray : public CCObject { public: - ~CCArray(); static CCArray* array(); static CCArray* arrayWithObject(CCObject* pObject); static CCArray* arrayWithCapacity(unsigned int capacity); static CCArray* arrayWithArray(CCArray* otherArray); static CCArray* arrayWithContentsOfFile(const char* pFileName); - static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); - - bool init(); - bool initWithObject(CCObject* pObject); - bool initWithCapacity(unsigned int capacity); - bool initWithArray(CCArray* otherArray); unsigned int count(); @@ -59,6 +52,4 @@ public: void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); - CCArray(); - CCArray(unsigned int capacity); }; \ No newline at end of file diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg index b20977c600..1884038dfb 100644 --- a/tools/tolua++/CCDictionary.pkg +++ b/tools/tolua++/CCDictionary.pkg @@ -1,27 +1,24 @@ class CCDictionary : public CCObject { - CCDictionary(); - ~CCDictionary(); - unsigned int count(); CCArray* allKeys(); CCArray* allKeysForObject(CCObject* object); - CCObject* objectForKey(const CCString& key); + CCObject* objectForKey(const std::string& key); CCObject* objectForKey(int key); - const CCString* valueForKey(const CCString& key); + const CCString* valueForKey(const std::string& key); const CCString* valueForKey(int key); - void setObject(CCObject* pObject, const CCString& key); + void setObject(CCObject* pObject, const std::string& key); void setObject(CCObject* pObject, int key); - void removeObjectForKey(const CCString& key); + void removeObjectForKey(const std::string& key); void removeObjectForKey(int key); void removeObjectsForKeys(CCArray* pKeyArray); - void removeObjectForElememt(CCDictElement* pElement); void removeAllObjects(); + static CCDictionary* dictionary(); static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg index b87e223f4c..bf0aa0f6e9 100644 --- a/tools/tolua++/CCString.pkg +++ b/tools/tolua++/CCString.pkg @@ -1,35 +1,18 @@ - + class CCString : public CCObject { -public: - CCString(); - CCString(const char* str); - CCString(const std::string& str); - CCString(const CCString& str); - ~CCString(); - -// CCString& operator= (const CCString& other); - - // bool initWithFormat(const char* format, ...); - int intValue() const; - unsigned int uintValue() const; - float floatValue() const; - double doubleValue() const; - bool boolValue() const; - const char* getCString() const; - unsigned int length() const; bool isEqual(const CCObject* pObject); static CCString* stringWithCString(const char* pStr); - // static CCString* stringWithFormat(const char* format, ...); static CCString* stringWithData(unsigned char* pData, unsigned long nLen); static CCString* stringWithContentsOfFile(const char* pszFileName); -}; +}; + From b21944e1d30094cf996ca8282aea2d8651a13584 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 11:45:22 +0800 Subject: [PATCH 3/8] issue #1190: Updated main.cpp and Android.mk for HelloLua project of android. --- HelloLua/Classes/Android.mk | 2 +- HelloLua/proj.android/jni/helloworld/main.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HelloLua/Classes/Android.mk b/HelloLua/Classes/Android.mk index f52dcfb4ab..407e777ef0 100644 --- a/HelloLua/Classes/Android.mk +++ b/HelloLua/Classes/Android.mk @@ -20,7 +20,7 @@ LOCAL_STATIC_LIBRARIES += jpeg_static_prebuilt LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_SHARED_LIBRARIES := cocosdenshion_shared lua_shared - + include $(BUILD_STATIC_LIBRARY) $(call import-module,cocos2dx/platform/third_party/android/modules/libpng) diff --git a/HelloLua/proj.android/jni/helloworld/main.cpp b/HelloLua/proj.android/jni/helloworld/main.cpp index 9aa8ade077..2f5b1c64f3 100644 --- a/HelloLua/proj.android/jni/helloworld/main.cpp +++ b/HelloLua/proj.android/jni/helloworld/main.cpp @@ -23,10 +23,10 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi { if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView()) { - cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView(); - view->setFrameWidthAndHeight(w, h); + cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView(); + view->setFrameSize(w, h); // if you want to run in WVGA with HVGA resource, set it - view->create(480, 320); + // view->create(480, 320); cocos2d::CCDirector::sharedDirector()->setOpenGLView(view); AppDelegate *pAppDelegate = new AppDelegate(); From 8d63e9f1bd0922ed91ca674dfb0c614fe1d3c87f Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 11:52:21 +0800 Subject: [PATCH 4/8] issue #1190: Updated some files for android port. --- HelloLua/proj.android/default.properties | 2 +- .../gen/org/cocos2dx/hellolua/R.java | 52 +++++++++---------- cocos2dx/platform/android/CCCommon.cpp | 5 ++ cocos2dx/platform/android/CCEGLView.cpp | 3 +- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/HelloLua/proj.android/default.properties b/HelloLua/proj.android/default.properties index c4fb5b6aa9..51ff180e82 100644 --- a/HelloLua/proj.android/default.properties +++ b/HelloLua/proj.android/default.properties @@ -1,2 +1,2 @@ # Project target. -target=android-7 +target=android-10 diff --git a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java b/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java index bad0413877..ba4eac96cd 100644 --- a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java +++ b/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java @@ -1,26 +1,26 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.cocos2dx.hellolua; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int test_demo_gl_surfaceview=0x7f050001; - public static final int textField=0x7f050000; - } - public static final class layout { - public static final int game_demo=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package org.cocos2dx.hellolua; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int icon=0x7f020000; + } + public static final class id { + public static final int test_demo_gl_surfaceview=0x7f050001; + public static final int textField=0x7f050000; + } + public static final class layout { + public static final int game_demo=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + } +} diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index fcfc2acaf5..89879a29f9 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -50,4 +50,9 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle) showMessageBoxJNI(pszMsg, pszTitle); } +void CCLuaLog(const char * pszFormat) +{ + CCLog(pszFormat); +} + NS_CC_END diff --git a/cocos2dx/platform/android/CCEGLView.cpp b/cocos2dx/platform/android/CCEGLView.cpp index ae00ea5da6..21cbee45c7 100644 --- a/cocos2dx/platform/android/CCEGLView.cpp +++ b/cocos2dx/platform/android/CCEGLView.cpp @@ -30,8 +30,7 @@ THE SOFTWARE. #include "jni/MessageJni.h" #include -#include -#include +#include "CCGL.h" #include #include From 394622f538448ef11d79045bed970674d3b159eb Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 12:06:51 +0800 Subject: [PATCH 5/8] issue #1190: Updated HelloLua.java and Cocos2dxGLSurfaceView.java, make HelloLua app support opengles2.0. --- .../src/org/cocos2dx/hellolua/HelloLua.java | 33 +++++++++++++++---- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 9 +++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java index e39c70fac8..85d3b23b8e 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java +++ b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java @@ -24,22 +24,34 @@ THE SOFTWARE. package org.cocos2dx.hellolua; import org.cocos2dx.lib.Cocos2dxActivity; import org.cocos2dx.lib.Cocos2dxGLSurfaceView; +import org.cocos2dx.lib.Cocos2dxRenderer; +import android.app.ActivityManager; import android.content.Context; +import android.content.pm.ConfigurationInfo; import android.opengl.GLSurfaceView; import android.os.Bundle; +import android.util.Log; import android.view.KeyEvent; public class HelloLua extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - // get the packageName,it's used to set the resource path - String packageName = getApplication().getPackageName(); - super.setPackageName(packageName); + if (detectOpenGLES20()) { + // get the packageName,it's used to set the resource path + String packageName = getApplication().getPackageName(); + super.setPackageName(packageName); - mGLView = new LuaGLSurfaceView(this); - setContentView(mGLView); + mGLView = new LuaGLSurfaceView(this); + setContentView(mGLView); + mGLView.setEGLContextClientVersion(2); + mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); + } + else { + Log.d("activity", "don't support gles2.0"); + finish(); + } } @Override @@ -54,7 +66,16 @@ public class HelloLua extends Cocos2dxActivity{ mGLView.onResume(); } - private GLSurfaceView mGLView; + private boolean detectOpenGLES20() + { + ActivityManager am = + (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + ConfigurationInfo info = am.getDeviceConfigurationInfo(); + return (info.reqGlEsVersion >= 0x20000); + } + + private LuaGLSurfaceView mGLView; + static { System.loadLibrary("cocosdenshion"); diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java index ef43af7835..e7c4721cf3 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java @@ -144,11 +144,14 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView { super(context, attrs); initView(); } + + public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ + mRenderer = renderer; + setRenderer(mRenderer); + } - protected void initView() { - mRenderer = new Cocos2dxRenderer(); + protected void initView() { setFocusableInTouchMode(true); - setRenderer(mRenderer); textInputWraper = new TextInputWraper(this); From f5ffe8249ea0ea012aa9d618e0ccfa11301ecab8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 13:05:05 +0800 Subject: [PATCH 6/8] issue #1190: Updated ios lua project. --- HelloLua/proj.ios/AppController.mm | 2 +- .../HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/platform/ios/CCCommon.mm | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/HelloLua/proj.ios/AppController.mm b/HelloLua/proj.ios/AppController.mm index 8a7e27674b..d1a4bf868d 100644 --- a/HelloLua/proj.ios/AppController.mm +++ b/HelloLua/proj.ios/AppController.mm @@ -45,7 +45,7 @@ static AppDelegate s_sharedApplication; window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; EAGLView *__glView = [EAGLView viewWithFrame: [window bounds] pixelFormat: kEAGLColorFormatRGBA8 - depthFormat: GL_DEPTH_COMPONENT16_OES + depthFormat: GL_DEPTH_COMPONENT16 preserveBackbuffer: NO sharegroup: nil multiSampling: NO diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index 26724f5d31..20a602eb43 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -ffad21bda3a4ed5edc31bc8177fe0bf9d8262a5d \ No newline at end of file +9b310a8b553efc1db798797273bd0bfb1b11c857 \ No newline at end of file diff --git a/cocos2dx/platform/ios/CCCommon.mm b/cocos2dx/platform/ios/CCCommon.mm index 5bfc440560..9a476fc9ba 100644 --- a/cocos2dx/platform/ios/CCCommon.mm +++ b/cocos2dx/platform/ios/CCCommon.mm @@ -58,4 +58,9 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle) [messageBox show]; } +void CCLuaLog(const char * pszFormat) +{ + CCLog(pszFormat); +} + NS_CC_END From 6f62251bb670c0c3f6d2744a2f6f619c5a573322 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 14:32:17 +0800 Subject: [PATCH 7/8] fixed #1190: Updated some .pkg files. --- HelloLua/proj.android/project.properties | 11 ++++ .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCActionProgressTimer.pkg | 10 +++ tools/tolua++/CCProgressTimer.pkg | 65 ++++++++++--------- tools/tolua++/CCTMXLayer.pkg | 6 +- tools/tolua++/CCTMXObjectGroup.pkg | 10 +-- tools/tolua++/CCTMXTiledMap.pkg | 10 +-- tools/tolua++/CCTMXXMLParser.pkg | 24 +++---- tools/tolua++/Cocos2d.pkg | 12 ++-- 9 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 HelloLua/proj.android/project.properties create mode 100644 tools/tolua++/CCActionProgressTimer.pkg diff --git a/HelloLua/proj.android/project.properties b/HelloLua/proj.android/project.properties new file mode 100644 index 0000000000..f049142c17 --- /dev/null +++ b/HelloLua/proj.android/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-10 diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 5d2bb86aae..299dc0b33a 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -a0c234a2d1f002f0166f256737cd5a3167597a2e \ No newline at end of file +ae3ae184f6137f05f4caa10d92a1d2f99dca3c54 \ No newline at end of file diff --git a/tools/tolua++/CCActionProgressTimer.pkg b/tools/tolua++/CCActionProgressTimer.pkg new file mode 100644 index 0000000000..f887b2d901 --- /dev/null +++ b/tools/tolua++/CCActionProgressTimer.pkg @@ -0,0 +1,10 @@ + +class CCProgressTo : public CCActionInterval +{ + static CCProgressTo* actionWithDuration(ccTime duration, float fPercent); +}; + +class CCProgressFromTo : public CCActionInterval +{ + static CCProgressFromTo* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); +}; diff --git a/tools/tolua++/CCProgressTimer.pkg b/tools/tolua++/CCProgressTimer.pkg index ff7f75d351..ec84778f19 100644 --- a/tools/tolua++/CCProgressTimer.pkg +++ b/tools/tolua++/CCProgressTimer.pkg @@ -1,29 +1,36 @@ - -typedef enum { - /// Radial Counter-Clockwise - kCCProgressTimerTypeRadialCCW, - /// Radial ClockWise - kCCProgressTimerTypeRadialCW, - /// Horizontal Left-Right - kCCProgressTimerTypeHorizontalBarLR, - /// Horizontal Right-Left - kCCProgressTimerTypeHorizontalBarRL, - /// Vertical Bottom-top - kCCProgressTimerTypeVerticalBarBT, - /// Vertical Top-Bottom - kCCProgressTimerTypeVerticalBarTB, -} CCProgressTimerType; - -class CCProgressTimer : public CCNode -{ - CCProgressTimerType getType(void); - float getPercentage(void); - CCSprite* getSprite(void); - - void setPercentage(float fPercentage); - void setSprite(CCSprite *pSprite); - void setType(CCProgressTimerType type); - - static CCProgressTimer* progressWithFile(const char *pszFileName); - static CCProgressTimer* progressWithTexture(CCTexture2D *pTexture); -}; +typedef enum { + kCCProgressTimerTypeRadial, + kCCProgressTimerTypeBar, +} CCProgressTimerType; + +class CCProgressTimer : public CCNode +{ + CCProgressTimerType getType(void); + + float getPercentage(void); + + CCSprite* getSprite(void) { return m_pSprite; } + + void setPercentage(float fPercentage); + void setSprite(CCSprite *pSprite); + void setType(CCProgressTimerType type); + void setReverseProgress(bool reverse); + void setAnchorPoint(CCPoint anchorPoint); + + void setColor(const ccColor3B& color); + const ccColor3B& getColor(void); + GLubyte getOpacity(void); + void setOpacity(GLubyte opacity); + void setIsOpacityModifyRGB(bool bValue); + bool getIsOpacityModifyRGB(void); + + static CCProgressTimer* progressWithSprite(CCSprite* sp); + + CCPoint getMidpoint(); + void setMidpoint(CCPoint pt); + CCPoint getBarChangeRate(); + void setBarChangeRate(CCPoint rate); + + bool getIsReverseDirection(); + void setIsReverseDirection(bool bReverseDir); +}; diff --git a/tools/tolua++/CCTMXLayer.pkg b/tools/tolua++/CCTMXLayer.pkg index d9eed02219..15c53fd7de 100644 --- a/tools/tolua++/CCTMXLayer.pkg +++ b/tools/tolua++/CCTMXLayer.pkg @@ -16,14 +16,16 @@ class CCTMXLayer : public CCSpriteBatchNode void setLayerOrientation(unsigned int val); unsigned int getLayerOrientation(); - void setProperties(CCStringToStringDictionary* pval); - CCStringToStringDictionary* getProperties(); + void setProperties(CCDictionary* pval); + CCDictionary* getProperties(); void releaseMap(); CCSprite* tileAt(CCPoint tileCoordinate); unsigned int tileGIDAt(CCPoint tileCoordinate); + unsigned int tileGIDAt(CCPoint tileCoordinate, ccTMXTileFlags* flags); void setTileGID(unsigned int gid, CCPoint tileCoordinate); + void setTileGID(unsigned int gid, CCPoint tileCoordinate, ccTMXTileFlags flags); void removeTileAt(CCPoint tileCoordinate); CCPoint positionAt(CCPoint tileCoordinate); CCString *propertyNamed(const char *propertyName); diff --git a/tools/tolua++/CCTMXObjectGroup.pkg b/tools/tolua++/CCTMXObjectGroup.pkg index bbabd9998f..c870abb741 100644 --- a/tools/tolua++/CCTMXObjectGroup.pkg +++ b/tools/tolua++/CCTMXObjectGroup.pkg @@ -4,16 +4,16 @@ class CCTMXObjectGroup : public CCObject void setPositionOffset(CCPoint pt); CCPoint getPositionOffset(); - void setProperties(CCStringToStringDictionary* pval); - CCStringToStringDictionary* getProperties(); + void setProperties(CCDictionary* pval); + CCDictionary* getProperties(); - void setObjects(CCMutableArray* val); - CCMutableArray* getObjects(); + void setObjects(CCArray* val); + CCArray* getObjects(); void setGroupName(const char *groupName); const char* getGroupName(); CCString *propertyNamed(const char* propertyName); - CCStringToStringDictionary* objectNamed(const char *objectName); + CCDictionary* objectNamed(const char *objectName); }; diff --git a/tools/tolua++/CCTMXTiledMap.pkg b/tools/tolua++/CCTMXTiledMap.pkg index 2f7163a534..ff779e0380 100644 --- a/tools/tolua++/CCTMXTiledMap.pkg +++ b/tools/tolua++/CCTMXTiledMap.pkg @@ -20,16 +20,16 @@ class CCTMXTiledMap : public CCNode void setMapOrientation(int val); int getMapOrientation(); - void setObjectGroups(CCMutableArray* pval); - CCMutableArray* getObjectGroups(); + void setObjectGroups(CCArray* pval); + CCArray* getObjectGroups(); - void setProperties(CCStringToStringDictionary* pval); - CCStringToStringDictionary* getProperties(); + void setProperties(CCDictionary* pval); + CCDictionary* getProperties(); CCTMXLayer* layerNamed(const char *layerName); CCTMXObjectGroup* objectGroupNamed(const char *groupName); CCString *propertyNamed(const char *propertyName); - CCDictionary *propertiesForGID(int GID); + CCDictionary *propertiesForGID(int GID); static CCTMXTiledMap * tiledMapWithTMXFile(const char *tmxFile); }; diff --git a/tools/tolua++/CCTMXXMLParser.pkg b/tools/tolua++/CCTMXXMLParser.pkg index 679219e90d..b01ac217ab 100644 --- a/tools/tolua++/CCTMXXMLParser.pkg +++ b/tools/tolua++/CCTMXXMLParser.pkg @@ -17,8 +17,8 @@ enum { class CCTMXLayerInfo : public CCObject { - CCStringToStringDictionary* getProperties(); - void setProperties(CCStringToStringDictionary* pval); + CCDictionary* getProperties(); + void setProperties(CCDictionary* pval); }; class CCTMXTilesetInfo : public CCObject @@ -34,12 +34,12 @@ class CCTMXMapInfo : public CCObject CCSize getMapSize(); void setTileSize(CCSize sz); CCSize getTileSize(); - void setLayers(CCMutableArray* pval); - CCMutableArray* getLayers(); - void setTilesets(CCMutableArray* pval); - CCMutableArray* getTilesets(); - void setObjectGroups(CCMutableArray* val); - CCMutableArray* getObjectGroups(); + void setLayers(CCArray* pval); + CCArray* getLayers(); + void setTilesets(CCArray* pval); + CCArray* getTilesets(); + void setObjectGroups(CCArray* val); + CCArray* getObjectGroups(); void setParentElement(int val); int getParentElement(); void setParentGID(unsigned int val); @@ -48,10 +48,10 @@ class CCTMXMapInfo : public CCObject int getLayerAttribs(); void setStoringCharacters(bool val); bool getStoringCharacters(); - void setProperties(CCStringToStringDictionary* pval); - CCStringToStringDictionary* getProperties(); - void setTileProperties(CCDictionary * tileProperties); - CCDictionary * getTileProperties(); + void setProperties(CCDictionary* pval); + CCDictionary* getProperties(); + void setTileProperties(CCDictionary* tileProperties); + CCDictionary* getTileProperties(); void setCurrentString(const char *currentString); const char* getCurrentString(); void setTMXFileName(const char *fileName); diff --git a/tools/tolua++/Cocos2d.pkg b/tools/tolua++/Cocos2d.pkg index 53e9f34398..ea5b7b7127 100644 --- a/tools/tolua++/Cocos2d.pkg +++ b/tools/tolua++/Cocos2d.pkg @@ -8,6 +8,7 @@ $pfile "CCActionGrid.pkg" $pfile "CCActionGrid3D.pkg" $pfile "CCActionManager.pkg" $pfile "CCActionPageTurn3D.pkg" +$pfile "CCActionProgressTimer.pkg" $pfile "CCActionTiledGrid.pkg" $pfile "CCAffineTransform.pkg" $pfile "CCAnimation.pkg" @@ -34,9 +35,8 @@ $pfile "CCObject.pkg" $pfile "CCParallaxNode.pkg" $pfile "CCParticleSystem.pkg" $pfile "CCPointExtension.pkg" -//$pfile "CCProgressTimer.pkg" +$pfile "CCProgressTimer.pkg" $pfile "CCRenderTexture.pkg" -//$pfile "CCRibbon.pkg" $pfile "CCScene.pkg" $pfile "CCScheduler.pkg" $pfile "CCSprite.pkg" @@ -49,10 +49,10 @@ $pfile "CCTexture2D.pkg" $pfile "CCTextureAtlas.pkg" $pfile "CCTextureCache.pkg" $pfile "CCTileMapAtlas.pkg" -//$pfile "CCTMXLayer.pkg" -//$pfile "CCTMXObjectGroup.pkg" -//$pfile "CCTMXTiledMap.pkg" -//$pfile "CCTMXXMLParser.pkg" +$pfile "CCTMXLayer.pkg" +$pfile "CCTMXObjectGroup.pkg" +$pfile "CCTMXTiledMap.pkg" +$pfile "CCTMXXMLParser.pkg" $pfile "CCTouch.pkg" $pfile "CCTransition.pkg" $pfile "ccTypes.pkg" From ceb5b122b05c1448261693173b2d7eae6f1617c7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Apr 2012 14:37:28 +0800 Subject: [PATCH 8/8] fixed #1190: closed CC_LUA_ENGINE_DEBUG by default. --- cocos2dx/include/ccConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index e17899a57a..b1eead860b 100755 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -256,7 +256,7 @@ To enable set it to a value different than 0. Disabled by default. /** Enable Lua engine debug log */ #ifndef CC_LUA_ENGINE_DEBUG -#define CC_LUA_ENGINE_DEBUG 1 +#define CC_LUA_ENGINE_DEBUG 0 #endif #endif // __CCCONFIG_H__