Reputation: 4929
I want to make sort of a chalk board for part of my app, and I was wondering how to accomplish this?
I was thinking I could create a sprite and have it's image set to something very small (maybe a small point), and then add a new instance of that sprite everywhere the user touches to simulate a draw event. Something like [self addChild:someSprite];
for each touch location.
But it seems like that would be extremely memory inefficient. There has to be a better way than that, Maybe drawing actual lines? I'm probably overlooking some method.
Thanks for any help.
Upvotes: 0
Views: 298
Reputation: 64477
You need to use CCRenderTexture for chalk board paintings. Check this article & project for a drawing example.
Upvotes: 2
Reputation: 10860
Your variant isn't such "memory inefficient" as you think. No matter how much sprites will you create with the same texture, your texture will be placed to the memory only once. And all the sprites will use pointer to it. Just one thing to prevent many unnessesary calls is to use CCBatchNode. It will draw all it's children with single draw
call. Without using it, draw
will be called on every children.
Upvotes: 1