Dynamic Sprite Help - Getting started (SOLVED)

Started by Creator, Sun 15/05/2011 11:28:58

Previous topic - Next topic

Creator

This is my first experiance with dynamic sprites, so I need a little nudge to get me started.

All I want to do is draw an image onto the screen, preferbly in front of everything else on screen. I did a quick search and searched through the manual and just can't understand it.

I tried:

Code: ags

DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(0, 0, 63);
surface.Release();


But then I couldn't delete it or clear it without the game crashing, plus it draws on the background, behind the characters.

Again, all I need it a push into getting started and for how to delete it when finished.

Example: Draw image to screen, wait for 3 seconds, clear sprite from screen and delete it.

Dualnames

#1
Then it's better to use an overlay imho.

Code: ags
Overlay* myOverlay = Overlay.CreateGraphical(0, 0, 63, false);
Wait(120);
myOverlay.Remove();


EDIT: I thought the alpha parameter was optional.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Creator

#2
Dualnames... thank you. :D

Apparantly the final paramater (4th) isn't optional, so I had to set it to true/false. No matter though. Thanks again.

monkey0506

If you ever need to draw something onto a sprite and then display it this way you can use the DynamicSprite.GetDrawingSurface function to get the surface you need. If you then use that DynamicSprite with an Overlay you can delete the sprite and the Overlay won't be affected. If you display the sprite on a GUI though, you must not delete the sprite and must keep a global pointer to it available or you'll run into problems. Just so you know..;)

SMF spam blocked by CleanTalk