// // RotateBy // CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle) { CCRotateBy *pRotateBy = new CCRotateBy(); pRotateBy->initWithDuration(duration, fDeltaAngle); pRotateBy->autorelease(); return pRotateBy; }
CCRotateBy* CCRotateBy::create(float fDuration, float fDeltaAngleX, float fDeltaAngleY) { CCRotateBy *pRotateBy = new CCRotateBy(); pRotateBy->initWithDuration(fDuration, fDeltaAngleX, fDeltaAngleY); pRotateBy->autorelease(); return pRotateBy; }
void HelloWorld::ccTouchEnded(cocos2d::CCTouch *pTouches, cocos2d::CCEvent *pEvent){ if(m_score<0){ return; } CCPoint point = pTouches->getLocation(); char pos[100]; int y_ = (int)((point.y-diamondRect.origin.y)/dh); int y = 7-y_; int x = (int)((point.x-diamondRect.origin.x)/dw); int result[64] = {0}; if(y>=8||x>=8){ return; } int count = handlerTouchInSquare(y*8+x, result); if(count < 3) return; for(int i = 0; i < count; i++){ CCSprite *sprite = diamonds[result[i]]; CCRotateBy *rotateAct = new CCRotateBy(); rotateAct->initWithDuration(0.2f, 90.0f); sprite->runAction(rotateAct); char str[20]; CCImage *image = new CCImage(); int color = getDiamond(str); base[result[i]] = color; image->initWithImageFile(str, CCImage::kFmtJpg); CCTexture2D* texture = new CCTexture2D(); texture->initWithImage(image); sprite->setTexture(texture); } //delete rotateAct; m_score += 5*count; char str[20]; sprintf(str, "Score: %d", m_score); pLabelScore->setString(str); //fflush(file); }
CCObject* CCRotateBy::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; CCRotateBy* pCopy = NULL; if(pZone && pZone->m_pCopyObject) { //in case of being called at sub class pCopy = (CCRotateBy*)(pZone->m_pCopyObject); } else { pCopy = new CCRotateBy(); pZone = pNewZone = new CCZone(pCopy); } CCActionInterval::copyWithZone(pZone); pCopy->initWithDuration(m_fDuration, m_fAngle); CC_SAFE_DELETE(pNewZone); return pCopy; }