• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            1.先說下Ui的input部分
            在GUI部分輸入輸出通常是需要采用回調函數來處理的
            比如:

            void G_CALL MousePosCallBack(int x,int y)
            {
                UIWidgetManager::Instance().OnMouseMove(x, y);
            }
            所以我就先給引擎的Input部分加入了幾個輸入輸出回調函數以方便使用

            2.然后上幾個UI小圖

            當鼠標劃過按鈕時:
            .

            相關的代碼:
            void RenderGUI();

            RefPtr
            <Device> device;
            RefPtr
            <Input>  input;
            Panel 
            *panel = NULL; 
            ProgressBar 
            *progressbar = NULL;
            Button 
            *button1 = NULL;
            Button 
            *button2 = NULL;
            Button 
            *button3 = NULL;
            Button 
            *button4 = NULL; 
             
            void G_CALL MouseStateCallBack(int mouse,int action)
            {
                
            int x,y;
                input
            ->GetMousePosition(x,y); 
                
            if(action == KEY_PRESS && mouse == MOUSE_BUTTON_LEFT)
                
            {
                    UIWidgetManager::Instance().OnLeftButtonDown(x,y);          
                }

                
            else if(action == KEY_PRESS && mouse == MOUSE_BUTTON_RIGHT)
                
            {
                    UIWidgetManager::Instance().OnRightButtonDown(x,y);  
                }

                
            else if(action == KEY_RELEASE && mouse == MOUSE_BUTTON_LEFT)
                
            {
                    UIWidgetManager::Instance().OnLeftButtonUp(x,y); 
                }

                
            else if(action == KEY_RELEASE && mouse == MOUSE_BUTTON_RIGHT)
                
            {
                    UIWidgetManager::Instance().OnRightButtonUp(x,y);    
                }

            }


            void G_CALL MousePosCallBack(int x,int y)
            {
                UIWidgetManager::Instance().OnMouseMove(x, y);
            }

             
            bool G_CALL IsShiftPressed()
            {
                
            return false;
            }


            bool G_CALL IsAltPressed()
            {
                
            return false;
            }


            bool G_CALL IsCtrlPressed()
            {
                
            return false
            }
             

            void SettingPanel();

            int main()
            {
                device 
            = InitDevice("UI測試1");
                input 
            = device->GetInput();
                input
            ->AttachMouseState(&MouseStateCallBack);
                input
            ->AttachMousePos(&MousePosCallBack);
                core::TextDesc::SetDefaultFont(engine_string(
            "simhei.ttf"));
                
                UIWidgetManager::Instance().Initialize(
            &IsShiftPressed,&IsAltPressed,&IsCtrlPressed);
                UIWidgetManager::Instance().AppResized(
            640,480);
                SettingPanel();
                BEGIN_LOOP(device)
                   glClearColor(
            0.1,0.1,0.2,1.0f);
                   glClear( GL_COLOR_BUFFER_BIT 
            | GL_DEPTH_BUFFER_BIT );   
                   RenderGUI();    
                END_LOOP(device)
                
                
            return 0;
            }


            void SettingPanel()
            {
                panel 
            = new Panel(Rectf(10,75,180,180),NULL);
                
                button1 
            = new Button(panel,L"寮€濮嬫父鎴?);
                button2 = new Button(panel,L"淇濆瓨娓告垙");
                button3 
            = new Button(panel,L"杞藉叆娓告垙");
                button4 
            = new Button(panel,L"閫€鍑烘父鎴?);
                progressbar = new ProgressBar(panel,Rectf(150,90,40,220),UI_DIRECTION_VERTICAL);
                progressbar
            ->SetPercentage(65.0f);
                  
                panel
            ->AddChildWidget(button1);
                panel
            ->AddChildWidget(button2);
                panel
            ->AddChildWidget(button3);
                panel
            ->AddChildWidget(button4);
             
                panel
            ->AddChildWidget(progressbar);
                
                button1
            ->SetSize(Vector2f(120,40));
                button2
            ->SetSize(Vector2f(120,40));
                button3
            ->SetSize(Vector2f(120,40));
                button4
            ->SetSize(Vector2f(120,40));
                button1
            ->SetPosition(Vector2f(20,90));
                button2
            ->SetPosition(Vector2f(20,150));
                button3
            ->SetPosition(Vector2f(20,210));
                button4
            ->SetPosition(Vector2f(20,270));  
                
                UIWidgetManager::Instance().AddWidget(panel);      
            }


            void RenderGUI()
            {
                
            float precent = progressbar->GetPercentage();
                precent 
            += 1.0f;
                
            if(precent >= 100.0f)
                    precent 
            = 0.0f;
                progressbar
            ->SetPercentage(precent);    
                UIWidgetManager::Instance().Update();      
            }




            對于UI部分基本上所有的常見器件都需要一個一個設計
            一次性做完太難了
            而且設計的不好就需要重新設計
            所以我決定先設計以下幾個器件 Widget,Panel,StaticText,SliderBar
            其余的等把基本框架做成熟了再做吧
            posted on 2010-06-19 17:57 ccsdu2009 閱讀(1502) 評論(1)  編輯 收藏 引用 所屬分類: Game引擎
            Comments
             
            久久丝袜精品中文字幕| 久久精品综合网| 青青草国产精品久久| 久久国产美女免费观看精品 | 久久se精品一区二区| 国产成人精品综合久久久| 要久久爱在线免费观看| 国产精品久久毛片完整版| 精品久久人人爽天天玩人人妻| 精品久久久无码人妻中文字幕豆芽| 久久精品国产亚洲精品| 精品国产VA久久久久久久冰| 思思久久99热免费精品6| 久久夜色精品国产噜噜噜亚洲AV| 精品久久久无码中文字幕天天| 久久天堂AV综合合色蜜桃网 | 久久精品成人免费网站| 久久精品国产清自在天天线 | 国内精品久久久久影院免费| 热99RE久久精品这里都是精品免费 | 午夜视频久久久久一区 | 69SEX久久精品国产麻豆| 日韩美女18网站久久精品| 久久亚洲精品视频| 亚洲国产欧美国产综合久久| 狠狠色丁香久久婷婷综| 国内精品久久久久久不卡影院| 亚洲人成伊人成综合网久久久| 精品久久久久香蕉网| 久久精品国产亚洲av日韩| 无夜精品久久久久久| 97r久久精品国产99国产精| 久久午夜无码鲁丝片| 久久午夜福利无码1000合集| 手机看片久久高清国产日韩| 国内精品久久国产| 国产精品美女久久福利网站| 伊人久久大香线蕉综合热线| 香蕉久久夜色精品国产尤物| 免费精品国产日韩热久久| 亚洲国产小视频精品久久久三级 |