Jump to content
  • Advertisement
Sign in to follow this  
aspragg

[.net] DirectDraw and Form Controls...

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all... First off, I'm somewhat new to this, so bear with me... I've started writing a little DirectDraw game using Managed DirectX. So far, everything is going great. I have a custom Player class, with references to my own custom Sprite class, so as the player updates, he draws himself to the backbuffer at his x,y position. Every game cycle, the backbuffer is flipped and he appears. Fine. It occurs to me that I might want to use the mouse as input for certain things (say, clicking on a door to open it). So, in a general sense, I'd like my custom objects to be "mouse-aware". The first thing I tried was making my Player class inherit from Forms.UserControls (also tried Controls). I could then set the location and size of the control to match my (already defined) player location and size, and I could add a new "MouseEnter" event. This did fire when I moused over my player, so that was great. The problem is that the control wants to paint itself (it appears as a grey box on top of my sprite). Not good. Optimally, I'd like to supress the automatic painting of the control (since I already handle that by drawing to the backbuffer). Making the control invisible works, but then I lose my mouse interaction. I kind of feel like I'm mixing apples and oranges (DirectDraw and Form Controls). Is there a way I can have my cake and eat it, too? My guess is I'm going to have to do something like paint my sprite on to the control, and then paint the control onto the backbuffer. Thanks for any assistance you can provide! Adam

Share this post


Link to post
Share on other sites
Advertisement
More like, you're mixing apples with fruitcakes here, you shouldnt put any controls in your rendering area at all. If you want to use the mouse, take the mouse events from the rendering area (I assume its a Form or a Panel) and pass these events on to your own objects in your scene. The objects can check if the coordinates of your mouse click are within the object region and act upon the event or do nothing.

Share this post


Link to post
Share on other sites
"Apples and fruitcakes"... I love it. :)

Thanks for the response. I think you're right in that I might be overthinking the matter. Objects that I want to be mouse-aware certainly could get access to the mouse coordinates and check if the mouse is nearby, and act accordingly. Good idea.

As I said, I'm somewhat new to this, and just wanted to expiriment a little.

Adam

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!