diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 5dfd20f426..1e897146f3 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -98,7 +98,7 @@ public: public: /** Allocates and initializes the action - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create() instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAction* action(); @@ -185,7 +185,7 @@ public: public: /** creates the action - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create(CCActionInterval* float) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); @@ -234,7 +234,7 @@ public: public: /** creates the action with a set boundary, It will work with no boundary if @param rect is equal to CCRectZero. - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create(CCNode*, const CCRect&) intead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); /** creates the action with a set boundary, diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 1178685dec..9cc9d5c5e6 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -299,9 +299,19 @@ CCObject* CCArray::lastObject() CCObject* CCArray::randomObject() { - if(data->num==0) return NULL; + if (data->num==0) + { + return NULL; + } - return data->arr[(int)(data->num*CCRANDOM_0_1())]; + float r = CCRANDOM_0_1(); + + if (r == 1) // to prevent from accessing data-arr[data->num], out of range. + { + r = 0; + } + + return data->arr[(int)(data->num * r)]; } bool CCArray::containsObject(CCObject* object) diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index b0eecdd118..c35e8ce225 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -116,37 +116,37 @@ public: /* static functions */ /** Create an array - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create() instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* array(); /** Create an array with one object - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithObject(CCObject*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObject(CCObject* pObject); /** Create an array with some objects - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create(CCObject*, ...) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObjects(CCObject* pObject, ...); /** Create an array with capacity - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithCapacity(unsigned int) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithCapacity(unsigned int capacity); /** Create an array with an existing array - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithArray(CCArray*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithArray(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithContentsOfFile(const char*) intead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithContentsOfFileThreadSafe(const char*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index c6f8e3392f..d39d7c5783 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -141,23 +141,24 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); /* static functions */ - //@deprecated: This interface will be deprecated sooner or later. + //@deprecated: Please use create() instead. This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionary(); - //@deprecated: This interface will be deprecated sooner or later. + //@deprecated: Please use createWithDictionary(CCDictionary*) instead. This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithContentsOfFile(const char*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithContentsOfFileThreadSafe(const char*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index e71ba6cd97..e5afefcbc6 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -44,9 +44,8 @@ static void removeUsedIndexBit(int index) CCEGLViewProtocol::CCEGLViewProtocol() : m_pDelegate(NULL) -, m_fScreenScaleFactor(1.0f) -, m_fYScale(1.0f) -, m_fXScale(1.0f) +, m_fScaleY(1.0f) +, m_fScaleX(1.0f) , m_bIsRetinaEnabled(false) , m_eResolutionPolicy(kResolutionUnKnown) { @@ -69,22 +68,22 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, Resol m_obDesignResolutionSize.setSize(width, height); - m_fXScale = (float)m_obScreenSize.width / m_obDesignResolutionSize.width; - m_fYScale = (float)m_obScreenSize.height / m_obDesignResolutionSize.height; + m_fScaleX = (float)m_obScreenSize.width / m_obDesignResolutionSize.width; + m_fScaleY = (float)m_obScreenSize.height / m_obDesignResolutionSize.height; if (resolutionPolicy == kCCResolutionNoBorder) { - m_fXScale = m_fYScale = MAX(m_fXScale, m_fYScale); + m_fScaleX = m_fScaleY = MAX(m_fScaleX, m_fScaleY); } if (resolutionPolicy == kCCResolutionShowAll) { - m_fXScale = m_fYScale = MIN(m_fXScale, m_fYScale); + m_fScaleX = m_fScaleY = MIN(m_fScaleX, m_fScaleY); } // calculate the rect of viewport - float viewPortW = m_obDesignResolutionSize.width * m_fXScale; - float viewPortH = m_obDesignResolutionSize.height * m_fYScale; + float viewPortW = m_obDesignResolutionSize.width * m_fScaleX; + float viewPortH = m_obDesignResolutionSize.height * m_fScaleY; m_obViewPortRect.setRect((m_obScreenSize.width - viewPortW) / 2, (m_obScreenSize.height - viewPortH) / 2, viewPortW, viewPortH); @@ -103,21 +102,26 @@ bool CCEGLViewProtocol::enableRetina() return false; } -CCSize CCEGLViewProtocol::getSize() +const CCSize& CCEGLViewProtocol::getSize() const { return m_obDesignResolutionSize; } -void CCEGLViewProtocol::setSize(float width, float height) +const CCSize& CCEGLViewProtocol::getFrameSize() const +{ + return m_obScreenSize; +} + +void CCEGLViewProtocol::setFrameSize(float width, float height) { m_obDesignResolutionSize = m_obScreenSize = CCSizeMake(width, height); } -CCSize CCEGLViewProtocol::getVisibleSize() +CCSize CCEGLViewProtocol::getVisibleSize() const { if (m_eResolutionPolicy == kCCResolutionNoBorder) { - return CCSizeMake(m_obScreenSize.width/m_fXScale, m_obScreenSize.height/m_fYScale); + return CCSizeMake(m_obScreenSize.width/m_fScaleX, m_obScreenSize.height/m_fScaleY); } else { @@ -125,12 +129,12 @@ CCSize CCEGLViewProtocol::getVisibleSize() } } -CCPoint CCEGLViewProtocol::getVisibleOrigin() +CCPoint CCEGLViewProtocol::getVisibleOrigin() const { if (m_eResolutionPolicy == kCCResolutionNoBorder) { - return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fXScale)/2, - (m_obDesignResolutionSize.height - m_obScreenSize.height/m_fYScale)/2); + return CCPointMake((m_obDesignResolutionSize.width - m_obScreenSize.width/m_fScaleX)/2, + (m_obDesignResolutionSize.height - m_obScreenSize.height/m_fScaleY)/2); } else { @@ -143,11 +147,6 @@ void CCEGLViewProtocol::setTouchDelegate(EGLTouchDelegate * pDelegate) m_pDelegate = pDelegate; } -float CCEGLViewProtocol::getScreenScaleFactor() -{ - return m_fScreenScaleFactor; -} - bool CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor) { return false; @@ -155,18 +154,18 @@ bool CCEGLViewProtocol::setContentScaleFactor(float contentScaleFactor) void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float h) { - glViewport((GLint)(x * m_fXScale + m_obViewPortRect.origin.x), - (GLint)(y * m_fYScale + m_obViewPortRect.origin.y), - (GLsizei)(w * m_fXScale), - (GLsizei)(h * m_fYScale)); + glViewport((GLint)(x * m_fScaleX + m_obViewPortRect.origin.x), + (GLint)(y * m_fScaleY + m_obViewPortRect.origin.y), + (GLsizei)(w * m_fScaleX), + (GLsizei)(h * m_fScaleY)); } void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h) { - glScissor((GLint)(x * m_fXScale + m_obViewPortRect.origin.x), - (GLint)(y * m_fYScale + m_obViewPortRect.origin.y), - (GLsizei)(w * m_fXScale), - (GLsizei)(h * m_fYScale)); + glScissor((GLint)(x * m_fScaleX + m_obViewPortRect.origin.x), + (GLint)(y * m_fScaleY + m_obViewPortRect.origin.y), + (GLsizei)(w * m_fScaleX), + (GLsizei)(h * m_fScaleY)); } void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) @@ -202,8 +201,8 @@ void CCEGLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float } else { - pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fXScale, - (y - m_obViewPortRect.origin.y) / m_fYScale); + pTouch->setTouchInfo(nUnusedIndex, (x - m_obViewPortRect.origin.x) / m_fScaleX, + (y - m_obViewPortRect.origin.y) / m_fScaleY); } CCLOG("x = %f y = %f", pTouch->getLocationInView().x, pTouch->getLocationInView().y); @@ -250,8 +249,8 @@ void CCEGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float } else { - pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fXScale, - (y - m_obViewPortRect.origin.y) / m_fYScale); + pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fScaleX, + (y - m_obViewPortRect.origin.y) / m_fScaleY); } set.addObject(pTouch); @@ -300,8 +299,8 @@ void CCEGLViewProtocol::getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[ } else { - pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fXScale, - (y - m_obViewPortRect.origin.y) / m_fYScale); + pTouch->setTouchInfo(pIndex->getValue(), (x - m_obViewPortRect.origin.x) / m_fScaleX, + (y - m_obViewPortRect.origin.y) / m_fScaleY); } set.addObject(pTouch); @@ -343,4 +342,24 @@ void CCEGLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], floa m_pDelegate->touchesCancelled(&set, NULL); } +const CCRect& CCEGLViewProtocol::getViewPortRect() const +{ + return m_obViewPortRect; +} + +float CCEGLViewProtocol::getScaleX() const +{ + return m_fScaleX; +} + +float CCEGLViewProtocol::getScaleY() const +{ + return m_fScaleY; +} + +bool CCEGLViewProtocol::isRetinaEnabled() const +{ + return m_bIsRetinaEnabled; +} + NS_CC_END diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index 0cb3be3574..f285d8ba22 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -36,43 +36,126 @@ public: CCEGLViewProtocol(); virtual ~CCEGLViewProtocol(); + /** Force destorying EGL view, subclass must implement this method. */ virtual void end() = 0; + + /** Get whether opengl render system is ready, subclass must implement this method. */ virtual bool isOpenGLReady() = 0; + + /** Exchanges the front and back buffers, subclass must implement this method. */ virtual void swapBuffers() = 0; + + /** Open or close IME keyboard , subclass must implement this method. */ virtual void setIMEKeyboardState(bool bOpen) = 0; - virtual CCSize getSize(); - virtual void setSize(float width, float height); - virtual CCSize getVisibleSize(); - virtual CCPoint getVisibleOrigin(); - virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); - virtual void setTouchDelegate(EGLTouchDelegate * pDelegate); - virtual float getScreenScaleFactor(); - virtual bool setContentScaleFactor(float contentScaleFactor); - virtual void setViewPortInPoints(float x , float y , float w , float h); - virtual void setScissorInPoints(float x , float y , float w , float h); - virtual bool enableRetina(); + /** + * Get design resolution size. + * If setDesignResolutionSize wasn't invoked, the result of this function return is the same as 'getFrameSize' + */ + + virtual const CCSize& getSize() const; + + /** + * Get the frame size of EGL view. + * In general, it returns the screen size since the EGL view is a fullscreen view. + */ + virtual const CCSize& getFrameSize() const; + + /** + * Set the frame size of EGL view. + */ + virtual void setFrameSize(float width, float height); + + /** + * Get the visible area size of opengl viewport. + */ + virtual CCSize getVisibleSize() const; + + /** + * Get the visible origin point of opengl viewport. + */ + virtual CCPoint getVisibleOrigin() const; + + /** + * Set the design resolutin size. + * You can't use it with enableRetina together. + * @param width Design resolution width. + * @param height Design resolution height. + * @param resolutionPolicy The resolution policy you need, there are: + * [1] kCCResolutionExactFit Fill screen, if the design resolution ratio of width and height is different from the screen resolution ratio, your game view will be stretched. + * [2] kCCResolutionNoBorder Full screen without black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two areas of your game view will be cut. + * [3] kCCResolutionShowAll Full screen with black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two black border will be shown on the screen; + */ + virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); + + /** Set touch delegate */ + virtual void setTouchDelegate(EGLTouchDelegate * pDelegate); + + /** + * Set content scale factor. + * @return If return true, it means the plaform supports retina display. + */ + virtual bool setContentScaleFactor(float contentScaleFactor); + + /** + * Set opengl view port rectangle with points. + */ + virtual void setViewPortInPoints(float x , float y , float w , float h); + + /** + * Set Scissor rectangle with points. + */ + virtual void setScissorInPoints(float x , float y , float w , float h); + + /** + * Enable retina mode. + * You can't use it with setDesignResolutionSize + */ + virtual bool enableRetina(); /** handle touch events by default, if you want to custom your handles, please override these functions */ - virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); - virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); - virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); - virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); + virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); + virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); + virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); + virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); + /** + * Get opengl view port rectangle. + */ + const CCRect& getViewPortRect() const; + + /** + * Get the scale factor of horizontal direction. + * + */ + float getScaleX() const; + + /** + * Get the scale factor of vertical direction. + */ + float getScaleY() const; + + /** + * Get whether the retina mode is enabled. + */ + bool isRetinaEnabled() const; private: void getSetOfTouchesEndOrCancel(CCSet& set, int num, int ids[], float xs[], float ys[]); + protected: EGLTouchDelegate* m_pDelegate; - float m_fScreenScaleFactor; + // real size of screen CCSize m_obScreenSize; // resolution size, it is the size the app resources designed for CCSize m_obDesignResolutionSize; // the view port size CCRect m_obViewPortRect; + // the view name char m_szViewName[50]; - float m_fXScale; - float m_fYScale; + + float m_fScaleX; + float m_fScaleY; ResolutionPolicy m_eResolutionPolicy; bool m_bIsRetinaEnabled; }; diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 0e6b1d2af0..100bb1db46 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -77,13 +77,13 @@ public: /// @endcond /** - @brief Set the ResourcePath,we will find resource relative to this path - @param pszResourcePath Relative path to root + @brief Set the resource directory,we will find resource relative to this directory + @param pszDirectoryName Relative path to root */ void setResourceDirectory(const char *pszDirectoryName); /** - @brief Get the ResourcePath + @brief Get the resource directory */ const char* getResourceDirectory(); diff --git a/cocos2dx/platform/ios/CCEGLView.mm b/cocos2dx/platform/ios/CCEGLView.mm index 7e3b3e109d..fb7abd0747 100644 --- a/cocos2dx/platform/ios/CCEGLView.mm +++ b/cocos2dx/platform/ios/CCEGLView.mm @@ -62,7 +62,7 @@ bool CCEGLView::setContentScaleFactor(float contentScaleFactor) view.contentScaleFactor = contentScaleFactor; [view setNeedsLayout]; - m_fXScale = m_fYScale = contentScaleFactor; + m_fScaleX = m_fScaleY = contentScaleFactor; m_bIsRetinaEnabled = true; return true; @@ -99,12 +99,6 @@ void CCEGLView::swapBuffers() [[EAGLView sharedEGLView] swapBuffers]; } -CCSize CCEGLView::getFrameSize() -{ - assert(false); - return CCSizeMake(0, 0); -} - void CCEGLView::setIMEKeyboardState(bool bOpen) { if (bOpen) diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 6ecd08cc38..828068e8d8 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -171,6 +171,15 @@ void CCFileUtils::purgeCachedEntries() void CCFileUtils::setResourceDirectory(const char *pszDirectoryName) { m_obDirectory = pszDirectoryName; + if (m_obDirectory.size() > 0 && m_obDirectory[m_obDirectory.size() - 1] != '/') + { + m_obDirectory.append("/"); + } +} + +const char* CCFileUtils::getResourceDirectory() +{ + return m_obDirectory.c_str(); } const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath) diff --git a/cocos2dx/platform/ios/EAGLView.h b/cocos2dx/platform/ios/EAGLView.h index 98760ca99d..5f10b7795e 100755 --- a/cocos2dx/platform/ios/EAGLView.h +++ b/cocos2dx/platform/ios/EAGLView.h @@ -92,9 +92,13 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. //fsaa addition BOOL multisampling_; unsigned int requestedSamples_; + BOOL isUseUITextField; @private NSString * markedText_; CGRect caretRect_; + CGRect originalRect_; + NSNotification* keyboardShowNotification_; + BOOL isKeyboardShown_; } @property(nonatomic, readonly) UITextPosition *beginningOfDocument; @@ -104,7 +108,8 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. @property (nonatomic, copy) NSDictionary *markedTextStyle; @property(readwrite, copy) UITextRange *selectedTextRange; @property(nonatomic, readonly) id tokenizer; - +@property(nonatomic, readonly, getter = isKeyboardShown) BOOL isKeyboardShown; +@property(nonatomic, retain) NSNotification* keyboardShowNotification; /** creates an initializes an EAGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */ + (id) viewWithFrame:(CGRect)frame; /** creates an initializes an EAGLView with a frame, a color buffer format, and 0-bit depth buffer */ @@ -147,4 +152,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. -(int) getWidth; -(int) getHeight; +-(void) doAnimationWhenKeyboardMoveWithDuration:(float) duration distance:(float) dis; +-(void) doAnimationWhenAnotherEditBeClicked; @end diff --git a/cocos2dx/platform/ios/EAGLView.mm b/cocos2dx/platform/ios/EAGLView.mm index bf4c664165..dbc9c81ebd 100755 --- a/cocos2dx/platform/ios/EAGLView.mm +++ b/cocos2dx/platform/ios/EAGLView.mm @@ -70,7 +70,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. #import "CCTouch.h" #import "CCIMEDispatcher.h" #import "OpenGL_Internal.h" - +#import "CCEGLView.h" //CLASS IMPLEMENTATIONS: @@ -87,7 +87,8 @@ static EAGLView *view = 0; @synthesize pixelFormat=pixelformat_, depthFormat=depthFormat_; @synthesize context=context_; @synthesize multiSampling=multiSampling_; - +@synthesize isKeyboardShown=isKeyboardShown_; +@synthesize keyboardShowNotification = keyboardShowNotification_; + (Class) layerClass { return [CAEAGLLayer class]; @@ -132,6 +133,7 @@ static EAGLView *view = 0; { if((self = [super initWithFrame:frame])) { + isUseUITextField = YES; pixelformat_ = format; depthFormat_ = depth; multiSampling_ = sampling; @@ -145,6 +147,9 @@ static EAGLView *view = 0; view = self; + + originalRect_ = self.frame; + self.keyboardShowNotification = nil; } return self; @@ -237,6 +242,7 @@ static EAGLView *view = 0; - (void) dealloc { [renderer_ release]; + [self.keyboardShowNotification release]; [super dealloc]; } @@ -359,11 +365,34 @@ static EAGLView *view = 0; return ret; } + +-(void) handleTouchesAfterKeyboardShow +{ + NSArray *subviews = self.subviews; + + for(UIView* view in subviews) + { + if([view isKindOfClass:NSClassFromString(@"CustomUITextField")]) + { + if ([view isFirstResponder]) + { + [view resignFirstResponder]; + return; + } + } + } +} + // Pass the touches to the superview #pragma mark EAGLView - Touch Delegate - - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + if (isKeyboardShown_) + { + [self handleTouchesAfterKeyboardShow]; + return; + } + int ids[CC_MAX_TOUCHES] = {0}; float xs[CC_MAX_TOUCHES] = {0.0f}; float ys[CC_MAX_TOUCHES] = {0.0f}; @@ -435,12 +464,29 @@ static EAGLView *view = 0; [markedText_ release]; } markedText_ = nil; + if (isUseUITextField) + { + return NO; + } return YES; } +- (BOOL)becomeFirstResponder +{ + isUseUITextField = NO; + return [super becomeFirstResponder]; +} + +- (BOOL)resignFirstResponder +{ + isUseUITextField = YES; + return [super resignFirstResponder]; +} + #pragma mark - #pragma mark UIKeyInput protocol + - (BOOL)hasText { return NO; @@ -724,19 +770,47 @@ static EAGLView *view = 0; default: break; } + cocos2d::CCIMEKeyboardNotificationInfo notiInfo; notiInfo.begin = cocos2d::CCRect(begin.origin.x, begin.origin.y, - begin.size.width, + begin.size.width, begin.size.height); notiInfo.end = cocos2d::CCRect(end.origin.x, end.origin.y, - end.size.width, + end.size.width, end.size.height); notiInfo.duration = (float)aniDuration; + + float offestY = cocos2d::CCEGLView::sharedOpenGLView().getViewPortRect().origin.y; + + if (offestY > 0.0f) + { + notiInfo.begin.origin.y += offestY; + notiInfo.begin.size.height -= offestY; + notiInfo.end.size.height -= offestY; + } + + if (!cocos2d::CCEGLView::sharedOpenGLView().isRetinaEnabled()) + { + float scaleX = cocos2d::CCEGLView::sharedOpenGLView().getScaleX(); + float scaleY = cocos2d::CCEGLView::sharedOpenGLView().getScaleY(); + + notiInfo.begin.origin.x /= scaleX; + notiInfo.begin.origin.y /= scaleY; + notiInfo.begin.size.width /= scaleX; + notiInfo.begin.size.height /= scaleY; + + notiInfo.end.origin.x /= scaleX; + notiInfo.end.origin.y /= scaleY; + notiInfo.end.size.width /= scaleX; + notiInfo.end.size.height /= scaleY; + } + cocos2d::CCIMEDispatcher* dispatcher = cocos2d::CCIMEDispatcher::sharedDispatcher(); if (UIKeyboardWillShowNotification == type) { + self.keyboardShowNotification = [notif copy]; dispatcher->dispatchKeyboardWillShow(notiInfo); } else if (UIKeyboardDidShowNotification == type) @@ -746,6 +820,7 @@ static EAGLView *view = 0; caretRect_ = end; caretRect_.origin.y = viewSize.height - (caretRect_.origin.y + caretRect_.size.height + [UIFont smallSystemFontSize]); caretRect_.size.height = 0; + isKeyboardShown_ = YES; } else if (UIKeyboardWillHideNotification == type) { @@ -755,6 +830,58 @@ static EAGLView *view = 0; { caretRect_ = CGRectZero; dispatcher->dispatchKeyboardDidHide(notiInfo); + isKeyboardShown_ = NO; } } + +-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)dis +{ + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDuration:duration]; + [UIView setAnimationBeginsFromCurrentState:YES]; + + NSLog(@"[animation] dis = %f\n", dis); + + if (dis < 0.0f) dis = 0.0f; + + if (!cocos2d::CCEGLView::sharedOpenGLView().isRetinaEnabled()) + { + dis *= cocos2d::CCEGLView::sharedOpenGLView().getScaleY(); + } + + switch ([[UIApplication sharedApplication] statusBarOrientation]) + { + case UIInterfaceOrientationPortrait: + self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y - dis, originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationPortraitUpsideDown: + self.frame = CGRectMake(originalRect_.origin.x, originalRect_.origin.y + dis, originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationLandscapeLeft: + self.frame = CGRectMake(originalRect_.origin.x - dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); + break; + + case UIInterfaceOrientationLandscapeRight: + self.frame = CGRectMake(originalRect_.origin.x + dis, originalRect_.origin.y , originalRect_.size.width, originalRect_.size.height); + break; + + default: + break; + } + + [UIView commitAnimations]; +} + + +-(void) doAnimationWhenAnotherEditBeClicked +{ + if (self.keyboardShowNotification != nil) + { + [[NSNotificationCenter defaultCenter]postNotification:self.keyboardShowNotification]; + } +} + @end diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index e72daec808..328282a805 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -397,10 +397,10 @@ void CCEGLView::resize(int width, int height) rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); } -void CCEGLView::setSize(float width, float height) +void CCEGLView::setFrameSize(float width, float height) { Create((LPCTSTR)m_szViewName, (int)width, (int)height); - CCEGLViewProtocol::setSize(width, height); + CCEGLViewProtocol::setFrameSize(width, height); } void CCEGLView::centerWindow() diff --git a/cocos2dx/platform/win32/CCEGLView.h b/cocos2dx/platform/win32/CCEGLView.h index 88104b8e94..552ba9c99d 100644 --- a/cocos2dx/platform/win32/CCEGLView.h +++ b/cocos2dx/platform/win32/CCEGLView.h @@ -45,7 +45,7 @@ public: virtual void end(); virtual void swapBuffers(); virtual bool setContentScaleFactor(float contentScaleFactor); - virtual void setSize(float width, float height); + virtual void setFrameSize(float width, float height); virtual void setIMEKeyboardState(bool bOpen); private: diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index b4f96e482c..1eb5ac7ba1 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -128,17 +128,17 @@ public: /** Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithTexture(CCTexture2D*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithTexture(CCTexture2D*, const CCRect&) instead, This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); - /** Creates an sprite with a texture. + /** Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0). */ @@ -150,14 +150,14 @@ public: static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); /** Creates an sprite with an sprite frame. - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithSpriteFrame(CCSpriteFrame*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception. - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use createWithSpriteFrameName(const char*) instead. This interface will be deprecated sooner or later. @since v0.9 */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); @@ -175,13 +175,13 @@ public: /** Creates an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create(const char*) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName); /** Creates an sprite with an image filename and a rect. The offset will be (0,0). - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create(const char*, const CCRect&) instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); @@ -197,7 +197,7 @@ public: static CCSprite* create(const char *pszFileName, const CCRect& rect); /** Creates an sprite. - @deprecated: This interface will be deprecated sooner or later. + @deprecated: Please use create() instead. This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* node(); /** Creates an sprite. diff --git a/document/doxygen.cocos2d-x b/document/doxygen.config similarity index 99% rename from document/doxygen.cocos2d-x rename to document/doxygen.config index 156fff923d..dd84e01078 100644 --- a/document/doxygen.cocos2d-x +++ b/document/doxygen.config @@ -1214,7 +1214,7 @@ MATHJAX_EXTENSIONS = # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client diff --git a/extensions/GUI/CCEditBox/CCEditBox.cpp b/extensions/GUI/CCEditBox/CCEditBox.cpp new file mode 100644 index 0000000000..a3d3401243 --- /dev/null +++ b/extensions/GUI/CCEditBox/CCEditBox.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCEditBox.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "CCEditBoxImplIOS.h" +#endif + +NS_CC_EXT_BEGIN + +CCEditBox::CCEditBox(void) +: m_pEditBoxImpl(NULL) +, m_pDelegate(NULL) +, m_eEditBoxInputMode(kEditBoxInputModeAny) +, m_eEditBoxInputFlag(kEditBoxInputFlagInitialCapsAllCharacters) +, m_eKeyboardReturnType(kKeyboardReturnTypeDefault) +, m_colText(ccWHITE) +, m_colPlaceHolder(ccGRAY) +, m_nMaxLength(0) +, m_fAdjustHeight(0.0f) +{ +} + +CCEditBox::~CCEditBox(void) +{ + CC_SAFE_DELETE(m_pEditBoxImpl); +} + + +void CCEditBox::touchDownAction(CCObject *sender, CCControlEvent controlEvent) +{ + m_pEditBoxImpl->openKeyboard(); +} + +CCEditBox* CCEditBox::create(const CCSize& size) +{ + CCEditBox* pRet = new CCEditBox(); + + if (pRet != NULL && pRet->initWithSize(size)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + + return pRet; +} + +bool CCEditBox::initWithSize(const CCSize& size) +{ + if (CCControlButton::init()) + { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + m_pEditBoxImpl = new CCEditBoxImplIOS(this); +#endif + m_pEditBoxImpl->initWithSize(size); + + + CCScale9Sprite* pNormal9Sprite = CCScale9Sprite::create("extensions/button.png"); + CCScale9Sprite* pPressed9Sprite = CCScale9Sprite::create("extensions/buttonHighlighted.png"); + CCScale9Sprite* pDisabled9Sprite = CCScale9Sprite::create("extensions/button.png"); + setBackgroundSpriteForState(pNormal9Sprite, CCControlStateNormal); + setBackgroundSpriteForState(pPressed9Sprite, CCControlStateHighlighted); + setBackgroundSpriteForState(pDisabled9Sprite, CCControlStateDisabled); + + this->setPreferredSize(size); + this->setPosition(ccp(0, 0)); + this->addTargetWithActionForControlEvent(this, cccontrol_selector(CCEditBox::touchDownAction), CCControlEventTouchDown); + + return true; + } + return false; +} + +void CCEditBox::setDelegate(CCEditBoxDelegate* pDelegate) +{ + m_pDelegate = pDelegate; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setDelegate(pDelegate); + } +} + +void CCEditBox::setText(const char* pText) +{ + if (pText != NULL) + { + m_strText = pText; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setText(pText); + } + } +} + +const char* CCEditBox::getText(void) +{ + if (m_pEditBoxImpl != NULL) + { + return m_pEditBoxImpl->getText(); + } + + return NULL; +} + +void CCEditBox::setFontColor(const ccColor3B& color) +{ + m_colText = color; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setFontColor(color); + } +} + +void CCEditBox::setPlaceholderFontColor(const ccColor3B& color) +{ + m_colText = color; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setPlaceholderFontColor(color); + } +} + +void CCEditBox::setPlaceHolder(const char* pText) +{ + if (pText != NULL) + { + m_strPlaceHolder = pText; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setPlaceHolder(pText); + } + } +} + +const char* CCEditBox::getPlaceHolder(void) +{ + return m_strPlaceHolder.c_str(); +} + +void CCEditBox::setInputMode(EditBoxInputMode inputMode) +{ + m_eEditBoxInputMode = inputMode; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setInputMode(inputMode); + } +} + +void CCEditBox::setMaxLength(int maxLength) +{ + m_nMaxLength = maxLength; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setMaxLength(maxLength); + } +} + + +int CCEditBox::getMaxLength() +{ + return m_nMaxLength; +} + +void CCEditBox::setInputFlag(EditBoxInputFlag inputFlag) +{ + m_eEditBoxInputFlag = inputFlag; + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setInputFlag(inputFlag); + } +} + +void CCEditBox::setReturnType(KeyboardReturnType returnType) +{ + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setReturnType(returnType); + } +} + +/* override function */ +void CCEditBox::setPosition(const CCPoint& pos) +{ + CCControlButton::setPosition(pos); + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setPosition(pos); + } +} + +void CCEditBox::setContentSize(const CCSize& size) +{ + CCControlButton::setContentSize(size); + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->setContentSize(size); + } +} + +void CCEditBox::visit(void) +{ + CCControlButton::visit(); + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->visit(); + } +} + +void CCEditBox::onExit(void) +{ + CCControlButton::onExit(); + if (m_pEditBoxImpl != NULL) + { + // remove system edit control + m_pEditBoxImpl->closeKeyboard(); + } +} + +static CCRect getRect(CCNode * pNode) +{ + CCRect rc; + rc.origin = pNode->getPosition(); + rc.size = pNode->getContentSize(); + rc.origin.x -= rc.size.width / 2; + rc.origin.y -= rc.size.height / 2; + return rc; +} + +void CCEditBox::keyboardWillShow(CCIMEKeyboardNotificationInfo& info) +{ + //CCLOG("TextInputTest:keyboardWillShowAt(origin:%f,%f, size:%f,%f)", + // info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height); + + CCRect rectTracked = getRect(this); + //CCLOG("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)", + // rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height); + + // if the keyboard area doesn't intersect with the tracking node area, nothing need to do. + if (! rectTracked.intersectsRect(info.end)) + { + CCLog("info end x = %f, y = %f; width = %f, height = %f", info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height); + CCLog("rectTracked end x = %f, y = %f; width = %f, height = %f", rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height); + CCLog("needn't to adjust view layout."); + return; + } + + // assume keyboard at the bottom of screen, calculate the vertical adjustment. + m_fAdjustHeight = info.end.getMaxY() - rectTracked.getMinY(); + CCLOG("CCEditBox:needAdjustVerticalPosition(%f)", m_fAdjustHeight); + + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->doAnimationWhenKeyboardMove(info.duration, m_fAdjustHeight); + } +} + +void CCEditBox::keyboardDidShow(CCIMEKeyboardNotificationInfo& info) +{ + if (m_pDelegate != NULL) + { + m_pDelegate->editBoxEditingDidBegin(this); + } +} + +void CCEditBox::keyboardWillHide(CCIMEKeyboardNotificationInfo& info) +{ + if (m_pEditBoxImpl != NULL) + { + m_pEditBoxImpl->doAnimationWhenKeyboardMove(info.duration, -m_fAdjustHeight); + } + +} + +void CCEditBox::keyboardDidHide(CCIMEKeyboardNotificationInfo& info) +{ + if (m_pDelegate != NULL) + { + m_pDelegate->editBoxEditingDidEnd(this); + m_pDelegate->editBoxReturn(this); + } +} + + +NS_CC_EXT_END diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h new file mode 100644 index 0000000000..7869c7fdac --- /dev/null +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -0,0 +1,308 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CCEDITTEXT_H__ +#define __CCEDITTEXT_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" +#include "../CCControlExtension/CCControlExtensions.h" + +NS_CC_EXT_BEGIN + + +enum KeyboardReturnType { + kKeyboardReturnTypeDefault = 0, + kKeyboardReturnTypeDone, + kKeyboardReturnTypeSend, + kKeyboardReturnTypeSearch, + kKeyboardReturnTypeGo +}; + + +/** + * \brief The EditBoxInputMode defines the type of text that the user is allowed + * to enter. + */ +enum EditBoxInputMode +{ + /** + * The user is allowed to enter any text, including line breaks. + */ + kEditBoxInputModeAny = 0, + + /** + * The user is allowed to enter an e-mail address. + */ + kEditBoxInputModeEmailAddr, + + /** + * The user is allowed to enter an integer value. + */ + kEditBoxInputModeNumeric, + + /** + * The user is allowed to enter a phone number. + */ + kEditBoxInputModePhoneNumber, + + /** + * The user is allowed to enter a URL. + */ + kEditBoxInputModeUrl, + + /** + * The user is allowed to enter a real number value. + * This extends kEditBoxInputModeNumeric by allowing a decimal point. + */ + kEditBoxInputModeDecimal, + + /** + * The user is allowed to enter any text, except for line breaks. + */ + kEditBoxInputModeSingleLine +}; + +/** + * \brief The EditBoxInputFlag defines how the input text is displayed/formatted. + */ +enum EditBoxInputFlag +{ + /** + * Indicates that the text entered is confidential data that should be + * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE. + */ + kEditBoxInputFlagPassword = 0, + + /** + * Indicates that the text entered is sensitive data that the + * implementation must never store into a dictionary or table for use + * in predictive, auto-completing, or other accelerated input schemes. + * A credit card number is an example of sensitive data. + */ + kEditBoxInputFlagSensitive, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each word should be capitalized. + */ + kEditBoxInputFlagInitialCapsWord, + + /** + * This flag is a hint to the implementation that during text editing, + * the initial letter of each sentence should be capitalized. + */ + kEditBoxInputFlagInitialCapsSentence, + + /** + * Capitalize all characters automatically. + */ + kEditBoxInputFlagInitialCapsAllCharacters + +}; + + +class CCEditBox; +class CCEditBoxImpl; + + +class CCEditBoxDelegate +{ +public: + virtual ~CCEditBoxDelegate() {}; + + /** + * This method is called when an edit box gains focus after keyboard is shown. + * @param editBox The edit box object that generated the event. + */ + virtual void editBoxEditingDidBegin(CCEditBox* editBox) {}; + + + /** + * This method is called when an edit box loses focus after keyboard is hidden. + * @param editBox The edit box object that generated the event. + */ + virtual void editBoxEditingDidEnd(CCEditBox* editBox) {}; + + /** + * This method is called when the edit box text was changed. + * @param editBox The edit box object that generated the event. + * @param text The new text. + */ + virtual void editBoxTextChanged( + CCEditBox* editBox, + const std::string& text) {}; + + /** + * This method is called when the return button was pressed or the outside area of keyboard was touched. + * @param editBox The edit box object that generated the event. + */ + virtual void editBoxReturn(CCEditBox* editBox) = 0; + +}; + +/** + * \brief Class for edit box. + * + * You can use this widget to gather small amounts of text from the user. + * + */ + +class CCEditBox +: public CCControlButton +, public CCIMEDelegate +{ +public: + /** + * Constructor. + */ + CCEditBox(void); + + /** + * Destructor. + */ + virtual ~CCEditBox(void); + + /** + * create a edit box with size. + * @return An autorelease pointer of CCEditBox, you don't need to release it only if you retain it again. + */ + static CCEditBox* create(const CCSize& size); + + /** + * Init edit box with specified size. This method should be invoked right after constructor. + * @param size The size of edit box. + */ + bool initWithSize(const CCSize& size); + + /** + * Set the delegate for edit box. + */ + void setDelegate(CCEditBoxDelegate* pDelegate); + + /** + * Set the text entered in the edit box. + * @param pText The given text. + */ + void setText(const char* pText); + + /** + * Get the text entered in the edit box. + * @return The text entered in the edit box. + */ + const char* getText(void); + + /** + * Set the font color of the widget's text. + */ + void setFontColor(const ccColor3B& color); + + /** + * Set the font color of the placeholder text when the edit box is empty. + */ + void setPlaceholderFontColor(const ccColor3B& color); + + /** + * Set a text in the edit box that acts as a placeholder when an + * edit box is empty. + * @param pText The given text. + */ + void setPlaceHolder(const char* pText); + + /** + * Get a text in the edit box that acts as a placeholder when an + * edit box is empty. + */ + const char* getPlaceHolder(void); + + /** + * Set the input mode of the edit box. + * @param inputMode One of the EditBoxInputMode constants. + */ + void setInputMode(EditBoxInputMode inputMode); + + /** + * Sets the maximum input length of the edit box. + * Setting this value enables multiline input mode by default. + * Available on Android, iOS and Windows Phone. + * + * @param maxLength The maximum length. + */ + void setMaxLength(int maxLength); + + /** + * Gets the maximum input length of the edit box. + * + * @return Maximum input length. + */ + int getMaxLength(); + + /** + * Set the input flags that are to be applied to the edit box. + * @param inputFlag One of the EditBoxInputFlag constants. + */ + void setInputFlag(EditBoxInputFlag inputFlag); + + /** + * Set the return type that are to be applied to the edit box. + * @param returnType One of the CCKeyboardReturnType constants. + */ + void setReturnType(KeyboardReturnType returnType); + + /* override functions */ + virtual void setPosition(const CCPoint& pos); + virtual void setContentSize(const CCSize& size); + virtual void visit(void); + virtual void onExit(void); + virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo& info); + virtual void keyboardDidShow(CCIMEKeyboardNotificationInfo& info); + virtual void keyboardWillHide(CCIMEKeyboardNotificationInfo& info); + virtual void keyboardDidHide(CCIMEKeyboardNotificationInfo& info); + + /* callback funtions */ + void touchDownAction(CCObject *sender, CCControlEvent controlEvent); + +protected: + CCEditBoxImpl* m_pEditBoxImpl; + CCEditBoxDelegate* m_pDelegate; + + EditBoxInputMode m_eEditBoxInputMode; + EditBoxInputFlag m_eEditBoxInputFlag; + KeyboardReturnType m_eKeyboardReturnType; + + std::string m_strText; + std::string m_strPlaceHolder; + + ccColor3B m_colText; + ccColor3B m_colPlaceHolder; + + int m_nMaxLength; + float m_fAdjustHeight; +}; + +NS_CC_EXT_END + +#endif /* __CCEDITTEXT_H__ */ + diff --git a/extensions/GUI/CCEditBox/CCEditBoxImpl.h b/extensions/GUI/CCEditBox/CCEditBoxImpl.h new file mode 100644 index 0000000000..91857e2d2a --- /dev/null +++ b/extensions/GUI/CCEditBox/CCEditBoxImpl.h @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CCEditBoxIMPL_H__ +#define __CCEditBoxIMPL_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" +#include "CCEditBox.h" + +NS_CC_EXT_BEGIN + + +class CCEditBoxImpl +{ +public: + CCEditBoxImpl(CCEditBox* pEditBox) : m_pEditBox(pEditBox), m_pDelegate(NULL) {} + virtual ~CCEditBoxImpl() {} + + virtual bool initWithSize(const CCSize& size) = 0; + virtual void setFontColor(const ccColor3B& color) = 0; + virtual void setPlaceholderFontColor(const ccColor3B& color) = 0; + virtual void setInputMode(EditBoxInputMode inputMode) = 0; + virtual void setInputFlag(EditBoxInputFlag inputFlag) = 0; + virtual void setMaxLength(int maxLength) = 0; + virtual int getMaxLength() = 0; + virtual void setReturnType(KeyboardReturnType returnType) = 0; + + virtual void setText(const char* pText) = 0; + virtual const char* getText(void) = 0; + virtual void setPlaceHolder(const char* pText) = 0; + virtual void doAnimationWhenKeyboardMove(float duration, float distance) = 0; + + virtual void openKeyboard() = 0; + virtual void closeKeyboard() = 0; + + virtual void setPosition(const CCPoint& pos) = 0; + virtual void setContentSize(const CCSize& size) = 0; + virtual void visit(void) = 0; + + void setDelegate(CCEditBoxDelegate* pDelegate) { m_pDelegate = pDelegate; }; + CCEditBoxDelegate* getDelegate() { return m_pDelegate; }; + CCEditBox* getCCEditBox() { return m_pEditBox; }; +protected: + CCEditBoxDelegate* m_pDelegate; + CCEditBox* m_pEditBox; +}; + + +NS_CC_EXT_END + +#endif /* __CCEditBoxIMPL_H__ */ diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h new file mode 100644 index 0000000000..ebe8144a3c --- /dev/null +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.h @@ -0,0 +1,73 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CCEditBoxIMPLIOS_H__ +#define __CCEditBoxIMPLIOS_H__ + +#include "cocos2d.h" +#include "ExtensionMacros.h" +#include "CCEditBoxImpl.h" + +NS_CC_EXT_BEGIN + +class CCEditBox; + +class CCEditBoxImplIOS : public CCEditBoxImpl +{ +public: + CCEditBoxImplIOS(CCEditBox* pEditText); + virtual ~CCEditBoxImplIOS(); + + virtual bool initWithSize(const CCSize& size); + virtual void setFontColor(const ccColor3B& color); + virtual void setPlaceholderFontColor(const ccColor3B& color); + virtual void setInputMode(EditBoxInputMode inputMode); + virtual void setInputFlag(EditBoxInputFlag inputFlag); + virtual void setMaxLength(int maxLength); + virtual int getMaxLength(); + virtual void setReturnType(KeyboardReturnType returnType); + + virtual void setText(const char* pText); + virtual const char* getText(void); + virtual void setPlaceHolder(const char* pText); + virtual void setPosition(const CCPoint& pos); + virtual void setContentSize(const CCSize& size); + virtual void visit(void); + virtual void doAnimationWhenKeyboardMove(float duration, float distance); + virtual void openKeyboard(); + virtual void closeKeyboard(); + +private: + CCEditBox* m_pEditBox; + CCSize m_tContentSize; + void* m_pSysEdit; + int m_nMaxTextLength; +}; + + +NS_CC_EXT_END + +#endif /* __CCEditBoxIMPLIOS_H__ */ + diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm new file mode 100644 index 0000000000..d818752b76 --- /dev/null +++ b/extensions/GUI/CCEditBox/CCEditBoxImplIOS.mm @@ -0,0 +1,235 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCEditBoxImplIOS.h" +#include "CCEditBox.h" +#import "EAGLView.h" +#import "EditBoxImplIOS.h" + +NS_CC_EXT_BEGIN + +#define GET_IMPL ((EditBoxImplIOS*)m_pSysEdit) + +CCEditBoxImplIOS::CCEditBoxImplIOS(CCEditBox* pEditText) +: CCEditBoxImpl(pEditText) +, m_pSysEdit(NULL) +, m_nMaxTextLength(-1) +{ + +} + +CCEditBoxImplIOS::~CCEditBoxImplIOS() +{ + [GET_IMPL release]; +} + +void CCEditBoxImplIOS::doAnimationWhenKeyboardMove(float duration, float distance) +{ + if ([GET_IMPL isEditState] || distance < 0.0f) + { + [GET_IMPL doAnimationWhenKeyboardMoveWithDuration:duration distance:distance]; + } +} + +bool CCEditBoxImplIOS::initWithSize(const CCSize& size) +{ + do + { + CCEGLViewProtocol& eglView = CCEGLView::sharedOpenGLView(); + + CGRect rect; + if (eglView.isRetinaEnabled()) + { + rect = CGRectMake(0, 0, size.width,size.height); + } + else + { + rect = CGRectMake(0, 0, size.width * eglView.getScaleX(),size.height * eglView.getScaleY()); + } + m_pSysEdit = [[EditBoxImplIOS alloc] initWithFrame:rect editBox:this]; + if (!m_pSysEdit) break; + + return true; + }while (0); + + return false; +} + +void CCEditBoxImplIOS::setFontColor(const ccColor3B& color) +{ + GET_IMPL.textField.textColor = [UIColor colorWithRed:color.r / 255.0f green:color.g / 255.0f blue:color.b / 255.0f alpha:1.0f]; +} + +void CCEditBoxImplIOS::setPlaceholderFontColor(const ccColor3B& color) +{ + // TODO need to be implemented. +} + +void CCEditBoxImplIOS::setInputMode(EditBoxInputMode inputMode) +{ + switch (inputMode) + { + case kEditBoxInputModeEmailAddr: + GET_IMPL.textField.keyboardType = UIKeyboardTypeEmailAddress; + break; + case kEditBoxInputModeNumeric: + GET_IMPL.textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; + break; + case kEditBoxInputModePhoneNumber: + GET_IMPL.textField.keyboardType = UIKeyboardTypePhonePad; + break; + case kEditBoxInputModeUrl: + GET_IMPL.textField.keyboardType = UIKeyboardTypeURL; + break; + case kEditBoxInputModeDecimal: + GET_IMPL.textField.keyboardType = UIKeyboardTypeDecimalPad; + break; + case kEditBoxInputModeSingleLine: + GET_IMPL.textField.keyboardType = UIKeyboardTypeDefault; + break; + default: + GET_IMPL.textField.keyboardType = UIKeyboardTypeDefault; + break; + } +} + +void CCEditBoxImplIOS::setMaxLength(int maxLength) +{ + m_nMaxTextLength = maxLength; +} + +int CCEditBoxImplIOS::getMaxLength() +{ + return m_nMaxTextLength; +} + +void CCEditBoxImplIOS::setInputFlag(EditBoxInputFlag inputFlag) +{ + switch (inputFlag) + { + case kEditBoxInputFlagPassword: + GET_IMPL.textField.secureTextEntry = YES; + break; + case kEditBoxInputFlagInitialCapsWord: + GET_IMPL.textField.autocapitalizationType = UITextAutocapitalizationTypeWords; + break; + case kEditBoxInputFlagInitialCapsSentence: + GET_IMPL.textField.autocapitalizationType = UITextAutocapitalizationTypeSentences; + break; + case kEditBoxInputFlagInitialCapsAllCharacters: + GET_IMPL.textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; + break; + default: + break; + } +} + +void CCEditBoxImplIOS::setReturnType(KeyboardReturnType returnType) +{ + switch (returnType) { + case kKeyboardReturnTypeDefault: + GET_IMPL.textField.returnKeyType = UIReturnKeyDefault; + break; + case kKeyboardReturnTypeDone: + GET_IMPL.textField.returnKeyType = UIReturnKeyGo; + break; + case kKeyboardReturnTypeSend: + GET_IMPL.textField.returnKeyType = UIReturnKeyDone; + break; + case kKeyboardReturnTypeSearch: + GET_IMPL.textField.returnKeyType = UIReturnKeySearch; + break; + case kKeyboardReturnTypeGo: + GET_IMPL.textField.returnKeyType = UIReturnKeySend; + break; + default: + GET_IMPL.textField.returnKeyType = UIReturnKeyDefault; + break; + } +} + +void CCEditBoxImplIOS::setText(const char* pText) +{ + GET_IMPL.textField.text = [NSString stringWithUTF8String:pText]; +} + +const char* CCEditBoxImplIOS::getText(void) +{ + return [GET_IMPL.textField.text UTF8String]; +} + +void CCEditBoxImplIOS::setPlaceHolder(const char* pText) +{ + GET_IMPL.textField.placeholder = [NSString stringWithUTF8String:pText]; +} + +static CGPoint convertDesignCoordToScreenCoord(const CCPoint& designCoord) +{ + float viewH = (float)[[EAGLView sharedEGLView] getHeight]; + CCEGLViewProtocol& eglView = CCEGLView::sharedOpenGLView(); + CCPoint visiblePos; + if (eglView.isRetinaEnabled()) + { + visiblePos = ccp(designCoord.x, designCoord.y); + } + else + { + visiblePos = ccp(designCoord.x * eglView.getScaleX(), designCoord.y * eglView.getScaleY()); + } + + CCPoint screenGLPos = ccpAdd(visiblePos, eglView.getViewPortRect().origin); + CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y); + return screenPos; +} + +void CCEditBoxImplIOS::setPosition(const CCPoint& pos) +{ + //TODO should consider anchor point, the default value is (0.5, 0,5) + [GET_IMPL setPosition:convertDesignCoordToScreenCoord(ccp(pos.x-m_tContentSize.width/2, pos.y+m_tContentSize.height/2))]; +} + +void CCEditBoxImplIOS::setContentSize(const CCSize& size) +{ + m_tContentSize = size; + CCLog("[Edit text] content size = (%f, %f)", size.width, size.height); +} + +void CCEditBoxImplIOS::visit(void) +{ + +} + +void CCEditBoxImplIOS::openKeyboard() +{ + [GET_IMPL openKeyboard]; +} + +void CCEditBoxImplIOS::closeKeyboard() +{ + [GET_IMPL closeKeyboard]; +} + +NS_CC_EXT_END + diff --git a/extensions/GUI/CCEditBox/EditBoxImplIOS.h b/extensions/GUI/CCEditBox/EditBoxImplIOS.h new file mode 100644 index 0000000000..4127c99ba6 --- /dev/null +++ b/extensions/GUI/CCEditBox/EditBoxImplIOS.h @@ -0,0 +1,54 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import + +@interface CustomUITextField : UITextField +{ +} + +@end + + +@interface EditBoxImplIOS : NSObject +{ + CustomUITextField* textField_; + void* editBox_; + BOOL editState_; +} + +@property(nonatomic, retain) UITextField* textField; +@property(nonatomic, readonly, getter = isEditState) BOOL editState; +@property(nonatomic, assign) void* editBox; + +-(id) initWithFrame: (CGRect) frameRect editBox: (void*) editBox; +-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance; +-(void) setPosition:(CGPoint) pos; +-(void) setContentSize:(CGSize) size; +-(void) visit; +-(void) openKeyboard; +-(void) closeKeyboard; + +@end \ No newline at end of file diff --git a/extensions/GUI/CCEditBox/EditBoxImplIOS.mm b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm new file mode 100644 index 0000000000..ff21b39641 --- /dev/null +++ b/extensions/GUI/CCEditBox/EditBoxImplIOS.mm @@ -0,0 +1,189 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2012 James Chen + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#import "EditBoxImplIOS.h" +#import "EAGLView.h" +#import "CCEditBoxImplIOS.h" + +#define getEditBoxImplIOS() ((cocos2d::extension::CCEditBoxImplIOS*)editBox_) + +@implementation CustomUITextField +- (CGRect)textRectForBounds:(CGRect)bounds { + float padding = 5.0f; + return CGRectMake(bounds.origin.x + padding, bounds.origin.y + padding, + bounds.size.width - padding*2, bounds.size.height - padding*2); +} +- (CGRect)editingRectForBounds:(CGRect)bounds { + return [self textRectForBounds:bounds]; +} +@end + + +@implementation EditBoxImplIOS + +@synthesize textField = textField_; +@synthesize editState = editState_; +@synthesize editBox = editBox_; + +- (void)dealloc +{ + [textField_ resignFirstResponder]; + [textField_ removeFromSuperview]; + [textField_ release]; + [super dealloc]; +} + +-(id) initWithFrame: (CGRect) frameRect editBox: (void*) editBox +{ + self = [super init]; + + do + { + if (self == nil) break; + editState_ = NO; + textField_ = [[CustomUITextField alloc] initWithFrame: frameRect]; + if (!textField_) break; + [textField_ setTextColor:[UIColor whiteColor]]; + textField_.font = [UIFont systemFontOfSize:frameRect.size.height*2/3]; //TODO need to delete hard code here. + textField_.backgroundColor = [UIColor clearColor]; + textField_.borderStyle = UITextBorderStyleNone; + textField_.delegate = self; + textField_.returnKeyType = UIReturnKeyDefault; + [textField_ addTarget:self action:@selector(textChanged) forControlEvents:UIControlEventEditingChanged]; + self.editBox = editBox; + + [[EAGLView sharedEGLView] addSubview:textField_]; + + return self; + }while(0); + + [textField_ release]; + + + return nil; +} + +-(void) doAnimationWhenKeyboardMoveWithDuration:(float)duration distance:(float)distance +{ + id eglView = [EAGLView sharedEGLView]; + [eglView doAnimationWhenKeyboardMoveWithDuration:duration distance:distance]; +} + +-(void) setPosition:(CGPoint) pos +{ + CGRect frame = [textField_ frame]; + frame.origin = pos; + [textField_ setFrame:frame]; +} + +-(void) setContentSize:(CGSize) size +{ + +} + +-(void) visit +{ + +} + +-(void) openKeyboard +{ + [textField_ becomeFirstResponder]; +} + +-(void) closeKeyboard +{ + [textField_ resignFirstResponder]; + [textField_ removeFromSuperview]; +} + +- (BOOL)textFieldShouldReturn:(UITextField *)sender +{ + if (sender == textField_) { + [sender resignFirstResponder]; + } + return NO; +} + +-(void)animationSelector +{ + id eglView = [EAGLView sharedEGLView]; + [eglView doAnimationWhenAnotherEditBeClicked]; +} + +- (BOOL)textFieldShouldBeginEditing:(UITextField *)sender // return NO to disallow editing. +{ + editState_ = YES; + id eglView = [EAGLView sharedEGLView]; + if ([eglView isKeyboardShown]) + { + [self performSelector:@selector(animationSelector) withObject:nil afterDelay:0.0f]; + } + return YES; +} + +- (BOOL)textFieldShouldEndEditing:(UITextField *)sender +{ + editState_ = NO; + return YES; +} + +/** + * Delegate method called before the text has been changed. + * @param textField The text field containing the text. + * @param range The range of characters to be replaced. + * @param string The replacement string. + * @return YES if the specified text range should be replaced; otherwise, NO to keep the old text. + */ +- (BOOL)textField:(UITextField *) textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ + if (getEditBoxImplIOS()->getMaxLength() < 0) + { + return YES; + } + + NSUInteger oldLength = [textField.text length]; + NSUInteger replacementLength = [string length]; + NSUInteger rangeLength = range.length; + + NSUInteger newLength = oldLength - rangeLength + replacementLength; + + return newLength <= getEditBoxImplIOS()->getMaxLength(); +} + +/** + * Called each time when the text field's text has changed. + */ +- (void) textChanged +{ + NSLog(@"text is %@", self.textField.text); + cocos2d::extension::CCEditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate(); + if (pDelegate != NULL) + { + pDelegate->editBoxTextChanged(getEditBoxImplIOS()->getCCEditBox(), getEditBoxImplIOS()->getText()); + } +} + +@end diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index cd7fec1868..ac03fefe0b 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -27,6 +27,7 @@ #include "GUI/CCControlExtension/CCControlExtensions.h" #include "GUI/CCScrollView/CCScrollView.h" +#include "GUI/CCEditBox/CCEditBox.h" #include "network/HttpRequest.h" #include "network/HttpResponse.h" diff --git a/samples/HelloCpp/proj.android/jni/hellocpp/main.cpp b/samples/HelloCpp/proj.android/jni/hellocpp/main.cpp index 3af2b89f1f..2c7455571d 100644 --- a/samples/HelloCpp/proj.android/jni/hellocpp/main.cpp +++ b/samples/HelloCpp/proj.android/jni/hellocpp/main.cpp @@ -25,7 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = &CCEGLView::sharedOpenGLView(); - view->setSize(w, h); + view->setFrameSize(w, h); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/samples/HelloCpp/proj.win32/main.cpp b/samples/HelloCpp/proj.win32/main.cpp index a71654a4f1..b876619ed6 100644 --- a/samples/HelloCpp/proj.win32/main.cpp +++ b/samples/HelloCpp/proj.win32/main.cpp @@ -15,6 +15,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setSize(960, 640 ); + eglView.setFrameSize(960, 640 ); return CCApplication::sharedApplication().run(); } diff --git a/samples/HelloLua/Resources/hello.lua b/samples/HelloLua/Resources/hello.lua index 33efc36f37..624992f73a 100644 --- a/samples/HelloLua/Resources/hello.lua +++ b/samples/HelloLua/Resources/hello.lua @@ -22,11 +22,11 @@ local function creatDog() -- create dog animate local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:create(textureDog, rect) + local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:create(textureDog, rect) + local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) - local spriteDog = CCSprite:create(frame0) + local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) diff --git a/samples/HelloLua/proj.android/jni/hellolua/main.cpp b/samples/HelloLua/proj.android/jni/hellolua/main.cpp index 033ec82421..921d2d4e88 100644 --- a/samples/HelloLua/proj.android/jni/hellolua/main.cpp +++ b/samples/HelloLua/proj.android/jni/hellolua/main.cpp @@ -24,7 +24,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = &CCEGLView::sharedOpenGLView(); - view->setSize(w, h); + view->setFrameSize(w, h); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/samples/HelloLua/proj.win32/main.cpp b/samples/HelloLua/proj.win32/main.cpp index 25653f4e54..4ec6228a62 100644 --- a/samples/HelloLua/proj.win32/main.cpp +++ b/samples/HelloLua/proj.win32/main.cpp @@ -25,7 +25,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setSize(480, 320); + eglView.setFrameSize(480, 320); int ret = CCApplication::sharedApplication().run(); #ifdef USE_WIN32_CONSOLE diff --git a/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp new file mode 100644 index 0000000000..4cd0669c99 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp @@ -0,0 +1,69 @@ +// +// CCEditBoxTest.cpp +// TestCpp +// +// Created by James on 8/14/12. +// +// + +#include "EditBoxTest.h" +#include "../ExtensionsTest.h" + +USING_NS_CC; +USING_NS_CC_EXT; + + +EditBoxTest::EditBoxTest() +{ + CCPoint visibleOrigin = CCEGLView::sharedOpenGLView().getVisibleOrigin(); + CCSize visibleSize = CCEGLView::sharedOpenGLView().getVisibleSize(); + + CCSprite* pBg = CCSprite::create("Images/HelloWorld.png"); + pBg->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); + addChild(pBg); + + // Back Menu + CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(EditBoxTest::toExtensionsMainLayer)); + itemBack->setPosition(ccp(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25)); + CCMenu *menuBack = CCMenu::create(itemBack, NULL); + menuBack->setPosition(CCPointZero); + addChild(menuBack); + + CCSize editBoxSize = CCSizeMake(visibleSize.width/3, visibleSize.height/8); + CCEditBox* pEdit = NULL; + // top + pEdit = CCEditBox::create(editBoxSize); + pEdit->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)); + addChild(pEdit); + // middle + pEdit = CCEditBox::create(editBoxSize); + pEdit->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)); + addChild(pEdit); + // bottom + pEdit = CCEditBox::create(editBoxSize); + pEdit->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)); + addChild(pEdit); +} + +EditBoxTest::~EditBoxTest() +{ + +} + +void EditBoxTest::toExtensionsMainLayer(cocos2d::CCObject *sender) +{ + ExtensionsTestScene *pScene = new ExtensionsTestScene(); + pScene->runThisTest(); + pScene->release(); +} + + +void runEditBoxTest() +{ + CCScene *pScene = CCScene::create(); + EditBoxTest *pLayer = new EditBoxTest(); + pScene->addChild(pLayer); + + CCDirector::sharedDirector()->replaceScene(pScene); + pLayer->release(); +} \ No newline at end of file diff --git a/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h b/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h new file mode 100644 index 0000000000..2d6b6123e7 --- /dev/null +++ b/samples/TestCpp/Classes/ExtensionsTest/EditBoxTest/EditBoxTest.h @@ -0,0 +1,28 @@ +// +// CCEditBoxTest.h +// TestCpp +// +// Created by James on 8/14/12. +// +// + +#ifndef __TestCpp__CCEditBoxTest__ +#define __TestCpp__CCEditBoxTest__ + +#include "cocos2d.h" +#include "cocos-ext.h" + +class EditBoxTest : public cocos2d::CCLayer +{ +public: + EditBoxTest(); + virtual ~EditBoxTest(); + void toExtensionsMainLayer(cocos2d::CCObject *sender); + +private: + +}; + +void runEditBoxTest(); + +#endif /* defined(__TestCpp__CCEditBoxTest__) */ diff --git a/samples/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index d52406744b..a0300337b7 100644 --- a/samples/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -4,6 +4,9 @@ #include "ControlExtensionTest/CCControlSceneManager.h" #include "CocosBuilderTest/CocosBuilderTest.h" #include "NetworkTest/HttpClientTest.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "EditBoxTest/EditBoxTest.h" +#endif enum { @@ -17,6 +20,9 @@ enum TEST_CCCONTROLBUTTON, TEST_COCOSBUILDER, TEST_HTTPCLIENT, +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + TEST_EDITBOX, +#endif TEST_MAX_COUNT, }; @@ -26,6 +32,9 @@ static const std::string testsName[TEST_MAX_COUNT] = "CCControlButtonTest", "CocosBuilderTest", "HttpClientTest", +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + "EditBoxTest" +#endif }; //////////////////////////////////////////////////////// @@ -87,6 +96,14 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender) { runHttpClientTest(); } + break; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + case TEST_EDITBOX: + { + runEditBoxTest(); + } + break; +#endif default: break; } diff --git a/samples/TestCpp/proj.android/jni/testcpp/main.cpp b/samples/TestCpp/proj.android/jni/testcpp/main.cpp index 21b56b9156..197e90e3b1 100644 --- a/samples/TestCpp/proj.android/jni/testcpp/main.cpp +++ b/samples/TestCpp/proj.android/jni/testcpp/main.cpp @@ -25,7 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = &CCEGLView::sharedOpenGLView(); - view->setSize(w, h); + view->setFrameSize(w, h); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id index fd8eccb0f6..c7c5b5c2c3 100644 --- a/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/TestCpp/proj.ios/TestCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -86f6b6c3837508de917c08ed3e087b901da16e27 \ No newline at end of file +9dc4229a0e1a4577d300081dc8e3abc2a1e2f1f2 \ No newline at end of file diff --git a/samples/TestCpp/proj.win32/main.cpp b/samples/TestCpp/proj.win32/main.cpp index 27223ff8dd..ace8690a1c 100644 --- a/samples/TestCpp/proj.win32/main.cpp +++ b/samples/TestCpp/proj.win32/main.cpp @@ -15,6 +15,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setSize(480, 320); + eglView.setFrameSize(480, 320); return CCApplication::sharedApplication().run(); } diff --git a/samples/TestJavascript/proj.android/jni/testjavascript/main.cpp b/samples/TestJavascript/proj.android/jni/testjavascript/main.cpp index b326bf94e1..1abaf1917e 100644 --- a/samples/TestJavascript/proj.android/jni/testjavascript/main.cpp +++ b/samples/TestJavascript/proj.android/jni/testjavascript/main.cpp @@ -25,7 +25,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi if (!CCDirector::sharedDirector()->getOpenGLView()) { CCEGLView *view = &CCEGLView::sharedOpenGLView(); - view->setSize(w, h); + view->setFrameSize(w, h); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/samples/TestJavascript/proj.win32/main.cpp b/samples/TestJavascript/proj.win32/main.cpp index e4b4e2c48e..5ec4f5040a 100644 --- a/samples/TestJavascript/proj.win32/main.cpp +++ b/samples/TestJavascript/proj.win32/main.cpp @@ -25,7 +25,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setSize(480, 320); + eglView.setFrameSize(480, 320); int ret = CCApplication::sharedApplication().run(); diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 6dd7bd14d7..6ca4bf16e0 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -7cb982a0fdfc6ad650535099fa5fadf5d05073e4 \ No newline at end of file +0b7cd029edf3970b0b444a943661d09f58aeba3d \ No newline at end of file diff --git a/tools/JenkinsScript/Mac/android/androidtest-debug3.sh b/tools/JenkinsScript/Mac/android/AndroidCompile-debug2_2-3_2.sh similarity index 100% rename from tools/JenkinsScript/Mac/android/androidtest-debug3.sh rename to tools/JenkinsScript/Mac/android/AndroidCompile-debug2_2-3_2.sh diff --git a/tools/JenkinsScript/Mac/android/androidtest-debug4.sh b/tools/JenkinsScript/Mac/android/AndroidCompile-debug4_0-4_0_3.sh similarity index 100% rename from tools/JenkinsScript/Mac/android/androidtest-debug4.sh rename to tools/JenkinsScript/Mac/android/AndroidCompile-debug4_0-4_0_3.sh diff --git a/tools/JenkinsScript/Mac/android/androidtest-release3.sh b/tools/JenkinsScript/Mac/android/AndroidCompile-release2_2-3_2.sh similarity index 100% rename from tools/JenkinsScript/Mac/android/androidtest-release3.sh rename to tools/JenkinsScript/Mac/android/AndroidCompile-release2_2-3_2.sh diff --git a/tools/JenkinsScript/Mac/android/androidtest-release4.sh b/tools/JenkinsScript/Mac/android/AndroidCompile-release4_0-4_0_3.sh similarity index 100% rename from tools/JenkinsScript/Mac/android/androidtest-release4.sh rename to tools/JenkinsScript/Mac/android/AndroidCompile-release4_0-4_0_3.sh diff --git a/tools/JenkinsScript/Mac/ios/iostest-debug.sh b/tools/JenkinsScript/Mac/ios/iOSCompile-debug.sh similarity index 100% rename from tools/JenkinsScript/Mac/ios/iostest-debug.sh rename to tools/JenkinsScript/Mac/ios/iOSCompile-debug.sh diff --git a/tools/JenkinsScript/Mac/ios/iostest-release.sh b/tools/JenkinsScript/Mac/ios/iOSCompile-release.sh similarity index 100% rename from tools/JenkinsScript/Mac/ios/iostest-release.sh rename to tools/JenkinsScript/Mac/ios/iOSCompile-release.sh diff --git a/tools/JenkinsScript/Mac/mac/mactest-debug.sh b/tools/JenkinsScript/Mac/mac/Mactest-debug.sh similarity index 100% rename from tools/JenkinsScript/Mac/mac/mactest-debug.sh rename to tools/JenkinsScript/Mac/mac/Mactest-debug.sh diff --git a/tools/JenkinsScript/Mac/mac/mactest-release.sh b/tools/JenkinsScript/Mac/mac/Mactest-release.sh similarity index 100% rename from tools/JenkinsScript/Mac/mac/mactest-release.sh rename to tools/JenkinsScript/Mac/mac/Mactest-release.sh diff --git a/tools/JenkinsScript/Windows/android/androidtest-debug3.bat b/tools/JenkinsScript/Windows/android/AndroidCompile-debug2_2-3_2.bat similarity index 100% rename from tools/JenkinsScript/Windows/android/androidtest-debug3.bat rename to tools/JenkinsScript/Windows/android/AndroidCompile-debug2_2-3_2.bat diff --git a/tools/JenkinsScript/Windows/android/androidtest-debug4.bat b/tools/JenkinsScript/Windows/android/AndroidCompile-debug4_0-4_0_3.bat similarity index 100% rename from tools/JenkinsScript/Windows/android/androidtest-debug4.bat rename to tools/JenkinsScript/Windows/android/AndroidCompile-debug4_0-4_0_3.bat diff --git a/tools/JenkinsScript/Windows/android/androidtest-release3.bat b/tools/JenkinsScript/Windows/android/AndroidCompile-release2_2-3_2.bat similarity index 100% rename from tools/JenkinsScript/Windows/android/androidtest-release3.bat rename to tools/JenkinsScript/Windows/android/AndroidCompile-release2_2-3_2.bat diff --git a/tools/JenkinsScript/Windows/android/androidtest-release4.bat b/tools/JenkinsScript/Windows/android/AndroidCompile-release4_0-4_0_3.bat similarity index 100% rename from tools/JenkinsScript/Windows/android/androidtest-release4.bat rename to tools/JenkinsScript/Windows/android/AndroidCompile-release4_0-4_0_3.bat diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id new file mode 100644 index 0000000000..60a18c6b19 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id @@ -0,0 +1 @@ +7cda137d3b8d286470f2b504faaa77d981947cbf \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Resource.mtr b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Resource.mtr new file mode 100644 index 0000000000..cb618ad251 Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Resource.mtr differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Script.mts b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Script.mts new file mode 100644 index 0000000000..90fb8f6028 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/Action0/Script.mts @@ -0,0 +1 @@ +RunAction "Action1", oneIteration \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id new file mode 100644 index 0000000000..3b87f73dcb --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id @@ -0,0 +1 @@ +b92978b50737213fe6e10b1a95285f63f650b651 \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Resource.mtr b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Resource.mtr new file mode 100644 index 0000000000..310d109d4a Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Resource.mtr differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Script.mts b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Script.mts new file mode 100644 index 0000000000..150f5cdc87 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/Action1/Script.mts @@ -0,0 +1,706 @@ +Dim Milliseconds +DefaultTimeout = Setting("DefaultTimeout") + +If DefaultTimeout > 10000 Then + Milliseconds = 10000 + Setting("DefaultTimeout") = Milliseconds +End If + +Err.Clear +On Error Resume Next +call CaseFunctionName + +If Err.Number <> 0 Then + + If Dialog("TestCpp.exe").Exist(3) Then + Dialog("TestCpp.exe").Activate + Dialog("TestCpp.exe").Move 872,177 + Dialog("TestCpp.exe").WinObject("DirectUIHWND").Click 21,235 + Wait 1 + End If + + WriteLog Err.Number + WriteLog Err.Description + WriteLog Err.Source + + Dim FileName ,TimeNow, ResPath + ResPath = Environment.Value("TestDir") + ResPath = ResPath & "\" + TestNameNow=environment.Value("TestName") + FileName = ResPath & ""&TestNameNow & ".png" + + desktop.CaptureBitmap filename,True + Systemutil.closedescendentprocesses + + If Dialog("TestCpp.exe").Exist(3) Then + Dialog("TestCpp.exe").WinObject("关闭程序").Click + End If + +End If +Err.Clear +On Error goto 0 + +Function common_test(a,b,c) + For i = a To b + Window("Hello Tests").Click 338,291 + Wait c + Next +End Function + +Function random_click(a,b,c) + Dim touch_x,touch_y + Randomize + For Response = a To b + touch_x = Int((400 * Rnd + 0)) + touch_y = Int((250 * Rnd + 0)) + Window("Hello Tests").Click touch_x,touch_y + Wait c + Next +End Function + +Function random_drag(a,b,c) + Dim drag_x,drag_y,drop_x,drop_y + Randomize + For Response = a To b + drag_x = Int((400 * Rnd + 0)) + drag_y = Int((250 * Rnd + 0)) + drop_x = Int((400 * Rnd + 0)) + drop_y = Int((250 * Rnd + 0)) + Window("Hello Tests").Drag drag_x,drag_y + Window("Hello Tests").Drop drop_x,drop_y + Wait c + Next +End Function + +Function CaseFunctionName() + 'SystemUtil.BlockInput + Window("Hello Tests").Activate + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ActionsTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 241,43 + Wait 2 + + Call common_test(1,27,1) + + Window("Hello Tests").Click 338,291 + Wait 5 + Window("Hello Tests").Click 338,291 + Wait 2 + + Call common_test(1,5,1) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'TransitionsTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 236,77 + Wait 2 + + Call common_test(1,26,1) + Wait 1 + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ActionsProgressTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 287,113 + Wait 2 + + Call common_test(1,7,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'EffectsTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 236,163 + Wait 3 + + Call common_test(1,21,4) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ClickAndMoveTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 228,199 + Wait 3 + + Call random_click(1,10,2) + + Call random_click(1,100,0) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'RotateWorldTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 237,235 + Wait 3.5 + ''MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ParticleTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 236,276 + Wait 3 + + Call common_test(1,42,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ActionEaseTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Drag 363,307 + Window("Hello Tests").Drop 363,10 + Wait 1 + Window("Hello Tests").Click 237,19 + Wait 2 + + Call common_test(1,13,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + Wait 2 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'MotionStreakTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,61 + Wait 2 + + Window("Hello Tests").Click 230,239 + Window("Hello Tests").Click 338,291 + + Call random_drag(1,10,0) + Window("Hello Tests").Click 230,239 + Call random_drag(1,10,0) + + Window("Hello Tests").Click 338,291 + Wait 2 + + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'DrawPrimitivesTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 235,101 + Wait 1 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'NodeTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 237,139 + Wait 1 + + Call common_test(1,13,1) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'TouchesTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 238,183 + Window("Hello Tests").Drag 236,221 + Window("Hello Tests").Drop 175,226 + + Wait 5 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'MenuTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 234,220 + Window("Hello Tests").Click 238,63 + Window("Hello Tests").Click 158,132 + + Window("Hello Tests").Click 238,155 + Window("Hello Tests").Click 236,180 + Window("Hello Tests").Click 158,188 + Window("Hello Tests").Click 313,184 + Window("Hello Tests").Click 190,217 + Window("Hello Tests").Click 235,216 + Window("Hello Tests").Click 205,144 + Window("Hello Tests").Click 218,143 + Window("Hello Tests").Click 237,247 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ActionManagerTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 234,261 + + Call common_test(1,4,3) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'LayerTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,302 + + Call random_drag(1,10,0) + Window("Hello Tests").Click 338,291 + Wait 2 + Window("Hello Tests").Click 338,291 + Wait 2 + Window("Hello Tests").Click 338,291 + Call random_drag(1,10,0) + Window("Hello Tests").Click 338,291 + Wait 1 + Window("Hello Tests").Click 242,164 + Wait 1 + Window("Hello Tests").Click 338,291 + Wait 1 + Window("Hello Tests").Click 254,163 + Wait 1 + Window("Hello Tests").Click 338,291 + Wait 1 + Window("Hello Tests").Click 231,164 + Wait 1 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'SceneTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Drag 370,306 + Window("Hello Tests").Drop 370,-20 + Wait 1 + Window("Hello Tests").Click 234,17 + Wait 1 + Window("Hello Tests").Click 230,111 + Window("Hello Tests").Click 230,111 + Window("Hello Tests").Click 230,111 + Window("Hello Tests").Click 233,163 + Window("Hello Tests").Click 226,218 + Window("Hello Tests").Click 226,218 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ParallaxTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 232,55 + Wait 5 + Window("Hello Tests").Click 338,291 + + Call random_drag(1,10,0) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'TileMapTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 233,99 + Wait 2 + Window("Hello Tests").Click 338,291 + Wait 2 + + Call random_drag(1,10,0) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'IntervalTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 235,139 + Wait 3 + Window("Hello Tests").Click 224,48 + Wait 1 + Window("Hello Tests").Click 231,52 + Window("Hello Tests").Click 228,56 + Window("Hello Tests").Click 228,56 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ChipmunkAccelTouchTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 235,178 + + Call random_click(1,20,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'LabelTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 239,216 + Wait 3 + Call common_test(1,25,0.5) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'TextInputTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 236,255 + + Window("Hello Tests").Click 238,161 + Const constring = "0123456789abcdefgchijklmnopqrstuvwxyz" + Dim TextInput_i,TextInput_j,randstring + Randomize + For TextInput_i=1 To 8 + randstring = randstring & Mid(constring, Int(Len(constring)*Rnd)+1, 1) + Next + Window("Hello Tests").Type randstring + Window("Hello Tests").Click 338,291 + Window("Hello Tests").Click 238,161 + Randomize + For TextInput_j=1 To 8 + randstring = randstring & Mid(constring, Int(Len(constring)*Rnd)+1, 1) + Next + Window("Hello Tests").Type randstring + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'SpriteTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 238,294 + + Call random_click(1,10,2) + Window("Hello Tests").Click 338,291 + Call random_click(1,10,2) + Window("Hello Tests").Click 338,291 + Call common_test(1,108,0.5) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'SchdulerTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Drag 359,309 + Window("Hello Tests").Drop 359,-11 + Wait 1 + 'Schedule with delay of 3sec,repeat 4 + Window("Hello Tests").Click 236,15 + Window("Hello Tests").Click 338,291 + 'Scheduler timeScale Test + Window("Hello Tests").Drag 260,212 + Window("Hello Tests").Drop 301,212 + Wait 1 + Window("Hello Tests").Drag 301,212 + Window("Hello Tests").Drop 209,214 + Wait 1 + Window("Hello Tests").Drag 209,214 + Window("Hello Tests").Drop 100,208 + Wait 2 + Window("Hello Tests").Click 338,291 + 'Two custom schedulers + Window("Hello Tests").Drag 126,16 + Window("Hello Tests").Drop 81,22 + Wait 1 + Window("Hello Tests").Drag 361,19 + Window("Hello Tests").Drop 422,22 + Wait 3 + Window("Hello Tests").Click 338,291 + 'Self -remove an scheduler + Window("Hello Tests").Click 338,291 + 'Pause/Resume + Window("Hello Tests").Click 338,291 + 'Pause/Resume + Wait 3 + Window("Hello Tests").Click 338,291 + 'Unschedule All selectors + Window("Hello Tests").Click 338,291 + 'Unschedule All selectors(HARD) + Wait 2 + Window("Hello Tests").Click 338,291 + 'Unschedule All selectors + Wait 4 + Window("Hello Tests").Click 338,291 + 'Schedule from Schedule + Window("Hello Tests").Click 338,291 + 'Schedule update with priority + Window("Hello Tests").Click 338,291 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'RenderTextureTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,59 + 'Save Image + + Call random_drag(1,10,0) + Window("Hello Tests").Click 388,17 + Window("Hello Tests").Click 398,41 + Wait 1 + Window("Hello Tests").Click 338,291 + 'Testing issue #937 + Window("Hello Tests").Click 338,291 + 'Testing Z Buffer in Render Texture + Call random_click(1,10,0) + Window("Hello Tests").Click 338,291 + 'Testing depthStencil attachment + MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'Texture2DTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 234,97 + Call common_test(1,35,0.5) + MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'Box2dTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 235,134 + Call random_click(1,30,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'Box2dTestBed + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 236,176 + Call common_test(1,35,2) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'EffectAdvancedTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 237,217 + Call common_test(1,5,1) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + AccelerometerTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 244,255 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'KeypadTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,298 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'CocosDenshionTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Drag 377,314 + Window("Hello Tests").Drop 377,0 + Wait 1 + Window("Hello Tests").Click 243,20 + + Window("Hello Tests").Click 248,38 + Wait 1 + Window("Hello Tests").Click 248,78 + Wait 1 + Window("Hello Tests").Click 247,121 + Wait 1 + Window("Hello Tests").Click 246,158 + Wait 1 + Window("Hello Tests").Click 251,202 + Wait 1 + Window("Hello Tests").Click 246,238 + Wait 1 + Window("Hello Tests").Click 241,282 + Wait 1 + Window("Hello Tests").Drag 427,260 + Window("Hello Tests").Drop 427,6 + Window("Hello Tests").Click 232,18 + Wait 1 + Window("Hello Tests").Click 245,56 + Wait 1 + Window("Hello Tests").Click 242,109 + Wait 1 + Window("Hello Tests").Click 242,144 + Wait 1 + Window("Hello Tests").Click 243,189 + Wait 1 + Window("Hello Tests").Click 243,230 + Wait 1 + Window("Hello Tests").Click 254,275 + Wait 1 + Window("Hello Tests").Click 248,304 + Wait 1 + Window("Hello Tests").Drag 412,272 + Window("Hello Tests").Drop 412,-13 + Window("Hello Tests").Click 235,124 + Wait 1 + Window("Hello Tests").Click 238,158 + Wait 1 + Window("Hello Tests").Click 229,200 + Wait 1 + Window("Hello Tests").Click 239,243 + Wait 1 + Window("Hello Tests").Click 246,277 + Wait 1 + 'MainMenu + Window("Hello Tests").Click 441,296 + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'PerformanceTest + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 237,64 + Window("Hello Tests").Click 238,37 + + 'PerformanceNodeChildrenTest + Window("Hello Tests").Click 238,38 + Dim Performance_i + For Performance_i = 1 To 4 + Window("Hello Tests").Click 273,145 + Window("Hello Tests").Click 338,291 + Wait 1 + Next + Back + Window("Hello Tests").Click 427,290 + + 'PerformanceParticeTest + Window("Hello Tests").Click 237,78 + + For Performance_j = 1 To 4 + Window("Hello Tests").Click 273,145 + Window("Hello Tests").Click 338,291 + Wait 1 + Next + 'Back + Window("Hello Tests").Click 427,290 + 'PerformanceSpriteTest + Window("Hello Tests").Click 233,120 + Dim Performance_k + For Performance_k = 1 To 5 + Window("Hello Tests").Click 271,64 + Window("Hello Tests").Click 338,291 + Wait 1 + Next + 'Back + Window("Hello Tests").Click 427,290 + + 'PerformanceTextureTest + Window("Hello Tests").Click 229,159 + 'Back + Window("Hello Tests").Click 427,290 + + 'PerformanceTouchesTest + Window("Hello Tests").Click 234,200 + Call random_drag(1,10,0) + Window("Hello Tests").Click 338,291 + Call random_drag(1,10,0) + 'Back + Window("Hello Tests").Click 427,290 + 'MainMenu + Window("Hello Tests").Click 441,296 + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ZwoptexTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 233,104 + Wait 1 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'CurlTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 239,141 + Window("Hello Tests").Click 242,160 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'UserDefaultTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 238,184 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'BugsTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,222 + 'MainMenu + Window("Hello Tests").Click 441,296 + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'FontTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 237,261 + Call common_test(1,4,0.5) + 'MainMenu + Window("Hello Tests").Click 441,296 + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'CurrentLanguageTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 244,301 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'TextureCacheTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Drag 385,309 + Window("Hello Tests").Drop 385,33 + Wait 1 + Window("Hello Tests").Click 241,159 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'ExtensionsTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 241,197 + Wait 1 + 'NotificationCenterTest + Window("Hello Tests").Click 235,41 + Window("Hello Tests").Click 339,166 + Window("Hello Tests").Click 339,166 + Window("Hello Tests").Click 113,189 + 'Back + Window("Hello Tests").Click 429,289 + Wait 1 + 'CCControlButtonTest + Window("Hello Tests").Click 238,79 + Window("Hello Tests").Drag 118,181 + Window("Hello Tests").Drop 374,189 + Wait 1 + Window("Hello Tests").Drag 367,179 + Window("Hello Tests").Drop 76,183 + Wait 1 + 'Back + Window("Hello Tests").Click 422,293 + 'CocosBuilderTest + Window("Hello Tests").Click 237,119 + 'Menus_Items + Window("Hello Tests").Click 137,158 + Window("Hello Tests").Click 242,157 + Window("Hello Tests").Click 113,147 + Window("Hello Tests").Click 23,20 + 'Button + Window("Hello Tests").Click 132,209 + Window("Hello Tests").Click 240,149 + Window("Hello Tests").Drag 255,150 + Window("Hello Tests").Drop 259,233 + Window("Hello Tests").Click 23,20 + 'Particle Systems + Window("Hello Tests").Click 131,261 + Window("Hello Tests").Click 23,20 + 'Sprites_9 Slice + Window("Hello Tests").Click 341,161 + Window("Hello Tests").Click 23,20 + 'Labels + Window("Hello Tests").Click 345,210 + Window("Hello Tests").Click 23,20 + 'ScrollViewTest + Window("Hello Tests").Click 347,259 + Call random_drag(1,10,0) + Window("Hello Tests").Click 23,20 + + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'SharderTest + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 242,239 + Dim Sharder_i + Call common_test(1,6,0.5) + Window("Hello Tests").Drag 197,235 + Window("Hello Tests").Drop 358,236 + Wait 1 + Window("Hello Tests").Drag 358,236 + Window("Hello Tests").Drop 78,221 + + Window("Hello Tests").Click 338,291 + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'MutiTouchTest + ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 240,279 + Call random_drag(1,5,0) + 'MainMenu + Window("Hello Tests").Click 441,296 + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + 'Quit + '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Window("Hello Tests").Click 461,22 + 'SystemUtil.UnblockInput +End function \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Default.xls b/tools/JenkinsScript/Windows/win32/qtp_win32/Default.xls new file mode 100644 index 0000000000..3320733acf Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Default.xls differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Error_Sub.vbs b/tools/JenkinsScript/Windows/win32/qtp_win32/Error_Sub.vbs new file mode 100644 index 0000000000..a3921e9364 Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Error_Sub.vbs differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Error_appcrash.qrs b/tools/JenkinsScript/Windows/win32/qtp_win32/Error_appcrash.qrs new file mode 100644 index 0000000000..4f6c0d3259 Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Error_appcrash.qrs differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Parameters.mtr b/tools/JenkinsScript/Windows/win32/qtp_win32/Parameters.mtr new file mode 100644 index 0000000000..5dfd0cb80e Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Parameters.mtr differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/Test.tsp b/tools/JenkinsScript/Windows/win32/qtp_win32/Test.tsp new file mode 100644 index 0000000000..a881a81cd9 Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/Test.tsp differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id b/tools/JenkinsScript/Windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id new file mode 100644 index 0000000000..9d2b35038c --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id @@ -0,0 +1 @@ +1bbfcd16748887dfb66d264a6327737e2ed5a3b1 \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/default.cfg b/tools/JenkinsScript/Windows/win32/qtp_win32/default.cfg new file mode 100644 index 0000000000..b3bfe18832 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/default.cfg @@ -0,0 +1,89 @@ +[General] +XlBridgeTimeout=120 +ContinueOnError=0 +AutomaticTransactions=0 +AutomaticTransactionsPerFunc=0 +automatic_nested_transactions=1 + +[ThinkTime] +Options=RECORDED +Factor=1.000000 +LimitFlag=0 +Limit=10 +ThinkTimeRandomLow=50 +ThinkTimeRandomHigh=150 + +[Log] +LogOptions=LogExtended +MsgClassData=0 +MsgClassParameters=0 +MsgClassFull=0 + +[RtsNetwork] +LoadImages=1 +LoadActiveX=1 +LoadJava=0 +LoadScripts=1 +NavigationTimeout=60000 +ObjectTimeout=3000 + +[RtsPerformance] +MinThinkTime=3500 +MaxThinkTime=3500 +AutoThinkTime=1 +EnableChecks=0 +ExcludeThinkTime=0 +FitThinkTime=0 + +[RtsUserInfo] +UserName= +Password=5029fb73e + +[RtsGeneral] +EnableAutoTrans=1 +FailOnHttpErrors=0 +RunInSeparateThread=0 + +[WEB] +HttpVer=1.1 +UseCustomAgent=1 +SimulateCache=1 +TurboLoadTechnology=0 +WinInetReplay=0 +EnableModemSpeed=0 +ModemSpeed=14400 +KeepAlive=Yes +SearchForImages=1 +CacheSize=20000 +MaxConnections=4 +AutomaticThinkTime=0 +MaxAutoThinkTime=0 +MinAutoThinkTime=0 +ConnectTimeout=120 +ReceiveTimeout=120 +ResolveTimeout=120 +EnableChecks=1 +AnalogMode=1 +ResetContext=1 +ProxyUseBrowser=1 +ProxyUseProxy=0 +ProxyHTTPHost= +ProxyHTTPSHost= +ProxyHTTPPort=0 +ProxyHTTPSPort=0 +ProxyUseSame=0 +ProxyNoLocal=0 +ProxyBypass= +ProxyUserName= +ProxyPassword= +UseMshtml=1 +Retry401ThinkTime="0" +CustomUserAgent=Mozilla/4.0 (compatible; MSIE 5.5; Windows NT) +UseBrowserEmulation=0 + +[RtsConfigfuration] +AutMode=0 +ScalableMode=1 +EnableShowBrowser=0 +[Snapshots] +SnapshotOnErrorActive=0 diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/default.usp b/tools/JenkinsScript/Windows/win32/qtp_win32/default.usp new file mode 100644 index 0000000000..d7432ce479 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/default.usp @@ -0,0 +1,15 @@ +[RunLogicInitRoot] +RunLogicActionType="VuserInit" + +[RunLogicEndRoot] +RunLogicActionType="VuserEnd" + +[RunLogicRunRoot] +RunLogicNumOfIterations="1" +MercIniTreeSons="Action0" +RunLogicActionOrder="Action0" + +[RunLogicRunRoot:Action0] +MercIniTreeFather="RunLogicRunRoot" +RunLogicObjectKind="Action" +RunLogicInterpreterType="ActiveScript" diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/lock.lck b/tools/JenkinsScript/Windows/win32/qtp_win32/lock.lck new file mode 100644 index 0000000000..471a8069fc Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/lock.lck differ diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/qtp_win32.usr b/tools/JenkinsScript/Windows/win32/qtp_win32/qtp_win32.usr new file mode 100644 index 0000000000..440b650854 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/qtp_win32/qtp_win32.usr @@ -0,0 +1,54 @@ +[General] +Type=Tulip +RunType=ActiveScript +DefaultCfg=default.cfg +DefaultRunLogic=default.usp +ParamRightBrace=> +ParamLeftBrace=< +NewFunctionHeader=1 +MinorVersion=0 +MajorVersion=6 +DevelopTool=AQT + +[Actions] +Action0=Action0\Script.mts +Action1=Action1\Script.mts + +[VuserProfiles] +Profiles=Default Profile + +[CfgFiles] +Default Profile=default.cfg + +[RunLogicFiles] +Default Profile=default.usp + +[Rendezvous] + +[Transactions] + +[ActiveScript] +Lang=none + +[TulipInfo] +ProductName=QuickTest Professional +Version=10.00 + +[TulipAddins] +ActiveX= +Database= +Windows Applications= +TEA= +Web= +XML= + +[ExtraFiles] +Test.tsp= +Default.xls= +Parameters.mtr= +Action0\Script.mts= +Action0\Resource.mtr= +Action0\ObjectRepository.bdb= +Action1\Script.mts= +Action1\Resource.mtr= +Action1\ObjectRepository.bdb= diff --git a/tools/JenkinsScript/Windows/win32/qtp_win32/qtrunner.vbs b/tools/JenkinsScript/Windows/win32/qtp_win32/qtrunner.vbs new file mode 100644 index 0000000000..697a387a29 Binary files /dev/null and b/tools/JenkinsScript/Windows/win32/qtp_win32/qtrunner.vbs differ diff --git a/tools/JenkinsScript/Windows/win32/vs2008_debugtest.bat b/tools/JenkinsScript/Windows/win32/vs2008_debugtest.bat new file mode 100644 index 0000000000..4abd8566f6 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/vs2008_debugtest.bat @@ -0,0 +1,29 @@ +echo./* +echo.* Run cocos2d-win32 tests.exe +echo.*/ +echo. + +set qtpproj=%cd% +cd ..\..\..\..\ + +"%VS90COMNTOOLS%..\IDE\devenv.com" "%WORKSPACE%\cocos2d-win32.vc2008.sln" /Build "Debug|Win32" + +set CC_TEST_BIN=TestCpp.exe + +set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* +set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* +set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* +set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* + +cd Debug.win32 + +xcopy /E /Y /Q "%CC_TEST_RES%" . +xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . +xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + +cd .. +cd %qtpproj%\qtp_win32 +cscript qtrunner.vbs + +pause \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/vs2008_releasetest.bat b/tools/JenkinsScript/Windows/win32/vs2008_releasetest.bat new file mode 100644 index 0000000000..0a59315573 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/vs2008_releasetest.bat @@ -0,0 +1,29 @@ +echo./* +echo.* Run cocos2d-win32 tests.exe +echo.*/ +echo. + +set qtpproj=%cd% +cd ..\..\..\..\ + +"%VS90COMNTOOLS%..\IDE\devenv.com" "%WORKSPACE%\cocos2d-win32.vc2008.sln" /Build "Release|Win32" + +set CC_TEST_BIN=TestCpp.exe + +set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* +set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* +set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* +set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* + +cd Debug.win32 + +xcopy /E /Y /Q "%CC_TEST_RES%" . +xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . +xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + +cd .. +cd %qtpproj%\qtp_win32 +cscript qtrunner.vbs + +pause \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/vs2010_debugtest.bat b/tools/JenkinsScript/Windows/win32/vs2010_debugtest.bat new file mode 100644 index 0000000000..d01ab98612 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/vs2010_debugtest.bat @@ -0,0 +1,29 @@ +echo./* +echo.* Run cocos2d-win32 tests.exe +echo.*/ +echo. + +set qtpproj=%cd% +cd ..\..\..\..\ + +"%VS100COMNTOOLS%..\IDE\devenv.com" "%WORKSPACE%\cocos2d-win32.vc2010.sln" /Build "Debug|Win32" + +set CC_TEST_BIN=TestCpp.exe + +set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* +set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* +set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* +set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* + +cd Debug.win32 + +xcopy /E /Y /Q "%CC_TEST_RES%" . +xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . +xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + +cd .. +cd %qtpproj%\qtp_win32 +cscript qtrunner.vbs + +pause \ No newline at end of file diff --git a/tools/JenkinsScript/Windows/win32/vs2010_releasetest.bat b/tools/JenkinsScript/Windows/win32/vs2010_releasetest.bat new file mode 100644 index 0000000000..58ac5409e7 --- /dev/null +++ b/tools/JenkinsScript/Windows/win32/vs2010_releasetest.bat @@ -0,0 +1,29 @@ +echo./* +echo.* Run cocos2d-win32 tests.exe +echo.*/ +echo. + +set qtpproj=%cd% +cd ..\..\..\..\ + +"%VS100COMNTOOLS%..\IDE\devenv.com" "%WORKSPACE%\cocos2d-win32.vc2010.sln" /Build "Release|Win32" + +set CC_TEST_BIN=TestCpp.exe + +set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* +set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* +set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* +set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* + +cd Release.win32 + +xcopy /E /Y /Q "%CC_TEST_RES%" . +xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . +xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + +cd .. +cd %qtpproj%\qtp_win32 +cscript qtrunner.vbs + +pause \ No newline at end of file diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index 80b9349896..3181a2ebba 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -5,29 +5,34 @@ enum { class CCAction : public CCObject { - // bool isDone(void); - // CCNode* getTarget(void); + bool isDone(void); + CCNode* getTarget(void); // void setTarget(CCNode *pTarget); - // CCNode* getOriginalTarget(void); + CCNode* getOriginalTarget(void); // void setOriginalTarget(CCNode *pOriginalTarget); - // int getTag(void); - // void setTag(int nTag); - - // static CCAction* create(); + // static CCAction* create(); + int getTag(void); + void setTag(int nTag); + CCObject* copyWithZone(CCZone* pZone); }; class CCActionInterval : public CCAction { - // float getElapsed(void); - // void setAmplitudeRate(CGFloat amp); - // CGFloat getAmplitudeRate(void); + float getElapsed(void); + bool isDone(void); + void setAmplitudeRate(float amp); + float getAmplitudeRate(void); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + CCActionInterval* create(float d); }; class CCFiniteTimeAction : public CCActionInterval { - // float getDuration(void); - // void setDuration(float duration); - // CCFiniteTimeAction* reverse(void); + float getDuration(void); + void setDuration(float duration); + CCFiniteTimeAction* reverse(void); }; // CCActionInterval @@ -35,7 +40,9 @@ class CCSpeed : public CCAction { float getSpeed(void); void setSpeed(float fSpeed); - CCAction* reverse(void); + CCActionInterval* reverse(void); + bool isDone(void); + CCObject* copyWithZone(CCZone* pZone); static CCSpeed* create(CCActionInterval *pAction, float fRate); }; @@ -44,6 +51,8 @@ class CCFollow : public CCAction { bool isBoundarySet(void); void setBoudarySet(bool bValue); + bool isDone(void); + CCObject* copyWithZone(CCZone* pZone); static CCFollow* create(CCNode *pFollowedNode); static CCFollow* create(CCNode *pFollowedNode, CCRect rect); @@ -51,63 +60,97 @@ class CCFollow : public CCAction class CCSequence : public CCActionInterval { - static CCFiniteTimeAction* create(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCFiniteTimeAction* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); static CCFiniteTimeAction* create(CCArray *actions); }; class CCRepeat : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + bool isDone(void); + CCActionInterval* reverse(void); + static CCRepeat* create(CCActionInterval *pAction, unsigned int times); }; class CCRepeatForever : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + bool isDone(void); + CCActionInterval* reverse(void); + static CCRepeatForever* create(CCActionInterval *pAction); }; class CCSpawn : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCFiniteTimeAction* create(CCArray *actions); - static CCSpawn* create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); }; class CCRotateTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCRotateTo* create(float duration, float fDeltaAngle); }; class CCRotateBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCRotateBy* create(float duration, float fDeltaAngle); }; class CCMoveTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCMoveTo* create(float duration, CCPoint position); }; class CCMoveBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCMoveBy* create(float duration, CCPoint position); }; class CCSkewTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCSkewTo* create(float t, float sx, float sy); }; class CCSkewBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); }; class CCJumpBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCJumpBy* create(float duration, CCPoint position, float height, int jumps); }; class CCJumpTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCJumpTo* create(float duration, CCPoint position, float height, int jumps); }; @@ -119,112 +162,169 @@ typedef struct _ccBezierConfig { class CCBezierBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCBezierBy* create(float t, ccBezierConfig c); }; class CCBezierTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCBezierTo* create(float t, ccBezierConfig c); }; class CCScaleTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCScaleTo* create(float duration, float s); static CCScaleTo* create(float duration, float sx, float sy); }; class CCScaleBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCScaleBy* create(float duration, float s); static CCScaleBy* create(float duration, float sx, float sy); }; class CCBlink : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCBlink* create(float duration, unsigned int uBlinks); }; class CCFadeIn : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCFadeIn* create(float d); }; class CCFadeOut : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCFadeOut* create(float d); }; class CCFadeTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCFadeTo* create(float duration, GLubyte opacity); }; class CCTintTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); }; class CCTintBy : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); }; class CCDelayTime : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCDelayTime* create(float d); }; class CCReverseTime : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + static CCReverseTime* create(CCFiniteTimeAction *pAction); }; class CCAnimate : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + CCAnimation* getAnimation(void); void setAnimation(CCAnimation *pAnimation); - static CCAction* create(CCAnimation *pAnimation); + static CCAnimate* create(CCAnimation *pAnimation); }; -class CCProgressTo : public CCAction +class CCTargetedAction : public CCActionInterval { - static CCAction* create(float duration, float fPercent); -}; + CCObject* copyWithZone(CCZone* pZone); + CCNode* getForcedTarget(void); + void setForcedTarget(CCNode* target); -class CCProgressFromTo : public CCAction -{ - static CCAction* create(float duration, float fFromPercentage, float fToPercentage); + static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction); }; // CCActionInstant -class CCShow : public CCAction +class CCActionInstant : public CCFiniteTimeAction { - static CCAction* create(); + CCObject* copyWithZone(CCZone* pZone); + CCFiniteTimeAction* reverse(void); + bool isDone(void); }; -class CCHide : public CCAction +class CCShow : public CCActionInstant { - static CCAction* create(); + CCObject* copyWithZone(CCZone* pZone); + CCFiniteTimeAction* reverse(void); + + static CCShow* create(); }; -class CCToggleVisibility : public CCAction +class CCHide : public CCActionInstant { - static CCAction* create(); + CCObject* copyWithZone(CCZone* pZone); + CCFiniteTimeAction* reverse(void); + + static CCHide* create(); }; -class CCFlipX : public CCAction +class CCToggleVisibility : public CCActionInstant { - static CCAction* create(bool x); + CCObject* copyWithZone(CCZone* pZone); + + static CCToggleVisibility* create(); }; -class CCFlipY : public CCAction +class CCFlipX : public CCActionInstant { - static CCAction* create(bool y); + CCObject* copyWithZone(CCZone* pZone); + CCFiniteTimeAction* reverse(void); + + static CCFlipX* create(bool x); }; -class CCPlace : public CCAction // +class CCFlipY : public CCActionInstant { - static CCAction* create(CCPoint pos); + CCObject* copyWithZone(CCZone* pZone); + CCFiniteTimeAction* reverse(void); + + static CCFlipY* create(bool y); +}; + +class CCPlace : public CCActionInstant // +{ + CCObject* copyWithZone(CCZone* pZone); + + static CCPlace* create(CCPoint pos); }; diff --git a/tools/tolua++/CCActionCamera.pkg b/tools/tolua++/CCActionCamera.pkg index b76d064c8c..b10c9f7e7d 100644 --- a/tools/tolua++/CCActionCamera.pkg +++ b/tools/tolua++/CCActionCamera.pkg @@ -2,10 +2,12 @@ class CCActionCamera : public CCActionInterval { void startWithTarget(CCNode *pTarget); + CCActionInterval* reverse(); }; class CCOrbitCamera : public CCActionCamera { + CCObject* copyWithZone(CCZone* pZone); void sphericalRadius(float *r, float *zenith, float *azimuth); static CCOrbitCamera * create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); diff --git a/tools/tolua++/CCActionCatmullRom.pkg b/tools/tolua++/CCActionCatmullRom.pkg new file mode 100644 index 0000000000..a8756d0a3b --- /dev/null +++ b/tools/tolua++/CCActionCatmullRom.pkg @@ -0,0 +1,46 @@ + +class CCPointArray : public CCNode +{ + bool initWithCapacity(unsigned int capacity); + void addControlPoint(CCPoint controlPoint); + void insertControlPoint(CCPoint &controlPoint, unsigned int index); + void replaceControlPoint(CCPoint &controlPoint, unsigned int index); + CCPoint getControlPointAtIndex(unsigned int index); + void removeControlPointAtIndex(unsigned int index); + unsigned int count(); + CCPointArray* reverse(); + void reverseInline(); + CCObject* copyWithZone(CCZone *zone); + CCArray* getControlPoints(); + void setControlPoints(CCArray *controlPoints); + + static CCPointArray* create(unsigned int capacity); +}; + +class CCCardinalSplineTo : public CCActionInterval +{ + CCCardinalSplineTo* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(); + CCPointArray* getPoints(); + void setPoints(CCPointArray* points); + + static CCCardinalSplineTo* create(float duration, CCPointArray* points, float tension); +}; + + +class CCCardinalSplineBy : public CCCardinalSplineTo +{ + CCActionInterval* reverse(); + + static CCCardinalSplineBy* create(float duration, CCPointArray* points, float tension); +}; + +class CCCatmullRomTo : public CCCardinalSplineTo +{ + static CCCatmullRomTo* create(float dt, CCPointArray* points); +}; + +class CCCatmullRomBy : public CCCardinalSplineBy +{ + static CCCatmullRomBy* create(float dt, CCPointArray* points); +}; diff --git a/tools/tolua++/CCActionEase.pkg b/tools/tolua++/CCActionEase.pkg index 9455a1a7bb..d317f58704 100644 --- a/tools/tolua++/CCActionEase.pkg +++ b/tools/tolua++/CCActionEase.pkg @@ -1,114 +1,183 @@ class CCActionEase : public CCActionInterval { - static CCActionInterval* create(CCActionInterval *pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCActionEase* create(CCActionInterval *pAction); }; -class CCEaseRateAction : public CCActionInterval +class CCEaseRateAction : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction, float fRate); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseRateAction* create(CCActionInterval* pAction, float fRate); }; -class CCEaseIn : public CCActionInterval +class CCEaseIn : public CCEaseRateAction { - static CCActionInterval* create(CCActionInterval* pAction, float fRate); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseIn* create(CCActionInterval* pAction, float fRate); }; -class CCEaseOut : public CCActionInterval +class CCEaseOut : public CCEaseRateAction { - static CCActionInterval* create(CCActionInterval* pAction, float fRate); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseOut* create(CCActionInterval* pAction, float fRate); }; -class CCEaseInOut : public CCActionInterval +class CCEaseInOut : public CCEaseRateAction { - static CCActionInterval* create(CCActionInterval* pAction, float fRate); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseInOut* create(CCActionInterval* pAction, float fRate); }; -class CCEaseExponentialIn : public CCActionInterval +class CCEaseExponentialIn : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseExponentialIn* create(CCActionInterval* pAction); }; -class CCEaseExponentialOut : public CCActionInterval +class CCEaseExponentialOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseExponentialOut* create(CCActionInterval* pAction); }; -class CCEaseExponentialInOut : public CCActionInterval +class CCEaseExponentialInOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseExponentialInOut* create(CCActionInterval* pAction); }; -class CCEaseSineIn : public CCActionInterval +class CCEaseSineIn : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseSineIn* create(CCActionInterval* pAction); }; -class CCEaseSineOut : public CCActionInterval +class CCEaseSineOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseSineOut* create(CCActionInterval* pAction); }; -class CCEaseSineInOut : public CCActionInterval +class CCEaseSineInOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseSineInOut* create(CCActionInterval* pAction); }; -class CCEaseElastic : public CCActionInterval +class CCEaseElastic : public CCActionEase { - static CCActionInterval* create(CCActionInterval *pAction); - static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + float getPeriod(void); + void setPeriod(float fPeriod); + + static CCEaseElastic* create(CCActionInterval *pAction); + static CCEaseElastic* create(CCActionInterval *pAction, float fPeriod); }; -class CCEaseElasticIn : public CCActionInterval +class CCEaseElasticIn : public CCEaseElastic { - static CCActionInterval* create(CCActionInterval *pAction); - static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseElasticIn* create(CCActionInterval *pAction); + static CCEaseElasticIn* create(CCActionInterval *pAction, float fPeriod); }; -class CCEaseElasticOut : public CCActionInterval +class CCEaseElasticOut : public CCEaseElastic { - static CCActionInterval* create(CCActionInterval *pAction); - static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseElasticOut* create(CCActionInterval *pAction); + static CCEaseElasticOut* create(CCActionInterval *pAction, float fPeriod); }; -class CCEaseElasticInOut : public CCActionInterval +class CCEaseElasticInOut : public CCEaseElastic { - static CCActionInterval* create(CCActionInterval *pAction); - static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseElasticInOut* create(CCActionInterval *pAction); + static CCEaseElasticInOut* create(CCActionInterval *pAction, float fPeriod); }; -class CCEaseBounce : public CCActionInterval +class CCEaseBounce : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBounce* create(CCActionInterval* pAction); }; -class CCEaseBounceIn : public CCActionInterval +class CCEaseBounceIn : public CCEaseBounce { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBounceIn* create(CCActionInterval* pAction); }; -class CCEaseBounceOut : public CCActionInterval +class CCEaseBounceOut : public CCEaseBounce { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBounceOut* create(CCActionInterval* pAction); }; -class CCEaseBounceInOut : public CCActionInterval +class CCEaseBounceInOut : public CCEaseBounce { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBounceInOut* create(CCActionInterval* pAction); }; -class CCEaseBackIn : public CCActionInterval +class CCEaseBackIn : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBackIn* create(CCActionInterval* pAction); }; -class CCEaseBackOut : public CCActionInterval +class CCEaseBackOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBackOut* create(CCActionInterval* pAction); }; -class CCEaseBackInOut : public CCActionInterval +class CCEaseBackInOut : public CCActionEase { - static CCActionInterval* create(CCActionInterval* pAction); + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + + static CCEaseBackInOut* create(CCActionInterval* pAction); }; diff --git a/tools/tolua++/CCActionGrid.pkg b/tools/tolua++/CCActionGrid.pkg index d10e154ac9..02d6fc7f7f 100644 --- a/tools/tolua++/CCActionGrid.pkg +++ b/tools/tolua++/CCActionGrid.pkg @@ -1,6 +1,9 @@ class CCGridAction : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + CCActionInterval* reverse(void); + CCGridBase* getGrid(void); static CCGridAction* create(ccGridSize gridSize, float duration); @@ -8,14 +11,38 @@ class CCGridAction : public CCActionInterval class CCAccelDeccelAmplitude : public CCActionInterval { + CCActionInterval* reverse(void); + float getRate(void); void setRate(float fRate); static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); }; +class CCGrid3DAction : public CCGridAction +{ + virtual CCGridBase* getGrid(void); + ccVertex3F vertex(const ccGridSize& pos); + ccVertex3F originalVertex(const ccGridSize& pos); + void setVertex(const ccGridSize& pos, const ccVertex3F& vertex); + + //static CCGrid3DAction* create(const ccGridSize& gridSize, float duration); +}; + +class CCTiledGrid3DAction : public CCGridAction +{ + ccQuad3 tile(ccGridSize pos); + ccQuad3 originalTile(ccGridSize pos); + void setTile(ccGridSize pos, ccQuad3 coords); + CCGridBase* getGrid(void); + + //static CCTiledGrid3DAction* create(ccGridSize gridSize, float duration); +}; + class CCAccelAmplitude : public CCActionInterval { + CCActionInterval* reverse(void); + float getRate(void); void setRate(float fRate); @@ -24,6 +51,8 @@ class CCAccelAmplitude : public CCActionInterval class CCDeccelAmplitude : public CCActionInterval { + CCActionInterval* reverse(void); + float getRate(void); void setRate(float fRate); diff --git a/tools/tolua++/CCActionGrid3D.pkg b/tools/tolua++/CCActionGrid3D.pkg index c3fca6ebfc..c3e3219911 100644 --- a/tools/tolua++/CCActionGrid3D.pkg +++ b/tools/tolua++/CCActionGrid3D.pkg @@ -1,6 +1,8 @@ class CCWaves3D : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getAmplitude(void); void setAmplitude(float fAmplitude); float getAmplitudeRate(void); @@ -11,16 +13,22 @@ class CCWaves3D : public CCGrid3DAction class CCFlipX3D : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCFlipX3D* create(float duration); }; class CCFlipY3D : public CCFlipX3D { + CCObject* copyWithZone(CCZone* pZone); + static CCFlipY3D* create(float duration); }; class CCLens3D : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getLensEffect(void); void setLensEffect(float fLensEffect); CCPoint getPosition(void); @@ -31,6 +39,8 @@ class CCLens3D : public CCGrid3DAction class CCRipple3D : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + CCPoint getPosition(void); void setPosition(CCPoint position); float getAmplitude(void); @@ -43,11 +53,15 @@ class CCRipple3D : public CCGrid3DAction class CCShaky3D : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCShaky3D* create(int range, bool shakeZ, ccGridSize gridSize, float duration); }; class CCLiquid : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getAmplitude(void); void setAmplitude(float fAmplitude); float getAmplitudeRate(void); @@ -58,6 +72,8 @@ class CCLiquid : public CCGrid3DAction class CCWaves : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getAmplitude(void); void setAmplitude(float fAmplitude); float getAmplitudeRate(void); @@ -68,6 +84,8 @@ class CCWaves : public CCGrid3DAction class CCTwirl : public CCGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + CCPoint getPosition(void); void setPosition(CCPoint position); float getAmplitude(void); diff --git a/tools/tolua++/CCActionManager.pkg b/tools/tolua++/CCActionManager.pkg index 5314b85fe2..114ad720af 100644 --- a/tools/tolua++/CCActionManager.pkg +++ b/tools/tolua++/CCActionManager.pkg @@ -18,4 +18,8 @@ class CCActionManager : public CCObject void pauseTarget(CCObject *pTarget); void resumeTarget(CCObject *pTarget); + + CCSet* pauseAllRunningActions(); + + void resumeTargets(CCSet* targetsToResume); }; diff --git a/tools/tolua++/CCActionProgressTimer.pkg b/tools/tolua++/CCActionProgressTimer.pkg index 6e3c911fd8..f4feb97fe5 100644 --- a/tools/tolua++/CCActionProgressTimer.pkg +++ b/tools/tolua++/CCActionProgressTimer.pkg @@ -1,10 +1,14 @@ class CCProgressTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCProgressTo* create(float duration, float fPercent); }; class CCProgressFromTo : public CCActionInterval { + CCObject* copyWithZone(CCZone* pZone); + static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); }; diff --git a/tools/tolua++/CCActionTiledGrid.pkg b/tools/tolua++/CCActionTiledGrid.pkg index 5018acaa99..48dc92f602 100644 --- a/tools/tolua++/CCActionTiledGrid.pkg +++ b/tools/tolua++/CCActionTiledGrid.pkg @@ -1,16 +1,22 @@ class CCShakyTiles3D : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCShakyTiles3D* create(int nRange, bool bShakeZ, ccGridSize gridSize, float duration); }; class CCShatteredTiles3D : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCShatteredTiles3D* create(int nRange, bool bShatterZ, ccGridSize gridSize, float duration); }; class CCShuffleTiles : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + void shuffle(int *pArray, int nLen); ccGridSize getDelta(ccGridSize pos); void placeTile(ccGridSize pos, Tile *t); @@ -34,6 +40,8 @@ class CCFadeOutBLTiles : public CCFadeOutTRTiles class CCFadeOutUpTiles : public CCFadeOutTRTiles { + void transformTile(ccGridSize pos, float distance); + static CCFadeOutUpTiles* create(ccGridSize gridSize, float time); }; @@ -44,6 +52,8 @@ class CCFadeOutDownTiles : public CCFadeOutUpTiles class CCTurnOffTiles : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + void shuffle(int *pArray, int nLen); void turnOnTile(ccGridSize pos); void turnOffTile(ccGridSize pos); @@ -54,6 +64,8 @@ class CCTurnOffTiles : public CCTiledGrid3DAction class CCWavesTiles3D : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getAmplitude(void); void setAmplitude(float fAmplitude); float getAmplitudeRate(void); @@ -64,6 +76,8 @@ class CCWavesTiles3D : public CCTiledGrid3DAction class CCJumpTiles3D : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + float getAmplitude(void); void setAmplitude(float fAmplitude); float getAmplitudeRate(void); @@ -74,10 +88,14 @@ class CCJumpTiles3D : public CCTiledGrid3DAction class CCSplitRows : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCSplitRows* create(int nRows, float duration); }; class CCSplitCols : public CCTiledGrid3DAction { + CCObject* copyWithZone(CCZone* pZone); + static CCSplitCols* create(int nCols, float duration); }; diff --git a/tools/tolua++/CCAffineTransform.pkg b/tools/tolua++/CCAffineTransform.pkg index 3bfcc39abb..dece0d7af9 100644 --- a/tools/tolua++/CCAffineTransform.pkg +++ b/tools/tolua++/CCAffineTransform.pkg @@ -1,11 +1,11 @@ struct CCAffineTransform { - CCFloat a, b, c, d; - CCFloat tx, ty; + float a, b, c, d; + float tx, 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); +CCAffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); +CCAffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float 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, CCFloat anAngle); -CCAffineTransform CCAffineTransformScale(CCAffineTransform t, CCFloat sx, CCFloat sy); +CCAffineTransform CCAffineTransformRotate(CCAffineTransform aTransform, float anAngle); +CCAffineTransform CCAffineTransformScale(CCAffineTransform t, float sx, float 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 c7c3f9de9f..8001ec4033 100644 --- a/tools/tolua++/CCAnimation.pkg +++ b/tools/tolua++/CCAnimation.pkg @@ -3,9 +3,10 @@ class CCAnimationFrame : public CCObject { CCAnimationFrame(); ~CCAnimationFrame(); - + CCObject* copyWithZone(CCZone* pZone); + bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo); - + CCSpriteFrame* getSpriteFrame(); void setSpriteFrame(CCSpriteFrame* pSpFrame); @@ -21,10 +22,11 @@ class CCAnimation : public CCObject { CCAnimation(); ~CCAnimation(void); + CCObject* copyWithZone(CCZone* pZone); static CCAnimation* create(void); - static CCAnimation* create(CCArray* arrayOfSpriteFrameNames); - static CCAnimation* create(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); static CCAnimation* create(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); void addSpriteFrame(CCSpriteFrame *pFrame); diff --git a/tools/tolua++/CCAnimationCache.pkg b/tools/tolua++/CCAnimationCache.pkg index f94ea138da..52def5edc5 100644 --- a/tools/tolua++/CCAnimationCache.pkg +++ b/tools/tolua++/CCAnimationCache.pkg @@ -7,4 +7,7 @@ class CCAnimationCache : public CCObject static CCAnimationCache* sharedAnimationCache(void); static void purgeSharedAnimationCache(void); + + void addAnimationsWithDictionary(CCDictionary* dictionary); + void addAnimationsWithFile(const char* plist); }; diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg index 7b7a15e9da..80b159a030 100644 --- a/tools/tolua++/CCArray.pkg +++ b/tools/tolua++/CCArray.pkg @@ -1,10 +1,13 @@ class CCArray : public CCObject { + CCObject* copyWithZone(CCZone* pZone); + static CCArray* create(); - static CCArray* createWithObject(CCObject* pObject); - static CCArray* create(const char* pFileName); - static CCArray* create(unsigned int capacity); - static CCArray* create(CCArray* otherArray); + + static CCArray* createWithObject(CCObject* pObject); + static CCArray* createWithArray(CCArray* otherArray); + static CCArray* createWithCapacity(unsigned int capacity); + static CCArray* createWithContentsOfFile(const char* pFileName); unsigned int count(); @@ -18,6 +21,8 @@ class CCArray : public CCObject CCObject* randomObject(); + bool isEqualToArray(CCArray* pOtherArray); + bool containsObject(CCObject* object); void addObject(CCObject* object); diff --git a/tools/tolua++/CCAtlasNode.pkg b/tools/tolua++/CCAtlasNode.pkg index 3b6ce53f69..97568e6dc2 100644 --- a/tools/tolua++/CCAtlasNode.pkg +++ b/tools/tolua++/CCAtlasNode.pkg @@ -1,9 +1,24 @@ class CCAtlasNode : public CCNode { - void updateAtlasValues(); - CCTexture2D* getTexture(void); + CCTextureAtlas* getTextureAtlas(); + void setTextureAtlas(CCTextureAtlas* atlas); + + CCTexture2D* getTexture(void); void setTexture(CCTexture2D *texture); - static CCAtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); + ccColor3B getColor(); + void setColor(ccColor3B color); + + unsigned int getQuadsToDraw(); + void setQuadsToDraw(unsigned int quadsToDraw); + + GLubyte getOpacity(); + void setOpacity(GLubyte opacity); + + void updateAtlasValues(); + bool isOpacityModifyRGB(); + void setOpacityModifyRGB(bool isOpacityModifyRGB); + + static CCAtlasNode * create(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); }; diff --git a/tools/tolua++/CCCommon.pkg b/tools/tolua++/CCCommon.pkg index 5f01e967be..126b60b18b 100644 --- a/tools/tolua++/CCCommon.pkg +++ b/tools/tolua++/CCCommon.pkg @@ -1,3 +1,13 @@ +typedef enum LanguageType +{ + kLanguageEnglish = 0, + kLanguageChinese, + kLanguageFrench, + kLanguageItalian, + kLanguageGerman, + kLanguageSpanish, + kLanguageRussian +} ccLanguageType; void CCLuaLog(const char * pszFormat); void CCMessageBox(const char * pszMsg, const char * pszTitle); diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg index 218e0f5ca2..3c87553265 100644 --- a/tools/tolua++/CCDictionary.pkg +++ b/tools/tolua++/CCDictionary.pkg @@ -19,8 +19,8 @@ class CCDictionary : public CCObject void removeAllObjects(); static CCDictionary* create(); - static CCDictionary* create(CCDictionary* srcDict); - static CCDictionary* create(const char *pFileName); + static CCDictionary* createWithDictionary(CCDictionary* srcDict); + static CCDictionary* createWithContentsOfFile(const char *pFileName); }; diff --git a/tools/tolua++/CCDirector.pkg b/tools/tolua++/CCDirector.pkg index 2832270833..d57327dc27 100644 --- a/tools/tolua++/CCDirector.pkg +++ b/tools/tolua++/CCDirector.pkg @@ -11,18 +11,26 @@ class CCDirector : public CCObject bool isPaused(void); unsigned int getTotalFrames(void); + CCEGLView* getOpenGLView(void); + bool enableRetinaDisplay(bool bEnableRetina); + CCSize getWinSize(void); CCSize getWinSizeInPixels(void); CCPoint convertToGL(CCPoint obPoint); CCPoint convertToUI(CCPoint obPoint); + void pause(); + void resume(); + void purgeCachedData(void); + void runWithScene(CCScene *pScene); void pushScene(CCScene *pScene); void popScene(void); void replaceScene(CCScene *pScene); + void endToLua(); - CCFloat getContentScaleFactor(void); + float getContentScaleFactor(void); CCScheduler* getScheduler(); CCActionManager* getActionManager(); diff --git a/tools/tolua++/CCDrawingPrimitives.pkg b/tools/tolua++/CCDrawingPrimitives.pkg index af6e0e9514..9a78396183 100644 --- a/tools/tolua++/CCDrawingPrimitives.pkg +++ b/tools/tolua++/CCDrawingPrimitives.pkg @@ -2,7 +2,15 @@ void ccDrawPoint(CCPoint point); void ccDrawPoints(const CCPoint *points, unsigned int numberOfPoints); void ccDrawLine(CCPoint origin, CCPoint destination); -void ccDrawPoly(const CCPoint *vertices, int numOfVertices, bool closePolygon); +void ccDrawRect(CCPoint origin, CCPoint destination); +void ccDrawSolidRect(CCPoint origin, CCPoint destination, ccColor4F color); +void ccDrawPoly(const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon); +void ccDrawSolidPoly(const CCPoint* poli, unsigned int numberOfPoints, ccColor4F color); void ccDrawCircle(CCPoint center, float radius, float angle, unsigned int segments, bool drawLineToCenter); void ccDrawQuadBezier(CCPoint origin, CCPoint control, CCPoint destination, unsigned int segments); void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, unsigned int segments); +void ccDrawCatmullRom(CCPointArray* arrayOfControlPoints, unsigned int segments); +void ccDrawCardinalSpline(CCPointArray* config, float tension, unsigned int segments); +void ccDrawColor4B(GLubyte r, GLubyte g, GLubyte b, GLubyte a); +void ccDrawColor4F(GLubyte r, GLubyte g, GLubyte b, GLubyte a); +void ccPointSize(GLfloat pointSize); diff --git a/tools/tolua++/CCFileUtils.pkg b/tools/tolua++/CCFileUtils.pkg index ee212bd7e0..c6429207c3 100644 --- a/tools/tolua++/CCFileUtils.pkg +++ b/tools/tolua++/CCFileUtils.pkg @@ -3,4 +3,7 @@ class CCFileUtils { static CCFileUtils* sharedFileUtils(); std::string getWriteablePath(); + const char* fullPathFromRelativePath(const char *pszRelativePath); + const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); + const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); }; diff --git a/tools/tolua++/CCGeometry.pkg b/tools/tolua++/CCGeometry.pkg index 801f5719d4..18c9e093d7 100644 --- a/tools/tolua++/CCGeometry.pkg +++ b/tools/tolua++/CCGeometry.pkg @@ -8,7 +8,7 @@ class CCPoint CCPoint(); CCPoint(float x, float y); - static bool CCPointEqualToPoint(const CCPoint& point1, const CCPoint& point2); + bool equals(const CCPoint & target) const ; }; class CCSize @@ -18,7 +18,7 @@ class CCSize CCSize(); CCSize(float width, float height); - static bool CCSizeEqualToSize(const CCSize& size1, const CCSize& size2); + bool equals(const CCSize & target) const; }; class CCRect @@ -28,15 +28,15 @@ class CCRect CCRect(); CCRect(float x, float y, float width, float height); - static CGFloat CCRectGetMinX(const CCRect& rect); - static CGFloat CCRectGetMaxX(const CCRect& rect); - static CGFloat CCRectGetMidX(const CCRect& rect); - static CGFloat CCRectGetMinY(const CCRect& rect); - static CGFloat CCRectGetMaxY(const CCRect& rect); - static CGFloat CCRectGetMidY(const CCRect& rect); - static bool CCRectEqualToRect(const CCRect& rect1, const CCRect& rect2); - static bool CCRectContainsPoint(const CCRect& rect, const CCPoint& point); - static bool CCRectIntersectsRect(const CCRect& rectA, const CCRect& rectB); + float getMinX(); + float getMidX(); + float getMaxX(); + float getMinY(); + float getMidY(); + float getMaxY(); + bool equals(const CCRect & rect) const; + bool containsPoint(const CCPoint & point) const; + bool intersectsRect(const CCRect & rect) const; }; CCPoint CCPointMake(float x, float y); diff --git a/tools/tolua++/CCLabelBMFont.pkg b/tools/tolua++/CCLabelBMFont.pkg index cde548f9b3..f2aeb918f8 100644 --- a/tools/tolua++/CCLabelBMFont.pkg +++ b/tools/tolua++/CCLabelBMFont.pkg @@ -2,7 +2,21 @@ class CCLabelBMFont : public CCNode { void setString(const char *label); - const char* getString(void); + void setString(const char *label, bool fromUpdate); + void setCString(const char *label); + const char* getString(void); + void updateString(bool fromUpdate); + + void setAnchorPoint(const CCPoint & var); + void setAlignment(CCTextAlignment alignment); + void setWidth(float width); + void setLineBreakWithoutSpace(bool breakWithoutSpace); + void setScale(float scale); + void setScaleX(float scaleX); + void setScaleY(float scaleY); + + void setFntFile(const char* fntFile); + const char* getFntFile(); void setColor(const ccColor3B& color); const ccColor3B& getColor(void); @@ -10,8 +24,12 @@ class CCLabelBMFont : public CCNode GLubyte getOpacity(void); void setOpacity(GLubyte opacity); + bool isOpacityModifyRGB(); + void setOpacityModifyRGB(bool isOpacityModifyRGB); + tolua_property__CCOpacity GLubyte opacity; static void purgeCachedData(); - static CCLabelBMFont * create(const char *str, const char *fntFile); + static CCLabelBMFont * create(); + static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointMake(0, 0)); }; diff --git a/tools/tolua++/CCLabelTTF.pkg b/tools/tolua++/CCLabelTTF.pkg index d8495a5cdb..215b889ad8 100644 --- a/tools/tolua++/CCLabelTTF.pkg +++ b/tools/tolua++/CCLabelTTF.pkg @@ -4,7 +4,23 @@ class CCLabelTTF : public CCSprite void setString(const char *label); const char* getString(void); - static CCLabelTTF * create(const char *label, CCSize dimensions, CCTextAlignment hAlignment,CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); - static CCLabelTTF * create(const char *label, CCSize dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); - static CCLabelTTF * create(const char *label, const char *fontName, float fontSize); + CCTextAlignment getHorizontalAlignment(); + void setHorizontalAlignment(CCTextAlignment alignment); + + CCVerticalTextAlignment getVerticalAlignment(); + void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment); + + CCSize getDimensions(); + void setDimensions(CCSize &dim); + + float getFontSize(); + void setFontSize(float fontSize); + + const char* getFontName(); + void setFontName(const char *fontName); + + static CCLabelTTF * create(); + static CCLabelTTF * create(const char *str, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment); + static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment); }; diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg index 25c47c2a6b..afd68899b8 100644 --- a/tools/tolua++/CCLayer.pkg +++ b/tools/tolua++/CCLayer.pkg @@ -25,6 +25,8 @@ class CCLayerColor : public CCLayer void changeHeight(GLfloat h); void changeWidthAndHeight(GLfloat w ,GLfloat h); + void setContentSize(const CCSize & var); + void setOpacity(GLubyte var); GLubyte getOpacity(void); void setColor(ccColor3B Value); @@ -32,6 +34,9 @@ class CCLayerColor : public CCLayer void setBlendFunc(ccBlendFunc Value); ccBlendFunc getBlendFunc(void); + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); + static CCLayerColor * create(ccColor4B color, GLfloat width, GLfloat height); static CCLayerColor * create(ccColor4B color); }; @@ -62,5 +67,6 @@ class CCLayerMultiplex : public CCLayer void switchTo(unsigned int n); void switchToAndReleaseMe(unsigned int n); + static CCLayerMultiplex * create(CCLayer* layer); static CCLayerMultiplex * createWithLayer(CCLayer* layer); }; diff --git a/tools/tolua++/CCMenu.pkg b/tools/tolua++/CCMenu.pkg index 0aa98fd3f6..42bf9f0903 100644 --- a/tools/tolua++/CCMenu.pkg +++ b/tools/tolua++/CCMenu.pkg @@ -1,5 +1,5 @@ /* -typedef enum +typedef enum { kCCMenuStateWaiting, kCCMenuStateTrackingTouch @@ -19,6 +19,8 @@ class CCMenu : public CCLayer void alignItemsInColumns(unsigned int columns, va_list args); void alignItemsInRows(unsigned int rows, va_list args); + setHandlerPriority(int newPriority); + void addChild(CCMenuItem* child, int zOrder = 0, int tag = -1); void setOpacity(GLubyte opacity); @@ -26,6 +28,13 @@ class CCMenu : public CCLayer void setColor(ccColor3B color); ccColor3B getColor(void); + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); + + bool isEnabled(); + void setEnabled(bool value); + static CCMenu* create(); static CCMenu* createWithItem(CCMenuItem* item); + static CCMenu* createWithArray(CCArray* pArrayOfItems); }; diff --git a/tools/tolua++/CCMenuItem.pkg b/tools/tolua++/CCMenuItem.pkg index 554b3229c0..d01b6dcf16 100644 --- a/tools/tolua++/CCMenuItem.pkg +++ b/tools/tolua++/CCMenuItem.pkg @@ -21,6 +21,18 @@ class CCMenuItemLabel : public CCMenuItem GLubyte getOpacity(); void setColor(ccColor3B color); ccColor3B getColor(); + void setDisabledColor(const ccColor3B & color); + const ccColor3B & getDisabledColor(); + void setLabel(CCNode* pLabel); + CCNode* getLabel(); + + void activate(); + void selected(); + void unselected(); + void setEnabled(bool enabled); + + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); static CCMenuItemLabel* create(CCNode* label); }; @@ -37,9 +49,14 @@ class CCMenuItemAtlasFont : public CCMenuItem class CCMenuItemFont : public CCMenuItem { static void setFontSize(int s); - static int fontSize(); + static unsigned int fontSize(); static void setFontName(const char* name); static const char* fontName(); + void setFontSizeObj(unsigned int s); + unsigned int fontSizeObj(); + void setFontNameObj(const char* name); + const char* fontNameObj(); + static CCMenuItemFont * create(const char* value); }; @@ -50,6 +67,20 @@ class CCMenuItemSprite : public CCMenuItem void setOpacity(GLubyte opacity); GLubyte getOpacity(); + void setNormalImage(CCNode* pImage); + CCNode* getNormalImage(); + void setSelectedImage(CCNode* pImage); + CCNode* getSelectedImage(); + void setDisabledImage(CCNode* pImage); + CCNode* getDisabledImage(); + + void selected(); + void unselected(); + void setEnabled(bool bEnabled); + + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite); static CCMenuItemSprite * create(CCNode* normalSprite, @@ -64,6 +95,11 @@ class CCMenuItemImage : public CCMenuItem void setOpacity(GLubyte opacity); GLubyte getOpacity(); + void setNormalSpriteFrame(CCSpriteFrame* frame); + void setSelectedSpriteFrame(CCSpriteFrame* frame); + void setDisabledSpriteFrame(CCSpriteFrame* frame); + + static CCMenuItemImage* create(); static CCMenuItemImage* create(const char* normalImage, const char* selectedImage); static CCMenuItemImage* create(const char* normalImage, @@ -73,8 +109,25 @@ class CCMenuItemImage : public CCMenuItem class CCMenuItemToggle : public CCMenuItem { - void addSubItem(CCMenuItem *item); + void setColor(ccColor3B color); + ccColor3B getColor(); + void setOpacity(GLubyte opacity); + GLubyte getOpacity(); + void setSelectedIndex(unsigned int index); + unsigned int getSelectedIndex(); + void setSubItems(CCArray* pArrayOfItems); + CCArray* getSubItems(); + + void addSubItem(CCMenuItem *item); CCMenuItem* selectedItem(); + void activate(); + void selected(); + void unselected(); + void setEnabled(bool var); + + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); + static CCMenuItemToggle* create(CCMenuItem *item); }; diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index 9fc60990af..4b05f2767d 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -1,3 +1,6 @@ +enum { + kCCNodeTagInvalid = -1, +}; enum { kCCNodeOnEnter, @@ -22,6 +25,7 @@ class CCNode : public CCObject float getPositionX(); float getPositionY(); void setPosition(float x, float y); + void setPosition(CCPoint pos); void setPositionX(float x); void setPositionY(float y); float getSkewX(); @@ -33,7 +37,7 @@ class CCNode : public CCObject CCPoint getAnchorPoint(); void setAnchorPoint(CCPoint point); CCSize getContentSize(); - void setContentSize(CCSize size); + void setContentSize(const CCSize & size); int getTag(); void setTag(int var); @@ -61,6 +65,7 @@ class CCNode : public CCObject //CCPoint getAnchorPointInPixels(); //CCSize getContentSizeInPixels(); //void setContentSizeInPixels(CCSize sz); + CCPoint getAnchorPointInPoints(); bool isRunning(); CCNode* getParent(); void setParent(CCNode * var); @@ -68,6 +73,18 @@ class CCNode : public CCObject void ignoreAnchorPointForPosition(bool newValue); void* getUserData(); void setUserData(void *var); + CCObject* getUserObject(); + void setUserObject(CCObject* pObject); + CCGLProgram* getShaderProgram(); + void setShaderProgram(CCGLProgram* pShaderProgram); + int getOrderOfArrival(); + void setOrderOfArrival(int order); + ccGLServerState getGLServerState(); + void setGLServerState(ccGLServerState state); + CCActionManager* getActionManager(); + void setActionManager(CCActionManager* pActionMgr); + CCScheduler* getScheduler(); + void setScheduler(CCScheduler* pScheduler); void addChild(CCNode * child); void addChild(CCNode * child, int zOrder); void addChild(CCNode * child, int zOrder, int tag); diff --git a/tools/tolua++/CCObject.pkg b/tools/tolua++/CCObject.pkg index 88773d3fd8..a03ef9dfaf 100644 --- a/tools/tolua++/CCObject.pkg +++ b/tools/tolua++/CCObject.pkg @@ -6,4 +6,6 @@ class CCObject bool isSingleReference(void); unsigned int retainCount(void); bool isEqual(const CCObject* pObject); + CCObject* copy(); + CCObject* autorelease(); }; diff --git a/tools/tolua++/CCParticleBatchNode.pkg b/tools/tolua++/CCParticleBatchNode.pkg index f30ecec06e..1f5a234160 100644 --- a/tools/tolua++/CCParticleBatchNode.pkg +++ b/tools/tolua++/CCParticleBatchNode.pkg @@ -1,7 +1,7 @@ class CCParticleBatchNode : public CCNode, public CCTextureProtocol { public: - static CCParticleBatchNode* create(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); virtual void addChild(CCNode * child); diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg index b7bb784375..9f24e037a9 100644 --- a/tools/tolua++/CCParticleSystem.pkg +++ b/tools/tolua++/CCParticleSystem.pkg @@ -1,9 +1,31 @@ +enum { + kCCParticleDurationInfinity = -1, + kCCParticleStartSizeEqualToEndSize = -1, + kCCParticleStartRadiusEqualToEndRadius = -1, + kParticleStartSizeEqualToEndSize = kCCParticleStartSizeEqualToEndSize, + kParticleDurationInfinity = kCCParticleDurationInfinity, +}; + +enum { + kCCParticleModeGravity, + kCCParticleModeRadius, +}; + +typedef enum { + kCCPositionTypeFree, + kCCPositionTypeRelative, + kCCPositionTypeGrouped, +}tCCPositionType; + +enum { + kPositionTypeFree = kCCPositionTypeFree, + kPositionTypeGrouped = kCCPositionTypeGrouped, +}; class CCParticleSystem : public CCNode { // mode A const CCPoint& getGravity(); - void setGravity(const CCPoint& g); float getSpeed(); void setSpeed(float speed); @@ -40,6 +62,26 @@ class CCParticleSystem : public CCNode void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition); void postStep(); + float getStartSize(); + float getStartSizeVar(); + float getEndSize(); + float getEndSizeVar(); + const ccColor4F & getStartColor(); + const ccColor4F & getStartColorVar(); + const ccColor4F & getEndColor(); + const ccColor4F & getEndColorVar(); + float getStartSpin(); + float getStartSpinVar(); + float getEndSpin(); + float getEndSpinVar(); + float getEmissionRate(); + unsigned int getTotalParticles(); + + bool isAutoRemoveOnFinish(); + void setAutoRemoveOnFinish(bool var); + int getEmitterMode(); + void setEmitterMode(int mode); + CCTexture2D* getTexture(void); void setTexture(CCTexture2D* var); @@ -50,7 +92,7 @@ class CCParticleSystem : public CCNode void setRotation(float newRotation); void setScaleX(float newScaleX); void setScaleY(float newScaleY); - + bool isActive(); bool isBlendAdditive(); void setBlendAdditive(bool value); @@ -58,7 +100,20 @@ class CCParticleSystem : public CCNode static CCParticleSystem * create(const char *plistFile); }; -class CCParticleSystemQuad : public CCParticleSystem { +class CCParticleSystemQuad : public CCParticleSystem +{ + void postStep(); + void setDisplayFrame(CCSpriteFrame* spriteFrame); + void setTexture(CCTexture2D* texture); + void setTextureWithRect(CCTexture2D *texture, const CCRect& rect); + void setBatchNode(CCParticleBatchNode* batchNode); + void setTotalParticles(unsigned int tp); + + void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition); + void postStep(); + void setTotalParticles(unsigned int tp); + + static CCParticleSystemQuad * create(); static CCParticleSystemQuad * create(const char *plistFile); }; diff --git a/tools/tolua++/CCPointExtension.pkg b/tools/tolua++/CCPointExtension.pkg index 19c0678546..3aea350a14 100644 --- a/tools/tolua++/CCPointExtension.pkg +++ b/tools/tolua++/CCPointExtension.pkg @@ -12,6 +12,7 @@ static CCPoint ccpProject(const CCPoint& v1, const CCPoint& v2); static CCPoint ccpRotate(const CCPoint& v1, const CCPoint& v2); static CCPoint ccpUnrotate(const CCPoint& v1, const CCPoint& v2); static CGFloat ccpLengthSQ(const CCPoint& v); +static CGFloat ccpDistanceSQ(const CCPoint p1, const CCPoint p2); CGFloat ccpLength(const CCPoint& v); CGFloat ccpDistance(const CCPoint& v1, const CCPoint& v2); CCPoint ccpNormalize(const CCPoint& v); diff --git a/tools/tolua++/CCScheduler.pkg b/tools/tolua++/CCScheduler.pkg index 33b526a663..4c4032b34e 100644 --- a/tools/tolua++/CCScheduler.pkg +++ b/tools/tolua++/CCScheduler.pkg @@ -4,6 +4,8 @@ class CCTimer : public CCObject float getInterval(void); void setInterval(float fInterval); void update(float dt); + + static CCTimer* timerWithScriptHandler(LUA_FUNCTION funcID, float fSeconds); }; class CCScheduler : public CCObject @@ -21,6 +23,8 @@ class CCScheduler : public CCObject void unscheduleAllSelectorsForTarget(CCObject *pTarget); void unscheduleAllSelectors(void); + void unscheduleAllSelectorsWithMinPriority(int nMinPriority); + void pauseTarget(CCObject *pTarget); void resumeTarget(CCObject *pTarget); bool isTargetPaused(CCObject *pTarget); diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index 550bc8ecb0..ea65eb74f4 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -37,7 +37,7 @@ class CCSprite : public CCNode void setBlendFunc(ccBlendFunc blendFunc); ccBlendFunc getBlendFunc(void); - //CCPoint getOffsetPositionInPixels(void); + CCPoint getOffsetPosition(void); void setDirtyRecursively(bool bValue); void ignoreAnchorPointForPosition(bool newValue); @@ -47,6 +47,24 @@ class CCSprite : public CCNode bool isFlipY(void); void updateColor(void); + void removeChild(CCNode* pChild, bool bCleanUp); + void removeAllChildrenWithCleanup(bool bCleanup); + void reorderChild(CCNode* pChild, int zOrder); + void addChild(CCNode* pChild); + void addChild(CCNode* pChild, int zOrder); + void addChild(CCNode* pChild, int zOrder, int tag); + void sortAllChildren(); + //void setPosition(CCPoint pos); + void setRotation(float rotation); + void setSkewX(float sx); + void setSkewY(float sy); + void setScale(float fScale); + void setScaleX(float fScaleX); + void setScaleY(float fScaleY); + void setVertexZ(float fVertexZ); + void setAnchorPoint(const CCPoint & anchor); + void setVisible(bool bVisible); + void setOpacity(GLubyte opacity); GLubyte getOpacity(void); @@ -62,20 +80,22 @@ class CCSprite : public CCNode void updateTransform(void); //void useSelfRender(void); - void setTextureRect(CCRect rect); - //void setTextureRectInPixels(CCRect rect, bool rotated, CCSize size); + void setTextureRect(CCRect rect); + void setTextureRect(CCRect rect, bool rotated, CCSize size); + void setVertexRect(CCRect rect); //void useBatchNode(CCSpriteBatchNode *batchNode); void setDisplayFrame(CCSpriteFrame *pNewFrame); bool isFrameDisplayed(CCSpriteFrame *pFrame); - //CCSpriteFrame* displayedFrame(void); + CCSpriteFrame* displayFrame(void); + void setBatchNode(CCSpriteBatchNode* pBatchNode); + CCSpriteBatchNode* getBatchNode(); void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex); - static CCSprite* create(CCTexture2D *pTexture); - static CCSprite* create(CCTexture2D *pTexture, CCRect rect); -// static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset); - static CCSprite* create(CCSpriteFrame *pSpriteFrame); + static CCSprite* createWithTexture(CCTexture2D *pTexture); + static CCSprite* createWithTexture(CCTexture2D *pTexture, CCRect rect); + static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); - static CCSprite* create(const char *pszFileName); + static CCSprite* create(); + static CCSprite* create(const char *pszFileName); static CCSprite* create(const char *pszFileName, CCRect rect); - //static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect); }; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg index d644d65783..cf6ad522a8 100644 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ b/tools/tolua++/CCSpriteBatchNode.pkg @@ -8,6 +8,7 @@ class CCSpriteBatchNode : public CCNode void increaseAtlasCapacity(); void removeChildAtIndex(unsigned int index, bool doCleanup); void insertChild(CCSprite *child, unsigned int index); + void appendChild(CCSprite *child); void removeSpriteFromAtlas(CCSprite *sprite); unsigned int rebuildIndexInOrder(CCSprite *parent, unsigned int index); @@ -15,13 +16,23 @@ class CCSpriteBatchNode : public CCNode unsigned int lowestAtlasIndexInChild(CCSprite *sprite); unsigned int atlasIndexForChild(CCSprite *sprite, int z); + void reorderBatch(bool reorder); void setTexture(CCTexture2D *texture); CCTexture2D* getTexture(void); void setBlendFunc(ccBlendFunc blendFunc); ccBlendFunc getBlendFunc(void); - static CCSpriteBatchNode* create(CCTexture2D *tex); - static CCSpriteBatchNode* create(CCTexture2D* tex, unsigned int capacity); + void addChild(CCNode * child); + void addChild(CCNode * child, int zOrder); + void addChild(CCNode * child, int zOrder, int tag); + void reorderChild(CCNode * child, int zOrder); + + void removeChild(CCNode* child, bool cleanup); + void removeAllChildrenWithCleanup(bool cleanup); + void sortAllChildren(); + + static CCSpriteBatchNode* createWithTexture(CCTexture2D *tex); + static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity); static CCSpriteBatchNode* create(const char* fileImage); static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity); }; diff --git a/tools/tolua++/CCSpriteFrame.pkg b/tools/tolua++/CCSpriteFrame.pkg index 10e7047f10..337f1a77b6 100644 --- a/tools/tolua++/CCSpriteFrame.pkg +++ b/tools/tolua++/CCSpriteFrame.pkg @@ -16,11 +16,17 @@ class CCSpriteFrame : public CCObject CCSize getOriginalSizeInPixels(void); void setOriginalSizeInPixels(CCSize sizeInPixels); - CCTexture2D* getTexture(void); + const CCSize & getOriginalSize(); + void setOriginalSize(const CCSize & size); + + CCTexture2D* getTexture(void); void setTexture(CCTexture2D* pobTexture); - static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect); - static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); - static CCSpriteFrame* create(const char* filename, CCRect rect); + const CCPoint & getOffset(); + void setOffset(const CCPoint & offsets); + + static CCSpriteFrame* create(const char* filename, CCRect rect); static CCSpriteFrame* create(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); + static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect); + static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); }; diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg index 714e34af75..1950324a13 100644 --- a/tools/tolua++/CCString.pkg +++ b/tools/tolua++/CCString.pkg @@ -9,10 +9,11 @@ class CCString : public CCObject const char* getCString() const; unsigned int length() const; + int compare(const char* str) const; bool isEqual(const CCObject* pObject); static CCString* create(const char* pStr); - static CCString* create(unsigned char* pData, unsigned long nLen); + static CCString* createWithData(unsigned char* pData, unsigned long nLen); static CCString* createWithContentsOfFile(const char* pszFileName); }; diff --git a/tools/tolua++/CCTMXLayer.pkg b/tools/tolua++/CCTMXLayer.pkg index 758735f357..b76dbec9d8 100644 --- a/tools/tolua++/CCTMXLayer.pkg +++ b/tools/tolua++/CCTMXLayer.pkg @@ -22,10 +22,9 @@ class CCTMXLayer : public CCSpriteBatchNode 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); + unsigned int tileGIDAt(const CCPoint& tileCoordinate); + void setTileGID(unsigned int gid, const CCPoint& tileCoordinate); + void setTileGID(unsigned int gid, const CCPoint& tileCoordinate, ccTMXTileFlags flags); void removeTileAt(CCPoint tileCoordinate); CCPoint positionAt(CCPoint tileCoordinate); CCString *propertyNamed(const char *propertyName); diff --git a/tools/tolua++/CCTMXTiledMap.pkg b/tools/tolua++/CCTMXTiledMap.pkg index b01e9764b3..88cc6e5ffc 100644 --- a/tools/tolua++/CCTMXTiledMap.pkg +++ b/tools/tolua++/CCTMXTiledMap.pkg @@ -32,4 +32,5 @@ class CCTMXTiledMap : public CCNode CCDictionary *propertiesForGID(int GID); static CCTMXTiledMap * create(const char *tmxFile); + static CCTMXTiledMap* createWithXML(const char* tmxString, const char* resourcePath); }; diff --git a/tools/tolua++/CCTMXXMLParser.pkg b/tools/tolua++/CCTMXXMLParser.pkg index b01ac217ab..f41e999bc0 100644 --- a/tools/tolua++/CCTMXXMLParser.pkg +++ b/tools/tolua++/CCTMXXMLParser.pkg @@ -15,6 +15,14 @@ enum { TMXPropertyTile }; +typedef enum ccTMXTileFlags_ { + kCCTMXTileHorizontalFlag = 0x80000000, + kCCTMXTileVerticalFlag = 0x40000000, + kCCTMXTileDiagonalFlag = 0x20000000, + kCCFlipedAll = (kCCTMXTileHorizontalFlag|kCCTMXTileVerticalFlag|kCCTMXTileDiagonalFlag), + kCCFlippedMask = ~(kCCFlipedAll) +} ccTMXTileFlags; + class CCTMXLayerInfo : public CCObject { CCDictionary* getProperties(); @@ -61,6 +69,8 @@ class CCTMXMapInfo : public CCObject void endElement(void *ctx, const char *name); void textHandler(void *ctx, const char *ch, int len); bool parseXMLFile(const char *xmlFilename); + bool parseXMLString(const char *xmlString); static CCTMXMapInfo * formatWithTMXFile(const char *tmxFile); + static CCTMXMapInfo * formatWithXML(const char *tmxString, const char* resourcePath); }; diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg index 5585f964f5..a667d9fa38 100644 --- a/tools/tolua++/CCTexture2D.pkg +++ b/tools/tolua++/CCTexture2D.pkg @@ -38,6 +38,9 @@ typedef enum { class CCTexture2D : public CCObject { + void releaseData(void* data); + void* keepData(void* data, unsigned int length); + CCTexture2DPixelFormat getPixelFormat(); unsigned int getPixelsWide(); @@ -66,7 +69,9 @@ class CCTexture2D : public CCObject void setAliasTexParameters(); void generateMipmap(); - int bitsPerPixelForFormat(); + const char* stringForFormat(); + unsigned int bitsPerPixelForFormat(); + unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format); static void setDefaultAlphaPixelFormat(CCTexture2DPixelFormat format); static CCTexture2DPixelFormat defaultAlphaPixelFormat(); diff --git a/tools/tolua++/CCTextureAtlas.pkg b/tools/tolua++/CCTextureAtlas.pkg index 680bdd0d84..e255e1a52f 100644 --- a/tools/tolua++/CCTextureAtlas.pkg +++ b/tools/tolua++/CCTextureAtlas.pkg @@ -19,8 +19,12 @@ class CCTextureAtlas : public CCObject void drawNumberOfQuads(unsigned int n); void drawNumberOfQuads(unsigned int n, unsigned int start); + void increaseTotalQuadsWith(unsigned int amount); + void moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount, unsigned int newIndex); + void moveQuadsFromIndex(unsigned int index, unsigned int newIndex); + void fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount); void drawQuads(); static CCTextureAtlas* create(const char* file , unsigned int capacity); - static CCTextureAtlas* create(CCTexture2D *texture, unsigned int capacity); + static CCTextureAtlas* createWithTexture(CCTexture2D *texture, unsigned int capacity); }; diff --git a/tools/tolua++/CCTextureCache.pkg b/tools/tolua++/CCTextureCache.pkg index 267912bd12..3feb401a61 100644 --- a/tools/tolua++/CCTextureCache.pkg +++ b/tools/tolua++/CCTextureCache.pkg @@ -5,6 +5,8 @@ class CCTextureCache : public CCObject CCTexture2D* addUIImage(CCImage *image, const char *key); CCTexture2D* textureForKey(const char* key); + CCTexture2D* addPVRImage(const char* filename); + void removeAllTextures(); void removeUnusedTextures(); void removeTexture(CCTexture2D* texture); diff --git a/tools/tolua++/CCTileMapAtlas.pkg b/tools/tolua++/CCTileMapAtlas.pkg index 4125983ee9..6eafdd11bb 100644 --- a/tools/tolua++/CCTileMapAtlas.pkg +++ b/tools/tolua++/CCTileMapAtlas.pkg @@ -10,5 +10,7 @@ class CCTileMapAtlas : public CCAtlasNode void setTile(ccColor3B tile, ccGridSize position); void releaseMap(); + ccColor3B tileAt(const ccGridSize & pos); + static CCTileMapAtlas * create(const char *tile, const char *mapFile, int tileWidth, int tileHeight); }; diff --git a/tools/tolua++/CCTouch.pkg b/tools/tolua++/CCTouch.pkg index 4f6c9577d5..24e60e9c08 100644 --- a/tools/tolua++/CCTouch.pkg +++ b/tools/tolua++/CCTouch.pkg @@ -8,8 +8,13 @@ enum { class CCTouch : public CCObject { - CCPoint locationInView(); - CCPoint previousLocationInView(); + CCPoint getLocation() const; + CCPoint getPreviousLocation() const; + CCPoint getDelta() const; + CCPoint getLocationInView() const; + CCPoint getPreviousLocationInView() const; + + void setTouchInfo(int id, float x, float y); int getID(); }; diff --git a/tools/tolua++/CCUserDefault.pkg b/tools/tolua++/CCUserDefault.pkg index e7183f7532..d095b2a67c 100644 --- a/tools/tolua++/CCUserDefault.pkg +++ b/tools/tolua++/CCUserDefault.pkg @@ -15,6 +15,8 @@ class CCUserDefault void setDoubleForKey(const char* pKey, double value); void setStringForKey(const char* pKey, std::string value); + void flush(); + static CCUserDefault* sharedUserDefault(); static void purgeSharedUserDefault(); const static std::string& getXMLFilePath(); diff --git a/tools/tolua++/Cocos2d.pkg b/tools/tolua++/Cocos2d.pkg index 9479c1d8e9..47aa1deb0f 100644 --- a/tools/tolua++/Cocos2d.pkg +++ b/tools/tolua++/Cocos2d.pkg @@ -3,6 +3,7 @@ $#include "LuaCocos2d.h" $pfile "CCAction.pkg" $pfile "CCActionCamera.pkg" +$pfile "CCActionCatmullRom.pkg" $pfile "CCActionEase.pkg" $pfile "CCActionGrid.pkg" $pfile "CCActionGrid3D.pkg" diff --git a/tools/tolua++/basic.lua b/tools/tolua++/basic.lua index dcfff784f9..8997610623 100644 --- a/tools/tolua++/basic.lua +++ b/tools/tolua++/basic.lua @@ -25,6 +25,10 @@ local CCObjectTypes = { "CCAccelDeccelAmplitude", "CCActionCamera", "CCOrbitCamera", + "CCCardinalSplineTo", + "CCCardinalSplineBy", + "CCCatmullRomTo", + "CCCatmullRomBy", "CCActionEase", "CCEaseBackIn", "CCEaseBackInOut", diff --git a/tools/tolua++/ccTypes.pkg b/tools/tolua++/ccTypes.pkg index d86f19fd6a..69e9088f60 100644 --- a/tools/tolua++/ccTypes.pkg +++ b/tools/tolua++/ccTypes.pkg @@ -11,30 +11,31 @@ typedef float GLfloat; typedef struct _ccColor3B { - GLubyte r; - GLubyte g; + GLubyte r; + GLubyte g; GLubyte b; } ccColor3B; static ccColor3B ccc3(const GLubyte r, const GLubyte g, const GLubyte b); -// static const ccColor3B ccWHITE; +//! White color (255,255,255) +//static const ccColor3B ccWHITE={255,255,255}; //! Yellow color (255,255,0) -// static const ccColor3B ccYELLOW; +//static const ccColor3B ccYELLOW={255,255,0}; //! Blue color (0,0,255) -// static const ccColor3B ccBLUE; +//static const ccColor3B ccBLUE={0,0,255}; //! Green Color (0,255,0) -// static const ccColor3B ccGREEN; +//static const ccColor3B ccGREEN={0,255,0}; //! Red Color (255,0,0,) -// static const ccColor3B ccRED; +//static const ccColor3B ccRED={255,0,0}; //! Magenta Color (255,0,255) -// static const ccColor3B ccMAGENTA; +//static const ccColor3B ccMAGENTA={255,0,255}; //! Black Color (0,0,0) -// static const ccColor3B ccBLACK; +//static const ccColor3B ccBLACK={0,0,0}; //! Orange Color (255,127,0) -// static const ccColor3B ccORANGE; +//static const ccColor3B ccORANGE={255,127,0}; //! Gray Color (166,166,166) -// static const ccColor3B ccGRAY; +//static const ccColor3B ccGRAY={166,166,166}; /** RGBA color composed of 4 bytes @since v0.8 @@ -47,7 +48,7 @@ typedef struct _ccColor4B GLubyte a; } ccColor4B; //! helper macro that creates an ccColor4B type -static ccColor4B ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o); +static ccColor4B ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o); /** RGBA color composed of 4 floats @@ -60,10 +61,15 @@ typedef struct _ccColor4F { GLfloat a; } ccColor4F; + /** Returns a ccColor4F from a ccColor3B. Alpha will be 1. @since v0.99.1 */ -static ccColor4F ccc4FFromccc3B(ccColor3B c); +static ccColor4F ccc4FFromccc3B(ccColor3B c); + +//! helper that creates a ccColor4f type +static ccColor4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a); + /** Returns a ccColor4F from a ccColor4B. @since v0.99.1 */ @@ -83,7 +89,7 @@ typedef struct _ccVertex2F GLfloat y; } ccVertex2F; -static ccVertex2F vertex2(const float x, const float y); +static ccVertex2F vertex2(const float x, const float y); /** A vertex composed of 2 floats: x, y @@ -96,129 +102,128 @@ typedef struct _ccVertex3F GLfloat z; } ccVertex3F; -static ccVertex3F vertex3(const float x, const float y, const float z); +static ccVertex3F vertex3(const float x, const float y, const float z); /** A texcoord composed of 2 floats: u, y @since v0.8 */ typedef struct _ccTex2F { - GLfloat u; - GLfloat v; + GLfloat u; + GLfloat v; } ccTex2F; -static ccTex2F tex2(const float u, const float v); - +static ccTex2F tex2(const float u, const float v); //! Point Sprite component typedef struct _ccPointSprite { - ccVertex2F pos; // 8 bytes - ccColor4B color; // 4 bytes - GLfloat size; // 4 bytes + ccVertex2F pos; // 8 bytes + ccColor4B color; // 4 bytes + GLfloat size; // 4 bytes } ccPointSprite; -//! A 2D Quad. 4 * 2 floats +//! A 2D Quad. 4 * 2 floats typedef struct _ccQuad2 { - ccVertex2F tl; - ccVertex2F tr; - ccVertex2F bl; - ccVertex2F br; + ccVertex2F tl; + ccVertex2F tr; + ccVertex2F bl; + ccVertex2F br; } ccQuad2; -//! A 3D Quad. 4 * 3 floats +//! A 3D Quad. 4 * 3 floats typedef struct _ccQuad3 { - ccVertex3F bl; - ccVertex3F br; - ccVertex3F tl; - ccVertex3F tr; + ccVertex3F bl; + ccVertex3F br; + ccVertex3F tl; + ccVertex3F tr; } ccQuad3; //! A 2D grid size typedef struct _ccGridSize { - int x; - int y; + int x; + int y; } ccGridSize; //! helper function to create a ccGridSize -static ccGridSize ccg(const int x, const int y); +static ccGridSize ccg(const int x, const int y); //! a Point with a vertex point, a tex coord point and a color 4B typedef struct _ccV2F_C4B_T2F { //! vertices (2F) - ccVertex2F vertices; + ccVertex2F vertices; //! colors (4B) - ccColor4B colors; + ccColor4B colors; //! tex coords (2F) - ccTex2F texCoords; + ccTex2F texCoords; } ccV2F_C4B_T2F; //! a Point with a vertex point, a tex coord point and a color 4F typedef struct _ccV2F_C4F_T2F { //! vertices (2F) - ccVertex2F vertices; + ccVertex2F vertices; //! colors (4F) - ccColor4F colors; + ccColor4F colors; //! tex coords (2F) - ccTex2F texCoords; + ccTex2F texCoords; } ccV2F_C4F_T2F; //! a Point with a vertex point, a tex coord point and a color 4B typedef struct _ccV3F_C4B_T2F { //! vertices (3F) - ccVertex3F vertices; // 12 bytes -// char __padding__[4]; + ccVertex3F vertices; // 12 bytes +// char __padding__[4]; //! colors (4B) - ccColor4B colors; // 4 bytes -// char __padding2__[4]; + ccColor4B colors; // 4 bytes +// char __padding2__[4]; // tex coords (2F) - ccTex2F texCoords; // 8 byts + ccTex2F texCoords; // 8 byts } ccV3F_C4B_T2F; //! 4 ccVertex2FTex2FColor4B Quad typedef struct _ccV2F_C4B_T2F_Quad { //! bottom left - ccV2F_C4B_T2F bl; + ccV2F_C4B_T2F bl; //! bottom right - ccV2F_C4B_T2F br; + ccV2F_C4B_T2F br; //! top left - ccV2F_C4B_T2F tl; + ccV2F_C4B_T2F tl; //! top right - ccV2F_C4B_T2F tr; + ccV2F_C4B_T2F tr; } ccV2F_C4B_T2F_Quad; //! 4 ccVertex3FTex2FColor4B typedef struct _ccV3F_C4B_T2F_Quad { //! top left - ccV3F_C4B_T2F tl; + ccV3F_C4B_T2F tl; //! bottom left - ccV3F_C4B_T2F bl; + ccV3F_C4B_T2F bl; //! top right - ccV3F_C4B_T2F tr; + ccV3F_C4B_T2F tr; //! bottom right - ccV3F_C4B_T2F br; + ccV3F_C4B_T2F br; } ccV3F_C4B_T2F_Quad; //! 4 ccVertex2FTex2FColor4F Quad typedef struct _ccV2F_C4F_T2F_Quad { //! bottom left - ccV2F_C4F_T2F bl; + ccV2F_C4F_T2F bl; //! bottom right - ccV2F_C4F_T2F br; + ccV2F_C4F_T2F br; //! top left - ccV2F_C4F_T2F tl; + ccV2F_C4F_T2F tl; //! top right - ccV2F_C4F_T2F tr; + ccV2F_C4F_T2F tr; } ccV2F_C4F_T2F_Quad; //! Blend Function used for textures @@ -230,11 +235,8 @@ typedef struct _ccBlendFunc GLenum dst; } ccBlendFunc; -//! delta time type -//! if you want more resolution redefine it as a double - -//typedef double float; - +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Vertical text alignment type typedef enum { kCCVerticalTextAlignmentTop, @@ -251,3 +253,25 @@ typedef enum kCCTextAlignmentRight, } CCTextAlignment; +// types for animation in particle systems + +// texture coordinates for a quad +typedef struct _ccT2F_Quad +{ + //! bottom left + ccTex2F bl; + //! bottom right + ccTex2F br; + //! top left + ccTex2F tl; + //! top right + ccTex2F tr; +} ccT2F_Quad; + +// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad +typedef struct +{ + ccT2F_Quad texCoords; + float delay; + CCSize size; +} ccAnimationFrameData;