Menu

#843 While & Object Deletion

Bug report
open
Ashley
4
2009-09-24
2009-05-15
Charly Piva
No

Object Deletion doesn't seem to work well in a While Loop.

The Attached cap file contains a layout with 1250 Sprites. The code in the Event Sheet is supposed to destroy the Sprites one by one, till only 800 Sprites remain. Here is the code :

System: Start of layout
> Sprite2 : Set 'OBJ' to Sprite 0 .Count

Sprite2 : Value 'OBJ' Greater or equal 800
Sprite: Pick one at random
> Sprite2 : Subtract 1 from 'OBJ'
> Sprite : Destroy

It works and destroys objects as it should.

Yet if you add a While to the seconde line, so the objects could be destroyed in almost no time, in the end there are about 860 sprites, while the "Sprite2"'s variable 'OBJ' has reached 800. Like if sometimes the variable was decremented but no "Sprite" was destroyed. Maybe the final number of Sprites depend on the PC's speed. Mine is pretty slow.

Also, try to replace the "Sprite2 : Subtract 1 from 'OBJ'" by a "Sprite2 : Set 'OBJ' to Sprite.Count", and it goes into an infinite loop. That's weird, because one "Sprite" is supposed to be destroyed at each loop, so the object count should decrease.

Discussion

  • Charly Piva

    Charly Piva - 2009-05-15
     
  • Ashley

    Ashley - 2009-09-24
    • priority: 5 --> 4
     

Log in to post a comment.

MongoDB Logo MongoDB