LoadImage from different locations
Monkey Forums/Monkey Programming/LoadImage from different locations
| ||
I'm wondering...Class Animal Field Image1:Image Field Image2:Image Method New() Image1 = LoadImage("dog.png") Image2 = LoadImage("dog.png") End End If dog.png has already been loaded, does the second loadimage call load it into memory at a different location, or simply refer to the existing instance in memory? Thanks -Chris |
| ||
It will load it into a different memory area. You can design your own image loading function that checks if an image is already loaded. I've posted code how to do this somewhere on the boards here (sorry, don't know where). Basically you use a Map<path:String,image:Image>. |
| ||
Thanks Shinkiro, that's a good idea. I use the same image for lots of different things and that seems the easiest way of dealing with it :) |
| ||
Or you can just do this:Class Animal Field Image1:Image Field Image2:Image Method New() Image1 = LoadImage("dog.png") Image2 = Image1 End End |
| ||
Hi therevills, the above was just a very simple example. I'm actually loading the same image across a few different classes so I don't want one class to rely on another. |
| ||
Ah... in that case you need a resource manager of some kind like what Shinkiro1 has suggested, we've got something similar in Diddy - either that or heaps of globals ;) |