• Advertisement
Sign in to follow this  

Graphics: Dragging a 2D 'object' across a static background.

This topic is 3322 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, I have a simple desktop based game with 2D graphics. I have some square playing pieces, and an image as background. One actions of the game is to pick up a piece, drag it somewhere, and put it down again. Now I would like to show the piece while it is being dragged, however I would like to avoid redrawing the entire "scene" for every little bit the mouse moves. I could imagine it being similar to making for instance, a drawing program - where you draw objects while they are moved. Does anyone have any experience with doing this? I am using simple .NET event-based developing. Cheers, Kristian

Share this post


Link to post
Share on other sites
Advertisement
Well an old fashioned technique of animation was to save a piece of the background (underneath where the object is to be drawn), then draw the image, then replace the background before moving the object. As long as you are double buffering and deal with other dynamic objects carefully this will work fine. But.. you should be able to redraw the entire background with out any problems (this is how most games work, the entire scene is redrawn every frame), if not then you are using the wrong techniques, althrough I can't remember offhand if .NET has any bit-blit type operations.

Share this post


Link to post
Share on other sites
Thanks for the answer.

You are probably right, I was just thinking along the line of InvalidateRect(rect).

I will try with an implementation with the OnMouseMove-event.

Cheers.

Share this post


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

  • Advertisement