bool THelloWorld::onTouchBegan(TTouch* touch, TEvent* event)
{
auto sprite = (TSprite*)(this->getChildByTag(1000));
static int nTempIdx = 0;
switch (nTempIdx++)
{
case 0: // 右转到90° 向右
{
sprite->runAction( TRotateTo::create(1, 90.0f));
} break;
case 1: // 左转到-90° 向左
{
sprite->runAction( TRotateTo::create(1, -90.0f));
} break;
case 2: // 回正 向上
{
sprite->runAction( TRotateTo::create(1, 0.0f) );
} break;
case 3: // 右转90° 向右
{
sprite->runAction( TRotateBy::create(1, 90.0f) );
} break;
case 4: // 右转180° 向左
{
sprite->runAction( TRotateBy::create(1, 180.0f) );
} break;
case 5: // 左转270° 绕回来
{
sprite->runAction( TRotateBy::create(1, -270.0f) );
} break;
case 6: // 右转1圈
{
sprite->runAction( TRotateBy::create(1, 360.0f) );
} break;
case 7: // 右转2圈
{
sprite->runAction( TRotateBy::create(1, 720.0f) );
} break;
default: // 回正
{
sprite->runAction( TRotateTo::create(1, 0.0f) );
nTempIdx = 0;
}
}
CCLOG("THelloWorld::onTouchBegan id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
return true;
}