/** * タッチイベント 移動中(?) * */ void GameScene::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) { CCPoint point = this->convertTouchToNodeSpace(pTouch); // 座標を取得 // Tag番号から対象のオブジェクト取得 CCMotionStreak* pStreak = (CCMotionStreak*)this->getChildByTag(MOTION_STREAK_TAG); // 移動先にオブジェクトを表示させる pStreak->setPosition(point); }
void Recipe39Scene::ccTouchMoved(CCTouch* pTouch, CCEvent* pEvent) { CCPoint point = this->convertTouchToNodeSpace(pTouch); CCMotionStreak* streak = (CCMotionStreak*)this->getChildByTag(MOTION_STREAK_TAG); streak->setPosition(point); }
void CCMotionStreakCreator::setAttribute(CCNode* pNode, const char* strName, const char* strValue, bool bCache) { if(bCache) mAttrMap[strName] = strValue; else { CCMotionStreak* pMotionStreak = (CCMotionStreak*)pNode; if(strcmp(strName, "file") == 0 ||strcmp(strName, "fade") == 0 ||strcmp(strName, "segment") == 0 ||strcmp(strName, "stroke") == 0 ||strcmp(strName, "color") == 0) return; else if(strcmp(strName, "blend") == 0) { CCPoint p = ccXmlAttrParse::toPoint(strValue); ccBlendFunc blend; blend.src = p.x; blend.dst = p.y; pMotionStreak->setBlendFunc(blend); } else CCNodeRGBACreator::setAttribute(pNode, strName, strValue,bCache); } }
void CCMotionStreakCreator::endNode(CCNode* pNode) { CCMotionStreak* pMotionStreak = (CCMotionStreak*)pNode; pMotionStreak->initWithFade(ccXmlAttrParse::toFloat(mAttrMap["fade"].c_str()), ccXmlAttrParse::toFloat(mAttrMap["segment"].c_str()), ccXmlAttrParse::toFloat(mAttrMap["stroke"].c_str()), ccXmlAttrParse::toColor3B(mAttrMap["color"].c_str()), mAttrMap["file"].c_str()); CCNodeCreator::setAttribute(pNode); }
CCMotionStreak * CCMotionStreak::streakWithFade(float fade, float seg, StreamSource* source, float width, float length, const ccColor4B& color) { CCMotionStreak *pRet = new CCMotionStreak(); if(pRet && pRet->initWithFade(fade, seg, source, width, length, color)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet) return NULL; }
bool Recipe39Scene::ccTouchBegan(CCTouch* pTouch, CCEvent* pEvent) { this->removeChildByTag(MOTION_STREAK_TAG, true); CCMotionStreak* streak = CCMotionStreak::create(0.5f, 1, 10, ccc3(255, 255, 0), "line.png"); this->addChild(streak, 5, MOTION_STREAK_TAG); CCPoint point = this->convertTouchToNodeSpace(pTouch); streak->setPosition(point); return true; }
CCMotionStreak* CCMotionStreakCreator::createNode() { CCMotionStreak* pProgressTimer = new CCMotionStreak(); if(pProgressTimer) { pProgressTimer->autorelease(); return pProgressTimer; } CC_SAFE_DELETE(pProgressTimer); return NULL; }
CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, const ccColor3B& color, CCTexture2D* texture) { CCMotionStreak *pRet = new CCMotionStreak(); if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture)) { CC_SAFE_AUTORELEASE(pRet); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, const char* path) { CCMotionStreak *pRet = new CCMotionStreak(); if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path)) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; }
/** * タッチイベント 開始 * CCMotionStreak: * ・指定した画像を、ポイントの集合で示すパス上に連ねて表示する * ・各ポイントのパスに沿って画像を回転して配置する(ポイントが充分に密であれば、なめらかな曲線に見える) * ・時間経過とともに画像がフェードアウトする * * */ bool GameScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { this->removeChildByTag(MOTION_STREAK_TAG, true); // …? CCPoint point = this->convertTouchToNodeSpace(pTouch); // 座標を取得 //CCMotionStreak::create(フェードアウトSec, ???, ???, 色, 画像) CCMotionStreak* pStreak = CCMotionStreak::create(5.0f, 1.0f, 10.0f, ccc3(255, 255, 0), "line.png"); pStreak->setPosition(point); this->addChild(pStreak, 5, MOTION_STREAK_TAG); // Tgaに固定値(MOTION_STREAK_TAG=10)を指定 return true; }