Forum Libraries, Components, and Plugins

Create copy of CCDrawNode

Hello there,

Let's say I am drawing with CCDrawNode and then saving the drawing as a sprite and then I clear the CCDrawNode so I can create more drawings from scratch. I'd like now before I clear the CCDrawNode to save it as a property of a class ModelNode so I can reuse the CCDrawNode later on when trying to create copies of the drawing. Now by doing

CCDrawNode savedDrawNode = oldDrawNode

I realized that it is just saving the reference of the original CCDrawNode (so when I clear the original CCDrawNode the saved CCDrawNode is also cleared). I'd like to save a complete copy of the original CCDrawNode is that possible? If yes how?


  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai


    I was actually thinking of this last week and we at this time do not have this functionality. There is a way but it would involve creating your own CCDrawNode so you have access to all the line and triangle vertices.

    We have setup a new issue for feature enhancement.

  • Hi @kjpou1

    If now I wanted to create my own CCDrawNode while I'm waiting for the new feature enhancement, how would I do that? I will need that feature until 2 weeks so this seems to be my only choice I guess.

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    You can use the following to create a custom DrawNodeBuffer.

    DrawNodeBufferclass is just a copy of the CCDrawNodeclass drawing methods that creates the triangle and line vertices. So instead of drawing to the CCDrawNodeuse the drawing methods of DrawNodeBufferand when you are ready to display them call the following:


    Look at the IntroLayer.cs module to see it being used.

  • Thanks I will have a try :)

Sign In or Register to comment.