Here is some code
#include "template.h"
using namespace AGK;
app App;
Soundbites bites[13];
//USE FOR APP
//HANDLES for loaded images
UINT iIndvImg=0;
UINT GameBkgrdImg=0;
UINT CreditImg=0;
UINT loadingImg1=0;
UINT loadingImg2=0;
UINT loadingImg3=0;
UINT loadingImg4=0;
UINT logoImg=0;
//backgrounds SPRITES
UINT GameBkgrdSprite=0;
UINT Loading1Sprite=0;
UINT Loading2Sprite=0;
UINT Loading3Sprite=0;
UINT Loading4Sprite=0;
UINT IndvSprite=0;
UINT CreditSprite=0;
UINT doomBelt=0;
UINT doomBeltSprite=0;
//logo
UINT logoSprite=0;
//equalizer
UINT pic1Sprite=0;
UINT pic2Sprite=0;
UINT pic3Sprite=0;
//misc
UINT cnt=1;
UINT rndNum;
bool showLoadingScreen;
float Aspect=0.00;
UINT _millisecs=0;
UINT iLastPlayed;
int sprite=0;
int Screen =1; //1-mainscreen, 2-soundbites, 3-credits
//double nativeres = 921600;
//main screen
float xpos1=30;
float ypos1=70;
//individual
float xpos2=12;
float ypos2=36;
//btns images
UINT iCreditsBtn=0;
UINT iOverlayBtn=0;
UINT iPlayBtn=0;
UINT iSongTitleBtn=0;
UINT iFwdBtn=0;
UINT iwayRollBtn=0;
UINT iBckBtn=0;
UINT iOverlayBtn2=0;
UINT iWangBtn=0;
UINT iPillBtn=0;
UINT iHaterBtn=0;
UINT iInterviewBtn=0;
UINT iLooseBtn=0;
UINT iMethaneBtn=0;
UINT iMommaBtn=0;
UINT iFoolBtn=0;
UINT iOohhBtn=0;
UINT iOuttiBtn=0;
UINT iPolarBtn=0;
UINT iSummerBtn=0;
UINT iPlayallBtn=0;
UINT iStopBtn=0;
UINT iSountBtn=0;
//btn sprites
UINT iCreditsSprite=0;
UINT iOverlaySprite=0;
UINT iPlaySprite=0;
UINT iSongTitleSprite=0;
UINT iFwdSprite=0;
UINT iwayRollSprite=0;
UINT iBckSprite=0;
UINT iOverlaySprite2=0;
UINT iWangSprite=0;
UINT iPillSprite=0;
UINT iHaterSprite=0;
UINT iInterviewSprite=0;
UINT iLooseSprite=0;
UINT iMethaneSprite=0;
UINT iMommaSprite=0;
UINT iFoolSprite=0;
UINT iOohhSprite=0;
UINT iOuttiSprite=0;
UINT iPolarSprite=0;
UINT iSummerSprite=0;
UINT iPlayallSprite=0;
UINT iStopSprite=0;
UINT iSountSprite=0;
//virtual buttons
UINT iFwdVB=1;
UINT iBckVB=2;
UINT iBckVB2=3; //credit screen
UINT iBckVB3=4; //credit btn
UINT iBckVB4=5; //play btn
// Begin app, called once at the start
void app::Begin( void )
{
double resolution;
resolution = agk::GetDeviceWidth() * agk::GetDeviceHeight();
//if resolution equals 1280x720 which is what the graphics was design to set to that ratio;
//even if higher resolutions that equals an aspect of .56 set them to .68; for all lower resolution set to .68
if (resolution == 921600) { Aspect = .56;}
else { Aspect = 0.68;}
//dw/dh
agk::SetDisplayAspect(Aspect );
agk::SetOrientationAllowed(1,0,0,0);
logoImg = agk::LoadImage ( "pics/logo.png" );
logoSprite = agk::CreateSprite (logoImg );
agk::SetSpriteSize(logoSprite,60,-1);
agk::SetSpritePosition(logoSprite,20,40);
agk::Sync();
//show first loading screen on start up
loadingImg1 = agk::LoadImage ( "pics/LoadingImage1.jpg" );
Loading1Sprite = agk::CreateSprite (loadingImg1 );
agk::SetSpriteSize(Loading1Sprite,100.00,100.00);
agk::Sync();
GraphicImages();
//prepare for random numbers
//rndSwitch=true;
_millisecs = agk::GetMilliseconds();
agk::SetRandomSeed(_millisecs);
iLastPlayed=0;
//fwd btn - main screen
agk::AddVirtualButton(iFwdVB,xpos1+58,ypos1+10,15);
agk::SetVirtualButtonImageUp(iFwdVB,iFwdBtn);
agk::SetVirtualButtonImageDown(iFwdVB,iFwdBtn);
agk::SetVirtualButtonAlpha(iFwdVB,225);
//back btn -
agk::AddVirtualButton(iBckVB,xpos2+1,ypos2+48,15);
agk::SetVirtualButtonImageUp(iBckVB,iBckBtn);
agk::SetVirtualButtonImageDown(iBckVB,iBckBtn);
agk::SetVirtualButtonAlpha(iBckVB,225);
//back button on credit screen
agk::AddVirtualButton(iBckVB2,xpos2+1,ypos2+40,15);
agk::SetVirtualButtonImageUp(iBckVB2,iBckBtn);
agk::SetVirtualButtonImageDown(iBckVB2,iBckBtn);
agk::SetVirtualButtonAlpha(iBckVB2,225);
//credit button
agk::AddVirtualButton(iBckVB3,xpos1+18,(ypos1+22),34);
agk::SetVirtualButtonImageUp(iBckVB3,iCreditsBtn);
agk::SetVirtualButtonImageDown(iBckVB3,iCreditsBtn);
agk::SetVirtualButtonAlpha(iBckVB3,225);
//play button
agk::AddVirtualButton(iBckVB4,xpos1+18,(ypos1-1),34);
agk::SetVirtualButtonImageUp(iBckVB4,iPlayBtn);
agk::SetVirtualButtonImageDown(iBckVB4,iPlayBtn);
agk::SetVirtualButtonAlpha(iBckVB4,225);
SetupMainScreen();
agk::DeleteSprite(logoSprite);
agk::DeleteSprite(Loading1Sprite);
agk::DeleteSprite(Loading2Sprite);
agk::DeleteSprite(Loading3Sprite);
agk::DeleteSprite(Loading4Sprite);
agk::DeleteImage(logoImg);
agk::DeleteImage(loadingImg1);
agk::DeleteImage(loadingImg2);
agk::DeleteImage(loadingImg3);
agk::DeleteImage(loadingImg4);
LoadMP3();
agk::Sync();
}
void app::Loop ( void )
{
//put in code for inactivity
//press the escape key to exit game
if (agk::GetRawKeyPressed(27)==1)
{
//make sure music is not playing
agk::StopMusic();
exit(0);
}
if (Screen == 1)
{
MainScreen();
}
else if (Screen == 2)
{
SoundBiteScreen();
}
else if (Screen == 3)
{
CreditScreen();
}
agk::Sync();
}
// Called when the app ends
void app::End ( void )
{
DeleteCreditScreen();
DeleteMainScreen();
DeleteSoundBiteScreen();
DeleteAllImagesAndButtons();
}
void SetupMainScreen(void)
{
GameBkgrdSprite = agk::CreateSprite (GameBkgrdImg);
agk::SetSpriteSize(GameBkgrdSprite,100.00,100.00);
doomBeltSprite = agk::CreateSprite (doomBelt);
agk::SetSpriteSize(doomBeltSprite,85,-1);
agk::SetSpritePosition(doomBeltSprite,8,(3));
//song title string
iSongTitleSprite = agk::CreateSprite (iSongTitleBtn );
agk::SetSpriteSize(iSongTitleSprite,60,-1);
agk::SetSpritePosition(iSongTitleSprite,xpos1-9,(ypos1-15));
//place buttons
//play btn
//iPlaySprite = agk::CreateSprite (iPlayBtn );
//agk::SetSpriteSize(iPlaySprite,40,-1);
//agk::SetSpritePosition(iPlaySprite,xpos1,(ypos1-5));
//credit btn
//iCreditsSprite = agk::CreateSprite (iCreditsBtn );
//agk::SetSpriteSize(iCreditsSprite,40,-1);
//agk::SetSpritePosition(iCreditsSprite,xpos1,(ypos1+5));
//deactiveate btns
agk::SetVirtualButtonActive(iBckVB2,0);
agk::SetVirtualButtonVisible(iBckVB2,0);
agk::SetVirtualButtonActive(iBckVB,0);
agk::SetVirtualButtonVisible(iBckVB,0);
return;
}
void DeleteMainScreen(void)
{
agk::DeleteSprite(GameBkgrdSprite);
agk::DeleteSprite(doomBeltSprite);
agk::DeleteSprite(iSongTitleSprite );
agk::DeleteSprite(iPlaySprite);
agk::DeleteSprite(iCreditsSprite);
return;
}
void MainScreen(void)
{
//control the size when forward button is pressed on main screen
if (agk::GetVirtualButtonPressed(iFwdVB) == 1)
{
agk::SetVirtualButtonSize(iFwdVB,19);
}
if (agk::GetVirtualButtonReleased(iFwdVB) == 1)
{
IndvSprite = agk::CreateSprite (iIndvImg );
agk::SetSpriteSize(IndvSprite,100.00,100.00);
agk::SetVirtualButtonActive(iFwdVB,0);
agk::SetVirtualButtonVisible(iFwdVB,0);
agk::SetVirtualButtonActive(iBckVB4,0);
agk::SetVirtualButtonVisible(iBckVB4,0);
agk::SetVirtualButtonActive(iBckVB3,0);
agk::SetVirtualButtonVisible(iBckVB3,0);
Screen =2;
agk::SetVirtualButtonActive(iBckVB,1);
agk::SetVirtualButtonVisible(iBckVB,1);
agk::SetVirtualButtonSize(iBckVB,15);
DeleteMainScreen();
SetupSoundBiteScreen();
}
//credit virtual button
if (agk::GetVirtualButtonPressed(iBckVB3) == 1)
{
agk::SetVirtualButtonSize(iBckVB3,42);
}
if (agk::GetVirtualButtonReleased(iBckVB3) == 1)
{
Screen=3;
agk::SetVirtualButtonSize(iBckVB3,34);
CreditSprite = agk::CreateSprite (CreditImg);
agk::SetSpriteSize(CreditSprite,100.00,100.00);
}
//play button
if (agk::GetVirtualButtonPressed(iBckVB4) == 1)
{
agk::SetVirtualButtonSize(iBckVB4,42);
}
if (agk::GetVirtualButtonReleased(iBckVB4) == 1)
{
agk::SetVirtualButtonSize(iBckVB4,34);
rndNum = PickRandomNumber();
PlayIsm(iLastPlayed, rndNum);
}
return;
}
How is the DeleteSprite and the DeleteImage functions suppose to work? After the pass I check those variable it doesn't seem like the image has been released.