Claudio Ferraro
Claudio Ferraro

Reputation: 4721

How sprite memory management for COCOS2d sprites works

I have a lot of sprites loaded in a scene. more than 100. I'm trying to understand how memory management in COCOs2d works:

1) is setVisible(false) enough to remove it temporarily from memory ?

2) if a big sprite has let's say 90% of transparent pixels, is this sprite handled in memory the same way if this sprite was twice smaller but it had'd only 10% of transparent pixels. Does transparent pixels occupy memory ?

Upvotes: 3

Views: 310

Answers (1)

trojanfoe
trojanfoe

Reputation: 122458

1) is setVisible(false) enough to remove it temporarily from memory ?

No, you'd need to remove it from the node using:

[sprite removeFromParentAndCleanup:YES];

2) if a big sprite has let's say 90% of transparent pixels, is this sprite handled in memory the same way if this sprite was twice smaller but it had'd only 10% of transparent pixels. Does transparent pixels occupy memory ?

Transparency is a colour with alpha set to 0.0, so yes transparent pixels occupy the same amount of memory as opaque pixels.

Upvotes: 4

Related Questions