跑调的毕加索
发布于

Aiinone添加控件动画效果

示例

此例程是通过一个菜单按钮控制其它三个按钮移动隐藏和复位的动画效果

动画方向
<----反向
----> 正向

//(反向坐标),(正向坐标值)
string strVal[] = {"33,676", "164,676", "546,676"};
CHAR balance[] = {0, 0, 0, 0};

pCtrlAnimators[0] = CAM->CreateCtrlAnimator(mptheme_btn, ECTRL_ANIMATOR_MOVE, EEASING_BOUNCE_OUT); //主题mptheme_btn
pCtrlAnimators[1] = CAM->CreateCtrlAnimator(mpphone_btn, ECTRL_ANIMATOR_MOVE, EEASING_BOUNCE_OUT); //拨号mpphone_btn
pCtrlAnimators[2] = CAM->CreateCtrlAnimator(mpsteup_btn, ECTRL_ANIMATOR_MOVE, EEASING_BOUNCE_OUT); //设置mpsteup_btn

for (int i = 0; i < 3; ++i)
{
    pCtrlAnimators[i]->SetCtrlAnimatorListener(CtrlAnimPageCallback);
    pCtrlAnimators[i]->SetCtrlAnimator_PrivParam(CTRLANIM_XRANG, strVal[i]); // 设置控件动画的私有参数
}

控制动画按钮函数
VOID MainCtrl::menu_btn_OnClick(InoControl *pControl, WPARAM wParam, LPARAM lParam)
{
CLog::LogU("[%s:%s] Name:%s \n", FILE, FUNCTION, pControl->GetName().c_str());

for (int i = 0; i < 3; ++i)
{
    if (pControl->IsSelected())
    {
        printf("1state value:%d\n", pControl->IsSelected());
        pCtrlAnimators[i]->SetCtrlAnimator_Reversed(FALSE);              // 设置方向属性
        pCtrlAnimators[i]->SetCtrlAnimator_Easing(EEASING_QUADRATIC_IN); //控件动画的缓动类型

        MainCtrl::mpSelf->mptheme_lbl->SetVisible(false);
        MainCtrl::mpSelf->mpphone_lbl->SetVisible(false);
        MainCtrl::mpSelf->mpsteup_lbl->SetVisible(false);
        // CLog::LogU("[%s:%s] 禁止反向 \n", __FILE__, __FUNCTION__);
    }
    else
    {
        printf("2state value:%d\n", pControl->IsSelected());
        pCtrlAnimators[i]->SetCtrlAnimator_Reversed(TRUE);
        pCtrlAnimators[i]->SetCtrlAnimator_Easing(EEASING_QUINTIC_INOUT);

        MainCtrl::mpSelf->mptheme_lbl->SetVisible(true);
        MainCtrl::mpSelf->mpphone_lbl->SetVisible(true);
        MainCtrl::mpSelf->mpsteup_lbl->SetVisible(true);
        // CLog::LogU("[%s:%s] 允许反向 \n", __FILE__, __FUNCTION__);
    }
    // 启动控件动画
    pCtrlAnimators[i]->StartCtrlAnimator();
}

}

浏览 (49) 点赞 收藏 分享
评论