Results 1 to 3 of 3

Thread: Moving paint object with keyboard input

  1. #1
    Qobacha is offline C# Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Moving paint object with keyboard input

    Hi Everyone

    I have drawn a square on the screen/form using GDI. Now I want to move this object around using keyboard inputs. I just want it to move along the x-axis using left and right arrow keys. I can assign the keys but the problem is making that object move. Please help me on this

  2. #2
    jmcilhinney is offline C# Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2011
    Posts
    606
    Rep Power
    56
    I would suggest that you check this out regarding keyboard input:

    Keyboard Events in Windows Forms

    Perhaps you're already doing things the right way but maybe not. Even if you are, I'll wager that you'll find something in there that you didn't know and may be able to use some other time.

    As for moving the drawing, you should check this out:

    Manipulating GDI+ Drawings

    It shows how to move GDI+ drawings using drag & drop but moving is moving and how you calculate how far to move is irrelevant to that process.

  3. #3
    Qobacha is offline C# Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0
    Thanks the problem is solved. Used key-down event and increased velocity of the object by +/- depending on the direction.

Bookmarks

Posting Permissions

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