I'm creating a pop up hover menu, and figured I'd use an animated sprite. However, I cannot get the animated sprite to display, whereas if I use a standard image sprite the graphic does display.
Can anyone see where I'm going obviously wrong?
#include "DarkGDK.h"
int targetCard=0; // Target Card
int menuOn=0; // Mouse Menu visibility flag
char chatText[60]; // Chat Text
// ------------------------ Shrink Cards ----------------------------
int shrinkCards ()
{
//Player 1
for (int n=101; n<104; n++){
dbScaleSprite (n,13);
dbSetSpritePriority (n,0);
}
//Player 2
for (int n=201; n<204; n++){
dbScaleSprite (n,13);
dbSetSpritePriority (n,0);
dbSprite(n, dbSpriteX(n), 430, dbSpriteImage(n));
}
//Player 3
for (int n=301; n<304; n++){
dbScaleSprite (n,13);
dbSetSpritePriority (n,0);
}
//Player 4
for (int n=401; n<404; n++){
dbScaleSprite (n,13);
dbSetSpritePriority (n,0);
dbSprite(n, dbSpriteX(n), 430, dbSpriteImage(n));
}
return 0;
}
// ------------------------ Zoom Cards ----------------------------
int zoomCards ()
{
//Player 1
for (int n=101; n<104; n++){
if (dbSpriteHit (999, n)) {
dbScaleSprite (n,75);
dbSetSpritePriority (n,1);
if (dbMouseClick()==2) targetCard=n;
}
}
//Player 2
for (int n=201; n<204; n++){
if (dbSpriteHit (999, n)){
dbScaleSprite (n,75);
dbSetSpritePriority (n,1);
if ( dbSpriteY(n) + dbSpriteHeight(n) > dbScreenHeight() )
dbSprite(n, dbSpriteX(n), 130, dbSpriteImage(n));
if (dbMouseClick()==2) targetCard=n;
}
}
//Player 3
for (int n=301; n<304; n++){
if (dbSpriteHit (999, n)){
dbScaleSprite (n,75);
dbSetSpritePriority (n,1);
if (dbMouseClick()==2) targetCard=n;
}
}
//Player 4
for (int n=401; n<404; n++){
if (dbSpriteHit (999, n)){
dbScaleSprite (n,75);
dbSetSpritePriority (n,1);
if ( dbSpriteY(n) + dbSpriteHeight(n) > dbScreenHeight() )
dbSprite(n, dbSpriteX(n), 130, dbSpriteImage(n));
if (dbMouseClick()==2) targetCard=n;
}
}
return 0;
}
// ------------------------ Mouse Menu ------------------------------
int call_mouse_Menu()
{
if (dbMouseY()>(dbScreenHeight()/2)) dbSprite(998,dbMouseX()-20,dbMouseY()-130,997);
if (dbMouseY()<(dbScreenHeight()/2)) dbSprite(998,dbMouseX()-20,dbMouseY()-20,997);
dbShowSprite(998);
dbSetSpritePriority (998,10);
menuOn=1;
return 0;
}
int close_mouse_Menu()
{
dbHideSprite(998);
menuOn=0;
targetCard=0;
return 0;
}
int check_mouse_Menu()
{
if (dbSpriteHit (999, 998)==0) {
close_mouse_Menu();
}
else {
dbText(dbSpriteX(998)+10,dbSpriteY(998)+10,"Play Card");
dbText(dbSpriteX(998)+10,dbSpriteY(998)+30,"Sell Item");
dbText(dbSpriteX(998)+10,dbSpriteY(998)+50,"Charity");
dbText(dbSpriteX(998)+10,dbSpriteY(998)+70,"Discard");
}
return 0;
}
// ------------------------ Player Setup ----------------------------
int player_Setup()
{
// Player 1
dbSprite ( 101, 5, 5, 101 ); // Class
dbSprite ( 102, 52, 5, 101 ); // Race
dbSprite ( 103, 99, 5, 101 ); // Item
for (int n=101; n<104; n++){
dbScaleSprite (n, 13);
}
// Player 2
dbSprite ( 201, 5, 430, 101 ); // Class
dbSprite ( 202, 52, 430, 101 ); // Race
dbSprite ( 203, 99, 430, 101 ); // Item
for (int n=201; n<204; n++){
dbScaleSprite (n, 13);
}
// Player 3
dbSprite ( 301, 448, 5, 101 ); // Class
dbSprite ( 302, 495, 5, 101 ); // Race
dbSprite ( 303, 542, 5, 101 ); // Item
for (int n=301; n<304; n++){
dbScaleSprite (n, 13);
}
// Player 4
dbSprite ( 401, 448, 430, 101 ); // Class
dbSprite ( 402, 495, 430, 101 ); // Race
dbSprite ( 403, 542, 430, 101 ); // Item
for (int n=301; n<304; n++){
dbScaleSprite (n, 13);
}
return 0;
}
// ------------------------ Main Loop ----------------------------
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetDisplayMode ( 800, 600, 16) ;
dbSetWindowTitle ( "Munchkin Online!" ) ;
dbSetWindowPosition ( 50, 50);
dbDrawSpritesFirst();
dbSetTextTransparent();
//dbInk(dbRGB(150,150,100),0); // Greyed-out Text Colour
dbInk(dbRGB(100,100,50),0); // Standard Text Colour
dbSetTextFont("Stone Hinge");
dbSetTextSize(20);
// Background Spread
dbLoadImage ( "GFX/Spread2.png", 1 );
dbSprite ( 1, 0, 0, 1 );
// Menu
//dbLoadImage ("GFX/menu.png", 998);
dbCreateAnimatedSprite ( 998, "GFX/menu2.png", 113, 140, 997 );
dbSetSpriteFrame(998,1);
int val=0;
// Pointer
dbLoadImage ("GFX/pointer.png", 999);
// Wizard
dbLoadImage ( "Cards/Wizard.png", 101 );
// Player Setup
player_Setup();
while ( LoopGDK ( ) )
{
// Mouse
dbSprite (999,dbMouseX(),dbMouseY(),999);
if (dbSpriteVisible(998)>0) check_mouse_Menu();
shrinkCards();
zoomCards();
sprintf(chatText, "Sprite %d", targetCard);
dbText(610,15,chatText);
if (targetCard>0 && menuOn==0) call_mouse_Menu();
if (menuOn==1) check_mouse_Menu();
dbSync ( );
}
return;
}
Thanks