reading external graphics from folders

Started by Sackboy, Tue 14/05/2013 22:08:53

Previous topic - Next topic

Sackboy

i would like to store some external graphics in folders and create dynamic sprites from them at runtime, eg:

Code: AGS
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!

Crimson Wizard

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).

Khris

Do this instead:
Code: ags
  String dir = "Graphics";
  String filename = "Bla.bmp";
  String path = String.Format("%s/%s", dir, filename);
  
  DynamicSprite* sprite = DynamicSprite.CreateFromFile(path);

Sackboy

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!

SMF spam blocked by CleanTalk