Woot. Wrapped it all up in a nice clean function I can call from anywhere within my program with just one line. :)
Think this is worth adding to the code archive? It certianly was exactly what I was looking for. :)
'This code is public domain, yada yada yada. 'Tries to load an image at runtime, uses a default image if none exists. 'Note: if default image does not exist, the app still crashes! 'This was not meant as a crashfix, but as a placeholder for missing art assets during game development! Function dynamicLoadImage:TImage(prefix:String="", n:Int=0,suffix:String="") Local image:TImage ' Load in the required Images... 'Ensure backgroundImage exists before loading. Local sFileName:String=prefix+n+suffix Print sFileName If FileType(sFileName)=1 Then image = LoadImage(sFileName) Else image = LoadImage("graphics\null.png") EndIf Return image End Function 'Example of usage Local BackgroundImage:TImage BackgroundImage = dynamicLoadImage("graphics\stage", Level,".png")
Think this is worth adding to the code archive? It certianly was exactly what I was looking for. :)