05-16-2006, 11:41 PM
when you see my screenshot you will see the problem..
I want the picture to move across the screen and keep the background showing as normal.
How can I fix this
05-30-2006, 10:26 PM
You lost me with all that graphicsState stuff in the code in the picture.
From the msdn the save and restore methods of the Graphics class are used to save the state of the graphics object at a particular time. This does not save any drawing you have done. What it saves will be things like co-ordinate system alterations and probably stuff like anti-aliasing setting - not sure.
If you strip out all the stuff that isn't doing anything from your code then you have:
dim gfx as graphics = me.creategraphcis
and in the timer tick:
gfx.drawimage(pict, x, y)
(also, no need to load the image from file continuously!)
Public Class Form1
Private rabbit As Bitmap
Private background As Bitmap
Private x As Integer
Private WithEvents t As Timer
' This call is required by the Windows Form Designer.
rabbit = Bitmap.FromFile("c:\rabbit.png")
background = Bitmap.FromFile("C:\background.png")
Me.BackgroundImage = background
' try and reduce flicker:
t = New Timer
t.Interval = 10
Private Sub t_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles t.Tick
x += 1
If x > Me.Width Then x = -rabbit.Width
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawImageUnscaled(rabbit, x, 0)