Ok, I am working on a simple 2d game. For my menu, I put a backdrop of stars to scroll down. Here is the code for that:
fBackDropScrollY += 0.25f * fBackDropSpeedY;
if(fBackDropScrollY >= 768 )
fBackDropScrollY = 0;
dbSprite ( 4, 0, fBackDropScrollY, 4 );
dbSprite ( 5, 0, fBackDropScrollY-768, 4 );
Later on for my menu this is what I have:
dbSetTextSize ( 30 );
dbText ( 220, 200, "Player vs CPU" );
dbText ( 200, 270, "Player vs Player" );
dbText ( 300, 340, "Exit" );
dbSetTextSize (10);
dbText ( 555, 460, "Vers 1.0.1" );
MX = dbMouseX();
MY = dbMouseY();
dbShowMouse();
dbHideSprite ( 9 );
if(MX >= 290 && MX <= 370 && MY >= 330 && MY <= 370)
{
dbHideMouse();
dbSprite ( 9, MX, MY, 9 );
dbShowSprite ( 9 );
if(dbMouseClick())
{
break;
}
}
My objective here is to test out the Exit Button by pressing it and closing the game. But, I want the user to know the mouse is over the button so I made a image for the mouse. As you can see in the code, when the mouse is over the exit, it hides the mouse, shows the the image and moves it according to the position of the mouse. When that image goes off the exit button, the sprite hides, the mouse is shown again and perfect. Except there is one problem. The backdrop freezes until the mouse goes over the exit button. Once the mouse is over the exit button, the backdrop starts scrolling down. Now, once I put the arrow over the exit button, the backdrop keeps on scrolling on scrolling, even if you take the mouse of the exit button and put it back on it. Is there a way I can fix this.
ALSO, I played around with the code and I realized that if i take dbHideSprite(9); away, the backdrop is normal button is messes up the arrow.
Does anyone know how to fix this?