public void RenderGraphics(Point currentDestination)
{
if (!owner.Created)
return;
try
{
Rectangle rect = new Rectangle(owner.PointToScreen(new Point(0,0)), new Size(surfaceSecondary.SurfaceDescription.Width, surfaceSecondary.SurfaceDescription.Height));
sprMegaMan.PointToScreen(index,ref currentDestination);
surfaceSecondary.Draw(surfFondo, DrawFlags.DoNotWait);
surfaceSecondary.Draw(new Rectangle(currentDestination, new Size(sprMegaMan[index].Width, sprMegaMan[index].Height)), surfMegaman
,sprMegaMan[index] ,DrawFlags.DoNotWait | DrawFlags.KeySource);
//surfaceSecondary.DrawFast(0 ,0 ,surfFondo , DrawFastFlags.DoNotWait);
//surfaceSecondary.DrawFast(currentDestination.X, currentDestination.Y, surfMegaman
// ,sprMegaMan[index] ,DrawFastFlags.DoNotWait | DrawFastFlags.SourceColorKey);
/*esperar retrazado vertical*/
localDevice.WaitForVerticalBlank(WaitVbFlags.BlockEnd);
surfacePrimary.Draw(rect, surfaceSecondary , DrawFlags.DoNotWait);
ProccessNextFrame(currentDestination);
}
catch(SurfaceLostException)
{
AllSurfacesDisposer();
CreateSurfaces();
}
}
private void ProccessNextFrame(Point currentDestination)
{
if(fstload)
{
p = currentDestination;
fstload = false;
}
else
{
if((System.Environment.TickCount-tiempo)>= 100 )
{
if((index < sprMegaMan.Count()-1) )
{
index++;
tiempo = System.Environment.TickCount;
}
else
{
index = 1;
}
if(p == currentDestination)
index = 0;
}
p=currentDestination;
}
}