locked
Refresh CCDrawNode RRS feed

  • Question

  • User4641 posted

    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.

    Saturday, October 3, 2015 12:19 AM

Answers

  • User68494 posted

    Rick

    You can try calling _screen.Clear() to remove previously added primitives.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, October 4, 2015 4:16 AM

All replies

  • User68494 posted

    Rick

    You can try calling _screen.Clear() to remove previously added primitives.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, October 4, 2015 4:16 AM
  • User4641 posted

    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.

    Sunday, October 4, 2015 11:20 PM