Game Development Reference
In-Depth Information
classofthemenu_3dcalled item. Themenuobject willonlyneedoneitem, thiswillbethe
root item and it may have as many items as needed.
class menu_3d
{
. . .
private:
float m_currentAngle;
float m_targetAngle;
float m_animationTime;
bool m_animating;
int m_currentItem;
std::unique_ptr<item> m_root;
ui::interpolator m_interpolator;
std::shared_ptr<DirectX::SpriteBatch> m_spriteBatch;
};
Thegoalofthemenu_3dclassistorotatearootitemaboutitsyaxis,thisinturnwillmake
allofitschilditemsrotateinrelationtoit.Thecurrentanglewillbetheanimatedparameter
used to create the rotation matrix during each frame, the target angle will be set as a result
of user input.
void CycleLeft()
{
if ( m_animating )
return;
for (auto& item : m_root->Children() )
{
item->Selected() = false;
}
if ( m_currentItem - 1 < 0 )
{
m_currentItem = m_root->Children().size() - 1;
m_currentAngle = math::TwoPi;
}
else
{
--m_currentItem;
}
m_root->Children()[m_currentItem]->Selected() = true;
const float step = math::TwoPi / m_root->Children().size();
m_targetAngle = m_currentItem * step;
ui::animation anim(m_currentAngle, m_targetAngle,
m_animationTime,
ui::curves::ease_in_out<ui::curves::quadratic>,
Search WWH ::




Custom Search