Dynamic Sprite as inventory graphic <solved>

Started by abstauber, Thu 30/04/2009 09:49:26

Previous topic - Next topic

abstauber

Hi there,

I wonder, if it's possible to dynamically modify the look of an inventory graphic.

My code is something like this
Code: ags

  // the Item's called iBlueCup
  DynamicSprite  *invItem = DynamicSprite.CreateFromExistingSprite (517, true);
  DrawingSurface *spriteSurface = invItem.GetDrawingSurface();

  spriteSurface.DrawPixel(4, 4);
  spriteSurface.Release();

  iBlueCup.Graphic = invItem.Graphic;
  
  player.AddInventory(iBlueCup);


Unfortunately AGS crashes as soon as I add the item with the custom graphic.

Here's the output:
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x004038E8 ; program pointer is +379, ACI version 3.12.1074, gtags (1,8)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.



Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------


Thanks for your help!

GarageGothic

Yeah, it should be possible. You need to keep a global pointer to the DynamicSprite though, or it will be destroyed as soon as the function finishes. Where do you define the DynamicSprite, inside or outside your function?

abstauber

Ahh right, that did the trick   :D

I forgot about the global pointer and defined the sprite inside the function, 'doh!

Thanks a million!  ;D

SMF spam blocked by CleanTalk