I have made a menu that uses images. I want the links to be hovered if I press up and down key one at a time. At default the first link is hovered, but when I added a code that acts when down key is pressed, it works too fast and is buggy in a many way.
short
startFor = 2,
links = 3,
endFor = startFor + links,
menuHover = startFor;
for(short i = startFor; i < endFor; ++i) {
dbCreateAnimatedSprite(i, "gfx/menu.png", 1, links, i);
dbCreateAnimatedSprite(i + links, "gfx/menuhover.png", 1, links, i + links);
}
while(LoopGDK()) {
for(short i = startFor; i < endFor; ++i) {
if(menuHover == i) {
dbSprite(i + links, resX2 / 2 - 83, resY2 / 2 - 100 + 75 * (i - 2), i + links);
dbPlaySprite(i + links, i - 1, i - 1, 0);
}
else {
dbSprite(i, resX2 / 2 - 83, resY2 / 2 - 100 + 75 * (i - 2), i);
dbPlaySprite(i, i - 1, i - 1, 0);
}
}
if(dbDownKey()){
if(endFor == menuHover)
menuHover = startFor;
else
menuHover++;
}
dbSync();
}