DynamicSprite.CreateFromSaveGame trouble (SOLVED)

Started by Ivanovich, Sun 28/01/2007 15:25:43

Previous topic - Next topic

Ivanovich

I'm having a trouble trying to make a custom load/save GUI with thumbnails previews. When I try to load the thumbnail preview in a 'button', the code simply not work. The code is as follow:

Code: ags

DynamicSprite *sprite = DynamicSprite.CreateFromSaveGame(30, 50, 50);
MyButton.NormalGraphic = sprite.Graphic;


I'm sure slot '30' have an image to load (because I can load it with other templates).
Also if I replace the 2nd line of code for the next one:

Code: ags

MyButton.NormalGraphic = 10; // LOAD CURSOR SPRITE


Then the code works perfectly, and the button shows de '10' sprite image. The game resolution setting is 640x480, 16bits.

I'm confused about what is happening. Maybe the 'savescreenshots in save games' option uses 320x200 resolution ? I really don't know what is wrong.  ???

Thanks in advance for your help.

Ashen

Where exactly is that code, and how is it not working?
If the problem is just that the Button doesn't change graphic, then as I understand it DynamicSprites declared in a function (e.g. a Button's Control function, or the on_key_press condition that opens the Load Game GUI) are only good in that function - once it finishes running the DymanicSprite is deleted, and all uses are cleared. What if you move the declaration to the top of the Global script, and replace that code with:
Code: ags

sprite = DynamicSprite.CreateFromSaveGame(30, 50, 50);
MyButton.NormalGraphic = sprite.Graphic;


I believe that's how the example in the manual does it, as well.
I know what you're thinking ... Don't think that.

Ivanovich

Yoy are right. I was declaring 'DynamicSprite *sprite' inside a function. Now I've moved the declaration to the top of the code and it works.

Thanks a lot!!   ;D

SMF spam blocked by CleanTalk