本文整理汇总了C++中Ref::AddAnimation方法的典型用法代码示例。如果您正苦于以下问题:C++ Ref::AddAnimation方法的具体用法?C++ Ref::AddAnimation怎么用?C++ Ref::AddAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref::AddAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SelectMap
void SelectMap(int32 newIndex)
{
Set<MapIndex*> visibleMaps;
auto& srcCollection = m_SourceCollection();
auto it = srcCollection.find(newIndex);
if(it != srcCollection.end())
{
const float initialSpacing = 0.65f * m_style->frameMain->GetSize().y;
const float spacing = 0.8f * m_style->frameSub->GetSize().y;
const Anchor anchor = Anchor(0.0f, 0.5f, 1.0f, 0.5f);
static const int32 numItems = 10;
int32 istart;
for(istart = 0; istart > -numItems;)
{
if(it == srcCollection.begin())
break;
it--;
istart--;
}
for(int32 i = istart; i <= numItems; i++)
{
if(it != srcCollection.end())
{
visibleMaps.Add(it->second);
// Add a new map slot
bool newItem = m_guiElements.find(it->second) == m_guiElements.end();
Ref<SongSelectItem> item = m_GetMapGUIElement(it->second);
float offset = 0;
if(i != 0)
{
offset = initialSpacing * Math::Sign(i) +
spacing * (i - Math::Sign(i));
}
Canvas::Slot* slot = Add(item.As<GUIElementBase>());
int32 z = -abs(i);
slot->SetZOrder(z);
slot->anchor = anchor;
slot->autoSizeX = true;
slot->autoSizeY = true;
slot->alignment = Vector2(0, 0.5f);
if(newItem)
{
// Hard set target position
slot->offset.pos = Vector2(0, offset);
slot->offset.size.x = z * 50.0f;
}
else
{
// Animate towards target position
item->AddAnimation(Ref<IGUIAnimation>(
new GUIAnimation<Vector2>(&slot->offset.pos, Vector2(0, offset), 0.1f)), true);
item->AddAnimation(Ref<IGUIAnimation>(
new GUIAnimation<float>(&slot->offset.size.x, z * 50.0f, 0.1f)), true);
}
item->fade = 1.0f - ((float)abs(i) / (float)numItems);
item->innerOffset = item->fade * 100.0f;
if(i == 0)
{
m_OnMapSelected(it->second);
}
it++;
}
}
}
m_currentlySelectedId = newIndex;
// Cleanup invisible elements
for(auto it = m_guiElements.begin(); it != m_guiElements.end();)
{
if(!visibleMaps.Contains(it->first))
{
Remove(it->second.As<GUIElementBase>());
it = m_guiElements.erase(it);
continue;
}
it++;
}
}