Hello,I come from China!
EmilMatthewDesinging a good game all by myself is always a dream in my mind. When I touch VB ,I become to know that the time for my dream to become true is nearer. On Chinese Website ,there are many forums about VB,but rarely about using VB and DIRECT X to design a game . Now,I am a beginner of Direct X with VB designing. I feel very excited to be here. Ok ,I want to ask my first question now:(maybe it is not about directx but it's really about game design) How to use "up","Down" ,"Left" and "Right" button to control a object (for example,a "command" button) I wrote my programme in the "form_keydown"event the main part is like this>> SELECT CASE KEYCODE CASE VbKeydown command1.top=command1.top+5 case vbkeyup command1.top=command1.top-5 case vbkeyleft command1.left=command1.left-5 case vbkeyright command1.left=command1.left-5 end select >>>>> the result is that I failed to use these button to control the objects to move . However,when I use the up ,down,left and right on the number keys (I hope you know what I mean ,the number keys means the right part on the keyboard)I use their "Keycode " in the "select case".I became successfully to control the object. So ,who can tell me how to use "up","Down" ,"Left" and "Right" button to control a object ? Thank you [|)]
Eric ColemanIt's because VB is intercepting those key presses and it is moving the "control focus" to different objects on the form. If you want to see your command button move, then follow these steps: 1. Set Form1.KeyPreview = True 2. Create a PictureBox on the form along with your Command button. 3. Start the program. 4. Click on the picturebox to give it the focus. What happens in this example is that the picture box won't switch the focus to another control when using the arrow keys. Also, here is a slight correction for the code you're using [code]With Command1 Select Case KeyCode Case vbKeyDown .Top = .Top + Screen.TwipsPerPixelY Case vbKeyUp .Top = .Top - Screen.TwipsPerPixelY Case vbKeyLeft .Left = .Left - Screen.TwipsPerPixelX Case vbKeyRight .Left = .Left + Screen.TwipsPerPixelX End Select End With[/code]
DanCheck out the tutorial on Directx4vb: http://216.5.163.53/DirectX4VB/Tutorials/DirectX8/IN_Lesson01.asp A great step by step guide to getting keyboard presses using directx.
EmilMatthewYeah,I have gotta it .Thank you two so much.