How is it possible to actually display the overlay on the screen?
function Bubble::Render(int x, int y)
{
int radius = 10;
DynamicSprite* sprite = DynamicSprite.Create(radius, radius, true);
DrawingSurface* surface = sprite.GetDrawingSurface();
surface.DrawingColor = 100;
surface.DrawCircle(radius, radius, radius);
surface.Release();
Overlay* myOverlay = Overlay.CreateGraphical(x, y, sprite.Graphic, false);
// what now?
sprite.Delete();
}
The only way I found that worked displaying a dynamic sprite on the screen was to draw on the "Room.GetDrawingSurfaceForBackground()" surface:
DrawingSurface *roomSurface = Room.GetDrawingSurfaceForBackground();
roomSurface.DrawImage(x, y, sprite.Graphic);
roomSurface.Release();
But the problem with this approach is that it is not possible to delete the sprite afterwards.
The goal is to create random bubbles that will slowly raise to the to the top of the screen.
The creation process of the bubbles should be dynamic.
I could be totally wrong, but the Overlay.CreateGraphical draws the sprite at the x,y coordinates, but then you immediately delete the sprite which would cause the Overlay to not have a sprite to draw anymore.
Put a "wait" call where you have "// what now?" and see if the sprite shows up. If so then you will have to save the sprite to get it to work.
Declare the sprite and overlay outside your function.
DynamicSprite* sprite;
Overlay* myOverlay;
function Bubble::Render(int x, int y)
{
int radius = 10;
sprite = DynamicSprite.Create(radius, radius, true);
// ...
Like dayowlron says, all variables / Pointers declared inside a function don't survive it ending.