Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sackboy on Tue 14/05/2013 22:08:53

Title: reading external graphics from folders
Post by: Sackboy on Tue 14/05/2013 22:08:53
i would like to store some external graphics in folders and create dynamic sprites from them at runtime, eg:

Code (AGS) Select
Game.SetSaveGameDirectory("Graphics");
String Filename="Bla.bmp";
String Path=String.Format("$SAVEGAMEDIR$/%s", Filename);

DynamicSprite *sprite=DynamicSprite.CreateFromFile(Path);


in this case sprite gives me a null pointer error but File.Exists(Path); tells me that the file is there. do only the "FILE" commands know "$SAVEGAMEDIR$"? or is there some kind of trick i am missing?

thanks for your help!
Title: Re: reading external graphics from folders
Post by: Crimson Wizard on Wed 15/05/2013 12:13:07
Yes, according to engine code, in AGS 3.2.1 $SAVEGAMEDIR$ and $APPDATADIR$ are supported only by 1) File object 2) ListBox (to fill in directory contents).
Title: Re: reading external graphics from folders
Post by: Khris on Wed 15/05/2013 12:47:02
Do this instead:
Code (ags) Select
  String dir = "Graphics";
  String filename = "Bla.bmp";
  String path = String.Format("%s/%s", dir, filename);
 
  DynamicSprite* sprite = DynamicSprite.CreateFromFile(path);
Title: Re: reading external graphics from folders
Post by: Sackboy on Wed 15/05/2013 17:59:47
as i am reading this i am asking myself why i haven't thought of that myself? :P sorry for bothering you and thanks for your help!