I am developing freehand drawing game, and the drawing is not very smooth, I used this code:
Zero canvas :: on-touch mohaad (ccos 2d :: touch * touch, cocos 2d :: event * event) {canvas :: drawlesslyspacedprit (touch-> meeting place), Touch- & gt; Get pre-location ()); } Zero canvas :: DrawAnlySpaceSpirit (VC2 Launch, VAC2 End) {// Render Texture _target- & gt; Start (); Float distance = start.getDistance (end); If (distance> 1) {int d = (int) distance; For (int i = 0; i & lt; d; i ++) {float diffax = end.x - start.x; Float dify = end.y - start.y; Boat Delta = (Float) I / Distance; Sprite * Sprite = Sprite :: Create ("Brush 3 Page"); Sprite- & gt; SetColor (Color3B :: blue); Phantom-> Setposition (vac2 (start.x + (difx * delta), start.y + (dify * delta)); Sprite- & gt; journey (); }} // Finnish drawing and refund reference back to screen _target- & gt; End (); }
I am working with cocos2d-x v3.3
Please help me get a smooth drawing
thanks < / P>
As Nadrin says, every time you attract it you should not create a new sprite . Even if you can not reuse the same phantom, you can make the sprite with the same spriteframe.
First of all, you need to store SpriteFrame on some variables. Or, if you want, you can use SpriteFrame cache. I'll show the code that will use the Sprite Frame.
// Create Sport Auto Spread = Cocos 2D :: Sprite :: Creation ("Brush 3 Page"); // sprite auto spriteframe = sprite-> meet spriteframe (); GetSpriteFrame (); Create Sprite with and Canvas :: DrawwiseSpaceSitesSites
, archived spriteframe
.
Example is here, change this code
Sprite * sprite = sprite :: create ("brush3.png");
In this code,
Sprite * sprite = sprite :: createWithSpriteFrame (spriteframe);
Comments
Post a Comment