![]() |
|
A lil C# help - Printable Version +- Discovery Gaming Community (https://discoverygc.com/forums) +-- Forum: The Community (https://discoverygc.com/forums/forumdisplay.php?fid=4) +--- Forum: Real Life Discussion (https://discoverygc.com/forums/forumdisplay.php?fid=16) +--- Thread: A lil C# help (/showthread.php?tid=98000) |
RE: A lil C# help - Huhuh - 05-02-2013 (05-02-2013, 01:56 PM)utrack Wrote: -snip- Thanks, that really helped. After a quick play, I've got my player sprite moving across the screen by itself. I'll simply have to write the appropriate methods for controlling it. RE: A lil C# help - Huhuh - 05-06-2013 Hey guys, another question: How to do read and write to a text file from resource? I have already created and populated the text file, and I have added it to my program. I'm just having trouble figuring out how to access it. edit: Code: /// <summary>This is my code as it is, I'm being thrown this error in the output window: A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll My thinking is the file not being read in correctly. RE: A lil C# help - Huhuh - 05-15-2013 Hey guys, new issue: Where do I find the keydown/press/up for the arrow keys? Do I need some sort of listener or can I just have an event on my form that triggers when an arrow key is pressed? RE: A lil C# help - Stuffz - 05-15-2013 Google helps a lot. http://msdn.microsoft.com/en-us/library/ms171538.aspx RE: A lil C# help - Huhuh - 05-16-2013 (05-15-2013, 11:39 AM)Stuffz Wrote: Google helps a lot. Does not show how to use arrow keys. RE: A lil C# help - Stuffz - 05-16-2013 Another 5 seconds google.. http://www.dreamincode.net/forums/topic/25523-using-ekeychar-for-enter-and-arrow-keys/ If e.KeyCode = Keys.Up Then MessageBox.Show("It worked") You'll have to use KeyDown for arrow keys tho RE: A lil C# help - Huhuh - 05-16-2013 (05-16-2013, 01:38 PM)Stuffz Wrote: Another 5 seconds google.. That is VB, and it appears that the syntax is different. RE: A lil C# help - Ichiru - 05-16-2013 Try this Crackpunch In Form1() or whatever your constructor is called this.KeyDown += HandleKeyDown; void HandleKeyDown (object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { //do stuff here } } Also for your high scores use a file instead of a resource, you can't write to a resource. Also make sure that scoresList has been set somewhere. So in Form1() Or Form1_Load etc. make sure there is a line that says scoresList = new List<string>(); Add me on skype at crazy.ichiru if you want any more help. I've got enough experience
RE: A lil C# help - Huhuh - 05-16-2013 I fixed the high scores file a while ago. The key presses still aren't working. I'm thinking it might have something to do with my listbox on the form, as I can see it selecting things while I'm actually trying to steer my space ship. I'll skype ya later, off to bed now. RE: A lil C# help - Stuffz - 05-16-2013 Alright. So I opened VS myself and coded a bit. This works for me: Code: void Form1_KeyDown(object sender, KeyEventArgs e)And this in the constructor of the form: Code: this.KeyPreview = true; |