CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    9

    Directx9 menu screen,(probably) simple problem.

    Hey, i was trying to create a menu using sprites, when its selected.. Changes the sprite.
    Which works well.
    Its just that, i dont know how to implement i into the function, because obviously it keeps repeating itsself at 1 each time the function loops.

    This way of doing it may seem terribly simple, but it was all written by myself.
    If you could suggest otherways of accheiving the same effect. i'd love to hear it ^_^
    thanks.

    Code:
    void drawMenu(void){
    d3dspt->Begin(D3DXSPRITE_ALPHABLEND);
    
    int i = 1;
    
     D3DXVECTOR3 center(0.0f,0.0f,0.0f), position(30.0f,450.0f,0.0f);
     D3DXVECTOR3 center1(0.0f,0.0f,0.0f), position1(30.0f,400.0f,0.0f);
    
    d3dspt->Draw(newgame1, NULL, &center1, &position1, D3DCOLOR_ARGB(255, 255, 255, 255));
    d3dspt->Draw(credits1, NULL, &center, &position, D3DCOLOR_ARGB(255, 255, 255, 255));
    
    	if(KEY_DOWN(VK_UP)){
           i--;
    	}
    		if(KEY_DOWN(VK_DOWN)){
    			i++;
    		}
    		
    if (i <0){
    i = 1;
    }
    
    if (i >1){
    i = 0;
    }
    
    switch (i){
    case 0: 
        d3dspt->Draw(newgame2, NULL, &center1, &position1, D3DCOLOR_ARGB(255, 255, 255, 255));
    break;
    
    case 1:
        d3dspt->Draw(credits2, NULL, &center, &position, D3DCOLOR_ARGB(255, 255, 255, 255));
    break;
    }
    
     d3dspt->End();
    return;
    }

  2. #2
    Join Date
    Jun 2009
    Posts
    118

    Re: Directx9 menu screen,(probably) simple problem.

    im assuming you mean you want i to return the same value each time its called, not reset to 1.

    in that case, just declare i like so instead of just int i = 1;

    Code:
    static int i = 1;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured