One solution is to save relative position coordinates rather than absolute values.
What I mean is, for example, lets say we have an image of size = (100,100) placed on pos = (50,50) on a scene with scene size = (200,200).
If you save only absolute values of image size and position, you'll have a problem if the scene size changes after loading.
Instead, you can save image parameters like size = (0.5,0.5) and pos = (0.25,0.25) (or 50% and 25%, it means - how much of the whole scene size is occupied by this image, 0.5 = 100/200, 0.25 = 50/200...). Now if you load it on scene with scene size = (400,400), you simply rescale the values :
new_size = (0.5*400, 0.5*400)=(200,200), new_pos = (0.25*400,0.25*400)=(100,100). Simple, isn't it ?
Of course if scenes aspect ratio is changed, your image will change as well, but it's up to you how you want to deal with it.
Another solution is to save scene size as well and rescale everything after loading.
I won't give you working code as I think it's better if you work it out yourself.






Reply With Quote

Bookmarks