RawSave / Restore Screen and backgroundanimation? (solved)

Started by Skyhawk, Fri 10/06/2005 16:16:29

Previous topic - Next topic

Skyhawk

I've noticed a problem with the RawSaveScreen
and Raw Restore Screen
commands...

i'm using the new DynamicSprite functions in my repeatedly execute room-script
(player -> water reflections ....) the RawSaveScreen is located in Player enters screen and the RawRestoreScreenÃ,  in repeatedly execute....
Logically the background animation is not working...
(if i put the RawSaveScreen Command in repeatedly execute the whole reflection thing isn't working...)

is there any way to get both? reflection and animation?


Ã,  RawRestoreScreen();
Ã,  DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(GetGameParameter(GP_FRAMEIMAGE, cEgo.View, cEgo.Loop, cEgo.Frame));
//Ã,  sprite.Resize(50,93);
Ã,  sprite.Flip(eFlipUpsideDown);
Ã,  RawDrawImageTransparent(character[EGO].x-25, character[EGO].y-1, sprite.Graphic, 50);
Ã,  sprite.Delete();

GarageGothic

#1
Sure. Don't RawDraw the reflection, use an object instead.

Edit: Of course this means that you can't delete the sprite until the player leaves the room. And you must set a default (non-dynamic) sprite for the object at the same time, or the game will crash the next time you enter (as it's referring to a non-existing pointer).

Edit 2: Alternately, you could animate the background "by hand" in the same repeatedly_execute_always function as the reflection script. Instead of RawRestoring, you could draw another frame on top of the existing with 0% transparency. Then you could put in a counter for the animation to decide WHICH frame should be drawn. (you may come across a crash problem when redrawing the same frame over itself - I'm not sure how to get around it). This seems like a considerably slower solution though.

Skyhawk

hmmmm, the object method causes an error message


---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x0043E0EC ; program pointer is +72, ACI version 2.71.867, gtags (0,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.



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

perhaps it is a simple mistake in the script, but i dont think so...


object[1].Visible = 1;
DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(GetGameParameter(GP_FRAMEIMAGE, cEgo.View, cEgo.Loop, cEgo.Frame));
sprite.Resize(50,93);
sprite.Flip(eFlipUpsideDown);
object[1].Graphic = sprite.Graphic;
object[1].Transparency = 50;
object[1].SetPosition(cEgo.x, cEgo.y);




the easiest working way was a transparent character with extra sprites and a simple


cReflect.x=cEgo.x;
cReflect.y=cEgo.y+93;
cReflect.loop=cEgo.loop;
cReflect.frame=cEgo.frame;Ã, 


but i want to save sprite slots and keep the game as small as possible ;)
eventually a additional flip function in the view editor?

Pumaman

This is due to this bit from the manual:

"IMPORTANT: If the DynamicSprite instance is released from memory (ie. there is no longer a DynamicSprite* variable pointing to it), then the sprite will also be removed from memory. Make sure that you keep a global variable pointer to the sprite until you are finished with it, and at that point call Delete."

It shouldn't really crash the game though, I'll add some handling for a friendlier error report.

But basically, you need to declare the
DynamicSprite* sprite;
variable at the top of the script rather than within the function, otherwise it gets deleted as soon as the function returns.

SMF spam blocked by CleanTalk