bool THelloWorld::onTouchBegan(TTouch* touch, TEvent* event)
{
auto sprite = (TSprite*)(this->getChildByTag(1000));
static int nTempIdx = 0;
switch (nTempIdx++)
{
case 0: // 水平翻转
{
sprite->runAction( TFlipX::create(true));
} break;
case 1: // 翻回来
{
sprite->runAction( TFlipX::create(false));
} break;
case 2: // 垂直翻转
{
sprite->runAction( TFlipY::create(true));
} break;
case 3: // 翻回来
{
sprite->runAction( TFlipY::create(false));
} break;
case 4: // 隐藏
{
sprite->runAction( THide::create());
} break;
case 5: // 显示
{
sprite->runAction( TShow::create());
} break;
case 6: // 改变可见状态( 显示->隐藏 )
{
sprite->runAction( TToggleVisibility::create());
} break;
case 7: // 改变可见状态( 显示->隐藏 )
{
sprite->runAction( TToggleVisibility::create());
} break;
case 8: // 移动到位置
case 9:
case 10:
case 11:
{
sprite->runAction( TPlace::create(touch->getLocation()));
//等同于这段 sprite->setPosition(touch->getLocation());
} break;
default:
{
nTempIdx = 0;
}
}
CCLOG("THelloWorld::onTouchBegan id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y);
return true;
}
从Delphi开始学Cocos2dx-3.0[7]:瞬发动作
最新推荐文章于 2019-06-02 22:22:13 发布