<commit_before><!DOCTYPE html>
<html lang="en">
  <head>
  	
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width">
	    <title>
	    	
	    		codecampbell
	    	
	    </title>
	    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700,400italic,700italic">
	    <link rel="stylesheet" href="/css/main.css">
   
  </head>
  <body>
    <header class="header">
      <div class="content-wrap">
      
	<h1>
		How to draw a circle in Cocossharp
	</h1>
	<p class="author">
		<NAME>
	</p>

      </div>
    </header>
    <div id="content">
      <div class="content-wrap">
      	
	<article class="article">
		<section class="content">
			<p>I have recently started playing around with the 2D game framework <a href="https://github.com/mono/CocosSharp">CocosSharp</a>. The first thing I tried to do with CocosSharp was to draw a circle to the screen.  This article will show you howI ended up figuring it out.</p>
<p><span class="more"></span></p>
<h3 id="how-to-draw-shapes-in-cocossharp-how-to-use-the-ccdrawnode-">How to draw shapes in CocosSharp (How to use the CCDrawNode)</h3>
<p>The CCDrawNode is one of the ways you can draw things in CocosSharp.  You can check out the class documentation [here] (<a href="http://developer.xamarin.com/api/type/CocosSharp.CCDrawNode/">http://developer.xamarin.com/api/type/CocosSharp.CCDrawNode/</a>)</p>
<p>The function we are most interested in is this function </p>
<pre><code class="lang-cs">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">DrawSolidCircle</span> <span class="params">(CCPoint pos, <span class="keyword">float</span> radius, CCColor4B color)</span></span>
</code></pre>
<p>With this function we can initialize a CCDrawNode in our GameLayer and then draw a circle to the screen.  The code could look like this</p>
<pre><code class="lang-cs">    <span class="keyword">public</span> <span class="keyword">class</span> <span class="title">GameLayer</span> : <span class="title">CCLayerColor</span>
    {
        CCDrawNode drawingNode;
        <span class="keyword">const</span> <span class="keyword">float</span> CIRCLE_RADIUS = <span class="number">100</span>;
        <span class="function"><span class="keyword">public</span> <span class="title">GameLayer</span><span class="params">()</span> : <span class="title">base</span><span class="params">(CCColor4B.Black)</span></span>{
            drawingNode = <span class="keyword">new</span> CCDrawNode();
            AddChild(drawingNode);
        }

        <span class="function"><span class="keyword">public</span> <span class="keyword">override</span> <span class="keyword">void</span> <span class="title">AddedToScene</span><span class="params">()</span></span>{
            drawingNode.Clear();
            drawingNode.DrawSolidCircle(VisibleBoundsWorldspace.Center, CIRCLE_RADIUS, CCColor4B.Blue);
        }

    }
</code></pre>
<p>Stay Tuned for more code snippets from my travels through CocosSharp.</p>

		</section>
		<div id="disqus_thread"></div>
		<script type="text/javascript"><commit_msg>fixed mistake<commit_after><!DOCTYPE html>
<html lang="en">
  <head>
  	
	    <meta charset="utf-8">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width">
	    <title>
	    	
	    		codecampbell
	    	
	    </title>
	    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Anonymous+Pro:400,700,400italic,700italic">
	    <link rel="stylesheet" href="/css/main.css">
   
  </head>
  <body>
    <header class="header">
      <div class="content-wrap">
      
	<h1>
		How to draw a circle in Cocossharp
	</h1>
	<p class="author">
		<NAME>
	</p>

      </div>
    </header>
    <div id="content">
      <div class="content-wrap">
      	
	<article class="article">
		<section class="content">
			<p>I have recently started playing around with the 2D game framework <a href="https://github.com/mono/CocosSharp">CocosSharp</a>. The first thing I tried to do with CocosSharp was to draw a circle to the screen.  This article will show you howI ended up figuring it out.</p>
<p><span class="more"></span></p>
<h3 id="how-to-draw-shapes-in-cocossharp-how-to-use-the-ccdrawnode-">How to draw shapes in CocosSharp (How to use the CCDrawNode)</h3>
<p>The CCDrawNode is one of the ways you can draw things in CocosSharp.  You can check out the class documentation <a href="http://developer.xamarin.com/api/type/CocosSharp.CCDrawNode/">here</a></p>
<p>The function we are most interested in is this function </p>
<pre><code class="lang-cs">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">DrawSolidCircle</span> <span class="params">(CCPoint pos, <span class="keyword">float</span> radius, CCColor4B color)</span></span>
</code></pre>
<p>With this function we can initialize a CCDrawNode in our GameLayer and then draw a circle to the screen.  The code could look like this</p>
<pre><code class="lang-cs">    <span class="keyword">public</span> <span class="keyword">class</span> <span class="title">GameLayer</span> : <span class="title">CCLayerColor</span>
    {
        CCDrawNode drawingNode;
        <span class="keyword">const</span> <span class="keyword">float</span> CIRCLE_RADIUS = <span class="number">100</span>;
        <span class="function"><span class="keyword">public</span> <span class="title">GameLayer</span><span class="params">()</span> : <span class="title">base</span><span class="params">(CCColor4B.Black)</span></span>{
            drawingNode = <span class="keyword">new</span> CCDrawNode();
            AddChild(drawingNode);
        }

        <span class="function"><span class="keyword">public</span> <span class="keyword">override</span> <span class="keyword">void</span> <span class="title">AddedToScene</span><span class="params">()</span></span>{
            drawingNode.Clear();
            drawingNode.DrawSolidCircle(VisibleBoundsWorldspace.Center, CIRCLE_RADIUS, CCColor4B.Blue);
        }

    }
</code></pre>
<p>Stay Tuned for more code snippets from my travels through CocosSharp.</p>

		</section>
		<div id="disqus_thread"></div>
		<script type="text/javascript">
{'fraction_non_alphanumeric': 0.16852696116962743, 'fraction_numerical': 0.007860399308284862, 'mean_word_length': 4.189233278955954, 'pattern_counts': {'":': 0, '<': 221, '<?xml version=': 0, '>': 221, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4256010', 'n_tokens_mistral': 2151, 'n_tokens_neox': 2008, 'n_words': 493}