CCDrawNodeRetained
CCDrawNodeRetained
Cocos2DA retained-mode draw node where individual shapes can be added, moved, recolored, or removed independently. Shape modifications (move, recolor, opacity) update vertices in-place. The draw buffer array is rebuilt from the vertex list on the next Draw() call when any change occurs. Use this instead of CCDrawNode when you have many shapes and only a few change per frame. The immediate-mode Clear() + redraw pattern still works if needed. var node = new CCDrawNodeRetained(); var dot = node.AddDot(center, 10f, CCColor4F.Red); // Later, move or recolor: node.SetShapePosition(dot, newCenter); node.RecolorShape(dot, CCColor4F.Blue); node.RemoveShape(dot);
Inheritance: System.Object → Cocos2D.CCNode
Implements: Cocos2D.ICCSelectorProtocol, Cocos2D.ICCFocusable, Cocos2D.ICCTargetedTouchDelegate, Cocos2D.ICCStandardTouchDelegate, Cocos2D.ICCTouchDelegate, Cocos2D.ICCKeypadDelegate, Cocos2D.ICCKeyboardDelegate, Cocos2D.ICCRGBAProtocol, System.Collections.Generic.IComparer{Cocos2D.CCNode}
Constructors
CCDrawNodeRetained()
CCDrawNodeRetained()()Properties
Number of active shapes in this node.
Total vertex count across all shapes.
Methods
AddDot(CCPoint, float, CCColor4F)
Cocos2D.CCShapeHandle AddDot(CCPoint, float, CCColor4F)(Cocos2D.CCPoint pos, System.Single radius, Cocos2D.CCColor4F color)Adds a filled dot and returns a handle for later manipulation.
Parameters:
pos (Cocos2D.CCPoint)radius (System.Single)color (Cocos2D.CCColor4F)Returns:
Cocos2D.CCShapeHandleExample
AddFilledCircle(CCPoint, float, CCColor4F, int)
Cocos2D.CCShapeHandle AddFilledCircle(CCPoint, float, CCColor4F, int)(Cocos2D.CCPoint center, System.Single radius, Cocos2D.CCColor4F color, System.Int32 segments)Adds a filled circle and returns a handle.
Parameters:
center (Cocos2D.CCPoint)radius (System.Single)color (Cocos2D.CCColor4F)segments (System.Int32)Returns:
Cocos2D.CCShapeHandleExample
AddRect(CCRect, CCColor4F)
Cocos2D.CCShapeHandle AddRect(CCRect, CCColor4F)(Cocos2D.CCRect rect, Cocos2D.CCColor4F color)Adds a filled rectangle and returns a handle.
Parameters:
rect (Cocos2D.CCRect)color (Cocos2D.CCColor4F)Returns:
Cocos2D.CCShapeHandleExample
AddSegment(CCPoint, CCPoint, float, CCColor4F)
Cocos2D.CCShapeHandle AddSegment(CCPoint, CCPoint, float, CCColor4F)(Cocos2D.CCPoint from, Cocos2D.CCPoint to, System.Single radius, Cocos2D.CCColor4F color)Adds a line segment and returns a handle.
Parameters:
from (Cocos2D.CCPoint)to (Cocos2D.CCPoint)radius (System.Single)color (Cocos2D.CCColor4F)Returns:
Cocos2D.CCShapeHandleExample
AddTriangle(CCPoint, CCPoint, CCPoint, CCColor4F)
Cocos2D.CCShapeHandle AddTriangle(CCPoint, CCPoint, CCPoint, CCColor4F)(Cocos2D.CCPoint a, Cocos2D.CCPoint b, Cocos2D.CCPoint c, Cocos2D.CCColor4F color)Adds a filled triangle and returns a handle.
Parameters:
a (Cocos2D.CCPoint)b (Cocos2D.CCPoint)c (Cocos2D.CCPoint)color (Cocos2D.CCColor4F)Returns:
Cocos2D.CCShapeHandleExample
Clear()
Clear()()Clears all shapes and vertices.
Example
Draw()
Draw()()This is called from the Visit() method. This is where you DRAW your node. Only draw stuff from this method call.
Example
MoveShape(CCShapeHandle, CCPoint)
MoveShape(CCShapeHandle, CCPoint)(Cocos2D.CCShapeHandle handle, Cocos2D.CCPoint offset)Moves all vertices of a shape by the given offset.
Parameters:
handle (Cocos2D.CCShapeHandle)offset (Cocos2D.CCPoint)Example
RecolorShape(CCShapeHandle, CCColor4F)
RecolorShape(CCShapeHandle, CCColor4F)(Cocos2D.CCShapeHandle handle, Cocos2D.CCColor4F color)Changes the color of all vertices in a shape.
Parameters:
handle (Cocos2D.CCShapeHandle)color (Cocos2D.CCColor4F)Example
RemoveShape(CCShapeHandle)
RemoveShape(CCShapeHandle)(Cocos2D.CCShapeHandle handle)Removes a shape from the draw node. This compacts the vertex buffer and adjusts indices on all remaining handles so they stay valid. For best performance, remove shapes in reverse order of creation or use Clear() when removing many shapes at once.
Parameters:
handle (Cocos2D.CCShapeHandle)Example
SetShapeOpacity(CCShapeHandle, byte)
SetShapeOpacity(CCShapeHandle, byte)(Cocos2D.CCShapeHandle handle, System.Byte opacity)Sets the opacity of all vertices in a shape.
Parameters:
handle (Cocos2D.CCShapeHandle)opacity (System.Byte)Example
SetShapePosition(CCShapeHandle, CCPoint)
SetShapePosition(CCShapeHandle, CCPoint)(Cocos2D.CCShapeHandle handle, Cocos2D.CCPoint position)Sets the position of all vertices by translating the shape so its centroid is at the given position.
Parameters:
handle (Cocos2D.CCShapeHandle)position (Cocos2D.CCPoint)Example