Refresh CCDrawNode

I'm using a CCDrawNode on a layer to draw a map on the screen and it draws great the first time. Afterwards, I generate a new map and call my rendering code to draw it again... but nothing appears to change on the screen.

I'm declaring the CCDrawNode as a private class variable so I only add it once as a child to the layer instead of instantiating a new version each time I call my render function. Even trying to instantiate a new version each time doesn't cause the screen to show the newly generated map. After playing around a bit, the only solution I found was to call ReplaceScene and send in the same scene... then the screen is refreshed with the new version. It works but seems like a brute-force approach to handling it.

Is there a best practice for refreshing the screen when using CCDrawNode other than replacing the scene? I've attached my code file if you want to have a look at what I'm doing. Any thoughts would be appreciated. Thanks.

Best Answer

Answers

  • RickElliottRickElliott USUniversity ✭✭

    DOH. I had actually tried the Clear method previously and it didn't appear to change anything. However, after examining my code, I had made a local reference to my map that was hanging around and I wasn't really rendering my newly generated version. After fixing that, Clear works just like it should. Thanks for your help.

Sign In or Register to comment.