Click here to Skip to main content
15,887,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i move the mouse, the image associated with it moves as it should, so no problem. But the RotatingFlash(); which is muzzleFlash.Paint(sender, e); is not rotating at all, until i stop moving the mouse. If i'm not moving the mouse, the flash is rotating.
If this is a common bug, please advise me what i'm doing wrong.
I think a solution could be working on threads...but, maybe im overthinking it.
So i want your input first.

What I have tried:

C#
private void canvas_Paint(object sender, PaintEventArgs e)
{
    background.Paint(sender, e);
    enemy01.Paint(sender, e);
    muzzleFlash.Paint(sender, e);
    e.Graphics.DrawString("SCORE " + score, new Font("Arial", 10), new SolidBrush(Color.Black), new PointF(10f, 5f));
    if (WinScreenOn)
    {
        e.Graphics.Clear(Color.DarkRed);
        e.Graphics.DrawString("You Win", new Font("Arial", 50), new SolidBrush(Color.Black), new PointF(10f, 5f));
        e.Graphics.DrawString("Next Level ", new Font("Arial", 10), new SolidBrush(Color.Black), new PointF(100f, 100f));
    }
    mousetarget.Paint(sender, e);
}


void timer1_Tick(object sender, EventArgs e)
{
    RotatingFlash();
    Refresh();
}


private void canvas_MouseMove(object sender, MouseEventArgs e)
{
    mousetarget.X = e.X; mousetarget.Y = e.Y;
    mousetarget.Move(sender, e); Refresh();
}
Posted
Updated 17-Mar-20 12:24pm
v2
Comments
[no name] 17-Mar-20 22:11pm    
Mouse move runs at a higher priority.

Disable the timer when mouse moving, and refresh in mouse move instead.
Daniele Rota Nodari 20-Apr-20 5:50am    
Have you tried Invalidate instead of Refresh?
Does RotatingFlash regenerate the image? Does it test the current timestamp (thorugh date/time, ticks, StopWatch or whatever...) or simply increments a frame counter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900