How to remove Sprite object from layers?

16 views
Skip to first unread message

Hugo Ruscitti

unread,
Jul 11, 2008, 4:55:04 PM7/11/08
to cocos-...@googlegroups.com
Hi, I have a Layer object with a lot of Sprite objects in (some
type of particle system), but i think that unused sprites make
the effect very slow. There are some method to remove sprites
immediately from any Layer?, some like "kill" [1] method of pygame's
sprites.

Thanks.


[1] http://www.pygame.org/docs/ref/sprite.html#Sprite.kill

--
Hugo Ruscitti
www.losersjuegos.com.ar

riq

unread,
Jul 11, 2008, 5:02:34 PM7/11/08
to cocos-...@googlegroups.com
On Fri, Jul 11, 2008 at 11:55 PM, Hugo Ruscitti <hugoru...@gmail.com> wrote:

Hi, I have a Layer object with a lot of Sprite objects in (some
type of particle system), but i think that unused sprites make
the effect very slow. There are some method to remove sprites
immediately from any Layer?, some like "kill" [1] method of pygame's


Yes, you can use:
  layer.remove( "name" or instance )

for example:

   sprite = Sprite("car.png")
   layer.add( sprite, name="sprite_1" )

and you can do:
   layer.remove( sprite )
   or
   layer.remove( "sprite_1")


btw,  i'm finishing a particle system engine (using numpy) in the branch : branches/europython2008-sprint/
It is running fast. I can run 3000 particles, it supports speed, gravity, radial acceleration, tangential acceleration, start/end color, all of them with a variance factor.

and the good news is that it is using display lists (slow), so there is still room to improve the speed (with VBO).

riq.

--
ser humano
http://monodiario.blogspot.com

riq

unread,
Jul 12, 2008, 11:12:57 AM7/12/08
to cocos-...@googlegroups.com
.

and the good news is that it is using display lists (slow), so there is still room to improve the speed (with VBO).

Sorry. I wasn't using display list but vertex array. I don't know if VBO is faster than vertex array for particles (since most of them are updated in every frame)... I need to do some tests.

On the other hand, since I'm a newbie using numpy, I guess that the my numpy code can be optimized a lot.

riq.

Hugo Ruscitti

unread,
Jul 14, 2008, 3:22:53 PM7/14/08
to cocos-...@googlegroups.com
> On Fri, Jul 11, 2008 at 11:55 PM, Hugo Ruscitti <hugoru...@gmail.com>
> wrote:
>>
>> Hi, I have a Layer object with a lot of Sprite objects in (some
>> type of particle system), but i think that unused sprites make
>> the effect very slow. There are some method to remove sprites
>> immediately from any Layer?, some like "kill" [1] method of pygame's
>
> Yes, you can use:
> layer.remove( "name" or instance )

Thanks, it's work fine !.


--
Hugo Ruscitti
www.losersjuegos.com.ar

Reply all
Reply to author
Forward
0 new messages