PDA

View Full Version : Access Violation with sprite engine in 1.07



seiferalmasy
21-09-2007, 11:42 PM
I am getting access violations (Eaccessviolation):

when using



Mainfm.dxspriteengine1.Engine.Clear;
TBall1Sprite.create(Mainfm.dxspriteengine1.engine) ;

Where clear supposedly kills off all sprites. It happens much more frequently if there is a scrolling background to be killed then recreated (perhaps because for me that means an extra 3 sprites).

Any ideas what is wrong? It doesnt do it each time. Seems to be pick and choose when it does it but it is always at this point wheer it fails.

The cpu window shows it is always hanging 00489060 Tsprite.getcount

[/code]

chronozphere
22-09-2007, 08:55 AM
You should use breakpoints to find out where it goes wrong. :)

My guess is, that something is destroyed when you call SpriteEngine.Clear, and the Constructor of TBallsprite assumes that object to exist.

Set some breakpoints in the constructor of TBallSprite. You could also add some breakpoints to the TSprite or TImageSprite constructors. I'm sure you will find the bug.

Good luck! ;)

FNX
22-09-2007, 03:46 PM
To kill all sprites try something like:

DXSpriteEngine.Engine.AllDead;
DXSpriteEngine.Dead.

That should work fine. I have never used the Clear function.

Hope this helps ;)

seiferalmasy
23-09-2007, 03:35 PM
THANKYOU. I shall test that right away.

In that case anyone know what is the difference with clear? hmm

and alldead doesnt seem to exist?


mainfm.DXSpriteEngine1.Engine.Items[0].dead;
mainfm.DXSpriteEngine1.Engine.Items[1].dead;
mainfm.DXSpriteEngine1.Engine.Items[2].dead;
mainfm.DXSpriteEngine1.Engine.Items[3].dead;
mainfm.DXSpriteEngine1.Engine.Items[4].dead;
mainfm.DXSpriteEngine1.Engine.Items[5].dead;
mainfm.DXSpriteEngine1.Engine.Items[6].dead;

which I have modified to


For I:=0 to mainfm.DXSpriteEngine1.Engine.allcount-1 do
begin
mainfm.DXSpriteEngine1.Engine.Items[i].dead;
end;

I have found the above does a pretty good job. Just testing. But wheer did you get alldead from?

seiferalmasy
23-09-2007, 05:01 PM
I am thinking this is a bug in undelphix/delphix with clear not getting the number of sprites correctly, since it hangs at getcount.

FNX
23-09-2007, 10:27 PM
and alldead doesnt seem to exist?

Well i wrote it by memory so it could be Engine.Items.Alldead or
something like that, just search on Engine and SpriteEngine methods,
i'm sure it's there ;)

seiferalmasy
23-09-2007, 11:26 PM
I have had a look, can't seem to find anything like that anywhere?

seiferalmasy
24-09-2007, 07:34 PM
jaro is looking into clear bug:)

ijcro
16-12-2007, 02:40 PM
Dead for freeing all unused sprite from memory cannot be use for static sprite. Static spite must be clonned and after them can be Dead.

harrypitfall
05-01-2008, 03:59 PM
The "Dead" engine is used for a simple motive... you can't free the sprites while a .move(), .collision() or .draw() is running, you can set it do deaded, will be ignored in these loops, and when you call Engine.Dead after all work is done, all "deaded" sprites are freeing then.

This is my procedure on timer that i use almost all the time (i use a class to manage "game states" using only the sprite engine to render all)

// In
Input.Update;
SpriteEngine.Move(1);
States.DoRun;
// Out
If Screen.CanDraw Then Begin
SpriteEngine.Draw;
Screen.Flip;
End;
// Garbage
SpriteEngine.Dead;