Jump to content
  • Advertisement
Sign in to follow this  
inmysights

[.net] Move a bmp image

This topic is 3005 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

Hello, I want to move the .bmp inside the picture box 32 pixels to the left when I press the button on the form not the box, I think this should be an easy change. Thank you! here is the code: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'movepicture 10 pixels to the left Static XInteger As Integer = MonsterPictureBox.Left Static YInteger As Integer = MonsterPictureBox.Top Static WidthInteger As Integer = MonsterPictureBox.Width Static HeightInteger As Integer = MonsterPictureBox.Height 'set new x coordinate XInteger -= 10 If XInteger <= -MonsterPictureBox.Width Then 'if graphic goes off screen reset it XInteger = Me.Width End If 'move image MonsterPictureBox.SetBounds(XInteger, YInteger, WidthInteger, HeightInteger) End Sub End Class

Share this post


Link to post
Share on other sites
Advertisement
First: get rid of the Statics you have no need for them

To move a bitmap in the picturebox:
Put a bitmap in the picturebox and draw the sprites on that bitmap using a Graphics object.

Every time the picturebox needs an update, redraw the entire bitmap (or just those parts that need redrawing) and position your sprites on the bitmap.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!