Sign in to follow this  

[.net] Move a bmp image

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

This topic is 2844 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this